Title: [289360] trunk/Source/WebCore
Revision
289360
Author
[email protected]
Date
2022-02-08 01:53:04 -0800 (Tue, 08 Feb 2022)

Log Message

RenderLayer: Simplify RenderElement::paint() calls
https://bugs.webkit.org/show_bug.cgi?id=236192

Reviewed by Simon Fraser.

Introduce "paintOffsetForRenderer(fragment, localPaintingInfo)" inline helper:
return toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset)

Avoid repeating this formula in various places in RenderLayer - unify it.

Covered by existing tests, no change in behaviour.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintBackgroundForFragments):
(WebCore::RenderLayer::paintForegroundForFragmentsWithPhase):
(WebCore::RenderLayer::paintOutlineForFragments):
(WebCore::RenderLayer::paintMaskForFragments):
(WebCore::RenderLayer::paintChildClippingMaskForFragments):
(WebCore::RenderLayer::paintOverflowControlsForFragments):
(WebCore::RenderLayer::collectEventRegionForFragments):
* rendering/RenderLayer.h:
(WebCore::RenderLayer::paintOffsetForRenderer const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (289359 => 289360)


--- trunk/Source/WebCore/ChangeLog	2022-02-08 05:47:11 UTC (rev 289359)
+++ trunk/Source/WebCore/ChangeLog	2022-02-08 09:53:04 UTC (rev 289360)
@@ -1,3 +1,28 @@
+2022-02-08  Nikolas Zimmermann  <[email protected]>
+
+        RenderLayer: Simplify RenderElement::paint() calls
+        https://bugs.webkit.org/show_bug.cgi?id=236192
+
+        Reviewed by Simon Fraser.
+
+        Introduce "paintOffsetForRenderer(fragment, localPaintingInfo)" inline helper:
+        return toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset)
+
+        Avoid repeating this formula in various places in RenderLayer - unify it.
+
+        Covered by existing tests, no change in behaviour.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paintBackgroundForFragments):
+        (WebCore::RenderLayer::paintForegroundForFragmentsWithPhase):
+        (WebCore::RenderLayer::paintOutlineForFragments):
+        (WebCore::RenderLayer::paintMaskForFragments):
+        (WebCore::RenderLayer::paintChildClippingMaskForFragments):
+        (WebCore::RenderLayer::paintOverflowControlsForFragments):
+        (WebCore::RenderLayer::collectEventRegionForFragments):
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::paintOffsetForRenderer const):
+
 2022-02-07  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r289227.

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (289359 => 289360)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-02-08 05:47:11 UTC (rev 289359)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-02-08 09:53:04 UTC (rev 289360)
@@ -3795,7 +3795,7 @@
         // Paint the background.
         // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
         PaintInfo paintInfo(context, fragment.backgroundRect.rect(), PaintPhase::BlockBackground, paintBehavior, subtreePaintRootForRenderer, nullptr, nullptr, &localPaintingInfo.rootLayer->renderer(), this);
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 
@@ -3890,7 +3890,7 @@
         PaintInfo paintInfo(context, fragment.foregroundRect.rect(), phase, paintBehavior, subtreePaintRootForRenderer, nullptr, nullptr, &localPaintingInfo.rootLayer->renderer(), this, localPaintingInfo.requireSecurityOriginAccessForWidgets);
         if (phase == PaintPhase::Foreground)
             paintInfo.overlapTestRequests = localPaintingInfo.overlapTestRequests;
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 
@@ -3908,7 +3908,7 @@
         EventRegionContextStateSaver eventRegionStateSaver(localPaintingInfo.eventRegionContext);
 
         clipToRect(context, stateSaver, eventRegionStateSaver, localPaintingInfo, paintBehavior, fragment.backgroundRect, DoNotIncludeSelfForBorderRadius);
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 
@@ -3928,7 +3928,7 @@
         // Paint the mask.
         // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
         PaintInfo paintInfo(context, fragment.backgroundRect.rect(), PaintPhase::Mask, paintBehavior, subtreePaintRootForRenderer, nullptr, nullptr, &localPaintingInfo.rootLayer->renderer(), this);
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 
@@ -3946,7 +3946,7 @@
 
         // Paint the clipped mask.
         PaintInfo paintInfo(context, fragment.backgroundRect.rect(), PaintPhase::ClippingMask, paintBehavior, subtreePaintRootForRenderer, nullptr, nullptr, &localPaintingInfo.rootLayer->renderer(), this);
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 
@@ -3962,7 +3962,7 @@
         EventRegionContextStateSaver eventRegionStateSaver(localPaintingInfo.eventRegionContext);
 
         clipToRect(context, stateSaver, eventRegionStateSaver, localPaintingInfo, { }, fragment.backgroundRect);
-        m_scrollableArea->paintOverflowControls(context, roundedIntPoint(toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset)), snappedIntRect(fragment.backgroundRect.rect()), true);
+        m_scrollableArea->paintOverflowControls(context, roundedIntPoint(paintOffsetForRenderer(fragment, localPaintingInfo)), snappedIntRect(fragment.backgroundRect.rect()), true);
     }
 }
 
@@ -3973,7 +3973,7 @@
     for (const auto& fragment : layerFragments) {
         PaintInfo paintInfo(context, fragment.foregroundRect.rect(), PaintPhase::EventRegion, paintBehavior);
         paintInfo.eventRegionContext = localPaintingInfo.eventRegionContext;
-        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + localPaintingInfo.subpixelOffset));
+        renderer().paint(paintInfo, paintOffsetForRenderer(fragment, localPaintingInfo));
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (289359 => 289360)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2022-02-08 05:47:11 UTC (rev 289359)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2022-02-08 09:53:04 UTC (rev 289360)
@@ -915,6 +915,11 @@
         EventRegionContext* eventRegionContext { nullptr };
     };
 
+    LayoutPoint paintOffsetForRenderer(const LayerFragment& fragment, const LayerPaintingInfo& paintingInfo) const
+    {
+        return toLayoutPoint(fragment.layerBounds.location() - rendererLocation() + paintingInfo.subpixelOffset);
+    }
+
     // Compute, cache and return clip rects computed with the given layer as the root.
     Ref<ClipRects> updateClipRects(const ClipRectsContext&);
     // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to