Index: Source/core/rendering/RenderLayer.cpp |
diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp |
index 1feec46b424d2956b68ab716aee7ee2903ef5b06..a18ab22ce0bc044933cbbba4ced6a615213cfcce 100644 |
--- a/Source/core/rendering/RenderLayer.cpp |
+++ b/Source/core/rendering/RenderLayer.cpp |
@@ -219,11 +219,10 @@ bool RenderLayer::canRender3DTransforms() const |
bool RenderLayer::paintsWithFilters() const |
{ |
- // FIXME: Eventually there will be more factors than isComposited() to decide whether or not to render the filter |
if (!renderer()->hasFilter()) |
return false; |
- if (!isComposited()) |
+ if (compositingState() != PaintsIntoOwnBacking) |
return true; |
if (!m_compositedLayerMapping || !m_compositedLayerMapping->canCompositeFilters()) |
@@ -310,7 +309,7 @@ void RenderLayer::updateLayerPositions(RenderGeometryMap* geometryMap, UpdateLay |
// Clear the IsCompositingUpdateRoot flag once we've found the first compositing layer in this update. |
bool isUpdateRoot = (flags & IsCompositingUpdateRoot); |
- if (isComposited()) |
+ if (compositedLayerMapping()) |
flags &= ~IsCompositingUpdateRoot; |
if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) { |
@@ -324,7 +323,7 @@ void RenderLayer::updateLayerPositions(RenderGeometryMap* geometryMap, UpdateLay |
for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
child->updateLayerPositions(geometryMap, flags); |
- if ((flags & UpdateCompositingLayers) && isComposited()) { |
+ if ((flags & UpdateCompositingLayers) && compositedLayerMapping()) { |
CompositedLayerMapping::UpdateAfterLayoutFlags updateFlags = CompositedLayerMapping::CompositingChildrenOnly; |
if (flags & NeedsFullRepaintInBacking) |
updateFlags |= CompositedLayerMapping::NeedsFullRepaint; |
@@ -843,7 +842,7 @@ void RenderLayer::updatePagination() |
m_isPaginated = false; |
m_enclosingPaginationLayer = 0; |
- if (isComposited() || !parent()) |
+ if (compositedLayerMapping() || !parent()) |
return; // FIXME: We will have to deal with paginated compositing layers someday. |
// FIXME: For now the RenderView can't be paginated. Eventually printing will move to a model where it is though. |
@@ -1194,7 +1193,7 @@ bool RenderLayer::updateLayerPosition() |
localPoint += offset; |
} |
} else if (parent()) { |
- if (isComposited()) { |
+ if (compositedLayerMapping()) { |
// FIXME: Composited layers ignore pagination, so about the best we can do is make sure they're offset into the appropriate column. |
// They won't split across columns properly. |
LayoutSize columnOffset; |
@@ -1326,13 +1325,17 @@ static inline const RenderLayer* compositingContainer(const RenderLayer* layer) |
return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStackingContainer(); |
} |
+// FIXME: having two different functions named enclosingCompositingLayer and enclosingCompositingLayerForRepaint |
+// is error-prone and misleading for reading code that uses these functions - especially compounded with |
+// the includeSelf option. It is very likely that some call sites of this function actually mean to use |
+// enclosingCompositingLayerForRepaint(). |
RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const |
{ |
- if (includeSelf && isComposited()) |
+ if (includeSelf && compositedLayerMapping()) |
return const_cast<RenderLayer*>(this); |
for (const RenderLayer* curr = compositingContainer(this); curr; curr = compositingContainer(curr)) { |
- if (curr->isComposited()) |
+ if (curr->compositedLayerMapping()) |
return const_cast<RenderLayer*>(curr); |
} |
@@ -1341,11 +1344,11 @@ RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const |
RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const |
{ |
- if (includeSelf && isComposited() && !compositedLayerMapping()->paintsIntoCompositedAncestor()) |
+ if (includeSelf && compositingState() == PaintsIntoOwnBacking) |
return const_cast<RenderLayer*>(this); |
for (const RenderLayer* curr = compositingContainer(this); curr; curr = compositingContainer(curr)) { |
- if (curr->isComposited() && !curr->compositedLayerMapping()->paintsIntoCompositedAncestor()) |
+ if (curr->compositingState() == PaintsIntoOwnBacking) |
return const_cast<RenderLayer*>(curr); |
} |
@@ -1383,7 +1386,7 @@ RenderLayer* RenderLayer::enclosingFilterLayer(bool includeSelf) const |
RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const |
{ |
for (const RenderLayer* curr = this; curr; curr = curr->parent()) { |
- if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr->isComposited() || curr->isRootLayer()) |
+ if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr->compositingState() == PaintsIntoOwnBacking || curr->isRootLayer()) |
return const_cast<RenderLayer*>(curr); |
} |
return 0; |
@@ -1414,7 +1417,7 @@ void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect) |
FloatQuad repaintQuad(rectForRepaint); |
LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, parentLayer->renderer()).enclosingBoundingBox(); |
- if (parentLayer->isComposited()) { |
+ if (parentLayer->compositedLayerMapping()) { |
parentLayer->setBackingNeedsRepaintInRect(parentLayerRect); |
return; |
} |
@@ -1445,7 +1448,7 @@ bool RenderLayer::hasAncestorWithFilterOutsets() const |
RenderLayer* RenderLayer::clippingRootForPainting() const |
{ |
- if (isComposited()) |
+ if (compositedLayerMapping()) |
return const_cast<RenderLayer*>(this); |
const RenderLayer* current = this; |
@@ -1456,7 +1459,7 @@ RenderLayer* RenderLayer::clippingRootForPainting() const |
current = compositingContainer(current); |
ASSERT(current); |
if (current->transform() |
- || (current->isComposited() && !current->compositedLayerMapping()->paintsIntoCompositedAncestor()) |
+ || (current->compositingState() == PaintsIntoOwnBacking) |
) |
return const_cast<RenderLayer*>(current); |
} |
@@ -1491,11 +1494,11 @@ bool RenderLayer::isTransparent() const |
RenderLayer* RenderLayer::transparentPaintingAncestor() |
{ |
- if (isComposited()) |
+ if (compositedLayerMapping()) |
return 0; |
for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { |
- if (curr->isComposited()) |
+ if (curr->compositedLayerMapping()) |
return 0; |
if (curr->isTransparent()) |
return curr; |
@@ -1944,7 +1947,7 @@ bool RenderLayer::usesCompositedScrolling() const |
if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntristicallyScrollable(HorizontalScrollbar))) |
return false; |
- return isComposited() && compositedLayerMapping()->scrollingLayer(); |
+ return compositedLayerMapping() && compositedLayerMapping()->scrollingLayer(); |
} |
bool RenderLayer::needsCompositedScrolling() const |
@@ -2575,7 +2578,7 @@ static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P |
void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
{ |
- if (isComposited()) { |
+ if (compositingState() != NotComposited) { |
// The updatingControlTints() painting pass goes through compositing layers, |
// but we need to ensure that we don't cache clip rects computed with the wrong root in this case. |
if (context->updatingControlTints() || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)) { |
@@ -4381,7 +4384,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded(); |
if (RenderLayer* reflection = reflectionLayer()) { |
- if (!reflection->isComposited()) { |
+ if (!reflection->compositedLayerMapping()) { |
IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags); |
unionBounds.unite(childUnionBounds); |
} |
@@ -4393,11 +4396,14 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this)); |
#endif |
+ // FIXME: Descendants that are composited should not necessarily be skipped, if they don't paint into their own |
+ // separate backing. Instead, they ought to contribute to the bounds of the layer we're trying to compute. |
+ // This applies to all z-order lists below. |
if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) { |
size_t listSize = negZOrderList->size(); |
for (size_t i = 0; i < listSize; ++i) { |
RenderLayer* curLayer = negZOrderList->at(i); |
- if (flags & IncludeCompositedDescendants || !curLayer->isComposited()) { |
+ if (flags & IncludeCompositedDescendants || !curLayer->compositedLayerMapping()) { |
IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
unionBounds.unite(childUnionBounds); |
} |
@@ -4408,7 +4414,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
size_t listSize = posZOrderList->size(); |
for (size_t i = 0; i < listSize; ++i) { |
RenderLayer* curLayer = posZOrderList->at(i); |
- if (flags & IncludeCompositedDescendants || !curLayer->isComposited()) { |
+ if (flags & IncludeCompositedDescendants || !curLayer->compositedLayerMapping()) { |
IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
unionBounds.unite(childUnionBounds); |
} |
@@ -4419,7 +4425,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
size_t listSize = normalFlowList->size(); |
for (size_t i = 0; i < listSize; ++i) { |
RenderLayer* curLayer = normalFlowList->at(i); |
- if (flags & IncludeCompositedDescendants || !curLayer->isComposited()) { |
+ if (flags & IncludeCompositedDescendants || !curLayer->compositedLayerMapping()) { |
IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
unionBounds.unite(curAbsBounds); |
} |
@@ -4472,6 +4478,21 @@ void RenderLayer::clearClipRects(ClipRectsType typeToClear) |
} |
} |
+CompositingState RenderLayer::compositingState() const |
+{ |
+ // This is computed procedurally so there is no redundant state variable that |
+ // can get out of sync from the real actual compositing state. |
+ |
+ if (!m_compositedLayerMapping) |
+ return NotComposited; |
+ |
+ if (m_compositedLayerMapping && compositedLayerMapping()->paintsIntoCompositedAncestor()) |
+ return HasOwnBackingButPaintsIntoAncestor; |
+ |
+ ASSERT(m_compositedLayerMapping); |
+ return PaintsIntoOwnBacking; |
+} |
+ |
CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping() |
{ |
if (!m_compositedLayerMapping) { |
@@ -4533,7 +4554,7 @@ GraphicsLayer* RenderLayer::layerForScrollCorner() const |
bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const |
{ |
- return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited()); |
+ return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || compositingState() != PaintsIntoOwnBacking); |
} |
bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const |
@@ -4584,7 +4605,7 @@ bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer |
for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); iter != list->rend(); ++iter) { |
const RenderLayer* childLayer = *iter; |
- if (childLayer->isComposited()) |
+ if (childLayer->compositedLayerMapping()) |
continue; |
if (!childLayer->canUseConvertToLayerCoords()) |
@@ -4841,7 +4862,7 @@ void RenderLayer::repaintIncludingDescendants() |
void RenderLayer::setBackingNeedsRepaint() |
{ |
- ASSERT(isComposited()); |
+ ASSERT(compositedLayerMapping()); |
compositedLayerMapping()->setContentsNeedDisplay(); |
} |
@@ -4849,8 +4870,8 @@ void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r) |
{ |
// https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here, |
// so assert but check that the layer is composited. |
- ASSERT(isComposited()); |
- if (!isComposited()) { |
+ ASSERT(compositedLayerMapping()); |
+ if (!compositedLayerMapping()) { |
// If we're trying to repaint the placeholder document layer, propagate the |
// repaint to the native view system. |
LayoutRect absRect(r); |
@@ -5067,7 +5088,7 @@ inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* |
inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderStyle* oldStyle, const RenderStyle* newStyle) const |
{ |
ASSERT(newStyle); |
- return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->overflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); |
+ return !compositedLayerMapping() && oldStyle && (oldStyle->overflowX() != newStyle->overflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); |
} |
inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const |
@@ -5111,7 +5132,7 @@ void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* |
updateOrRemoveFilterClients(); |
// During an accelerated animation, both WebKit and the compositor animate properties. |
// However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. |
- bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); |
+ bool shouldUpdateFilters = compositedLayerMapping() && !renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); |
if (shouldUpdateFilters) |
compositedLayerMapping()->updateFilters(renderer()->style()); |
updateOrRemoveFilterEffectRenderer(); |
@@ -5157,7 +5178,7 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
|| needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) |
|| needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintWithFilters)) |
compositor()->setCompositingLayersNeedRebuild(); |
- else if (isComposited()) |
+ else if (compositedLayerMapping()) |
compositedLayerMapping()->updateGraphicsLayerGeometry(); |
} |