Title: [288008] trunk/Source/WebCore
Revision
288008
Author
simon.fra...@apple.com
Date
2022-01-13 22:15:12 -0800 (Thu, 13 Jan 2022)

Log Message

Don't call invalidateRectsForAllMarkers() for every layer in the updateLayerPositions() traversal
https://bugs.webkit.org/show_bug.cgi?id=235211

Reviewed by Alan Bujtas.

RenderLayer::updateLayerPositions() called renderer().document().markers().invalidateRectsForAllMarkers()
but that is called on every layer in the recursive updateLayerPositions() traveral. Yet it only needs
to be called once.

So differentiate the entry points for layer traversal from the recursive traversal functions
by using "recursive" in the naming of the latter, and move two of those entrypoints from
RenderLayerScrollableArea back to RenderLayer so everything is in the same file.

Now the entrypoints can call willUpdateLayerPositions() which does the invalidateRectsForAllMarkers().

* page/FrameView.cpp:
(WebCore::FrameView::updateLayerPositionsAfterScrolling):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::willUpdateLayerPositions):
(WebCore::RenderLayer::updateLayerPositionsAfterStyleChange):
(WebCore::RenderLayer::updateLayerPositionsAfterLayout):
(WebCore::RenderLayer::recursiveUpdateLayerPositions):
(WebCore::RenderLayer::updateLayerPositionsAfterOverflowScroll):
(WebCore::RenderLayer::updateLayerPositionsAfterDocumentScroll):
(WebCore::RenderLayer::recursiveUpdateLayerPositionsAfterScroll):
(WebCore::RenderLayer::updateLayerPositions): Deleted.
(WebCore::RenderLayer::updateLayerPositionsAfterScroll): Deleted.
* rendering/RenderLayer.h:
(WebCore::RenderLayer::recursiveUpdateLayerPositionsAfterScroll):
(WebCore::RenderLayer::updateLayerPositionsAfterScroll): Deleted.
* rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollTo):
(WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterDocumentScroll): Deleted.
(WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterOverflowScroll): Deleted.
* rendering/RenderLayerScrollableArea.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288007 => 288008)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 06:15:12 UTC (rev 288008)
@@ -1,3 +1,41 @@
+2022-01-13  Simon Fraser  <simon.fra...@apple.com>
+
+        Don't call invalidateRectsForAllMarkers() for every layer in the updateLayerPositions() traversal
+        https://bugs.webkit.org/show_bug.cgi?id=235211
+
+        Reviewed by Alan Bujtas.
+
+        RenderLayer::updateLayerPositions() called renderer().document().markers().invalidateRectsForAllMarkers()
+        but that is called on every layer in the recursive updateLayerPositions() traveral. Yet it only needs
+        to be called once.
+
+        So differentiate the entry points for layer traversal from the recursive traversal functions
+        by using "recursive" in the naming of the latter, and move two of those entrypoints from
+        RenderLayerScrollableArea back to RenderLayer so everything is in the same file.
+
+        Now the entrypoints can call willUpdateLayerPositions() which does the invalidateRectsForAllMarkers().
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateLayerPositionsAfterScrolling):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::willUpdateLayerPositions):
+        (WebCore::RenderLayer::updateLayerPositionsAfterStyleChange):
+        (WebCore::RenderLayer::updateLayerPositionsAfterLayout):
+        (WebCore::RenderLayer::recursiveUpdateLayerPositions):
+        (WebCore::RenderLayer::updateLayerPositionsAfterOverflowScroll):
+        (WebCore::RenderLayer::updateLayerPositionsAfterDocumentScroll):
+        (WebCore::RenderLayer::recursiveUpdateLayerPositionsAfterScroll):
+        (WebCore::RenderLayer::updateLayerPositions): Deleted.
+        (WebCore::RenderLayer::updateLayerPositionsAfterScroll): Deleted.
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::recursiveUpdateLayerPositionsAfterScroll):
+        (WebCore::RenderLayer::updateLayerPositionsAfterScroll): Deleted.
+        * rendering/RenderLayerScrollableArea.cpp:
+        (WebCore::RenderLayerScrollableArea::scrollTo):
+        (WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterDocumentScroll): Deleted.
+        (WebCore::RenderLayerScrollableArea::updateLayerPositionsAfterOverflowScroll): Deleted.
+        * rendering/RenderLayerScrollableArea.h:
+
 2022-01-13  Alan Bujtas  <za...@apple.com>
 
         [Cleanup] Line::selectionState logic is slightly confusing and redundant

Modified: trunk/Source/WebCore/page/FrameView.cpp (288007 => 288008)


--- trunk/Source/WebCore/page/FrameView.cpp	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/page/FrameView.cpp	2022-01-14 06:15:12 UTC (rev 288008)
@@ -2628,10 +2628,9 @@
         return;
 
     if (!layoutContext().isLayoutNested() && hasViewportConstrainedObjects()) {
-        if (RenderView* renderView = this->renderView()) {
+        if (auto* renderView = this->renderView()) {
             updateWidgetPositions();
-            if (auto* scrollableArea = renderView->layer()->scrollableArea())
-                scrollableArea->updateLayerPositionsAfterDocumentScroll();
+            renderView->layer()->updateLayerPositionsAfterDocumentScroll();
         }
     }
 }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (288007 => 288008)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-01-14 06:15:12 UTC (rev 288008)
@@ -926,9 +926,15 @@
     return flags;
 }
 
+void RenderLayer::willUpdateLayerPositions()
+{
+    renderer().document().markers().invalidateRectsForAllMarkers();
+}
+
 void RenderLayer::updateLayerPositionsAfterStyleChange()
 {
-    updateLayerPositions(nullptr, flagsForUpdateLayerPositions(*this));
+    willUpdateLayerPositions();
+    recursiveUpdateLayerPositions(nullptr, flagsForUpdateLayerPositions(*this));
 }
 
 void RenderLayer::updateLayerPositionsAfterLayout(bool isRelayoutingSubtree, bool didFullRepaint)
@@ -945,14 +951,16 @@
     };
 
     LOG(Compositing, "RenderLayer %p updateLayerPositionsAfterLayout", this);
+    willUpdateLayerPositions();
+
     RenderGeometryMap geometryMap(UseTransforms);
     if (!isRenderViewLayer())
         geometryMap.pushMappingsToAncestor(parent(), nullptr);
 
-    updateLayerPositions(&geometryMap, updateLayerPositionFlags(isRelayoutingSubtree, didFullRepaint));
+    recursiveUpdateLayerPositions(&geometryMap, updateLayerPositionFlags(isRelayoutingSubtree, didFullRepaint));
 }
 
-void RenderLayer::updateLayerPositions(RenderGeometryMap* geometryMap, OptionSet<UpdateLayerPositionsFlag> flags)
+void RenderLayer::recursiveUpdateLayerPositions(RenderGeometryMap* geometryMap, OptionSet<UpdateLayerPositionsFlag> flags)
 {
     updateLayerPosition(&flags);
     if (m_scrollableArea)
@@ -1050,7 +1058,7 @@
         flags.add(SeenCompositedScrollingLayer);
 
     for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
-        child->updateLayerPositions(geometryMap, flags);
+        child->recursiveUpdateLayerPositions(geometryMap, flags);
 
     if (m_scrollableArea)
         m_scrollableArea->updateMarqueePosition();
@@ -1068,8 +1076,6 @@
 
     if (geometryMap)
         geometryMap->popMappingsToAncestor(parent());
-
-    renderer().document().markers().invalidateRectsForAllMarkers();
 }
 
 LayoutRect RenderLayer::repaintRectIncludingNonCompositingDescendants() const
@@ -1152,8 +1158,32 @@
     m_repaintRectsValid = false;
 }
 
-void RenderLayer::updateLayerPositionsAfterScroll(RenderGeometryMap* geometryMap, OptionSet<UpdateLayerPositionsAfterScrollFlag> flags)
+void RenderLayer::updateLayerPositionsAfterOverflowScroll()
 {
+    RenderGeometryMap geometryMap(UseTransforms);
+    if (!isRenderViewLayer())
+        geometryMap.pushMappingsToAncestor(parent(), nullptr);
+
+    willUpdateLayerPositions();
+
+    // FIXME: why is it OK to not check the ancestors of this layer in order to
+    // initialize the HasSeenViewportConstrainedAncestor and HasSeenAncestorWithOverflowClip flags?
+    recursiveUpdateLayerPositionsAfterScroll(&geometryMap, RenderLayer::IsOverflowScroll);
+}
+
+void RenderLayer::updateLayerPositionsAfterDocumentScroll()
+{
+    ASSERT(isRenderViewLayer());
+    LOG(Scrolling, "RenderLayer::updateLayerPositionsAfterDocumentScroll");
+
+    willUpdateLayerPositions();
+
+    RenderGeometryMap geometryMap(UseTransforms);
+    recursiveUpdateLayerPositionsAfterScroll(&geometryMap);
+}
+
+void RenderLayer::recursiveUpdateLayerPositionsAfterScroll(RenderGeometryMap* geometryMap, OptionSet<UpdateLayerPositionsAfterScrollFlag> flags)
+{
     // FIXME: This shouldn't be needed, but there are some corner cases where
     // these flags are still dirty. Update so that the check below is valid.
     updateDescendantDependentFlags();
@@ -1198,7 +1228,7 @@
     }
     
     for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
-        child->updateLayerPositionsAfterScroll(geometryMap, flags);
+        child->recursiveUpdateLayerPositionsAfterScroll(geometryMap, flags);
 
     // We don't update our reflection as scrolling is a translation which does not change the size()
     // of an object, thus RenderReplica will still repaint itself properly as the layer position was
@@ -1209,8 +1239,6 @@
 
     if (shouldPushAndPopMappings)
         geometryMap->popMappingsToAncestor(parent());
-
-    renderer().document().markers().invalidateRectsForAllMarkers();
 }
 
 #if ENABLE(CSS_COMPOSITING)

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (288007 => 288008)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2022-01-14 06:15:12 UTC (rev 288008)
@@ -496,6 +496,8 @@
 
     void updateLayerPositionsAfterStyleChange();
     void updateLayerPositionsAfterLayout(bool isRelayoutingSubtree, bool didFullRepaint);
+    void updateLayerPositionsAfterOverflowScroll();
+    void updateLayerPositionsAfterDocumentScroll();
 
     bool hasCompositedLayerInEnclosingPaginationChain() const;
     enum PaginationInclusionMode { ExcludeCompositedPaginatedLayers, IncludeCompositedPaginatedLayers };
@@ -935,6 +937,8 @@
 
     void updateSelfPaintingLayer();
 
+    void willUpdateLayerPositions();
+
     enum UpdateLayerPositionsFlag {
         CheckForRepaint                     = 1 << 0,
         NeedsFullRepaintInBacking           = 1 << 1,
@@ -950,7 +954,7 @@
     // Returns true if the position changed.
     bool updateLayerPosition(OptionSet<UpdateLayerPositionsFlag>* = nullptr);
 
-    void updateLayerPositions(RenderGeometryMap*, OptionSet<UpdateLayerPositionsFlag>);
+    void recursiveUpdateLayerPositions(RenderGeometryMap*, OptionSet<UpdateLayerPositionsFlag>);
 
     enum UpdateLayerPositionsAfterScrollFlag {
         IsOverflowScroll                        = 1 << 0,
@@ -958,7 +962,7 @@
         HasSeenAncestorWithOverflowClip         = 1 << 2,
         HasChangedAncestor                      = 1 << 3,
     };
-    void updateLayerPositionsAfterScroll(RenderGeometryMap*, OptionSet<UpdateLayerPositionsAfterScrollFlag> = { });
+    void recursiveUpdateLayerPositionsAfterScroll(RenderGeometryMap*, OptionSet<UpdateLayerPositionsAfterScrollFlag> = { });
 
     RenderLayer* enclosingPaginationLayerInSubtree(const RenderLayer* rootLayer, PaginationInclusionMode) const;
 

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (288007 => 288008)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2022-01-14 06:15:12 UTC (rev 288008)
@@ -334,7 +334,7 @@
     // We don't update compositing layers, because we need to do a deep update from the compositing ancestor.
     if (!view.frameView().layoutContext().isInRenderTreeLayout()) {
         // If we're in the middle of layout, we'll just update layers once layout has finished.
-        updateLayerPositionsAfterOverflowScroll();
+        m_layer.updateLayerPositionsAfterOverflowScroll();
 
         view.frameView().scheduleUpdateWidgetPositions();
 
@@ -1818,27 +1818,6 @@
     }
 }
 
-void RenderLayerScrollableArea::updateLayerPositionsAfterDocumentScroll()
-{
-    ASSERT(&m_layer == m_layer.renderer().view().layer());
-
-    LOG(Scrolling, "RenderLayerScrollableArea::updateLayerPositionsAfterDocumentScroll");
-
-    RenderGeometryMap geometryMap(UseTransforms);
-    m_layer.updateLayerPositionsAfterScroll(&geometryMap);
-}
-
-void RenderLayerScrollableArea::updateLayerPositionsAfterOverflowScroll()
-{
-    RenderGeometryMap geometryMap(UseTransforms);
-    if (&m_layer != m_layer.renderer().view().layer())
-        geometryMap.pushMappingsToAncestor(m_layer.parent(), nullptr);
-
-    // FIXME: why is it OK to not check the ancestors of this layer in order to
-    // initialize the HasSeenViewportConstrainedAncestor and HasSeenAncestorWithOverflowClip flags?
-    m_layer.updateLayerPositionsAfterScroll(&geometryMap, RenderLayer::IsOverflowScroll);
-}
-
 bool RenderLayerScrollableArea::mockScrollbarsControllerEnabled() const
 {
     return m_layer.renderer().settings().mockScrollbarsControllerEnabled();

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h (288007 => 288008)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2022-01-14 04:37:37 UTC (rev 288007)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2022-01-14 06:15:12 UTC (rev 288008)
@@ -236,9 +236,6 @@
 
     IntSize scrollbarOffset(const Scrollbar&) const;
 
-    void updateLayerPositionsAfterOverflowScroll();
-    void updateLayerPositionsAfterDocumentScroll();
-
     std::optional<LayoutRect> updateScrollPosition(const ScrollPositionChangeOptions&, const LayoutRect& revealRect, const LayoutRect& localExposeRect);
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to