Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2194273002: Fix border radius on composited children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now working on basic test cases Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9dafb44207f569135f2f12602748d2886397d8bc 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;
// 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,12 @@ 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))
+ bool needsAncestorClip = false;
+ bool needsAncestorClippingMask = false;
+ owningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
+ scrollParent, needsAncestorClip, needsAncestorClippingMask);
+ if (updateClippingLayers(needsAncestorClip, needsAncestorClippingMask,
+ needsDescendantsClippingLayer))
layerConfigChanged = true;
bool scrollingConfigChanged = false;
@@ -1058,6 +1073,11 @@ void CompositedLayerMapping::updateAncestorClippingLayerGeometry(
m_ancestorClippingLayer->setOffsetFromLayoutObject(
parentClipRect.location() - snappedOffsetFromCompositedAncestor);
+ if (m_ancestorClippingMaskLayer) {
+ 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 +1592,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 +1612,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 +1624,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 +2185,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 +2999,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 +3017,8 @@ 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_ancestorClippingMaskLayer.get()) {
bool paintRootBackgroundOntoScrollingContentsLayer =
m_backgroundPaintsOntoScrollingContentsLayer;
DCHECK(!paintRootBackgroundOntoScrollingContentsLayer ||
@@ -3224,6 +3273,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()) {

Powered by Google App Engine
This is Rietveld 408576698