[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(n^2) 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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@273241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index a5e8d12..3527914 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -3633,15 +3633,18 @@
     case LineBoxesPath:
         setLineLayoutPath(UndeterminedPath);
         return;
-    case ModernPath: // FIXME: Not all clients of invalidateLineLayoutPath() actually need to wipe the layout.
+    case ModernPath: {
+        // FIXME: Implement partial invalidation.
+        auto path = modernLineLayout() && modernLineLayout()->shouldSwitchToLegacyOnInvalidation() ? ForceLineBoxesPath : UndeterminedPath;
         m_lineLayout = WTF::Monostate();
-        setLineLayoutPath(UndeterminedPath);
+        setLineLayoutPath(path);
         if (needsLayout())
             return;
         // FIXME: We should just kick off a subtree layout here (if needed at all) see webkit.org/b/172947.
         setNeedsLayout();
         return;
     }
+    }
     ASSERT_NOT_REACHED();
 }