Changeset 295477 in webkit


Ignore:
Timestamp:
Jun 11, 2022 8:25:59 PM (2 years ago)
Author:
Alan Bujtas
Message:

Reset the dirty bit on the inline level renderers when counter is present
https://bugs.webkit.org/show_bug.cgi?id=241534

Reviewed by Antti Koivisto.

While the actual line layout happens in layoutRunsAndFloats, we pre-reset the needsLayout flag as we walk the renderers and prepare them for the inline layout.
Normally this simple DOM order walk clears all the layout bits just fine, but counters can re-dirty any "connected" renderer in a seemingly random order.
This patch ensures that all inline level box renders are marked clean before returning from layoutLineBoxes.

  • Source/WebCore/rendering/LegacyLineLayout.cpp:

(WebCore::LegacyLineLayout::layoutLineBoxes):

Canonical link: https://commits.webkit.org/251482@main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/LegacyLineLayout.cpp

    r295265 r295477  
    17471747        // elements at the same time.
    17481748        bool hasInlineChild = false;
     1749        auto hasDirtyRenderCounterWithInlineBoxParent = false;
    17491750        Vector<RenderBox*> replacedChildren;
    17501751        for (InlineWalker walker(m_flow); !walker.atEnd(); walker.advance()) {
     
    17831784                }
    17841785            } else if (o.isTextOrLineBreak() || is<RenderInline>(o)) {
    1785                 if (layoutState.isFullLayout() || o.selfNeedsLayout())
     1786                if (layoutState.isFullLayout() || o.selfNeedsLayout()) {
    17861787                    dirtyLineBoxesForRenderer(o, layoutState.isFullLayout());
     1788                    hasDirtyRenderCounterWithInlineBoxParent = hasDirtyRenderCounterWithInlineBoxParent || (is<RenderCounter>(o) && is<RenderInline>(o.parent()));
     1789                }
    17871790                o.clearNeedsLayout();
    17881791            }
     
    17911794        for (size_t i = 0; i < replacedChildren.size(); i++)
    17921795            replacedChildren[i]->layoutIfNeeded();
     1796
     1797        auto clearNeedsLayoutIfNeeded = [&] {
     1798            if (!hasDirtyRenderCounterWithInlineBoxParent)
     1799                return;
     1800            for (InlineWalker walker(m_flow); !walker.atEnd(); walker.advance()) {
     1801                auto& renderer = *walker.current();
     1802                if (is<RenderCounter>(renderer) || is<RenderInline>(renderer))
     1803                    renderer.clearNeedsLayout();
     1804            }
     1805        };
     1806        clearNeedsLayoutIfNeeded();
    17931807
    17941808        layoutRunsAndFloats(layoutState, hasInlineChild);
Note: See TracChangeset for help on using the changeset viewer.