This source file includes following definitions.
- destroyLayer
- createLayer
- hasSelfPaintingLayer
- scrollableArea
- willBeDestroyed
- styleWillChange
- styleDidChange
- addLayerHitTestRects
- compositedLayerMapping
- hasCompositedLayerMapping
- groupedMapping
#include "config.h"
#include "core/rendering/RenderLayerModelObject.h"
#include "core/frame/LocalFrame.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderView.h"
using namespace std;
namespace WebCore {
bool RenderLayerModelObject::s_wasFloating = false;
RenderLayerModelObject::RenderLayerModelObject(ContainerNode* node)
: RenderObject(node)
{
}
RenderLayerModelObject::~RenderLayerModelObject()
{
ASSERT(!hasLayer());
ASSERT(!m_layer);
}
void RenderLayerModelObject::destroyLayer()
{
setHasLayer(false);
m_layer = nullptr;
}
void RenderLayerModelObject::createLayer(LayerType type)
{
ASSERT(!m_layer);
m_layer = adoptPtr(new RenderLayer(this, type));
setHasLayer(true);
m_layer->insertOnlyThisLayer();
}
bool RenderLayerModelObject::hasSelfPaintingLayer() const
{
return m_layer && m_layer->isSelfPaintingLayer();
}
ScrollableArea* RenderLayerModelObject::scrollableArea() const
{
return m_layer ? m_layer->scrollableArea() : 0;
}
void RenderLayerModelObject::willBeDestroyed()
{
if (isPositioned()) {
if (LocalFrame* frame = this->frame()) {
if (FrameView* frameView = frame->view()) {
if (style()->hasViewportConstrainedPosition())
frameView->removeViewportConstrainedObject(this);
}
}
}
RenderObject::willBeDestroyed();
destroyLayer();
}
void RenderLayerModelObject::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)
{
s_wasFloating = isFloating();
RenderStyle* oldStyle = style();
if (oldStyle) {
if (parent() && diff == StyleDifferenceRepaintLayer) {
layer()->repainter().repaintIncludingDescendants();
if (oldStyle->clip() != newStyle.clip())
layer()->clipper().clearClipRectsIncludingDescendants();
}
if (diff == StyleDifferenceLayout || diff == StyleDifferenceSimplifiedLayout) {
if (hasLayer()) {
if (oldStyle->hasClip() != newStyle.hasClip()
|| oldStyle->clip() != newStyle.clip()) {
layer()->repainter().repaintIncludingNonCompositingDescendants(containerForRepaint());
} else if (!layer()->hasCompositedLayerMapping()) {
if (oldStyle->position() != newStyle.position()
|| oldStyle->zIndex() != newStyle.zIndex()
|| oldStyle->hasAutoZIndex() != newStyle.hasAutoZIndex()
|| oldStyle->opacity() != newStyle.opacity()
|| oldStyle->transform() != newStyle.transform()
|| oldStyle->filter() != newStyle.filter())
layer()->repainter().repaintIncludingDescendants();
}
} else if (newStyle.hasTransform() || newStyle.opacity() < 1 || newStyle.hasFilter()) {
repaint();
}
}
}
RenderObject::styleWillChange(diff, newStyle);
}
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
bool hadTransform = hasTransform();
bool hadLayer = hasLayer();
bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer();
RenderObject::styleDidChange(diff, oldStyle);
updateFromStyle();
LayerType type = layerTypeRequired();
if (type != NoLayer) {
if (!layer() && layerCreationAllowedForSubtree()) {
if (s_wasFloating && isFloating())
setChildNeedsLayout();
createLayer(type);
if (parent() && !needsLayout() && containingBlock()) {
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
layer()->renderer()->setShouldDoFullRepaintAfterLayout(true);
else
layer()->repainter().setRepaintStatus(NeedsFullRepaint);
DisableCompositingQueryAsserts disabler;
layer()->updateLayerPositions(0);
}
}
} else if (layer() && layer()->parent()) {
setHasTransform(false);
setHasReflection(false);
layer()->removeOnlyThisLayer();
if (s_wasFloating && isFloating())
setChildNeedsLayout();
if (hadTransform)
setNeedsLayoutAndPrefWidthsRecalc();
}
if (layer()) {
layer()->setLayerType(type);
layer()->styleChanged(diff, oldStyle);
if (hadLayer && layer()->isSelfPaintingLayer() != layerWasSelfPainting)
setChildNeedsLayout();
}
if (FrameView *frameView = view()->frameView()) {
bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition();
bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
if (newStyleIsViewportConstained && layer())
frameView->addViewportConstrainedObject(this);
else
frameView->removeViewportConstrainedObject(this);
}
}
}
void RenderLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const
{
if (hasLayer()) {
if (isRenderView()) {
RenderObject::addLayerHitTestRects(rects, layer(), LayoutPoint(), LayoutRect());
} else {
layer()->addLayerHitTestRects(rects);
}
} else {
RenderObject::addLayerHitTestRects(rects, currentLayer, layerOffset, containerRect);
}
}
CompositedLayerMappingPtr RenderLayerModelObject::compositedLayerMapping() const
{
return m_layer ? m_layer->compositedLayerMapping() : 0;
}
bool RenderLayerModelObject::hasCompositedLayerMapping() const
{
return m_layer ? m_layer->hasCompositedLayerMapping() : false;
}
CompositedLayerMapping* RenderLayerModelObject::groupedMapping() const
{
return m_layer ? m_layer->groupedMapping() : 0;
}
}