Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
index ebe400f573dabc4f76ab52aa00f487e94387c851..12acd3959c5627dd2aef16b6b0a8f37ed5cfb949 100644 |
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
@@ -200,7 +200,7 @@ CompositedLayerMapping::~CompositedLayerMapping() { |
} |
} |
- updateClippingLayers(false, false); |
+ updateClippingLayers(false, false, false); |
updateOverflowControlsLayers(false, false, false, false); |
updateChildTransformLayer(false); |
updateForegroundLayer(false); |
@@ -244,6 +244,7 @@ void CompositedLayerMapping::destroyGraphicsLayers() { |
m_graphicsLayer->removeFromParent(); |
m_ancestorClippingLayer = nullptr; |
+ m_ancestorClippingMaskLayer = nullptr; |
m_graphicsLayer = nullptr; |
m_foregroundLayer = nullptr; |
m_backgroundLayer = nullptr; |
@@ -454,29 +455,37 @@ void CompositedLayerMapping::updateCompositingReasons() { |
m_owningLayer.getSquashingDisallowedReasons()); |
} |
-bool CompositedLayerMapping:: |
- owningLayerClippedByLayerNotAboveCompositedAncestor( |
- const PaintLayer* scrollParent) { |
+void CompositedLayerMapping:: |
+ owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( |
+ const PaintLayer* scrollParent, |
+ bool& owningLayerIsClipped, |
+ bool& owningLayerIsMasked) { |
+ owningLayerIsClipped = false; |
+ owningLayerIsMasked = false; |
+ |
if (!m_owningLayer.parent()) |
- return false; |
+ return; |
const PaintLayer* compositingAncestor = |
m_owningLayer.enclosingLayerWithCompositedLayerMapping(ExcludeSelf); |
if (!compositingAncestor) |
- return false; |
+ return; |
const LayoutObject* clippingContainer = m_owningLayer.clippingContainer(); |
if (!clippingContainer) |
- return false; |
+ return; |
if (clippingContainer->enclosingLayer() == scrollParent) |
- return false; |
+ return; |
if (clippingContainer->enclosingLayer()->hasRootScrollerAsDescendant()) |
- return false; |
+ return; |
if (compositingAncestor->layoutObject()->isDescendantOf(clippingContainer)) |
- return false; |
+ return; |
+ |
+ if (clippingContainer->enclosingLayer()->hasRootScrollerAsDescendant()) |
+ return; |
Stephen Chennney
2016/11/08 21:42:51
flackr@ told me we need this, and I agree.
|
// We ignore overflow clip here; we want composited overflow content to |
// behave as if it lives in an unclipped universe so it can prepaint, etc. |
@@ -491,7 +500,11 @@ bool CompositedLayerMapping:: |
clipRectsContext.setIgnoreOverflowClip(); |
IntRect parentClipRect = pixelSnappedIntRect( |
m_owningLayer.clipper().backgroundClipRect(clipRectsContext).rect()); |
- return parentClipRect != LayoutRect::infiniteIntRect(); |
+ owningLayerIsClipped = parentClipRect != LayoutRect::infiniteIntRect(); |
+ |
+ DCHECK(clippingContainer->style()); |
+ owningLayerIsMasked = |
+ owningLayerIsClipped && clippingContainer->style()->hasBorderRadius(); |
} |
const PaintLayer* CompositedLayerMapping::scrollParent() { |
@@ -547,10 +560,19 @@ bool CompositedLayerMapping::updateGraphicsLayerConfiguration() { |
// layoutObject hierarchy, but a sibling in the z-order hierarchy. Further, |
// that sibling need not be composited at all. In such scenarios, an ancestor |
// clipping layer is necessary to apply the composited clip for this layer. |
- bool needsAncestorClip = |
- owningLayerClippedByLayerNotAboveCompositedAncestor(scrollParent); |
- if (updateClippingLayers(needsAncestorClip, needsDescendantsClippingLayer)) |
+ // TODO(schenney): Can we apply a border radius clip with this ancestor clip |
+ // layer? Why do we need a mask for border radius, rather than modifying the |
+ // clip rects applied to the ancestor clip? |
Stephen Chennney
2016/11/08 21:42:51
This comment should be removed. I know why we have
|
+ bool needsAncestorClip = false; |
+ bool needsAncestorClippingMask = false; |
+ owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( |
+ scrollParent, needsAncestorClip, needsAncestorClippingMask); |
+ fprintf(stderr, "needsAnsectorClip %s, needsAncestorClippingMask %s\n", |
+ needsAncestorClip ? "true" : "false", |
+ needsAncestorClippingMask ? "true" : "false"); |
+ if (updateClippingLayers(needsAncestorClip, needsAncestorClippingMask, |
+ needsDescendantsClippingLayer)) |
layerConfigChanged = true; |
bool scrollingConfigChanged = false; |
@@ -1058,6 +1080,14 @@ void CompositedLayerMapping::updateAncestorClippingLayerGeometry( |
m_ancestorClippingLayer->setOffsetFromLayoutObject( |
parentClipRect.location() - snappedOffsetFromCompositedAncestor); |
+ if (m_ancestorClippingMaskLayer) { |
+ m_ancestorClippingMaskLayer->setPosition( |
+ m_ancestorClippingLayer |
+ ->position()); // TODO(schenney) Don't need this? |
Stephen Chennney
2016/11/08 21:42:51
Looks like we do not need this, but more testing i
|
+ m_ancestorClippingMaskLayer->setSize(m_ancestorClippingLayer->size()); |
+ m_ancestorClippingMaskLayer->setNeedsDisplay(); |
+ } |
+ |
// The primary layer is then parented in, and positioned relative to this |
// clipping layer. |
graphicsLayerParentLocation = parentClipRect.location(); |
@@ -1572,6 +1602,9 @@ void CompositedLayerMapping::updateDrawsContent() { |
if (m_backgroundLayer) |
m_backgroundLayer->setDrawsContent(hasPaintedContent); |
+ if (m_ancestorClippingMaskLayer) |
+ m_ancestorClippingMaskLayer->setDrawsContent(true); |
+ |
if (m_maskLayer) |
m_maskLayer->setDrawsContent(true); |
@@ -1589,8 +1622,10 @@ void CompositedLayerMapping::updateChildrenTransform() { |
} |
// Return true if the layers changed. |
-bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, |
- bool needsDescendantClip) { |
+bool CompositedLayerMapping::updateClippingLayers( |
+ bool needsAncestorClip, |
+ bool needsAncestorClippingMask, |
+ bool needsDescendantClip) { |
bool layersChanged = false; |
if (needsAncestorClip) { |
@@ -1599,9 +1634,26 @@ bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, |
createGraphicsLayer(CompositingReasonLayerForAncestorClip); |
m_ancestorClippingLayer->setMasksToBounds(true); |
m_ancestorClippingLayer->setShouldFlattenTransform(false); |
+ if (needsAncestorClippingMask) { |
+ m_ancestorClippingMaskLayer = |
+ createGraphicsLayer(CompositingReasonLayerForAncestorClippingMask); |
+ m_ancestorClippingMaskLayer->setPaintingPhase( |
+ GraphicsLayerPaintAncestorClippingMask); |
+ m_ancestorClippingLayer->setMaskLayer( |
+ m_ancestorClippingMaskLayer.get()); |
+ } else if (!needsAncestorClippingMask) { |
+ if (m_ancestorClippingMaskLayer) { |
+ m_ancestorClippingMaskLayer = nullptr; |
+ m_ancestorClippingLayer->setMaskLayer(nullptr); |
+ } |
+ } |
layersChanged = true; |
} |
} else if (m_ancestorClippingLayer) { |
+ if (m_ancestorClippingMaskLayer) { |
+ m_ancestorClippingMaskLayer->removeFromParent(); |
+ m_ancestorClippingMaskLayer = nullptr; |
+ } |
m_ancestorClippingLayer->removeFromParent(); |
m_ancestorClippingLayer = nullptr; |
layersChanged = true; |
@@ -2143,7 +2195,11 @@ static void updateClipParentForGraphicsLayer( |
void CompositedLayerMapping::updateClipParent(const PaintLayer* scrollParent) { |
const PaintLayer* clipParent = nullptr; |
- if (!owningLayerClippedByLayerNotAboveCompositedAncestor(scrollParent)) { |
+ bool haveAncestorClipLayer = false; |
+ bool haveAncestorMaskLayer = false; |
+ owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( |
+ scrollParent, haveAncestorClipLayer, haveAncestorMaskLayer); |
+ if (!haveAncestorClipLayer) { |
clipParent = m_owningLayer.clipParent(); |
if (clipParent) |
clipParent = |
@@ -2953,6 +3009,8 @@ void CompositedLayerMapping::paintContents( |
paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; |
if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) |
paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; |
+ if (graphicsLayerPaintingPhase & GraphicsLayerPaintAncestorClippingMask) |
+ paintLayerFlags |= PaintLayerPaintingAncestorClippingMaskPhase; |
if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) |
paintLayerFlags |= PaintLayerPaintingOverflowContents; |
if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) |
@@ -2969,7 +3027,9 @@ void CompositedLayerMapping::paintContents( |
graphicsLayer == m_backgroundLayer.get() || |
graphicsLayer == m_maskLayer.get() || |
graphicsLayer == m_childClippingMaskLayer.get() || |
- graphicsLayer == m_scrollingContentsLayer.get()) { |
+ graphicsLayer == m_scrollingContentsLayer.get() || |
+ graphicsLayer == m_scrollingContentsLayer.get() || |
+ graphicsLayer == m_ancestorClippingMaskLayer.get()) { |
bool paintRootBackgroundOntoScrollingContentsLayer = |
m_backgroundPaintsOntoScrollingContentsLayer; |
DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || |
@@ -3224,6 +3284,8 @@ String CompositedLayerMapping::debugName( |
")"; |
} else if (graphicsLayer == m_ancestorClippingLayer.get()) { |
name = "Ancestor Clipping Layer"; |
+ } else if (graphicsLayer == m_ancestorClippingMaskLayer.get()) { |
+ name = "Ancestor Clipping Mask Layer"; |
} else if (graphicsLayer == m_foregroundLayer.get()) { |
name = m_owningLayer.debugName() + " (foreground) Layer"; |
} else if (graphicsLayer == m_backgroundLayer.get()) { |