Commit 0a794033 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

Only allow positioned objects to be relayout boundaries.

Layout now generates some paint information on physical fragments.
Specifically (for this bug at least) if a sub-tree contains any floats.

This conflicted with the relayout boundary optimization. If a float was
added we wouldn't paint it, as we'd stop layout at the relayout
boundary, not telling the parent fragments that this subtree contained
a float.

This patch only allows relayout boundaries to occur at positioned
objects which always have self painting layers (which is the most
common self painting layer).

For the sites that I found which use this optimization (devtools,
facebook, bing) all occur on a positioned object.

Bug: 1049973
Change-Id: Iafaf68bf9642788a71e8f882a154e6acd7cbef46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076078
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745302}
parent 0dd5860e
...@@ -869,6 +869,12 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) { ...@@ -869,6 +869,12 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) {
// FIXME: In future it may be possible to broaden these conditions in order to // FIXME: In future it may be possible to broaden these conditions in order to
// improve performance. // improve performance.
// Positioned objects always have self-painting layers and are safe to use as
// relayout boundaries.
bool is_svg_root = object->IsSVGRoot();
if (!object->IsPositioned() && !is_svg_root)
return false;
// LayoutInline can't be relayout roots since LayoutBlockFlow is responsible // LayoutInline can't be relayout roots since LayoutBlockFlow is responsible
// for layouting them. // for layouting them.
if (object->IsLayoutInline()) if (object->IsLayoutInline())
...@@ -912,7 +918,7 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) { ...@@ -912,7 +918,7 @@ static inline bool ObjectIsRelayoutBoundary(const LayoutObject* object) {
if (object->IsTextControl()) if (object->IsTextControl())
return true; return true;
if (object->IsSVGRoot()) if (is_svg_root)
return true; return true;
if (!object->HasOverflowClip()) if (!object->HasOverflowClip())
......
<!DOCTYPE html>
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1049973">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="width: 100px; height: 100px; background: red; overflow: auto;">
<div id="target" style="display: none; float: left; width: 100px; height: 100px; background: green;"></div>
</div>
<script>
document.body.offsetTop;
document.getElementById('target').style.display = 'block';
</script>
...@@ -6,6 +6,7 @@ div { ...@@ -6,6 +6,7 @@ div {
width: 100px; width: 100px;
height: 100px; height: 100px;
overflow: hidden; overflow: hidden;
position: relative;
} }
</style> </style>
<div id="relayout-common-ancestor"><div><div></div></div><div><div></div></div></div> <div id="relayout-common-ancestor"><div><div></div></div><div><div></div></div></div>
......
...@@ -12,19 +12,9 @@ ...@@ -12,19 +12,9 @@
"reason": "appeared" "reason": "appeared"
}, },
{ {
"object": "InlineTextBox ' '", "object": "LayoutBlockFlow DIV id='dv'",
"rect": [8, 74, 46, 36], "rect": [8, 74, 46, 36],
"reason": "disappeared" "reason": "chunk disappeared"
},
{
"object": "InlineTextBox 'Lorem'",
"rect": [8, 74, 46, 36],
"reason": "disappeared"
},
{
"object": "InlineTextBox 'ipsum'",
"rect": [8, 74, 46, 36],
"reason": "disappeared"
} }
] ]
} }
......
This is a testharness.js-based test.
FAIL #target static position responded to parent relayout assert_equals: expected 100 but got 200
Harness: the test ran to completion.
...@@ -21,7 +21,7 @@ Layout Properties: ...@@ -21,7 +21,7 @@ Layout Properties:
startTime : <number> startTime : <number>
type : "Layout" type : "Layout"
} }
Text details for Layout: timeline-layout.js:39 Text details for Layout: timeline-layout.js:40
Layout Properties: Layout Properties:
{ {
data : { data : {
...@@ -43,5 +43,5 @@ Layout Properties: ...@@ -43,5 +43,5 @@ Layout Properties:
startTime : <number> startTime : <number>
type : "Layout" type : "Layout"
} }
Text details for Layout: timeline-layout.js:39 Text details for Layout: timeline-layout.js:40
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
overflow: hidden; overflow: hidden;
width: 100px; width: 100px;
height: 100px; height: 100px;
position: relative;
} }
</style> </style>
<body> <body>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
overflow: hidden; overflow: hidden;
width: 100px; width: 100px;
height: 100px; height: 100px;
position: relative;
} }
</style> </style>
<div id="boundary" class="relayout-boundary"> <div id="boundary" class="relayout-boundary">
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
width: 200px; width: 200px;
height: 40px; height: 40px;
overflow: hidden; overflow: hidden;
position: relative;
} }
</style> </style>
</head> </head>
......
...@@ -12,19 +12,9 @@ ...@@ -12,19 +12,9 @@
"reason": "appeared" "reason": "appeared"
}, },
{ {
"object": "InlineTextBox ' '", "object": "LayoutBlockFlow DIV id='dv'",
"rect": [8, 74, 46, 36], "rect": [8, 74, 46, 36],
"reason": "disappeared" "reason": "chunk disappeared"
},
{
"object": "InlineTextBox 'Lorem'",
"rect": [8, 74, 46, 36],
"reason": "disappeared"
},
{
"object": "InlineTextBox 'ipsum'",
"rect": [8, 74, 46, 36],
"reason": "disappeared"
} }
] ]
} }
......
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