Commit 9333ba3e authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Avoid excessive marking line boxes dirty

This patch changes marking lines dirty only when
|HasInlineFragments|, not when |FirstTextBox|, which is
always nullptr with LayoutNG.

|DirtyLinesFromChangedChild| is supposed to do nothing for
|NGPaintFragment|, but actually marks items dirty when
|FragmentItem| is enabled.

Also code for |InlineTextBox| was moved to inside of an if
block not to run at all for LayoutNG.

Bug: 982194
Change-Id: Icd933a1c3b6ad76b9437900bf104fc526d332dce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2237491
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776875}
parent 8991af40
......@@ -1760,11 +1760,12 @@ void LayoutText::SetTextWithOffset(scoped_refptr<StringImpl> text,
int delta = new_len - old_len;
unsigned end = len ? offset + len - 1 : offset;
bool dirtied_lines = false;
if (!IsInLayoutNGInlineFormattingContext()) {
RootInlineBox* first_root_box = nullptr;
RootInlineBox* last_root_box = nullptr;
bool dirtied_lines = false;
// Dirty all text boxes that include characters in between offset and
// offset+len.
for (InlineTextBox* curr : TextBoxes()) {
......@@ -1780,8 +1781,8 @@ void LayoutText::SetTextWithOffset(scoped_refptr<StringImpl> text,
RootInlineBox* root = &curr->Root();
if (!first_root_box) {
first_root_box = root;
// The affected area was in between two runs. Go ahead and mark the root
// box of the run after the affected area as dirty.
// The affected area was in between two runs. Go ahead and mark the
// root box of the run after the affected area as dirty.
first_root_box->MarkDirty();
dirtied_lines = true;
}
......@@ -1820,9 +1821,10 @@ void LayoutText::SetTextWithOffset(scoped_refptr<StringImpl> text,
if (curr->LineBreakObj().IsEqual(this) && curr->LineBreakPos() > end)
curr->SetLineBreakPos(clampTo<int>(curr->LineBreakPos() + delta));
}
}
// If the text node is empty, dirty the line where new text will be inserted.
if (!FirstTextBox() && Parent()) {
if (!HasInlineFragments() && Parent()) {
Parent()->DirtyLinesFromChangedChild(this);
dirtied_lines = true;
}
......
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