Commit 4bdec9d1 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Chromium LUCI CQ

Dump LayoutNG fragment roots that are inside legacy subtrees.

Previously we'd just stop when reaching a legacy fragment (since such
fragments are always childless). But descendants of a legacy object may
re-enter NG layout further down the road (this is the case for tables
and grid, for instance), and dumping those fragment subtrees may also be
useful.

Example (assuming that tables are laid out by the legacy engine):
  <!DOCTYPE html>
  <div style="display:table;">
    <div>HELLO</div>
  </div>

NGPhysicalFragment::DumpFragmentTree() will now include the DIV child
of the table:
  .:: LayoutNG Physical Fragment Tree ::.
    Box (block-flow-root block-flow)(self paint) offset:unplaced size:800x34 LayoutNGBlockFlow HTML
      Box (block-flow) offset:8,8 size:784x18 LayoutNGBlockFlow BODY
        Box (block-flow-root legacy-layout-root) offset:0,0 size:53x18 LayoutTable DIV
          (NG fragment root inside legacy subtree:)
            Box (block-flow-root block-flow) offset:unplaced size:53x18 LayoutNGTableCell (anonymous)
              Box (block-flow children-inline) offset:0,0 size:53x18 LayoutNGBlockFlow DIV
                NGPhysicalLineBoxFragment offset:0,0 size:52.4375x18
                  NGPhysicalTextFragment 'HELLO' offset:0,0 size:52.4375x17

Change-Id: I95c63181f1d716bd8f79dfb25b9e31fdde49545e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617845Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842458}
parent fde3c520
...@@ -103,6 +103,7 @@ class FragmentTreeDumper { ...@@ -103,6 +103,7 @@ class FragmentTreeDumper {
bool has_content = false; bool has_content = false;
if (const auto* box = DynamicTo<NGPhysicalBoxFragment>(fragment)) { if (const auto* box = DynamicTo<NGPhysicalBoxFragment>(fragment)) {
const LayoutObject* layout_object = box->GetLayoutObject();
if (flags_ & NGPhysicalFragment::DumpType) { if (flags_ & NGPhysicalFragment::DumpType) {
builder_->Append("Box"); builder_->Append("Box");
String box_type = StringForBoxType(*fragment); String box_type = StringForBoxType(*fragment);
...@@ -121,11 +122,10 @@ class FragmentTreeDumper { ...@@ -121,11 +122,10 @@ class FragmentTreeDumper {
} }
has_content = AppendOffsetAndSize(fragment, fragment_offset, has_content); has_content = AppendOffsetAndSize(fragment, fragment_offset, has_content);
if (flags_ & NGPhysicalFragment::DumpNodeName && if (flags_ & NGPhysicalFragment::DumpNodeName && layout_object) {
fragment->GetLayoutObject()) {
if (has_content) if (has_content)
builder_->Append(" "); builder_->Append(" ");
builder_->Append(fragment->GetLayoutObject()->DebugName()); builder_->Append(layout_object->DebugName());
} }
builder_->Append("\n"); builder_->Append("\n");
...@@ -138,6 +138,27 @@ class FragmentTreeDumper { ...@@ -138,6 +138,27 @@ class FragmentTreeDumper {
} }
} }
if (flags_ & NGPhysicalFragment::DumpSubtree) { if (flags_ & NGPhysicalFragment::DumpSubtree) {
if (flags_ & NGPhysicalFragment::DumpLegacyDescendants &&
layout_object && !layout_object->IsLayoutNGObject()) {
DCHECK(box->Children().empty());
for (const LayoutObject* descendant = layout_object->SlowFirstChild();
descendant;) {
if (!descendant->IsLayoutNGObject()) {
descendant = descendant->NextInPreOrder(layout_object);
continue;
}
if (flags_ & NGPhysicalFragment::DumpHeaderText) {
AppendIndentation(indent + 2);
builder_->Append("(NG fragment root inside legacy subtree:)\n");
}
const LayoutBox* box_descendant = To<LayoutBox>(descendant);
DCHECK_EQ(box_descendant->PhysicalFragmentCount(), 1u);
Append(box_descendant->GetPhysicalFragment(0), base::nullopt,
indent + 4);
descendant = descendant->NextInPreOrderAfterChildren(layout_object);
}
return;
}
for (auto& child : box->Children()) { for (auto& child : box->Children()) {
if (has_fragment_items && child->IsLineBox()) if (has_fragment_items && child->IsLineBox())
continue; continue;
......
...@@ -446,6 +446,7 @@ class CORE_EXPORT NGPhysicalFragment ...@@ -446,6 +446,7 @@ class CORE_EXPORT NGPhysicalFragment
DumpSelfPainting = 0x80, DumpSelfPainting = 0x80,
DumpNodeName = 0x100, DumpNodeName = 0x100,
DumpItems = 0x200, DumpItems = 0x200,
DumpLegacyDescendants = 0x400,
DumpAll = -1 DumpAll = -1
}; };
typedef int DumpFlags; typedef int DumpFlags;
......
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