Commit 44cf2759 authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

[LayoutNG] SVGs with percentage dimensions on child-initiated relayouts

On child-initiated re-layouts, SVG elements with percentage dimensions
overflow auto-sized parents when LayoutNG is enabled. The reason being
that ObjectIsRelayoutBoundary() treats all SVGs as layout roots upon
re-layout, even when the width and height are not fixed.

With LayoutNG enabled, this becomes a problem because
BoxLayoutExtraInput does not get set when LayoutSVGRoot is a layout
root, leading to a miscalculation in sizing.

One option would be to set BoxLayoutExtraInput for LayoutSVGRoots
when they are layout roots. However, in order to keep SVG behavior
consistent with other objects, this change fixes the above issue
by preventing layout root optimization altogether for SVG elements
that do not have a fixed height and width.

web_tests/paint/invalidation/svg/color-stop-properties.html was updated
to use "width:100vw" and "height:100vh" instead of "width:100%" and
"height:100%". With the new changes to ObjectIsRelayoutBoundary, an svg
root with a percentage height and width will cause extra invalidation
steps. Updating the width and height of the svg element in this test to
an equivalent fixed height and width avoids extra invalidation steps
and disruption to the test expectations.


Bug: 1016759
Change-Id: Id0ccdafb20e5ce3a1b58be3577ca74dccc0c20c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881691Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#712171}
parent d2470814
......@@ -849,11 +849,6 @@ LayoutFlowThread* LayoutObject::LocateFlowThreadContainingBlock() const {
static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) {
// FIXME: In future it may be possible to broaden these conditions in order to
// improve performance.
if (object->IsTextControl())
return true;
if (object->IsSVGRoot())
return true;
// LayoutInline can't be relayout roots since LayoutBlockFlow is responsible
// for layouting them.
......@@ -870,9 +865,6 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) {
object->ShouldApplySizeContainment())
return true;
if (!object->HasOverflowClip())
return false;
// If either dimension is percent-based, intrinsic, or anything but fixed,
// this object cannot form a re-layout boundary. A non-fixed computed logical
// height will allow the object to grow and shrink based on the content
......@@ -881,6 +873,15 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) {
if (!style->Width().IsFixed() || !style->Height().IsFixed())
return false;
if (object->IsTextControl())
return true;
if (object->IsSVGRoot())
return true;
if (!object->HasOverflowClip())
return false;
// Scrollbar parts can be removed during layout. Avoid the complexity of
// having to deal with that.
if (object->IsLayoutCustomScrollbarPart())
......
......@@ -367,6 +367,11 @@ Bug(none) paint/invalidation/offset-change-wrong-invalidation-with-float.html [
Bug(none) virtual/prefer_compositing_to_lcd_text/compositing/overflow/rotate-then-clip-effect-interleave.html [ Failure ]
Bug(none) virtual/prefer_compositing_to_lcd_text/compositing/overflow/rotate-then-clip-z-order-interleave.html [ Failure ]
Bug(none) virtual/prefer_compositing_to_lcd_text/compositing/overflow/rotate-then-clip.html [ Failure ]
crbug.com/1016759 paint/invalidation/multi-layout-one-frame.html [ Failure ]
crbug.com/1016759 paint/invalidation/search-field-cancel.html [ Failure ]
crbug.com/1016759 paint/invalidation/subtree-root-skipped.html [ Failure ]
crbug.com/1016759 paint/invalidation/svg/animated-path-inside-transformed-html.xhtml [ Failure ]
crbug.com/1016759 paint/invalidation/svg/circle-move-invalidation.svg [ Failure ]
# display-locking
crbug.com/1007506 wpt_internal/display-lock/rendersubtree/sizing/overflow-auto-with-overflow.html [ Failure ]
......
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://crbug.com/1016759">
<body>
<span style="position:relative; font-size:100px;">
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<svg style="position:absolute; border:1px solid black; width:100%; height:100%;">
<rect x="10" y="10" width="100" height="100" fill="red" id="child" stroke="blue" stroke-width="5px"/>
</svg>
</span>
</body>
</html>
<!DOCTYPE html>
<meta charset="utf-8">
<title>
Ensure SVGs with percentage dimensions do not overflow auto-sized parents on
child-initiated re-layout.
</title>
<link rel="help" href="https://crbug.com/1016759">
<link rel=match href="svg-with-precent-dimensions-relayout-ref.html">
<body>
<span style="position:relative; font-size:100px;">
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<svg style="position:absolute; border:1px solid black; width:100%; height:100%;">
<rect x="10" y="10" width="100" height="100" fill="red" id="child" stroke="blue" stroke-width="20px"/>
</svg>
</span>
</body>
<script>
document.body.offsetTop;
document.getElementById("child").setAttribute('stroke-width', '5px');
</script>
</html>
<!DOCTYPE html>
<svg width='800' height='600' style="width: 100%; height: 100%;" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<svg width='800' height='600' style="width: 100vw; height: 100vh;" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<rect id='r' width='100' height='100' fill='green'/>
<use href='#r' x='120' y='0'/>
......
......@@ -2,7 +2,7 @@
"layers": [
{
"name": "Scrolling Contents Layer",
"bounds": [800, 609],
"bounds": [808, 621],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF",
"paintInvalidations": [
......@@ -127,6 +127,23 @@
"reason": "SVG resource change"
}
]
},
{
"name": "ContentsLayer for Horizontal Scrollbar Layer",
"position": [0, 585],
"bounds": [785, 15],
"contentsOpaque": true
},
{
"name": "ContentsLayer for Vertical Scrollbar Layer",
"position": [785, 0],
"bounds": [15, 585],
"contentsOpaque": true
},
{
"name": "Scroll Corner Layer",
"position": [785, 585],
"bounds": [15, 15]
}
]
}
......
<!DOCTYPE html>
<svg width='800' height='600' style="width: 100%; height: 100%;" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<svg width='800' height='600' style="width: 100vw; height: 100vh;" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<linearGradient id='gradient1'>
<stop offset='0' stop-color='green'/>
......
......@@ -25,6 +25,11 @@
"object": "InlineTextBox 'FAILED'",
"rect": [10, 11, 45, 16],
"reason": "disappeared"
},
{
"object": "NGPhysicalTextFragment ' '",
"rect": [189, 9, 4, 19],
"reason": "geometry"
}
]
}
......
......@@ -25,6 +25,11 @@
"object": "InlineTextBox 'FAILED'",
"rect": [11, 11, 37, 14],
"reason": "disappeared"
},
{
"object": "NGPhysicalTextFragment ' '",
"rect": [139, 8, 4, 18],
"reason": "geometry"
}
]
}
......
......@@ -25,6 +25,11 @@
"object": "InlineTextBox 'FAILED'",
"rect": [11, 11, 38, 14],
"reason": "disappeared"
},
{
"object": "NGPhysicalTextFragment ' '",
"rect": [139, 8, 4, 18],
"reason": "geometry"
}
]
}
......
......@@ -2,7 +2,7 @@
"layers": [
{
"name": "Scrolling Contents Layer",
"bounds": [800, 608],
"bounds": [808, 620],
"contentsOpaque": true,
"backgroundColor": "#FFFFFF",
"paintInvalidations": [
......@@ -127,6 +127,23 @@
"reason": "SVG resource change"
}
]
},
{
"name": "ContentsLayer for Horizontal Scrollbar Layer",
"position": [0, 585],
"bounds": [785, 15],
"contentsOpaque": true
},
{
"name": "ContentsLayer for Vertical Scrollbar Layer",
"position": [785, 0],
"bounds": [15, 585],
"contentsOpaque": true
},
{
"name": "Scroll Corner Layer",
"position": [785, 585],
"bounds": [15, 15]
}
]
}
......
......@@ -25,6 +25,11 @@
"object": "InlineTextBox 'FAILED'",
"rect": [10, 10, 44, 18],
"reason": "disappeared"
},
{
"object": "NGPhysicalTextFragment ' '",
"rect": [181, 9, 4, 19],
"reason": "geometry"
}
]
}
......
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