Commit 009b4fbe authored by chrishtr's avatar chrishtr Committed by Commit bot

Apply both phsical bounding box and clip to composited bounds.

Before this patch and the one that was the proximate cause of issue 674098,
clips for composited bounds worked like this:
1. If there was a clip between the compositing container and a PaintLayer, the
clip would be that PaintLayer's contribution to composited bounds.

2.  If there was no such clip, we would fall back to physicalBoundingBox, and
also recurse into children.

After the patch causing issue 674098, we would always recurse, even in case 1.

This patch observes that we can always use a local bound of the intersection of
any clip with physicalBoundingBox. Recursion still always happens.

This avoids situations like in issue 674098 where skew matrices yielded bounds
much too large.

BUG=674098
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2591883002
Cr-Commit-Position: refs/heads/master@{#440929}
parent 8f3e4979
......@@ -646,6 +646,10 @@ crbug.com/649558 virtual/mojo-loading/http/tests/serviceworker/navigation-preloa
# Run these tests with under virtual/scalefactor... only.
crbug.com/567837 fast/hidpi/static [ Skip ]
crbug.com/674098 paint/invalidation/offset-change-wrong-invalidation-with-float.html [ NeedsRebaseline ]
crbug.com/674098 virtual/prefer_compositing_to_lcd_text/compositing/overflow/reparented-scrollbars-non-sc-anc.html [ NeedsRebaseline ]
crbug.com/674098 virtual/spinvalidation/paint/invalidation/offset-change-wrong-invalidation-with-float.html [ NeedsRebaseline ]
# TODO(xiaochengh): We should either convert the following tests with
# spellcheck_test, or remove if they become redundant or inapplicable.
crbug.com/563265 editing/spelling/spellcheck-editable-on-focus-multiframe.html [ Skip ]
......
......@@ -18,7 +18,6 @@ Layer tree when the fixed elements are out-of-view (should have just a root laye
{
"name": "LayoutBlockFlow (positioned) DIV id='fixed2'",
"position": [100, 100],
"bounds": [10, 0],
"contentsOpaque": true,
"drawsContent": true,
"backgroundColor": "#C0C0C0"
......@@ -72,7 +71,6 @@ Layer tree when the fixed elements are out-of-view again (should have just a roo
{
"name": "LayoutBlockFlow (positioned) DIV id='fixed2'",
"position": [100, 100],
"bounds": [10, 0],
"contentsOpaque": true,
"drawsContent": true,
"backgroundColor": "#C0C0C0"
......
......@@ -45,7 +45,7 @@
{
"name": "LayoutBlockFlow (relative positioned) DIV id='foreground'",
"position": [8, 10008],
"bounds": [1200, 0]
"contentsOpaque": true
},
{
"name": "Overflow Controls Ancestor Clipping Layer",
......
......@@ -10,7 +10,7 @@ Item 1
{
"name": "LayoutBlockFlow DIV id='composited-container'",
"position": [8, 8],
"bounds": [784, 0],
"contentsOpaque": true,
"drawsContent": true,
"backfaceVisibility": "hidden"
}
......
......@@ -12,7 +12,8 @@ Case 1, original layer tree:
{
"name": "LayoutBlockFlow DIV class='composited'",
"position": [8, 8],
"bounds": [784, 0]
"transformOrigin": [392, 0],
"contentsOpaque": true
},
{
"name": "Squashing Containment Layer",
......@@ -46,7 +47,8 @@ Case 2: hovering over the "middle" element (causes that div to become its own co
{
"name": "LayoutBlockFlow DIV class='composited'",
"position": [8, 8],
"bounds": [784, 0]
"transformOrigin": [392, 0],
"contentsOpaque": true
},
{
"name": "LayoutBlockFlow (positioned) DIV class='composited box behind'",
......@@ -88,7 +90,8 @@ Case 3: hovering over the "middle2" element (causes that div to become its own c
{
"name": "LayoutBlockFlow DIV class='composited'",
"position": [8, 8],
"bounds": [784, 0]
"transformOrigin": [392, 0],
"contentsOpaque": true
},
{
"name": "Squashing Containment Layer",
......@@ -140,7 +143,8 @@ Case 4: hovering over the "top" element (causes that div to become its own compo
{
"name": "LayoutBlockFlow DIV class='composited'",
"position": [8, 8],
"bounds": [784, 0]
"transformOrigin": [392, 0],
"contentsOpaque": true
},
{
"name": "Squashing Containment Layer",
......@@ -182,7 +186,8 @@ Case 5: back to situation in case 1
{
"name": "LayoutBlockFlow DIV class='composited'",
"position": [8, 8],
"bounds": [784, 0]
"transformOrigin": [392, 0],
"contentsOpaque": true
},
{
"name": "Squashing Containment Layer",
......
......@@ -26,7 +26,7 @@ Updated layer tree
div#b2 110x140 (11)
div#c 90x100 (12)
div#b1 100x150
div#b4 0x200
div#b4 0x0
Updated layer geometry
#document (9)
iframe#frame (10)
......@@ -40,5 +40,5 @@ Updated layer geometry
div#b2 110x140 (11)
div#c 90x80 (12)
div#b1 100x150
div#b4 0x200
div#b4 0x0
......@@ -9,16 +9,12 @@
{
"name": "LayoutBlockFlow (positioned) DIV id='composited-box'",
"position": [38, 38],
"bounds": [90, 90],
"bounds": [20, 70],
"contentsOpaque": true,
"drawsContent": true,
"backfaceVisibility": "hidden",
"backgroundColor": "#008000",
"paintInvalidations": [
{
"object": "LayoutBlockFlow (positioned) DIV id='composited-box'",
"rect": [0, 0, 70, 70],
"reason": "full"
},
{
"object": "LayoutBlockFlow (positioned) DIV id='composited-box'",
"rect": [-30, -30, 50, 100],
......@@ -28,6 +24,11 @@
"object": "LayoutBlockFlow DIV class='child'",
"rect": [-30, -30, 50, 50],
"reason": "subtree"
},
{
"object": "LayoutBlockFlow (positioned) DIV id='composited-box'",
"rect": [0, 0, 10, 60],
"reason": "full"
}
]
},
......
......@@ -9,7 +9,7 @@
{
"name": "LayoutTableRow TR",
"position": [8, 18],
"bounds": [234, 0],
"transformOrigin": [117, 0],
"drawsContent": true,
"backgroundColor": "#0000FF"
},
......
......@@ -38,7 +38,6 @@
{
"name": "LayoutInline (relative positioned) SPAN id='placeholder'",
"position": [18, 0],
"bounds": [0, 19],
"backfaceVisibility": "hidden"
},
{
......
......@@ -2536,13 +2536,10 @@ LayoutRect PaintLayer::boundingBoxForCompositingInternal(
const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
// If there is a clip applied by an ancestor to this PaintLayer but below or
// equal to |ancestorLayer|, use that clip as the bounds rather than the
// recursive bounding boxes, since the latter may be larger than the actual
// size. See https://bugs.webkit.org/show_bug.cgi?id=80372 for examples.
// equal to |ancestorLayer|, apply that clip.
LayoutRect result = clipper().localClipRect(compositedLayer);
// TODO(chrishtr): avoid converting to IntRect and back.
if (result == LayoutRect(LayoutRect::infiniteIntRect()))
result = physicalBoundingBox(LayoutPoint());
result.intersect(physicalBoundingBox(LayoutPoint()));
expandRectForStackingChildren(compositedLayer, result, options);
......
......@@ -58,6 +58,26 @@ TEST_P(PaintLayerTest, CompositedBoundsAbsPosGrandchild) {
parentLayer->boundingBoxForCompositing());
}
TEST_P(PaintLayerTest, CompositedBoundsTransformedChild) {
// TODO(chrishtr): fix this test for SPv2
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
return;
setBodyInnerHTML(
"<div id=parent style='overflow: scroll; will-change: transform'>"
" <div class='target'"
" style='position: relative; transform: skew(-15deg);'>"
" </div>"
" <div style='width: 1000px; height: 500px; background: lightgray'>"
" </div>"
"</div>");
PaintLayer* parentLayer =
toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer();
EXPECT_EQ(LayoutRect(0, 0, 784, 500),
parentLayer->boundingBoxForCompositing());
}
TEST_P(PaintLayerTest, PaintingExtentReflection) {
setBodyInnerHTML(
"<div id='target' style='background-color: blue; position: absolute;"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment