Commit dd517d65 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make ComputeMinMaxSizes() should not clear LayoutObject::NeedsLayout() flag

This patch changes |NGLineBreaker| not to clear |LayoutObject::
NeedsLayout()| when it is called from |ComputeMinMaxSizes()|.

Background:
The issue was caused by finding |NGInlineItem| from previous
|NGFragmentItem| because of |NGFragmenItems::
TryReuseFragmentsFromCache()| failed to make dirty for |LayoutText|
because of |ComputeMinMaxSizes()| clears |NeedsLayout()| flag before
actual layout.

Bug: 1116713
Change-Id: Ia3b08ae7295ccf62bbe38a1ed8d3cd6f6209faa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2367259
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800499}
parent 5f3f1ab5
...@@ -517,6 +517,25 @@ TEST_F(NGInlineNodeTest, MinMaxSizesTabulationWithBreakWord) { ...@@ -517,6 +517,25 @@ TEST_F(NGInlineNodeTest, MinMaxSizesTabulationWithBreakWord) {
EXPECT_EQ(170, sizes.max_size); EXPECT_EQ(170, sizes.max_size);
} }
// For http://crbug.com/1116713
TEST_F(NGInlineNodeTest, MinMaxSizesNeedsLayout) {
LoadAhem();
SetupHtml("t",
"<style>#t { width: 2ch; }</style>"
"<div id=t> a <b>b</b></div>");
auto& text = To<Text>(*GetElementById("t")->firstChild());
LayoutText& layout_text = *text.GetLayoutObject();
EXPECT_FALSE(layout_text.NeedsLayout());
text.replaceData(0, 1, u"X", ASSERT_NO_EXCEPTION);
EXPECT_TRUE(layout_text.NeedsLayout());
NGInlineNodeForTest node = CreateInlineNode();
ComputeMinMaxSizes(node);
EXPECT_TRUE(layout_text.NeedsLayout());
}
TEST_F(NGInlineNodeTest, AssociatedItemsWithControlItem) { TEST_F(NGInlineNodeTest, AssociatedItemsWithControlItem) {
SetBodyInnerHTML( SetBodyInnerHTML(
"<pre id=t style='-webkit-rtl-ordering:visual'>ab\nde</pre>"); "<pre id=t style='-webkit-rtl-ordering:visual'>ab\nde</pre>");
......
...@@ -146,14 +146,16 @@ void CreateHyphen(NGInlineNode node, ...@@ -146,14 +146,16 @@ void CreateHyphen(NGInlineNode node,
item_result->hyphen_shape_result = shaper.Shape(&style.GetFont(), direction); item_result->hyphen_shape_result = shaper.Shape(&style.GetFont(), direction);
} }
inline void ClearNeedsLayout(const NGInlineItem& item) { } // namespace
inline void NGLineBreaker::ClearNeedsLayout(const NGInlineItem& item) {
if (mode_ != NGLineBreakerMode::kContent)
return;
LayoutObject* layout_object = item.GetLayoutObject(); LayoutObject* layout_object = item.GetLayoutObject();
if (layout_object->NeedsLayout()) if (layout_object->NeedsLayout())
layout_object->ClearNeedsLayout(); layout_object->ClearNeedsLayout();
} }
} // namespace
LayoutUnit NGLineBreaker::ComputeAvailableWidth() const { LayoutUnit NGLineBreaker::ComputeAvailableWidth() const {
LayoutUnit available_width = line_opportunity_.AvailableInlineSize(); LayoutUnit available_width = line_opportunity_.AvailableInlineSize();
// Available width must be smaller than |LayoutUnit::Max()| so that the // Available width must be smaller than |LayoutUnit::Max()| so that the
......
...@@ -212,6 +212,8 @@ class CORE_EXPORT NGLineBreaker { ...@@ -212,6 +212,8 @@ class CORE_EXPORT NGLineBreaker {
bool CanFitOnLine() const { return position_ <= AvailableWidthToFit(); } bool CanFitOnLine() const { return position_ <= AvailableWidthToFit(); }
LayoutUnit ComputeAvailableWidth() const; LayoutUnit ComputeAvailableWidth() const;
void ClearNeedsLayout(const NGInlineItem& item);
// Represents the current offset of the input. // Represents the current offset of the input.
LineBreakState state_; LineBreakState state_;
unsigned item_index_ = 0; unsigned item_index_ = 0;
......
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