⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269145 in webkit


Ignore:
Timestamp:
Oct 29, 2020, 6:17:05 AM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][Integration] Implement outputLineTreeAndMark for IFC
https://bugs.webkit.org/show_bug.cgi?id=218310

Reviewed by Antti Koivisto.

Add a legacy like inline tree output. This helps when comparing legacy and modern line tree geometries.

"<div>before<img>after<div>" generates the following output:

DIV RenderBlock at (x, y) size width x height renderer->(address) node->(address)

line at (x, y) size (width x height) baseline (y)

Inline level boxes:

Root inline box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
Atomic inline level box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)

Runs:

text run at (x, y) size (width x height) run(start, end)
box run at (x, y) size (width x height)
text run at (x, y) size (width x height) run(start, end)

  • layout/inlineformatting/InlineLineBox.h:

(WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::height const):
(WebCore::Layout::LineBox::InlineLevelBox::layoutBounds const):
(WebCore::Layout::LineBox::InlineLevelBox::isRootInlineBox const):

  • layout/integration/LayoutIntegrationCoverage.cpp:
  • layout/integration/LayoutIntegrationLineLayout.cpp:

(WebCore::LayoutIntegration::LineLayout::outputLineTree const):

  • layout/integration/LayoutIntegrationLineLayout.h:
  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::showInlineTreeAndRuns):
(WebCore::Layout::outputLayoutTree):
(WebCore::Layout::outputInlineRuns): Deleted.

  • layout/layouttree/LayoutTreeBuilder.h:
  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::outputLineTreeAndMark const):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269144 r269145  
     12020-10-29  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][Integration] Implement outputLineTreeAndMark for IFC
     4        https://bugs.webkit.org/show_bug.cgi?id=218310
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Add a legacy like inline tree output. This helps when comparing legacy and modern line tree geometries.
     9
     10        "<div>before<img>after<div>" generates the following output:
     11
     12        DIV RenderBlock at (x, y) size width x height renderer->(address) node->(address)
     13          line at (x, y) size (width x height) baseline (y)
     14            Inline level boxes:
     15              Root inline box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
     16              Atomic inline level box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
     17            Runs:
     18              text run at (x, y) size (width x height) run(start, end)
     19              box run at (x, y) size (width x height)
     20              text run at (x, y) size (width x height) run(start, end)
     21
     22
     23        * layout/inlineformatting/InlineLineBox.h:
     24        (WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::height const):
     25        (WebCore::Layout::LineBox::InlineLevelBox::layoutBounds const):
     26        (WebCore::Layout::LineBox::InlineLevelBox::isRootInlineBox const):
     27        * layout/integration/LayoutIntegrationCoverage.cpp:
     28        * layout/integration/LayoutIntegrationLineLayout.cpp:
     29        (WebCore::LayoutIntegration::LineLayout::outputLineTree const):
     30        * layout/integration/LayoutIntegrationLineLayout.h:
     31        * layout/layouttree/LayoutTreeBuilder.cpp:
     32        (WebCore::Layout::showInlineTreeAndRuns):
     33        (WebCore::Layout::outputLayoutTree):
     34        (WebCore::Layout::outputInlineRuns): Deleted.
     35        * layout/layouttree/LayoutTreeBuilder.h:
     36        * rendering/RenderBlockFlow.cpp:
     37        (WebCore::RenderBlockFlow::outputLineTreeAndMark const):
     38
    1392020-10-29  Martin Robinson  <mrobinson@igalia.com>
    240
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h

    r268864 r269145  
    7676        InlineLayoutUnit baseline() const { return m_baseline; }
    7777        Optional<InlineLayoutUnit> descent() const { return m_descent; }
     78        // See https://www.w3.org/TR/css-inline-3/#layout-bounds
     79        struct LayoutBounds {
     80            InlineLayoutUnit height() const { return ascent + descent; }
     81
     82            InlineLayoutUnit ascent { 0 };
     83            InlineLayoutUnit descent { 0 };
     84        };
     85        LayoutBounds layoutBounds() const { return m_layoutBounds; }
    7886
    7987        bool isEmpty() const { return m_isEmpty; }
     
    8593
    8694        bool isInlineBox() const { return m_type == Type::InlineBox || m_type == Type::RootInlineBox; }
     95        bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
    8796        bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
    8897        bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
     
    107116        void setBaseline(InlineLayoutUnit);
    108117        void setDescent(InlineLayoutUnit);
    109 
    110         // See https://www.w3.org/TR/css-inline-3/#layout-bounds
    111         struct LayoutBounds {
    112             InlineLayoutUnit height() const { return ascent + descent; }
    113 
    114             InlineLayoutUnit ascent { 0 };
    115             InlineLayoutUnit descent { 0 };
    116         };
    117118        void setLayoutBounds(const LayoutBounds&);
    118         LayoutBounds layoutBounds() const { return m_layoutBounds; }
    119119
    120120    private:
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r269041 r269145  
    588588}
    589589
    590 
    591 }
    592 }
    593 
     590#if ENABLE(TREE_DEBUGGING)
     591void LineLayout::outputLineTree(WTF::TextStream& stream, size_t depth) const
     592{
     593    showInlineTreeAndRuns(stream, m_layoutState, rootLayoutBox(), depth);
     594}
    594595#endif
     596
     597}
     598}
     599
     600#endif
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

    r269041 r269145  
    9393    static void releaseCaches(RenderView&);
    9494
     95#if ENABLE(TREE_DEBUGGING)
     96    void outputLineTree(WTF::TextStream&, size_t depth) const;
     97#endif
     98
    9599private:
    96100    void prepareLayoutState();
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r268948 r269145  
    379379
    380380#if ENABLE(TREE_DEBUGGING)
    381 static void outputInlineRuns(TextStream& stream, const LayoutState& layoutState, const ContainerBox& inlineFormattingRoot, unsigned depth)
     381void showInlineTreeAndRuns(TextStream& stream, const LayoutState& layoutState, const ContainerBox& inlineFormattingRoot, size_t depth)
    382382{
    383383    auto& inlineFormattingState = layoutState.establishedInlineFormattingState(inlineFormattingRoot);
    384384    auto& lines = inlineFormattingState.lines();
     385    auto& lineBoxes = inlineFormattingState.lineBoxes();
    385386
    386387    for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
    387         size_t printedCharacters = 0;
    388         while (++printedCharacters <= depth * 2)
    389             stream << " ";
     388        auto addSpacing = [&] {
     389            size_t printedCharacters = 0;
     390            stream << "-------- --";
     391            while (++printedCharacters <= depth * 2)
     392                stream << " ";
     393
     394        };
     395        addSpacing();
    390396        auto& line = lines[lineIndex];
    391         stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size " << line.logicalWidth() << "x" << line.logicalHeight() << " baseline at (" << line.baseline() << ")";
     397        stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size (" << line.logicalWidth() << "x" << line.logicalHeight() << ") baseline (" << line.baseline() << ")";
     398        stream.nextLine();
     399
     400        addSpacing();
     401        stream << "  Inline level boxes:";
     402        stream.nextLine();
     403        auto& lineBox = lineBoxes[lineIndex];
     404        for (auto& inlineLevelBox : lineBox.inlineLevelBoxList()) {
     405            addSpacing();
     406            stream << "    ";
     407            if (inlineLevelBox->isRootInlineBox())
     408                stream << "Root inline box";
     409            else if (inlineLevelBox->isAtomicInlineLevelBox())
     410                stream << "Atomic inline level box";
     411            else if (inlineLevelBox->isLineBreakBox())
     412                stream << "Line break box";
     413            else if (inlineLevelBox->isInlineBox())
     414                stream << "Generic inline box";
     415            else
     416                stream << "Generic inline level box";
     417            auto logicalRect = lineBox.logicalRectForInlineLevelBox(inlineLevelBox->layoutBox());
     418            stream
     419                << " at (" << logicalRect.left() << "," << logicalRect.top() << ")"
     420                << " size (" << logicalRect.width() << "x" << logicalRect.height() << ")"
     421                << " baseline (" << logicalRect.top() + inlineLevelBox->baseline() << ")"
     422                << " ascent (" << inlineLevelBox->baseline() << "/" << inlineLevelBox->layoutBounds().ascent << ")"
     423                << " descent (" << inlineLevelBox->descent().valueOr(0.0f) << "/" << inlineLevelBox->layoutBounds().descent << ")";
     424            stream.nextLine();
     425        }
     426
     427        addSpacing();
     428        stream << "  Runs:";
    392429        stream.nextLine();
    393430        for (auto& run : inlineFormattingState.lineRuns()) {
    394431            if (run.lineIndex() != lineIndex)
    395432                continue;
    396             unsigned printedCharacters = 0;
    397             while (++printedCharacters <= depth * 2)
    398                 stream << " ";
     433            addSpacing();
    399434            stream << "    ";
    400435            if (run.text())
     
    502537                outputLayoutBox(stream, child, nullptr, depth);
    503538            if (child.establishesInlineFormattingContext())
    504                 outputInlineRuns(stream, *layoutState, downcast<ContainerBox>(child), depth + 1);
     539                showInlineTreeAndRuns(stream, *layoutState, downcast<ContainerBox>(child), depth + 1);
    505540        } else
    506541            outputLayoutBox(stream, child, nullptr, depth);
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h

    r268311 r269145  
    8181void showLayoutTree(const Box&, const LayoutState*);
    8282void showLayoutTree(const Box&);
     83void showInlineTreeAndRuns(TextStream&, const LayoutState&, const ContainerBox& inlineFormattingRoot, size_t depth);
    8384void printLayoutTreeForLiveDocuments();
    8485#endif
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r269053 r269145  
    37003700void RenderBlockFlow::outputLineTreeAndMark(WTF::TextStream& stream, const InlineBox* markedBox, int depth) const
    37013701{
     3702#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     3703    if (auto* modernLineLayout = this->modernLineLayout()) {
     3704        modernLineLayout->outputLineTree(stream, depth);
     3705        return;
     3706    }
     3707#endif
    37023708    for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
    37033709        root->outputLineTreeAndMark(stream, markedBox, depth);
Note: See TracChangeset for help on using the changeset viewer.