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

[LayoutNG] Make line dirty marking faster

This patch changes |NGPaintFragment::MarkLineBoxesDirtyFor()| and
|NGPaintFragment::TryMarkLineBoxDirtyFor()| to mark only first line of layout
object and stop scanning descendnats of culld inline box.

Speed improvement for layout/attach-inlines.html is
26.50 runs/s[1] to 68.45 run/s

Note: without marking dirty line, speed is 73.50 runs/s

[1] http://crrev.com/c/1248622 [LayoutNG] Make line dirty marking faster

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I897224f3bd7a19036718da79bf97d0fa0076cd3d
Reviewed-on: https://chromium-review.googlesource.com/1251263
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595390}
parent b8002c07
...@@ -538,18 +538,6 @@ void NGPaintFragment::MarkLineBoxesDirtyFor(const LayoutObject& layout_object) { ...@@ -538,18 +538,6 @@ void NGPaintFragment::MarkLineBoxesDirtyFor(const LayoutObject& layout_object) {
DCHECK(layout_object.IsInline()) << layout_object; DCHECK(layout_object.IsInline()) << layout_object;
if (TryMarkLineBoxDirtyFor(layout_object)) if (TryMarkLineBoxDirtyFor(layout_object))
return; return;
if (layout_object.IsLayoutInline()) {
bool marked = false;
for (LayoutObject* runner = layout_object.NextInPreOrder(&layout_object);
runner; runner = runner->NextInPreOrder(&layout_object)) {
if (runner->IsFloatingOrOutOfFlowPositioned())
continue;
if (TryMarkLineBoxDirtyFor(*runner))
marked = true;
}
if (marked)
return;
}
// Since |layout_object| isn't in fragment tree, check preceding siblings. // Since |layout_object| isn't in fragment tree, check preceding siblings.
// Note: Once we reuse lines below dirty lines, we should check next siblings. // Note: Once we reuse lines below dirty lines, we should check next siblings.
for (LayoutObject* previous = layout_object.PreviousSibling(); previous; for (LayoutObject* previous = layout_object.PreviousSibling(); previous;
...@@ -589,19 +577,14 @@ void NGPaintFragment::MarkLineBoxDirty() { ...@@ -589,19 +577,14 @@ void NGPaintFragment::MarkLineBoxDirty() {
bool NGPaintFragment::TryMarkLineBoxDirtyFor( bool NGPaintFragment::TryMarkLineBoxDirtyFor(
const LayoutObject& layout_object) { const LayoutObject& layout_object) {
if (!layout_object.IsInLayoutNGInlineFormattingContext()) // Once we reuse lines below dirty lines, we should mark lines for all
return false; // inline fragments.
const auto& range = InlineFragmentsFor(&layout_object); NGPaintFragment* const first_fragment = layout_object.FirstInlineFragment();
if (range.IsEmpty()) if (first_fragment) {
return false; first_fragment->MarkLineBoxDirty();
NGPaintFragment* last_parent = nullptr;
for (NGPaintFragment* fragment : range) {
if (last_parent == fragment->Parent())
continue;
fragment->MarkLineBoxDirty();
last_parent = fragment->Parent();
}
return true; return true;
}
return false;
} }
void NGPaintFragment::SetShouldDoFullPaintInvalidationRecursively() { void NGPaintFragment::SetShouldDoFullPaintInvalidationRecursively() {
......
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