Commit f1c0c8e7 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix DirtyLinesFromNeedsLayout

This patch fixes a case where |DirtyLinesFromNeedsLayout|
fails to mark items dirty for reusing cached lines.

When searching for |LayoutObject| needing layout, checking
|NormalChildNeedsLayout| and |PosChildNeedsLayout| were not
enough. In some specific cases, only
|NeedsSimplifiedNormalFlowLayout| was set for the parent
inline box.

This patch changes the condition to check descendants to
|NeedsLayout|.

Bug: 1101883
Change-Id: Ia73ace058c9ea1ebaaffdaff793b56d68099cd5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2281781Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785287}
parent a9cc4f47
...@@ -270,12 +270,12 @@ void NGFragmentItems::DirtyLinesFromNeedsLayout( ...@@ -270,12 +270,12 @@ void NGFragmentItems::DirtyLinesFromNeedsLayout(
return; return;
} }
} else if (auto* layout_inline = ToLayoutInlineOrNull(layout_object)) { } else if (auto* layout_inline = ToLayoutInlineOrNull(layout_object)) {
if (layout_object->SelfNeedsLayout()) { if (layout_object->NeedsLayout()) {
DirtyLinesFromChangedChild(layout_object); if (layout_object->SelfNeedsLayout()) {
return; DirtyLinesFromChangedChild(layout_object);
} return;
if (layout_object->NormalChildNeedsLayout() || }
layout_object->PosChildNeedsLayout()) { // If children need layout, look into them.
if (LayoutObject* child = layout_inline->FirstChild()) { if (LayoutObject* child = layout_inline->FirstChild()) {
layout_object = child; layout_object = child;
continue; continue;
......
<!DOCTYPE html>
<title>Chaning positioned objects in inline-block should not crash</title>
<link rel="author" href="mailto:kojii@chromium.org">
<link rel="help" href="https://crbug.com/1102128">
<style>
#container {
width: 5ch;
}
#inline-block {
display: inline-block;
position: relative;
width: 3ch;
}
#abs {
position: absolute;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="container">
<span>
<span id="inline-block">
<span id="abs"></span>
</span>
</span>
1234
</div>
<script>
test(() => {
document.body.offsetTop;
abs.style.top = '10px';
document.body.offsetTop;
}, 'No crash');
</script>
</body>
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