Title: [274682] trunk/Source/WebCore
Revision
274682
Author
[email protected]
Date
2021-03-18 16:11:05 -0700 (Thu, 18 Mar 2021)

Log Message

Don't spend time painting transparent cell backgrounds
https://bugs.webkit.org/show_bug.cgi?id=223459

Reviewed by Darin Adler.

We can bail early from RenderTableCell::paintBackgroundsBehindCell() if the style has
no background image, and the background color is transparent (the default).

Removes 2% of painting time in the MotionMark Design subtest.

* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBackgroundsBehindCell):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274681 => 274682)


--- trunk/Source/WebCore/ChangeLog	2021-03-18 23:09:34 UTC (rev 274681)
+++ trunk/Source/WebCore/ChangeLog	2021-03-18 23:11:05 UTC (rev 274682)
@@ -1,3 +1,18 @@
+2021-03-18  Simon Fraser  <[email protected]>
+
+        Don't spend time painting transparent cell backgrounds
+        https://bugs.webkit.org/show_bug.cgi?id=223459
+
+        Reviewed by Darin Adler.
+
+        We can bail early from RenderTableCell::paintBackgroundsBehindCell() if the style has
+        no background image, and the background color is transparent (the default).
+
+        Removes 2% of painting time in the MotionMark Design subtest.
+
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintBackgroundsBehindCell):
+
 2021-03-18  Chris Dumez  <[email protected]>
 
         Avoid heap allocation under PannerNode::processSampleAccurateValues()

Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (274681 => 274682)


--- trunk/Source/WebCore/rendering/RenderTableCell.cpp	2021-03-18 23:09:34 UTC (rev 274681)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp	2021-03-18 23:11:05 UTC (rev 274682)
@@ -1280,30 +1280,30 @@
     if (!tableElt->collapseBorders() && style().emptyCells() == EmptyCell::Hide && !firstChild())
         return;
 
-    LayoutPoint adjustedPaintOffset = paintOffset;
-    if (backgroundObject != this)
-        adjustedPaintOffset.moveBy(location());
-
     const auto& style = backgroundObject->style();
     auto& bgLayer = style.backgroundLayers();
 
     auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
-    auto compositeOp = document().compositeOperatorForBackgroundColor(color, *this);
+    if (!bgLayer.hasImage() && !color.isVisible())
+        return;
 
     color = style.colorByApplyingColorFilter(color);
 
-    if (bgLayer.hasImage() || color.isValid()) {
-        // We have to clip here because the background would paint
-        // on top of the borders otherwise.  This only matters for cells and rows.
-        bool shouldClip = backgroundObject->hasLayer() && (backgroundObject == this || backgroundObject == parent()) && tableElt->collapseBorders();
-        GraphicsContextStateSaver stateSaver(paintInfo.context(), shouldClip);
-        if (shouldClip) {
-            LayoutRect clipRect(adjustedPaintOffset.x() + borderLeft(), adjustedPaintOffset.y() + borderTop(),
-                width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
-            paintInfo.context().clip(clipRect);
-        }
-        paintFillLayers(paintInfo, color, bgLayer, LayoutRect(adjustedPaintOffset, frameRect().size()), BackgroundBleedNone, compositeOp, backgroundObject);
+    LayoutPoint adjustedPaintOffset = paintOffset;
+    if (backgroundObject != this)
+        adjustedPaintOffset.moveBy(location());
+
+    // We have to clip here because the background would paint
+    // on top of the borders otherwise. This only matters for cells and rows.
+    bool shouldClip = backgroundObject->hasLayer() && (backgroundObject == this || backgroundObject == parent()) && tableElt->collapseBorders();
+    GraphicsContextStateSaver stateSaver(paintInfo.context(), shouldClip);
+    if (shouldClip) {
+        LayoutRect clipRect(adjustedPaintOffset.x() + borderLeft(), adjustedPaintOffset.y() + borderTop(),
+            width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
+        paintInfo.context().clip(clipRect);
     }
+    auto compositeOp = document().compositeOperatorForBackgroundColor(color, *this);
+    paintFillLayers(paintInfo, color, bgLayer, LayoutRect(adjustedPaintOffset, frameRect().size()), BackgroundBleedNone, compositeOp, backgroundObject);
 }
 
 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to