Title: [266291] trunk/Source/WebCore
Revision
266291
Author
[email protected]
Date
2020-08-28 13:21:39 -0700 (Fri, 28 Aug 2020)

Log Message

No need to run full can-use-for (fast inline layout codepath) check on every style change.
https://bugs.webkit.org/show_bug.cgi?id=215937
<rdar://problem/67951360>

Reviewed by Antti Koivisto.

Let's use the StyleDifference to figure out how extensive the can-use-for check should be.
We can certainly skip some relatively expensive content checks when we know that the style change only triggers repaint or positioned-movement-only changes.

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::canUseForAfterStyleChange):
* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::styleDidChange):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForAfterStyleChange):
* rendering/SimpleLineLayout.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (266290 => 266291)


--- trunk/Source/WebCore/ChangeLog	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/ChangeLog	2020-08-28 20:21:39 UTC (rev 266291)
@@ -1,3 +1,23 @@
+2020-08-28  Zalan Bujtas  <[email protected]>
+
+        No need to run full can-use-for (fast inline layout codepath) check on every style change.
+        https://bugs.webkit.org/show_bug.cgi?id=215937
+        <rdar://problem/67951360>
+
+        Reviewed by Antti Koivisto.
+
+        Let's use the StyleDifference to figure out how extensive the can-use-for check should be.
+        We can certainly skip some relatively expensive content checks when we know that the style change only triggers repaint or positioned-movement-only changes.
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::canUseForAfterStyleChange):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::styleDidChange):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForAfterStyleChange):
+        * rendering/SimpleLineLayout.h:
+
 2020-08-28  Myles C. Maxfield  <[email protected]>
 
         [iOS] Vertical text's logical width calculation is stale from the previous height of the WKWebView

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (266290 => 266291)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-08-28 20:21:39 UTC (rev 266291)
@@ -83,6 +83,12 @@
     return true;
 }
 
+bool LineLayout::canUseForAfterStyleChange(const RenderBlockFlow& flow, StyleDifference diff)
+{
+    ASSERT(RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled());
+    return SimpleLineLayout::canUseForAfterStyleChange(flow, diff);
+}
+
 void LineLayout::updateStyle()
 {
     auto& root = rootLayoutBox();

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (266290 => 266291)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-08-28 20:21:39 UTC (rev 266291)
@@ -60,6 +60,7 @@
     ~LineLayout();
 
     static bool canUseFor(const RenderBlockFlow&, Optional<bool> couldUseSimpleLineLayout = { });
+    static bool canUseForAfterStyleChange(const RenderBlockFlow&, StyleDifference);
 
     void updateStyle();
     void layout();

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (266290 => 266291)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-08-28 20:21:39 UTC (rev 266291)
@@ -2107,11 +2107,10 @@
         auto shouldInvalidateLineLayoutPath = [&] {
             if (selfNeedsLayout() || complexLineLayout())
                 return true;
-            // FIXME: This could use a cheaper style-only test instead of SimpleLineLayout::canUseFor.
-            if (simpleLineLayout() && !SimpleLineLayout::canUseFor(*this))
+            if (simpleLineLayout() && !SimpleLineLayout::canUseForAfterStyleChange(*this, diff))
                 return true;
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-            if (layoutFormattingContextLineLayout() && !LayoutIntegration::LineLayout::canUseFor(*this))
+            if (layoutFormattingContextLineLayout() && !LayoutIntegration::LineLayout::canUseForAfterStyleChange(*this, diff))
                 return true;
 #endif
             return false;

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (266290 => 266291)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2020-08-28 20:21:39 UTC (rev 266291)
@@ -359,6 +359,30 @@
     return canUseForWithReason(flow, IncludeReasons::First) == NoReason;
 }
 
+bool canUseForAfterStyleChange(const RenderBlockFlow& blockContainer, StyleDifference diff)
+{
+    switch (diff) {
+    case StyleDifference::Equal:
+    case StyleDifference::RecompositeLayer:
+        return true;
+    case StyleDifference::Repaint:
+    case StyleDifference::RepaintIfTextOrBorderOrOutline:
+    case StyleDifference::RepaintLayer:
+        // FIXME: We could do a more focused style check by matching RendererStyle::changeRequiresRepaint&co.
+        return canUseForStyle(blockContainer.style(), IncludeReasons::First) == NoReason;
+    case StyleDifference::LayoutPositionedMovementOnly:
+        return true;
+    case StyleDifference::SimplifiedLayout:
+    case StyleDifference::SimplifiedLayoutAndPositionedMovement:
+        return canUseForStyle(blockContainer.style(), IncludeReasons::First) == NoReason;
+    case StyleDifference::Layout:
+    case StyleDifference::NewStyle:
+        return canUseFor(blockContainer);
+    }
+    ASSERT_NOT_REACHED();
+    return canUseFor(blockContainer);
+}
+
 static void revertAllRunsOnCurrentLine(Layout::RunVector& runs)
 {
     while (!runs.isEmpty() && !runs.last().isEndOfLine)

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (266290 => 266291)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.h	2020-08-28 20:21:18 UTC (rev 266290)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h	2020-08-28 20:21:39 UTC (rev 266291)
@@ -45,6 +45,7 @@
 class RunResolver;
 
 bool canUseFor(const RenderBlockFlow&);
+bool canUseForAfterStyleChange(const RenderBlockFlow&, StyleDifference);
 AvoidanceReasonFlags canUseForWithReason(const RenderBlockFlow&, IncludeReasons);
 
 struct Run {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to