Chromium Code Reviews| Index: Source/core/rendering/RenderLayer.cpp |
| diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp |
| index bf22001508a6ae178aa03294885d340e11aa34fa..6e8143d1369684b6277cfeccb2a91fd065898759 100644 |
| --- a/Source/core/rendering/RenderLayer.cpp |
| +++ b/Source/core/rendering/RenderLayer.cpp |
| @@ -247,11 +247,11 @@ 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()) |
| + // FIXME: shouldn't we return true if this layer has a backing but paints into its ancestor? |
|
Ian Vollick
2013/10/01 19:46:22
Whatever we decide for paintsWithTransparency, the
shawnsingh
2013/10/03 03:04:04
done.
|
| + if (!backing()) |
| return true; |
| if (!m_backing || !m_backing->canCompositeFilters()) |
| @@ -366,7 +366,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 (backing()) |
| flags &= ~IsCompositingUpdateRoot; |
| if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) { |
| @@ -380,7 +380,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) && backing()) { |
| RenderLayerBacking::UpdateAfterLayoutFlags updateFlags = RenderLayerBacking::CompositingChildrenOnly; |
| if (flags & NeedsFullRepaintInBacking) |
| updateFlags |= RenderLayerBacking::NeedsFullRepaint; |
| @@ -398,7 +398,7 @@ LayoutRect RenderLayer::repaintRectIncludingNonCompositingDescendants() const |
| LayoutRect repaintRect = m_repaintRect; |
| for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) { |
| // Don't include repaint rects for composited child layers; they will paint themselves and have a different origin. |
| - if (child->isComposited()) |
| + if (child->backing()) |
| continue; |
| repaintRect.unite(child->repaintRectIncludingNonCompositingDescendants()); |
| @@ -935,7 +935,7 @@ void RenderLayer::updatePagination() |
| m_isPaginated = false; |
| m_enclosingPaginationLayer = 0; |
| - if (isComposited() || !parent()) |
| + if (backing() || !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. |
| @@ -1245,7 +1245,7 @@ bool RenderLayer::updateLayerPosition() |
| localPoint += offset; |
| } |
| } else if (parent()) { |
| - if (isComposited()) { |
| + if (backing()) { |
| // 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; |
| @@ -1421,16 +1421,19 @@ inline bool RenderLayer::shouldRepaintAfterLayout() const |
| // Composited layers that were moved during a positioned movement only |
| // layout, don't need to be repainted. They just need to be recomposited. |
| ASSERT(m_repaintStatus == NeedsFullRepaintForPositionedMovementLayout); |
| - return !isComposited(); |
| + return !backing(); |
| } |
| +// 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. |
| RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const |
| { |
| - if (includeSelf && isComposited()) |
| + if (includeSelf && backing()) |
| return const_cast<RenderLayer*>(this); |
| for (const RenderLayer* curr = compositingContainer(this); curr; curr = compositingContainer(curr)) { |
| - if (curr->isComposited()) |
| + if (curr->backing()) |
| return const_cast<RenderLayer*>(curr); |
| } |
| @@ -1439,11 +1442,11 @@ RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const |
| RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const |
| { |
| - if (includeSelf && isComposited() && !backing()->paintsIntoCompositedAncestor()) |
| + if (includeSelf && compositingState() == PaintsIntoOwnBacking) |
| return const_cast<RenderLayer*>(this); |
| for (const RenderLayer* curr = compositingContainer(this); curr; curr = compositingContainer(curr)) { |
| - if (curr->isComposited() && !curr->backing()->paintsIntoCompositedAncestor()) |
| + if (curr->compositingState() == PaintsIntoOwnBacking) |
| return const_cast<RenderLayer*>(curr); |
| } |
| @@ -1481,7 +1484,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; |
| @@ -1512,7 +1515,7 @@ void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect) |
| FloatQuad repaintQuad(rectForRepaint); |
| LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, parentLayer->renderer()).enclosingBoundingBox(); |
| - if (parentLayer->isComposited()) { |
| + if (parentLayer->backing()) { |
| parentLayer->setBackingNeedsRepaintInRect(parentLayerRect); |
| return; |
| } |
| @@ -1543,7 +1546,7 @@ bool RenderLayer::hasAncestorWithFilterOutsets() const |
| RenderLayer* RenderLayer::clippingRootForPainting() const |
| { |
| - if (isComposited()) |
| + if (backing()) |
| return const_cast<RenderLayer*>(this); |
| const RenderLayer* current = this; |
| @@ -1554,7 +1557,7 @@ RenderLayer* RenderLayer::clippingRootForPainting() const |
| current = compositingContainer(current); |
| ASSERT(current); |
| if (current->transform() |
| - || (current->isComposited() && !current->backing()->paintsIntoCompositedAncestor()) |
| + || (current->backing() && !current->backing()->paintsIntoCompositedAncestor()) |
| ) |
| return const_cast<RenderLayer*>(current); |
| } |
| @@ -1589,11 +1592,11 @@ bool RenderLayer::isTransparent() const |
| RenderLayer* RenderLayer::transparentPaintingAncestor() |
| { |
| - if (isComposited()) |
| + if (backing()) |
| return 0; |
| for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { |
| - if (curr->isComposited()) |
| + if (curr->backing()) |
| return 0; |
| if (curr->isTransparent()) |
| return curr; |
| @@ -2032,7 +2035,7 @@ bool RenderLayer::usesCompositedScrolling() const |
| if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntristicallyScrollable(HorizontalScrollbar))) |
| return false; |
| - return isComposited() && backing()->scrollingLayer(); |
| + return backing() && backing()->scrollingLayer(); |
| } |
| bool RenderLayer::needsCompositedScrolling() const |
| @@ -2758,7 +2761,7 @@ void RenderLayer::positionOverflowControls(const IntSize& offsetFromRoot) |
| if (m_resizer) |
| m_resizer->setFrameRect(resizerCornerRect(borderBox, ResizerForPointer)); |
| - if (isComposited()) |
| + if (backing()) |
| backing()->positionOverflowControlsLayers(offsetFromRoot); |
| } |
| @@ -3050,7 +3053,7 @@ static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P |
| void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| { |
| - if (isComposited()) { |
| + if (backing()) { |
| // 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)) { |
| @@ -4862,7 +4865,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
| const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded(); |
| if (RenderLayer* reflection = reflectionLayer()) { |
| - if (!reflection->isComposited()) { |
| + if (!reflection->backing()) { |
| IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags); |
| unionBounds.unite(childUnionBounds); |
| } |
| @@ -4878,7 +4881,7 @@ IntRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, cons |
| 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->backing()) { |
| IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
| unionBounds.unite(childUnionBounds); |
| } |
| @@ -4889,7 +4892,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->backing()) { |
| IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
| unionBounds.unite(childUnionBounds); |
| } |
| @@ -4900,7 +4903,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->backing()) { |
| IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); |
| unionBounds.unite(curAbsBounds); |
| } |
| @@ -4953,6 +4956,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_backing) |
| + return NotComposited; |
| + |
| + if (m_backing && backing()->paintsIntoCompositedAncestor()) |
| + return HasOwnBackingButPaintsIntoAncestor; |
| + |
| + ASSERT(m_backing); |
| + return PaintsIntoOwnBacking; |
| +} |
| + |
| RenderLayerBacking* RenderLayer::ensureBacking() |
| { |
| if (!m_backing) { |
| @@ -5014,7 +5032,8 @@ GraphicsLayer* RenderLayer::layerForScrollCorner() const |
| bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const |
| { |
| - return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited()); |
| + // FIXME: shouldn't we return true if this layer has a backing but paints into its ancestor? |
| + return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !backing()); |
| } |
| bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const |
| @@ -5065,7 +5084,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->backing()) |
| continue; |
| if (!childLayer->canUseConvertToLayerCoords()) |
| @@ -5322,7 +5341,7 @@ void RenderLayer::repaintIncludingDescendants() |
| void RenderLayer::setBackingNeedsRepaint() |
| { |
| - ASSERT(isComposited()); |
| + ASSERT(backing()); |
| backing()->setContentsNeedDisplay(); |
| } |
| @@ -5330,8 +5349,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(backing()); |
| + if (!backing()) { |
| // If we're trying to repaint the placeholder document layer, propagate the |
| // repaint to the native view system. |
| LayoutRect absRect(r); |
| @@ -5352,7 +5371,7 @@ void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje |
| renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(renderer()->clippedOverflowRectForRepaint(repaintContainer))); |
| for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { |
| - if (!curr->isComposited()) |
| + if (!curr->backing()) |
| curr->repaintIncludingNonCompositingDescendants(repaintContainer); |
| } |
| } |
| @@ -5558,7 +5577,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 !backing() && oldStyle && (oldStyle->overflowX() != newStyle->overflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); |
| } |
| inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const |
| @@ -5602,7 +5621,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 = backing() && !renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); |
| if (shouldUpdateFilters) |
| backing()->updateFilters(renderer()->style()); |
| updateOrRemoveFilterEffectRenderer(); |
| @@ -5650,7 +5669,7 @@ void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
| || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) |
| || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintWithFilters)) |
| compositor()->setCompositingLayersNeedRebuild(); |
| - else if (isComposited()) |
| + else if (backing()) |
| backing()->updateGraphicsLayerGeometry(); |
| } |