<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194798] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194798">194798</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-01-08 15:26:48 -0800 (Fri, 08 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Consider painting to be disabled on a GraphicsContext with no platform data, and make updatingControlTints() immutable state
https://bugs.webkit.org/show_bug.cgi?id=152927

Reviewed by Tim Horton.

GraphicsContext had setters for paintingDisabled and updatingControlTints, but neither
were changed dynamically.

We can eliminate paintingDisabled by simply considering a GraphicsContext that was
created with no platform context to be paint-disabled.

We make updatingControlTints immutable state by providing a constructor that takes
a &quot;NonPaintingReasons&quot; enum, and doesn't create platform data.

More functions in platform code were protected by if (paintingDisabled())...

* page/FrameView.cpp:
(WebCore::FrameView::paintControlTints):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::setUpdatingControlTints): Deleted.
(WebCore::GraphicsContext::clip): Deleted.
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::paintingDisabled):
(WebCore::GraphicsContext::updatingControlTints):
(WebCore::GraphicsContextState::GraphicsContextState): Deleted.
(WebCore::GraphicsContext::setPaintingDisabled): Deleted.
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::savePlatformState):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::GraphicsContext::drawPattern):
(WebCore::GraphicsContext::drawRect):
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipBounds):
(WebCore::GraphicsContext::setLineDash):
(WebCore::GraphicsContext::roundToDevicePixels):
(WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
(WebCore::GraphicsContext::setIsCALayerContext):
(WebCore::GraphicsContext::isCALayerContext):
(WebCore::GraphicsContext::setIsAcceleratedContext):
(WebCore::GraphicsContext::isAcceleratedContext):
(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::GraphicsContext): Deleted.
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::GraphicsContext): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContextCGWincpp">trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContextCairoWincpp">trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/ChangeLog        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -1,3 +1,62 @@
</span><ins>+2016-01-08  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Consider painting to be disabled on a GraphicsContext with no platform data, and make updatingControlTints() immutable state
+        https://bugs.webkit.org/show_bug.cgi?id=152927
+
+        Reviewed by Tim Horton.
+
+        GraphicsContext had setters for paintingDisabled and updatingControlTints, but neither
+        were changed dynamically.
+        
+        We can eliminate paintingDisabled by simply considering a GraphicsContext that was
+        created with no platform context to be paint-disabled.
+        
+        We make updatingControlTints immutable state by providing a constructor that takes
+        a &quot;NonPaintingReasons&quot; enum, and doesn't create platform data.
+        
+        More functions in platform code were protected by if (paintingDisabled())...
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::paintControlTints):
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::GraphicsContext):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setUpdatingControlTints): Deleted.
+        (WebCore::GraphicsContext::clip): Deleted.
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContext::paintingDisabled):
+        (WebCore::GraphicsContext::updatingControlTints):
+        (WebCore::GraphicsContextState::GraphicsContextState): Deleted.
+        (WebCore::GraphicsContext::setPaintingDisabled): Deleted.
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::GraphicsContext):
+        (WebCore::GraphicsContext::platformInit):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::platformInit):
+        (WebCore::GraphicsContext::savePlatformState):
+        (WebCore::GraphicsContext::restorePlatformState):
+        (WebCore::GraphicsContext::drawNativeImage):
+        (WebCore::GraphicsContext::drawPattern):
+        (WebCore::GraphicsContext::drawRect):
+        (WebCore::GraphicsContext::applyStrokePattern):
+        (WebCore::GraphicsContext::applyFillPattern):
+        (WebCore::GraphicsContext::clip):
+        (WebCore::GraphicsContext::clipBounds):
+        (WebCore::GraphicsContext::setLineDash):
+        (WebCore::GraphicsContext::roundToDevicePixels):
+        (WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
+        (WebCore::GraphicsContext::setIsCALayerContext):
+        (WebCore::GraphicsContext::isCALayerContext):
+        (WebCore::GraphicsContext::setIsAcceleratedContext):
+        (WebCore::GraphicsContext::isAcceleratedContext):
+        (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
+        * platform/graphics/win/GraphicsContextCGWin.cpp:
+        (WebCore::GraphicsContext::platformInit):
+        (WebCore::GraphicsContext::GraphicsContext): Deleted.
+        * platform/graphics/win/GraphicsContextCairoWin.cpp:
+        (WebCore::GraphicsContext::platformInit):
+        (WebCore::GraphicsContext::GraphicsContext): Deleted.
+
</ins><span class="cx"> 2016-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         InputType::findClosestTickMarkValue should return an Optional&lt;Decimal&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/page/FrameView.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -3897,8 +3897,7 @@
</span><span class="cx">     if (needsLayout())
</span><span class="cx">         layout();
</span><span class="cx"> 
</span><del>-    GraphicsContext context((PlatformGraphicsContext*)nullptr);
-    context.setUpdatingControlTints(true);
</del><ins>+    GraphicsContext context(GraphicsContext::NonPaintingReasons::UpdatingControlTints);
</ins><span class="cx">     if (platformWidget()) {
</span><span class="cx">         // FIXME: consult paintsEntireContents().
</span><span class="cx">         paintContents(context, visibleContentRect(LegacyIOSDocumentVisibleRect));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -359,10 +359,12 @@
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GraphicsContext::GraphicsContext(NonPaintingReasons nonPaintingReasons)
+    : m_nonPaintingReasons(nonPaintingReasons)
+{
+}
</ins><span class="cx"> 
</span><span class="cx"> GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContext)
</span><del>-    : m_updatingControlTints(false)
-    , m_transparencyCount(0)
</del><span class="cx"> {
</span><span class="cx">     platformInit(platformGraphicsContext);
</span><span class="cx"> }
</span><span class="lines">@@ -570,12 +572,6 @@
</span><span class="cx">     --m_transparencyCount;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::setUpdatingControlTints(bool b)
-{
-    setPaintingDisabled(b);
-    m_updatingControlTints = b;
-}
-
</del><span class="cx"> float GraphicsContext::drawText(const FontCascade&amp; font, const TextRun&amp; run, const FloatPoint&amp; point, int from, int to)
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="lines">@@ -732,11 +728,6 @@
</span><span class="cx">     ImageBuffer::drawConsuming(WTFMove(image), *this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_useLowQualityScale);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::clip(const IntRect&amp; rect)
-{
-    clip(FloatRect(rect));
-}
-
</del><span class="cx"> void GraphicsContext::clipRoundedRect(const FloatRoundedRect&amp; rect)
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="lines">@@ -798,6 +789,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::fillRoundedRect(const FloatRoundedRect&amp; rect, const Color&amp; color, BlendMode blendMode)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     if (rect.isRounded()) {
</span><span class="cx">         setCompositeOperation(compositeOperation(), blendMode);
</span><span class="cx">         platformFillRoundedRect(rect, color);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -116,7 +116,6 @@
</span><span class="cx">         , shouldSmoothFonts(true)
</span><span class="cx">         , antialiasedFontDilationEnabled(true)
</span><span class="cx">         , shouldSubpixelQuantizeFonts(true)
</span><del>-        , paintingDisabled(false)
</del><span class="cx">         , shadowsIgnoreTransforms(false)
</span><span class="cx"> #if USE(CG)
</span><span class="cx">         // Core Graphics incorrectly renders shadows with radius &gt; 8px (&lt;rdar://problem/8103442&gt;),
</span><span class="lines">@@ -183,7 +182,6 @@
</span><span class="cx">     bool shouldSmoothFonts : 1;
</span><span class="cx">     bool antialiasedFontDilationEnabled : 1;
</span><span class="cx">     bool shouldSubpixelQuantizeFonts : 1;
</span><del>-    bool paintingDisabled : 1;
</del><span class="cx">     bool shadowsIgnoreTransforms : 1;
</span><span class="cx"> #if USE(CG)
</span><span class="cx">     bool shadowsUseLegacyRadius : 1;
</span><span class="lines">@@ -249,9 +247,18 @@
</span><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*);
</span><span class="cx">     WEBCORE_EXPORT ~GraphicsContext();
</span><ins>+    
+    enum class NonPaintingReasons {
+        NoReasons,
+        UpdatingControlTints
+    };
+    GraphicsContext(NonPaintingReasons);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
</span><span class="cx"> 
</span><ins>+    bool paintingDisabled() const { return !m_data; }
+    bool updatingControlTints() const { return m_nonPaintingReasons == NonPaintingReasons::UpdatingControlTints; }
+
</ins><span class="cx">     void setStrokeThickness(float);
</span><span class="cx">     float strokeThickness() const { return m_state.strokeThickness; }
</span><span class="cx"> 
</span><span class="lines">@@ -367,7 +374,6 @@
</span><span class="cx">     WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
</span><span class="cx">     InterpolationQuality imageInterpolationQuality() const { return m_state.imageInterpolationQuality; }
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void clip(const IntRect&amp;);
</del><span class="cx">     WEBCORE_EXPORT void clip(const FloatRect&amp;);
</span><span class="cx">     void clipRoundedRect(const FloatRoundedRect&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -408,12 +414,6 @@
</span><span class="cx">     static void updateDocumentMarkerResources();
</span><span class="cx">     void drawLineForDocumentMarker(const FloatPoint&amp;, float width, DocumentMarkerLineStyle);
</span><span class="cx"> 
</span><del>-    void setPaintingDisabled(bool paintingDisabled) { m_state.paintingDisabled = paintingDisabled; }
-    bool paintingDisabled() const { return m_state.paintingDisabled; }
-
-    void setUpdatingControlTints(bool);
-    bool updatingControlTints() const { return m_updatingControlTints; }
-
</del><span class="cx">     WEBCORE_EXPORT void beginTransparencyLayer(float opacity);
</span><span class="cx">     WEBCORE_EXPORT void endTransparencyLayer();
</span><span class="cx">     bool isInTransparencyLayer() const { return (m_transparencyCount &gt; 0) &amp;&amp; supportsTransparencyLayers(); }
</span><span class="lines">@@ -601,12 +601,13 @@
</span><span class="cx"> 
</span><span class="cx">     FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&amp;, float width, bool printing,  Color&amp;);
</span><span class="cx"> 
</span><del>-    GraphicsContextPlatformPrivate* m_data;
</del><ins>+    GraphicsContextPlatformPrivate* m_data { nullptr };
</ins><span class="cx"> 
</span><span class="cx">     GraphicsContextState m_state;
</span><span class="cx">     Vector&lt;GraphicsContextState, 1&gt; m_stack;
</span><del>-    bool m_updatingControlTints;
-    unsigned m_transparencyCount;
</del><ins>+
+    const NonPaintingReasons m_nonPaintingReasons { NonPaintingReasons::NoReasons };
+    unsigned m_transparencyCount { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class GraphicsContextStateSaver {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -175,19 +175,20 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GraphicsContext::GraphicsContext(cairo_t* cr)
</span><del>-    : m_updatingControlTints(false)
-    , m_transparencyCount(0)
</del><span class="cx"> {
</span><ins>+    if (!cr)
+        return;
+
</ins><span class="cx">     m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformInit(PlatformContextCairo* platformContext)
</span><span class="cx"> {
</span><ins>+    if (!platformContext)
+        return;
+
</ins><span class="cx">     m_data = new GraphicsContextPlatformPrivate(platformContext);
</span><del>-    if (platformContext)
-        m_data-&gt;syncContext(platformContext-&gt;cr());
-    else
-        setPaintingDisabled(true);
</del><ins>+    m_data-&gt;syncContext(platformContext-&gt;cr());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformDestroy()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -115,15 +115,15 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformInit(CGContextRef cgContext)
</span><span class="cx"> {
</span><ins>+    if (!cgContext)
+        return;
+
</ins><span class="cx">     m_data = new GraphicsContextPlatformPrivate(cgContext);
</span><del>-    setPaintingDisabled(!cgContext);
-    if (cgContext) {
-        // Make sure the context starts in sync with our state.
-        setPlatformFillColor(fillColor());
-        setPlatformStrokeColor(strokeColor());
-        setPlatformStrokeThickness(strokeThickness());
-        m_state.imageInterpolationQuality = convertInterpolationQuality(CGContextGetInterpolationQuality(platformContext()));
-    }
</del><ins>+    // Make sure the context starts in sync with our state.
+    setPlatformFillColor(fillColor());
+    setPlatformStrokeColor(strokeColor());
+    setPlatformStrokeThickness(strokeThickness());
+    m_state.imageInterpolationQuality = convertInterpolationQuality(CGContextGetInterpolationQuality(platformContext()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformDestroy()
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::savePlatformState()
</span><span class="cx"> {
</span><ins>+    ASSERT(!paintingDisabled());
</ins><span class="cx">     // Note: Do not use this function within this class implementation, since we want to avoid the extra
</span><span class="cx">     // save of the secondary context (in GraphicsContextPlatformPrivateCG.h).
</span><span class="cx">     CGContextSaveGState(platformContext());
</span><span class="lines">@@ -148,6 +149,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::restorePlatformState()
</span><span class="cx"> {
</span><ins>+    ASSERT(!paintingDisabled());
</ins><span class="cx">     // Note: Do not use this function within this class implementation, since we want to avoid the extra
</span><span class="cx">     // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h).
</span><span class="cx">     CGContextRestoreGState(platformContext());
</span><span class="lines">@@ -157,6 +159,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize&amp; imageSize, const FloatRect&amp; destRect, const FloatRect&amp; srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     RetainPtr&lt;CGImageRef&gt; image(imagePtr);
</span><span class="cx"> 
</span><span class="cx">     float currHeight = orientation.usesWidthAsHeight() ? CGImageGetWidth(image.get()) : CGImageGetHeight(image.get());
</span><span class="lines">@@ -271,7 +276,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::drawPattern(Image&amp; image, const FloatRect&amp; tileRect, const AffineTransform&amp; patternTransform, const FloatPoint&amp; phase, const FloatSize&amp; spacing, CompositeOperator op, const FloatRect&amp; destRect, BlendMode blendMode)
</span><span class="cx"> {
</span><del>-    if (!patternTransform.isInvertible())
</del><ins>+    if (paintingDisabled() || !patternTransform.isInvertible())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     CGContextRef context = platformContext();
</span><span class="lines">@@ -371,11 +376,10 @@
</span><span class="cx"> // Draws a filled rectangle with a stroked border.
</span><span class="cx"> void GraphicsContext::drawRect(const FloatRect&amp; rect, float borderThickness)
</span><span class="cx"> {
</span><del>-    // FIXME: this function does not handle patterns and gradients
-    // like drawPath does, it probably should.
</del><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    // FIXME: this function does not handle patterns and gradients like drawPath does, it probably should.
</ins><span class="cx">     ASSERT(!rect.isEmpty());
</span><span class="cx"> 
</span><span class="cx">     CGContextRef context = platformContext();
</span><span class="lines">@@ -552,6 +556,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::applyStrokePattern()
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     CGContextRef cgContext = platformContext();
</span><span class="cx">     AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
</span><span class="cx"> 
</span><span class="lines">@@ -568,6 +575,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::applyFillPattern()
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     CGContextRef cgContext = platformContext();
</span><span class="cx">     AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
</span><span class="cx"> 
</span><span class="lines">@@ -921,6 +931,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return;
</span><ins>+
</ins><span class="cx">     CGContextClipToRect(platformContext(), rect);
</span><span class="cx">     m_data-&gt;clip(rect);
</span><span class="cx"> }
</span><span class="lines">@@ -965,6 +976,9 @@
</span><span class="cx"> 
</span><span class="cx"> IntRect GraphicsContext::clipBounds() const
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return IntRect();
+
</ins><span class="cx">     return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1172,6 +1186,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setLineDash(const DashArray&amp; dashes, float dashOffset)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     if (dashOffset &lt; 0) {
</span><span class="cx">         float length = 0;
</span><span class="cx">         for (size_t i = 0; i &lt; dashes.size(); ++i)
</span><span class="lines">@@ -1277,6 +1294,9 @@
</span><span class="cx"> 
</span><span class="cx"> FloatRect GraphicsContext::roundToDevicePixels(const FloatRect&amp; rect, RoundingMode roundingMode)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return rect;
+
</ins><span class="cx">     // It is not enough just to round to pixels in device space. The rotation part of the
</span><span class="cx">     // affine transform matrix to device space can mess with this conversion if we have a
</span><span class="cx">     // rotating image like the hands of the world clock widget. We just need the scale, so
</span><span class="lines">@@ -1390,6 +1410,8 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality mode)
</span><span class="cx"> {
</span><ins>+    ASSERT(!paintingDisabled());
+
</ins><span class="cx">     CGInterpolationQuality quality = kCGInterpolationDefault;
</span><span class="cx">     switch (mode) {
</span><span class="cx">     case InterpolationDefault:
</span><span class="lines">@@ -1413,6 +1435,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setIsCALayerContext(bool isLayerContext)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     if (isLayerContext)
</span><span class="cx">         m_data-&gt;m_contextFlags |= IsLayerCGContext;
</span><span class="cx">     else
</span><span class="lines">@@ -1421,11 +1446,17 @@
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsContext::isCALayerContext() const
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return false;
+
</ins><span class="cx">     return m_data-&gt;m_contextFlags &amp; IsLayerCGContext;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::setIsAcceleratedContext(bool isAccelerated)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     if (isAccelerated)
</span><span class="cx">         m_data-&gt;m_contextFlags |= IsAcceleratedCGContext;
</span><span class="cx">     else
</span><span class="lines">@@ -1434,6 +1465,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsContext::isAcceleratedContext() const
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return false;
+
</ins><span class="cx">     return m_data-&gt;m_contextFlags &amp; IsAcceleratedCGContext;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1613,6 +1647,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformApplyDeviceScaleFactor(float deviceScaleFactor)
</span><span class="cx"> {
</span><ins>+    if (paintingDisabled())
+        return;
+
</ins><span class="cx">     // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it.
</span><span class="cx">     // Failing to change the base level CTM will cause certain CG features, such as focus rings,
</span><span class="cx">     // to draw with a scale factor of 1 rather than the actual scale factor.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContextCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -68,18 +68,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
</span><del>-    : m_updatingControlTints(false),
-      m_transparencyCount(0)
</del><span class="cx"> {
</span><span class="cx">     platformInit(hdc, hasAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
</span><span class="cx"> {
</span><ins>+    if (!hdc)
+        return;
+
</ins><span class="cx">     m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha));
</span><span class="cx">     CGContextRelease(m_data-&gt;m_cgContext.get());
</span><span class="cx">     m_data-&gt;m_hdc = hdc;
</span><del>-    setPaintingDisabled(!m_data-&gt;m_cgContext);
</del><span class="cx">     if (m_data-&gt;m_cgContext) {
</span><span class="cx">         // Make sure the context starts in sync with our state.
</span><span class="cx">         setPlatformFillColor(fillColor());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContextCairoWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp (194797 => 194798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp        2016-01-08 23:25:15 UTC (rev 194797)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp        2016-01-08 23:26:48 UTC (rev 194798)
</span><span class="lines">@@ -67,20 +67,17 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
</span><del>-    : m_updatingControlTints(false),
-      m_transparencyCount(0)
</del><span class="cx"> {
</span><span class="cx">     platformInit(dc, hasAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
</span><span class="cx"> {
</span><del>-    cairo_t* cr = 0;
-    if (dc)
-        cr = createCairoContextWithHDC(dc, hasAlpha);
-    else
-        setPaintingDisabled(true);
</del><ins>+    if (!dc)
+        return;
</ins><span class="cx"> 
</span><ins>+    cairo_t* cr = createCairoContextWithHDC(dc, hasAlpha);
+
</ins><span class="cx">     m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
</span><span class="cx">     m_data-&gt;m_hdc = dc;
</span><span class="cx">     if (platformContext()-&gt;cr()) {
</span></span></pre>
</div>
</div>

</body>
</html>