Title: [217748] trunk/Source/WebCore
Revision
217748
Author
wenson_hs...@apple.com
Date
2017-06-02 19:27:27 -0700 (Fri, 02 Jun 2017)

Log Message

REGRESSION(r216212): RenderReplaced::paint() should not save and restore the context unless it has to
https://bugs.webkit.org/show_bug.cgi?id=172883
<rdar://problem/32548614>

Reviewed by Tim Horton.

After implementing dragged content fading, RenderReplace::paint is now always guarded by unnecessary calls to
GraphicsContext::save and GraphicsContext::restore, even when there is no dragged content being rendered. To
address this, we initialize our GraphicsContextStateSaver with saveAndRestore = false, indicating that we don't
want to immediately try and save the context.

If we are in a dragged content range, we will then call GraphicsContextStateSaver::save, which saves the
graphics context and also causes the GraphicsContextStateSaver to eventually try and restore() when it is
destroyed. Otherwise, in the common codepath where the renderer is not in a dragged content range, the
constructor and destructor of GraphicsContextStateSaver will be no-ops with respect to saving and restoring the
graphics context.

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::paint):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (217747 => 217748)


--- trunk/Source/WebCore/ChangeLog	2017-06-03 01:35:00 UTC (rev 217747)
+++ trunk/Source/WebCore/ChangeLog	2017-06-03 02:27:27 UTC (rev 217748)
@@ -1,3 +1,25 @@
+2017-06-02  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        REGRESSION(r216212): RenderReplaced::paint() should not save and restore the context unless it has to
+        https://bugs.webkit.org/show_bug.cgi?id=172883
+        <rdar://problem/32548614>
+
+        Reviewed by Tim Horton.
+
+        After implementing dragged content fading, RenderReplace::paint is now always guarded by unnecessary calls to
+        GraphicsContext::save and GraphicsContext::restore, even when there is no dragged content being rendered. To
+        address this, we initialize our GraphicsContextStateSaver with saveAndRestore = false, indicating that we don't
+        want to immediately try and save the context.
+
+        If we are in a dragged content range, we will then call GraphicsContextStateSaver::save, which saves the
+        graphics context and also causes the GraphicsContextStateSaver to eventually try and restore() when it is
+        destroyed. Otherwise, in the common codepath where the renderer is not in a dragged content range, the
+        constructor and destructor of GraphicsContextStateSaver will be no-ops with respect to saving and restoring the
+        graphics context.
+
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::paint):
+
 2017-06-02  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         REGRESSION(r213464): [iOS] Fonts get too bold when the "Bold Text" accessibility setting is enabled

Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (217747 => 217748)


--- trunk/Source/WebCore/rendering/RenderReplaced.cpp	2017-06-03 01:35:00 UTC (rev 217747)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp	2017-06-03 02:27:27 UTC (rev 217748)
@@ -159,11 +159,13 @@
     SetLayoutNeededForbiddenScope scope(this);
 #endif
 
-    GraphicsContextStateSaver savedGraphicsContext(paintInfo.context());
+    GraphicsContextStateSaver savedGraphicsContext(paintInfo.context(), false);
     if (element() && element()->parentOrShadowHostElement()) {
         auto* parentContainer = element()->parentOrShadowHostElement();
-        if (draggedContentContainsReplacedElement(document().markers().markersFor(parentContainer, DocumentMarker::DraggedContent), *element()))
+        if (draggedContentContainsReplacedElement(document().markers().markersFor(parentContainer, DocumentMarker::DraggedContent), *element())) {
+            savedGraphicsContext.save();
             paintInfo.context().setAlpha(0.25);
+        }
     }
 
     LayoutPoint adjustedPaintOffset = paintOffset + location();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to