Changeset 273241 in webkit


Ignore:
Timestamp:
Feb 22, 2021 7:30:26 AM (3 years ago)
Author:
Antti Koivisto
Message:

[LFC][Integration] Switch out if large trees are being invalidated
https://bugs.webkit.org/show_bug.cgi?id=222264

Reviewed by Zalan Bujtas.

We don't support partial invalidation yet. To avoid hitting bad O(n2) cases limit the maximum tree size on invalidation.

Prevents editing/selection/move-by-character-brute-force.html, fast/innerHTML/identical-mutations.html and fast/text/emoji-num-glyphs.html
from timing out in debug.

  • layout/integration/LayoutIntegrationBoxTree.h:

(WebCore::LayoutIntegration::BoxTree::boxCount const):

  • layout/integration/LayoutIntegrationLineLayout.cpp:

(WebCore::LayoutIntegration::LineLayout::shouldSwitchToLegacyOnInvalidation const):

  • layout/integration/LayoutIntegrationLineLayout.h:
  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::invalidateLineLayoutPath):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273237 r273241  
     12021-02-22  Antti Koivisto  <antti@apple.com>
     2
     3        [LFC][Integration] Switch out if large trees are being invalidated
     4        https://bugs.webkit.org/show_bug.cgi?id=222264
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        We don't support partial invalidation yet. To avoid hitting bad O(n^2) cases limit the maximum tree size on invalidation.
     9
     10        Prevents editing/selection/move-by-character-brute-force.html, fast/innerHTML/identical-mutations.html and fast/text/emoji-num-glyphs.html
     11        from timing out in debug.
     12
     13        * layout/integration/LayoutIntegrationBoxTree.h:
     14        (WebCore::LayoutIntegration::BoxTree::boxCount const):
     15        * layout/integration/LayoutIntegrationLineLayout.cpp:
     16        (WebCore::LayoutIntegration::LineLayout::shouldSwitchToLegacyOnInvalidation const):
     17        * layout/integration/LayoutIntegrationLineLayout.h:
     18        * rendering/RenderBlockFlow.cpp:
     19        (WebCore::RenderBlockFlow::invalidateLineLayoutPath):
     20
    1212021-02-22  Chris Lord  <clord@igalia.com>
    222
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h

    r270195 r273241  
    5757    RenderObject& rendererForLayoutBox(const Layout::Box&);
    5858
     59    size_t boxCount() const { return m_boxes.size(); }
     60
    5961private:
    6062    void buildTree();
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r272906 r273241  
    120120}
    121121
     122bool LineLayout::shouldSwitchToLegacyOnInvalidation() const
     123{
     124    // FIXME: Support partial invalidation in LFC.
     125    // This avoids O(n^2) when lots of boxes are being added dynamically while forcing layouts between.
     126    constexpr size_t maximimumBoxTreeSizeForInvalidation = 128;
     127    return m_boxTree.boxCount() > maximimumBoxTreeSizeForInvalidation;
     128}
     129
    122130void LineLayout::updateReplacedDimensions(const RenderBox& replaced)
    123131{
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

    r272662 r273241  
    6767    static bool canUseForAfterStyleChange(const RenderBlockFlow&, StyleDifference);
    6868
     69    bool shouldSwitchToLegacyOnInvalidation() const;
     70
    6971    void updateReplacedDimensions(const RenderBox&);
    7072    void updateInlineBlockDimensions(const RenderBlock&);
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r272805 r273241  
    36343634        setLineLayoutPath(UndeterminedPath);
    36353635        return;
    3636     case ModernPath: // FIXME: Not all clients of invalidateLineLayoutPath() actually need to wipe the layout.
     3636    case ModernPath: {
     3637        // FIXME: Implement partial invalidation.
     3638        auto path = modernLineLayout() && modernLineLayout()->shouldSwitchToLegacyOnInvalidation() ? ForceLineBoxesPath : UndeterminedPath;
    36373639        m_lineLayout = WTF::Monostate();
    3638         setLineLayoutPath(UndeterminedPath);
     3640        setLineLayoutPath(path);
    36393641        if (needsLayout())
    36403642            return;
     
    36423644        setNeedsLayout();
    36433645        return;
     3646    }
    36443647    }
    36453648    ASSERT_NOT_REACHED();
Note: See TracChangeset for help on using the changeset viewer.