Changeset 217748 in webkit


Ignore:
Timestamp:
Jun 2, 2017 7:27:27 PM (7 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r217742 r217748  
     12017-06-02  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION(r216212): RenderReplaced::paint() should not save and restore the context unless it has to
     4        https://bugs.webkit.org/show_bug.cgi?id=172883
     5        <rdar://problem/32548614>
     6
     7        Reviewed by Tim Horton.
     8
     9        After implementing dragged content fading, RenderReplace::paint is now always guarded by unnecessary calls to
     10        GraphicsContext::save and GraphicsContext::restore, even when there is no dragged content being rendered. To
     11        address this, we initialize our GraphicsContextStateSaver with saveAndRestore = false, indicating that we don't
     12        want to immediately try and save the context.
     13
     14        If we are in a dragged content range, we will then call GraphicsContextStateSaver::save, which saves the
     15        graphics context and also causes the GraphicsContextStateSaver to eventually try and restore() when it is
     16        destroyed. Otherwise, in the common codepath where the renderer is not in a dragged content range, the
     17        constructor and destructor of GraphicsContextStateSaver will be no-ops with respect to saving and restoring the
     18        graphics context.
     19
     20        * rendering/RenderReplaced.cpp:
     21        (WebCore::RenderReplaced::paint):
     22
    1232017-06-02  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r216212 r217748  
    160160#endif
    161161
    162     GraphicsContextStateSaver savedGraphicsContext(paintInfo.context());
     162    GraphicsContextStateSaver savedGraphicsContext(paintInfo.context(), false);
    163163    if (element() && element()->parentOrShadowHostElement()) {
    164164        auto* parentContainer = element()->parentOrShadowHostElement();
    165         if (draggedContentContainsReplacedElement(document().markers().markersFor(parentContainer, DocumentMarker::DraggedContent), *element()))
     165        if (draggedContentContainsReplacedElement(document().markers().markersFor(parentContainer, DocumentMarker::DraggedContent), *element())) {
     166            savedGraphicsContext.save();
    166167            paintInfo.context().setAlpha(0.25);
     168        }
    167169    }
    168170
Note: See TracChangeset for help on using the changeset viewer.