- Revision
- 260910
- Author
- [email protected]
- Date
- 2020-04-29 12:38:11 -0700 (Wed, 29 Apr 2020)
Log Message
Simplify contents clipping layer geometry
https://bugs.webkit.org/show_bug.cgi?id=211162
Reviewed by Zalan Bujtas.
Source/WebCore:
GraphicsLayerCA uses a contents clipping layer, with an optional shape layer, to support
clipping replaced elements with composited contents, like video and WebGL canvas.
A future patch will use this code path for composited subframes. To achieve this,
we need to host the layers of child GraphicsLayers under m_contentsClippingLayer, but
without the GraphicsLayer client having to do geometry math. We can do this by setting
the bounds origin of m_contentsClippingLayer to adjust for its position relative
to the GraphicsLayer origin.
This patch does that, adjusting the position of the contents layer accordingly.
The shape mask layer also needs adjusting; its position has to be at the layer's
bounds origin, and the shape itself needs to have a zero origin.
Tested by existing tests.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateSublayerList):
(WebCore::GraphicsLayerCA::updateClippingStrategy):
(WebCore::GraphicsLayerCA::updateContentsRects):
LayoutTests:
New content layer positions.
* compositing/video/video-object-fit.html:
* compositing/video/video-object-position-expected.txt:
* platform/ios/compositing/video/video-object-position-expected.txt:
* platform/mac/compositing/video/video-object-fit-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (260909 => 260910)
--- trunk/LayoutTests/ChangeLog 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/LayoutTests/ChangeLog 2020-04-29 19:38:11 UTC (rev 260910)
@@ -1,3 +1,17 @@
+2020-04-29 Simon Fraser <[email protected]>
+
+ Simplify contents clipping layer geometry
+ https://bugs.webkit.org/show_bug.cgi?id=211162
+
+ Reviewed by Zalan Bujtas.
+
+ New content layer positions.
+
+ * compositing/video/video-object-fit.html:
+ * compositing/video/video-object-position-expected.txt:
+ * platform/ios/compositing/video/video-object-position-expected.txt:
+ * platform/mac/compositing/video/video-object-fit-expected.txt:
+
2020-04-29 Wenson Hsieh <[email protected]>
editing/selection/ios/selection-handles-after-touch-end.html is failing on iOS 13.4 after r260367
Modified: trunk/LayoutTests/compositing/video/video-object-fit.html (260909 => 260910)
--- trunk/LayoutTests/compositing/video/video-object-fit.html 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/LayoutTests/compositing/video/video-object-fit.html 2020-04-29 19:38:11 UTC (rev 260910)
@@ -7,7 +7,8 @@
width: 120px;
height: 200px;
margin: 5px;
- border: 2px solid blue;
+ padding: 20px;
+ border: 20px solid rgba(0, 0, 128, 0.5);
background-color: gray;
}
Modified: trunk/LayoutTests/compositing/video/video-object-position-expected.txt (260909 => 260910)
--- trunk/LayoutTests/compositing/video/video-object-position-expected.txt 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/LayoutTests/compositing/video/video-object-position-expected.txt 2020-04-29 19:38:11 UTC (rev 260910)
@@ -21,7 +21,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer 20.00, 10.00 120.00 x 200.00)
+ (contents layer 22.00, 12.00 120.00 x 200.00)
)
(GraphicsLayer
(position 289.00 13.00)
@@ -36,7 +36,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -10.00, -10.00 120.00 x 200.00)
+ (contents layer -8.00, -8.00 120.00 x 200.00)
)
(GraphicsLayer
(position 565.00 13.00)
@@ -58,7 +58,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer 20.00, 10.00 120.00 x 90.00)
+ (contents layer 22.00, 12.00 120.00 x 90.00)
)
(GraphicsLayer
(position 289.00 231.00)
@@ -73,7 +73,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -10.00, 100.00 120.00 x 90.00)
+ (contents layer -8.00, 102.00 120.00 x 90.00)
)
(GraphicsLayer
(position 565.00 231.00)
Modified: trunk/LayoutTests/platform/ios/compositing/video/video-object-position-expected.txt (260909 => 260910)
--- trunk/LayoutTests/platform/ios/compositing/video/video-object-position-expected.txt 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/LayoutTests/platform/ios/compositing/video/video-object-position-expected.txt 2020-04-29 19:38:11 UTC (rev 260910)
@@ -21,7 +21,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer 20.00, 10.00 120.00 x 200.00)
+ (contents layer 22.00, 12.00 120.00 x 200.00)
)
(GraphicsLayer
(position 289.00 13.00)
@@ -36,7 +36,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -10.00, -10.00 120.00 x 200.00)
+ (contents layer -8.00, -8.00 120.00 x 200.00)
)
(GraphicsLayer
(position 565.00 13.00)
@@ -58,7 +58,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer 20.00, 10.00 120.00 x 90.00)
+ (contents layer 22.00, 12.00 120.00 x 90.00)
)
(GraphicsLayer
(position 289.00 232.00)
@@ -73,7 +73,7 @@
(contentsOpaque 1)
(drawsContent 1)
(contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -10.00, 100.00 120.00 x 90.00)
+ (contents layer -8.00, 102.00 120.00 x 90.00)
)
(GraphicsLayer
(position 565.00 232.00)
Modified: trunk/LayoutTests/platform/mac/compositing/video/video-object-fit-expected.txt (260909 => 260910)
--- trunk/LayoutTests/platform/mac/compositing/video/video-object-fit-expected.txt 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/LayoutTests/platform/mac/compositing/video/video-object-fit-expected.txt 2020-04-29 19:38:11 UTC (rev 260910)
@@ -1,55 +1,55 @@
(GraphicsLayer
(anchor 0.00 0.00)
- (bounds 785.00 775.00)
+ (bounds 785.00 1003.00)
(children 1
(GraphicsLayer
- (bounds 785.00 775.00)
+ (bounds 785.00 1003.00)
(contentsOpaque 1)
(children 6
(GraphicsLayer
(position 13.00 13.00)
- (bounds 124.00 204.00)
+ (bounds 200.00 280.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents layer 2.00, 2.00 120.00 x 200.00)
+ (contents layer 40.00, 40.00 120.00 x 200.00)
)
(GraphicsLayer
- (position 151.00 13.00)
- (bounds 124.00 204.00)
+ (position 227.00 13.00)
+ (bounds 200.00 280.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -73.00, 0.00 266.00 x 200.00)
+ (contents clipping layer 40.00, 40.00 120.00 x 200.00)
+ (contents layer -33.00, 40.00 266.00 x 200.00)
)
(GraphicsLayer
- (position 289.00 13.00)
- (bounds 124.00 204.00)
+ (position 441.00 13.00)
+ (bounds 200.00 280.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents layer 2.00, 57.00 120.00 x 90.00)
+ (contents layer 40.00, 95.00 120.00 x 90.00)
)
(GraphicsLayer
- (position 13.00 231.00)
- (bounds 354.00 304.00)
+ (position 13.00 307.00)
+ (bounds 430.00 380.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents layer 17.00, 32.00 320.00 x 240.00)
+ (contents layer 55.00, 70.00 320.00 x 240.00)
)
(GraphicsLayer
- (position 13.00 569.00)
- (bounds 404.00 184.00)
+ (position 13.00 721.00)
+ (bounds 480.00 260.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents layer 82.00, 2.00 240.00 x 180.00)
+ (contents layer 120.00, 40.00 240.00 x 180.00)
)
(GraphicsLayer
- (position 431.00 549.00)
- (bounds 124.00 204.00)
+ (position 507.00 701.00)
+ (bounds 200.00 280.00)
(contentsOpaque 1)
(drawsContent 1)
- (contents clipping layer 2.00, 2.00 120.00 x 200.00)
- (contents layer -100.00, -20.00 320.00 x 240.00)
+ (contents clipping layer 40.00, 40.00 120.00 x 200.00)
+ (contents layer -60.00, 20.00 320.00 x 240.00)
)
)
)
Modified: trunk/Source/WebCore/ChangeLog (260909 => 260910)
--- trunk/Source/WebCore/ChangeLog 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/Source/WebCore/ChangeLog 2020-04-29 19:38:11 UTC (rev 260910)
@@ -1,3 +1,30 @@
+2020-04-29 Simon Fraser <[email protected]>
+
+ Simplify contents clipping layer geometry
+ https://bugs.webkit.org/show_bug.cgi?id=211162
+
+ Reviewed by Zalan Bujtas.
+
+ GraphicsLayerCA uses a contents clipping layer, with an optional shape layer, to support
+ clipping replaced elements with composited contents, like video and WebGL canvas.
+
+ A future patch will use this code path for composited subframes. To achieve this,
+ we need to host the layers of child GraphicsLayers under m_contentsClippingLayer, but
+ without the GraphicsLayer client having to do geometry math. We can do this by setting
+ the bounds origin of m_contentsClippingLayer to adjust for its position relative
+ to the GraphicsLayer origin.
+
+ This patch does that, adjusting the position of the contents layer accordingly.
+ The shape mask layer also needs adjusting; its position has to be at the layer's
+ bounds origin, and the shape itself needs to have a zero origin.
+
+ Tested by existing tests.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::updateSublayerList):
+ (WebCore::GraphicsLayerCA::updateClippingStrategy):
+ (WebCore::GraphicsLayerCA::updateContentsRects):
+
2020-04-29 Kenneth Russell <[email protected]>
REGRESSION (r256784?): Shadertoy demo no longer works in Safari
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (260909 => 260910)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2020-04-29 19:12:15 UTC (rev 260909)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2020-04-29 19:38:11 UTC (rev 260910)
@@ -1968,7 +1968,7 @@
void GraphicsLayerCA::updateSublayerList(bool maxLayerDepthReached)
{
if (maxLayerDepthReached) {
- m_layer->setSublayers(PlatformCALayerList());
+ m_layer->setSublayers({ });
return;
}
@@ -2658,9 +2658,18 @@
shapeMaskLayer->setAnchorPoint({ });
shapeMaskLayer->setName("shape mask");
}
+
+ // clippingLayer's boundsOrigin is roundedRect.rect().location(), and is non-zero to positioning descendant layers.
+ // The mask layer needs an equivalent position.
+ auto rectLocation = roundedRect.rect().location();
+ shapeMaskLayer->setPosition({ rectLocation.x(), rectLocation.y(), 0.0f });
+
+ auto shapeBounds = FloatRect { { }, roundedRect.rect().size() };
+ shapeMaskLayer->setBounds(shapeBounds);
- shapeMaskLayer->setBounds(clippingLayer.bounds());
- shapeMaskLayer->setShapeRoundedRect(roundedRect);
+ auto localRoundedRect = roundedRect;
+ localRoundedRect.setLocation({ });
+ shapeMaskLayer->setShapeRoundedRect(localRoundedRect);
clippingLayer.setCornerRadius(0);
clippingLayer.setMask(shapeMaskLayer.get());
@@ -2671,11 +2680,7 @@
if (!m_contentsLayer)
return;
- FloatPoint contentOrigin;
- const FloatRect contentBounds(0, 0, m_contentsRect.width(), m_contentsRect.height());
-
- FloatPoint clippingOrigin(m_contentsClippingRect.rect().location());
- FloatRect clippingBounds({ }, m_contentsClippingRect.rect().size());
+ auto contentBounds = FloatRect { { }, m_contentsRect.size() };
bool gainedOrLostClippingLayer = false;
if (m_contentsClippingRect.isRounded() || !m_contentsClippingRect.rect().contains(m_contentsRect)) {
@@ -2690,20 +2695,15 @@
gainedOrLostClippingLayer = true;
}
- m_contentsClippingLayer->setPosition(clippingOrigin);
- m_contentsClippingLayer->setBounds(clippingBounds);
+ m_contentsClippingLayer->setPosition(m_contentsClippingRect.rect().location());
+ m_contentsClippingLayer->setBounds(m_contentsClippingRect.rect());
- auto clippingRectRelativeToClippingLayer = m_contentsClippingRect;
- clippingRectRelativeToClippingLayer.setLocation({ });
+ updateClippingStrategy(*m_contentsClippingLayer, m_contentsShapeMaskLayer, m_contentsClippingRect);
- updateClippingStrategy(*m_contentsClippingLayer, m_contentsShapeMaskLayer, clippingRectRelativeToClippingLayer);
-
if (gainedOrLostClippingLayer) {
m_contentsLayer->removeFromSuperlayer();
m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
}
-
- contentOrigin = FloatPoint(m_contentsRect.location() - m_contentsClippingRect.rect().location());
} else {
if (m_contentsClippingLayer) {
m_contentsLayer->removeFromSuperlayer();
@@ -2719,19 +2719,17 @@
m_contentsShapeMaskLayer->setOwner(nullptr);
m_contentsShapeMaskLayer = nullptr;
}
-
- contentOrigin = m_contentsRect.location();
}
if (gainedOrLostClippingLayer)
noteSublayersChanged(DontScheduleFlush);
- m_contentsLayer->setPosition(contentOrigin);
+ m_contentsLayer->setPosition(m_contentsRect.location());
m_contentsLayer->setBounds(contentBounds);
if (m_layerClones) {
for (auto& layer : m_layerClones->contentsLayerClones.values()) {
- layer->setPosition(contentOrigin);
+ layer->setPosition(m_contentsRect.location());
layer->setBounds(contentBounds);
}