<!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>[149928] 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/149928">149928</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2013-05-11 01:36:42 -0700 (Sat, 11 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make CanvasStyle a plain object instead of an RefCounted object
https://bugs.webkit.org/show_bug.cgi?id=115775

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2013-05-11
Reviewed by Andreas Kling.

CanvasStyle is just 2 words wide. We do not gain anything from allocating
it on the heap. Change the object to be just a type and some data.

* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toJS):
(WebCore::toHTMLCanvasStyle):
* html/HTMLCanvasElement.cpp:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::State::State):
(WebCore::CanvasRenderingContext2D::setStrokeStyle):
(WebCore::CanvasRenderingContext2D::setFillStyle):
(WebCore::CanvasRenderingContext2D::setStrokeColor):
(WebCore::CanvasRenderingContext2D::setFillColor):
(WebCore::CanvasRenderingContext2D::fullCanvasCompositedFill):
(WebCore::CanvasRenderingContext2D::drawTextInternal):
* html/canvas/CanvasRenderingContext2D.h:
(WebCore::CanvasRenderingContext2D::strokeStyle):
(CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::fillStyle):
(State):
* html/canvas/CanvasStyle.cpp:
(WebCore::CanvasStyle::CanvasStyle):
(WebCore::CanvasStyle::createFromString):
(WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
(WebCore::CanvasStyle::isEquivalentColor):
(WebCore):
(WebCore::CanvasStyle::operator=):
(WebCore::CanvasStyle::applyStrokeColor):
(WebCore::CanvasStyle::applyFillColor):
* html/canvas/CanvasStyle.h:
(CanvasStyle):
(WebCore::CanvasStyle::isValid):
(WebCore::CanvasStyle::CanvasStyle):
(WebCore):
(WebCore::CanvasStyle::operator=):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCanvasRenderingContext2DCustomcpp">trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementcpp">trunk/Source/WebCore/html/HTMLCanvasElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasStylecpp">trunk/Source/WebCore/html/canvas/CanvasStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasStyleh">trunk/Source/WebCore/html/canvas/CanvasStyle.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/ChangeLog        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2013-05-11  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        Make CanvasStyle a plain object instead of an RefCounted object
+        https://bugs.webkit.org/show_bug.cgi?id=115775
+
+        Reviewed by Andreas Kling.
+
+        CanvasStyle is just 2 words wide. We do not gain anything from allocating
+        it on the heap. Change the object to be just a type and some data.
+
+        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
+        (WebCore::toJS):
+        (WebCore::toHTMLCanvasStyle):
+        * html/HTMLCanvasElement.cpp:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::State::State):
+        (WebCore::CanvasRenderingContext2D::setStrokeStyle):
+        (WebCore::CanvasRenderingContext2D::setFillStyle):
+        (WebCore::CanvasRenderingContext2D::setStrokeColor):
+        (WebCore::CanvasRenderingContext2D::setFillColor):
+        (WebCore::CanvasRenderingContext2D::fullCanvasCompositedFill):
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+        * html/canvas/CanvasRenderingContext2D.h:
+        (WebCore::CanvasRenderingContext2D::strokeStyle):
+        (CanvasRenderingContext2D):
+        (WebCore::CanvasRenderingContext2D::fillStyle):
+        (State):
+        * html/canvas/CanvasStyle.cpp:
+        (WebCore::CanvasStyle::CanvasStyle):
+        (WebCore::CanvasStyle::createFromString):
+        (WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
+        (WebCore::CanvasStyle::isEquivalentColor):
+        (WebCore):
+        (WebCore::CanvasStyle::operator=):
+        (WebCore::CanvasStyle::applyStrokeColor):
+        (WebCore::CanvasStyle::applyFillColor):
+        * html/canvas/CanvasStyle.h:
+        (CanvasStyle):
+        (WebCore::CanvasStyle::isValid):
+        (WebCore::CanvasStyle::CanvasStyle):
+        (WebCore):
+        (WebCore::CanvasStyle::operator=):
+
</ins><span class="cx"> 2013-05-11  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Gradient::platformGradient: Vector reserveCapacity -&gt; reserveInitialCapacity
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCanvasRenderingContext2DCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -38,25 +38,25 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CanvasStyle* style)
</del><ins>+static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const CanvasStyle&amp; style)
</ins><span class="cx"> {
</span><del>-    if (style-&gt;canvasGradient())
-        return toJS(exec, globalObject, style-&gt;canvasGradient());
-    if (style-&gt;canvasPattern())
-        return toJS(exec, globalObject, style-&gt;canvasPattern());
-    return jsStringWithCache(exec, style-&gt;color());
</del><ins>+    if (style.canvasGradient())
+        return toJS(exec, globalObject, style.canvasGradient());
+    if (style.canvasPattern())
+        return toJS(exec, globalObject, style.canvasPattern());
+    return jsStringWithCache(exec, style.color());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static PassRefPtr&lt;CanvasStyle&gt; toHTMLCanvasStyle(ExecState*, JSValue value)
</del><ins>+static CanvasStyle toHTMLCanvasStyle(ExecState*, JSValue value)
</ins><span class="cx"> {
</span><span class="cx">     if (!value.isObject())
</span><del>-        return 0;
</del><ins>+        return CanvasStyle();
</ins><span class="cx">     JSObject* object = asObject(value);
</span><span class="cx">     if (object-&gt;inherits(&amp;JSCanvasGradient::s_info))
</span><del>-        return CanvasStyle::createFromGradient(jsCast&lt;JSCanvasGradient*&gt;(object)-&gt;impl());
</del><ins>+        return CanvasStyle(jsCast&lt;JSCanvasGradient*&gt;(object)-&gt;impl());
</ins><span class="cx">     if (object-&gt;inherits(&amp;JSCanvasPattern::s_info))
</span><del>-        return CanvasStyle::createFromPattern(jsCast&lt;JSCanvasPattern*&gt;(object)-&gt;impl());
-    return 0;
</del><ins>+        return CanvasStyle(jsCast&lt;JSCanvasPattern*&gt;(object)-&gt;impl());
+    return CanvasStyle();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue JSCanvasRenderingContext2D::strokeStyle(ExecState* exec) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> #include &quot;CanvasGradient.h&quot;
</span><span class="cx"> #include &quot;CanvasPattern.h&quot;
</span><span class="cx"> #include &quot;CanvasRenderingContext2D.h&quot;
</span><del>-#include &quot;CanvasStyle.h&quot;
</del><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -40,7 +40,6 @@
</span><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="cx"> #include &quot;CanvasGradient.h&quot;
</span><span class="cx"> #include &quot;CanvasPattern.h&quot;
</span><del>-#include &quot;CanvasStyle.h&quot;
</del><span class="cx"> #include &quot;Console.h&quot;
</span><span class="cx"> #include &quot;DOMPath.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="lines">@@ -180,8 +179,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasRenderingContext2D::State::State()
</span><del>-    : m_strokeStyle(CanvasStyle::createFromRGBA(Color::black))
-    , m_fillStyle(CanvasStyle::createFromRGBA(Color::black))
</del><ins>+    : m_strokeStyle(Color::black)
+    , m_fillStyle(Color::black)
</ins><span class="cx">     , m_lineWidth(1)
</span><span class="cx">     , m_lineCap(ButtCap)
</span><span class="cx">     , m_lineJoin(MiterJoin)
</span><span class="lines">@@ -312,68 +311,56 @@
</span><span class="cx">     c-&gt;restore();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CanvasStyle* CanvasRenderingContext2D::strokeStyle() const
</del><ins>+void CanvasRenderingContext2D::setStrokeStyle(CanvasStyle style)
</ins><span class="cx"> {
</span><del>-    return state().m_strokeStyle.get();
-}
-
-void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr&lt;CanvasStyle&gt; prpStyle)
-{
-    RefPtr&lt;CanvasStyle&gt; style = prpStyle;
-
-    if (!style)
</del><ins>+    if (!style.isValid())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (state().m_strokeStyle &amp;&amp; state().m_strokeStyle-&gt;isEquivalentColor(*style))
</del><ins>+    if (state().m_strokeStyle.isValid() &amp;&amp; state().m_strokeStyle.isEquivalentColor(style))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (style-&gt;isCurrentColor()) {
-        if (style-&gt;hasOverrideAlpha())
-            style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentColor(canvas()), style-&gt;overrideAlpha()));
</del><ins>+    if (style.isCurrentColor()) {
+        if (style.hasOverrideAlpha())
+            style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()), style.overrideAlpha()));
</ins><span class="cx">         else
</span><del>-            style = CanvasStyle::createFromRGBA(currentColor(canvas()));
</del><ins>+            style = CanvasStyle(currentColor(canvas()));
</ins><span class="cx">     } else
</span><del>-        checkOrigin(style-&gt;canvasPattern());
</del><ins>+        checkOrigin(style.canvasPattern());
</ins><span class="cx"> 
</span><span class="cx">     realizeSaves();
</span><del>-    modifiableState().m_strokeStyle = style.release();
</del><ins>+    State&amp; state = modifiableState();
+    state.m_strokeStyle = style;
</ins><span class="cx">     GraphicsContext* c = drawingContext();
</span><span class="cx">     if (!c)
</span><span class="cx">         return;
</span><del>-    state().m_strokeStyle-&gt;applyStrokeColor(c);
-    modifiableState().m_unparsedStrokeColor = String();
</del><ins>+    state.m_strokeStyle.applyStrokeColor(c);
+    state.m_unparsedStrokeColor = String();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-CanvasStyle* CanvasRenderingContext2D::fillStyle() const
</del><ins>+void CanvasRenderingContext2D::setFillStyle(CanvasStyle style)
</ins><span class="cx"> {
</span><del>-    return state().m_fillStyle.get();
-}
-
-void CanvasRenderingContext2D::setFillStyle(PassRefPtr&lt;CanvasStyle&gt; prpStyle)
-{
-    RefPtr&lt;CanvasStyle&gt; style = prpStyle;
-
-    if (!style)
</del><ins>+    if (!style.isValid())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (state().m_fillStyle &amp;&amp; state().m_fillStyle-&gt;isEquivalentColor(*style))
</del><ins>+    if (state().m_fillStyle.isValid() &amp;&amp; state().m_fillStyle.isEquivalentColor(style))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (style-&gt;isCurrentColor()) {
-        if (style-&gt;hasOverrideAlpha())
-            style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentColor(canvas()), style-&gt;overrideAlpha()));
</del><ins>+    if (style.isCurrentColor()) {
+        if (style.hasOverrideAlpha())
+            style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()), style.overrideAlpha()));
</ins><span class="cx">         else
</span><del>-            style = CanvasStyle::createFromRGBA(currentColor(canvas()));
</del><ins>+            style = CanvasStyle(currentColor(canvas()));
</ins><span class="cx">     } else
</span><del>-        checkOrigin(style-&gt;canvasPattern());
</del><ins>+        checkOrigin(style.canvasPattern());
</ins><span class="cx"> 
</span><span class="cx">     realizeSaves();
</span><del>-    modifiableState().m_fillStyle = style.release();
</del><ins>+    State&amp; state = modifiableState();
+    state.m_fillStyle = style;
</ins><span class="cx">     GraphicsContext* c = drawingContext();
</span><span class="cx">     if (!c)
</span><span class="cx">         return;
</span><del>-    state().m_fillStyle-&gt;applyFillColor(c);
-    modifiableState().m_unparsedFillColor = String();
</del><ins>+    state.m_fillStyle.applyFillColor(c);
+    state.m_unparsedFillColor = String();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float CanvasRenderingContext2D::lineWidth() const
</span><span class="lines">@@ -782,9 +769,9 @@
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setStrokeColor(float grayLevel)
</span><span class="cx"> {
</span><del>-    if (state().m_strokeStyle &amp;&amp; state().m_strokeStyle-&gt;isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
</del><ins>+    if (state().m_strokeStyle.isValid() &amp;&amp; state().m_strokeStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
</ins><span class="cx">         return;
</span><del>-    setStrokeStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f));
</del><ins>+    setStrokeStyle(CanvasStyle(grayLevel, 1.0f));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setStrokeColor(const String&amp; color, float alpha)
</span><span class="lines">@@ -794,23 +781,23 @@
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setStrokeColor(float grayLevel, float alpha)
</span><span class="cx"> {
</span><del>-    if (state().m_strokeStyle &amp;&amp; state().m_strokeStyle-&gt;isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
</del><ins>+    if (state().m_strokeStyle.isValid() &amp;&amp; state().m_strokeStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
</ins><span class="cx">         return;
</span><del>-    setStrokeStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, alpha));
</del><ins>+    setStrokeStyle(CanvasStyle(grayLevel, alpha));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setStrokeColor(float r, float g, float b, float a)
</span><span class="cx"> {
</span><del>-    if (state().m_strokeStyle &amp;&amp; state().m_strokeStyle-&gt;isEquivalentRGBA(r, g, b, a))
</del><ins>+    if (state().m_strokeStyle.isValid() &amp;&amp; state().m_strokeStyle.isEquivalentRGBA(r, g, b, a))
</ins><span class="cx">         return;
</span><del>-    setStrokeStyle(CanvasStyle::createFromRGBAChannels(r, g, b, a));
</del><ins>+    setStrokeStyle(CanvasStyle(r, g, b, a));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setStrokeColor(float c, float m, float y, float k, float a)
</span><span class="cx"> {
</span><del>-    if (state().m_strokeStyle &amp;&amp; state().m_strokeStyle-&gt;isEquivalentCMYKA(c, m, y, k, a))
</del><ins>+    if (state().m_strokeStyle.isValid() &amp;&amp; state().m_strokeStyle.isEquivalentCMYKA(c, m, y, k, a))
</ins><span class="cx">         return;
</span><del>-    setStrokeStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a));
</del><ins>+    setStrokeStyle(CanvasStyle(c, m, y, k, a));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(const String&amp; color)
</span><span class="lines">@@ -824,9 +811,9 @@
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(float grayLevel)
</span><span class="cx"> {
</span><del>-    if (state().m_fillStyle &amp;&amp; state().m_fillStyle-&gt;isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
</del><ins>+    if (state().m_fillStyle.isValid() &amp;&amp; state().m_fillStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
</ins><span class="cx">         return;
</span><del>-    setFillStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f));
</del><ins>+    setFillStyle(CanvasStyle(grayLevel, 1.0f));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(const String&amp; color, float alpha)
</span><span class="lines">@@ -836,23 +823,23 @@
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(float grayLevel, float alpha)
</span><span class="cx"> {
</span><del>-    if (state().m_fillStyle &amp;&amp; state().m_fillStyle-&gt;isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
</del><ins>+    if (state().m_fillStyle.isValid() &amp;&amp; state().m_fillStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
</ins><span class="cx">         return;
</span><del>-    setFillStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, alpha));
</del><ins>+    setFillStyle(CanvasStyle(grayLevel, alpha));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(float r, float g, float b, float a)
</span><span class="cx"> {
</span><del>-    if (state().m_fillStyle &amp;&amp; state().m_fillStyle-&gt;isEquivalentRGBA(r, g, b, a))
</del><ins>+    if (state().m_fillStyle.isValid() &amp;&amp; state().m_fillStyle.isEquivalentRGBA(r, g, b, a))
</ins><span class="cx">         return;
</span><del>-    setFillStyle(CanvasStyle::createFromRGBAChannels(r, g, b, a));
</del><ins>+    setFillStyle(CanvasStyle(r, g, b, a));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::setFillColor(float c, float m, float y, float k, float a)
</span><span class="cx"> {
</span><del>-    if (state().m_fillStyle &amp;&amp; state().m_fillStyle-&gt;isEquivalentCMYKA(c, m, y, k, a))
</del><ins>+    if (state().m_fillStyle.isValid() &amp;&amp; state().m_fillStyle.isEquivalentCMYKA(c, m, y, k, a))
</ins><span class="cx">         return;
</span><del>-    setFillStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a));
</del><ins>+    setFillStyle(CanvasStyle(c, m, y, k, a));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::beginPath()
</span><span class="lines">@@ -1662,7 +1649,7 @@
</span><span class="cx">     path.translate(FloatSize(-bufferRect.x(), -bufferRect.y()));
</span><span class="cx"> 
</span><span class="cx">     buffer-&gt;context()-&gt;setCompositeOperation(CompositeSourceOver);
</span><del>-    state().m_fillStyle-&gt;applyFillColor(buffer-&gt;context());
</del><ins>+    modifiableState().m_fillStyle.applyFillColor(buffer-&gt;context());
</ins><span class="cx">     buffer-&gt;context()-&gt;fillPath(path);
</span><span class="cx"> 
</span><span class="cx">     compositeBuffer(buffer.get(), bufferRect, state().m_globalComposite);
</span><span class="lines">@@ -2252,8 +2239,8 @@
</span><span class="cx">         inflateStrokeRect(textRect);
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><del>-    CanvasStyle* drawStyle = fill ? state().m_fillStyle.get() : state().m_strokeStyle.get();
-    if (drawStyle-&gt;canvasGradient() || drawStyle-&gt;canvasPattern()) {
</del><ins>+    const CanvasStyle&amp; drawStyle = fill ? state().m_fillStyle : state().m_strokeStyle;
+    if (drawStyle.canvasGradient() || drawStyle.canvasPattern()) {
</ins><span class="cx">         IntRect maskRect = enclosingIntRect(textRect);
</span><span class="cx"> 
</span><span class="cx">         OwnPtr&lt;ImageBuffer&gt; maskImage = c-&gt;createCompatibleBuffer(maskRect.size());
</span><span class="lines">@@ -2281,7 +2268,7 @@
</span><span class="cx"> 
</span><span class="cx">         GraphicsContextStateSaver stateSaver(*c);
</span><span class="cx">         c-&gt;clipToImageBuffer(maskImage.get(), maskRect);
</span><del>-        drawStyle-&gt;applyFillColor(c);
</del><ins>+        drawStyle.applyFillColor(c);
</ins><span class="cx">         c-&gt;fillRect(maskRect);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;AffineTransform.h&quot;
</span><span class="cx"> #include &quot;CanvasPathMethods.h&quot;
</span><span class="cx"> #include &quot;CanvasRenderingContext.h&quot;
</span><ins>+#include &quot;CanvasStyle.h&quot;
</ins><span class="cx"> #include &quot;Color.h&quot;
</span><span class="cx"> #include &quot;ColorSpace.h&quot;
</span><span class="cx"> #include &quot;DashArray.h&quot;
</span><span class="lines">@@ -48,7 +49,6 @@
</span><span class="cx"> 
</span><span class="cx"> class CanvasGradient;
</span><span class="cx"> class CanvasPattern;
</span><del>-class CanvasStyle;
</del><span class="cx"> #if ENABLE(CANVAS_PATH)
</span><span class="cx"> class DOMPath;
</span><span class="cx"> #endif
</span><span class="lines">@@ -70,11 +70,11 @@
</span><span class="cx">     }
</span><span class="cx">     virtual ~CanvasRenderingContext2D();
</span><span class="cx"> 
</span><del>-    CanvasStyle* strokeStyle() const;
-    void setStrokeStyle(PassRefPtr&lt;CanvasStyle&gt;);
</del><ins>+    const CanvasStyle&amp; strokeStyle() const { return state().m_strokeStyle; }
+    void setStrokeStyle(CanvasStyle);
</ins><span class="cx"> 
</span><del>-    CanvasStyle* fillStyle() const;
-    void setFillStyle(PassRefPtr&lt;CanvasStyle&gt;);
</del><ins>+    const CanvasStyle&amp; fillStyle() const { return state().m_fillStyle; }
+    void setFillStyle(CanvasStyle);
</ins><span class="cx"> 
</span><span class="cx">     float lineWidth() const;
</span><span class="cx">     void setLineWidth(float);
</span><span class="lines">@@ -240,8 +240,8 @@
</span><span class="cx"> 
</span><span class="cx">         String m_unparsedStrokeColor;
</span><span class="cx">         String m_unparsedFillColor;
</span><del>-        RefPtr&lt;CanvasStyle&gt; m_strokeStyle;
-        RefPtr&lt;CanvasStyle&gt; m_fillStyle;
</del><ins>+        CanvasStyle m_strokeStyle;
+        CanvasStyle m_fillStyle;
</ins><span class="cx">         float m_lineWidth;
</span><span class="cx">         LineCap m_lineCap;
</span><span class="cx">         LineJoin m_lineJoin;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasStyle.cpp (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasStyle.cpp        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/html/canvas/CanvasStyle.cpp        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -92,46 +92,44 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CanvasStyle::CanvasStyle(Type type, float overrideAlpha)
-    : m_type(type)
-    , m_overrideAlpha(overrideAlpha)
-{
-}
-
</del><span class="cx"> CanvasStyle::CanvasStyle(RGBA32 rgba)
</span><del>-    : m_type(RGBA)
-    , m_rgba(rgba)
</del><ins>+    : m_rgba(rgba)
+    , m_type(RGBA)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::CanvasStyle(float grayLevel, float alpha)
</span><del>-    : m_type(RGBA)
-    , m_rgba(makeRGBA32FromFloats(grayLevel, grayLevel, grayLevel, alpha))
</del><ins>+    : m_rgba(makeRGBA32FromFloats(grayLevel, grayLevel, grayLevel, alpha))
+    , m_type(RGBA)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::CanvasStyle(float r, float g, float b, float a)
</span><del>-    : m_type(RGBA)
-    , m_rgba(makeRGBA32FromFloats(r, g, b, a))
</del><ins>+    : m_rgba(makeRGBA32FromFloats(r, g, b, a))
+    , m_type(RGBA)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a)
</span><del>-    : m_type(CMYKA)
-    , m_cmyka(new CMYKAValues(makeRGBAFromCMYKA(c, m, y, k, a), c, m, y, k, a))
</del><ins>+    : m_cmyka(new CMYKAValues(makeRGBAFromCMYKA(c, m, y, k, a), c, m, y, k, a))
+    , m_type(CMYKA)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::CanvasStyle(PassRefPtr&lt;CanvasGradient&gt; gradient)
</span><del>-    : m_type(Gradient)
-    , m_gradient(gradient.leakRef())
</del><ins>+    : m_gradient(gradient.leakRef())
+    , m_type(Gradient)
</ins><span class="cx"> {
</span><ins>+    if (!m_gradient)
+        m_type = Invalid;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::CanvasStyle(PassRefPtr&lt;CanvasPattern&gt; pattern)
</span><del>-    : m_type(ImagePattern)
-    , m_pattern(pattern.leakRef())
</del><ins>+    : m_pattern(pattern.leakRef())
+    , m_type(ImagePattern)
</ins><span class="cx"> {
</span><ins>+    if (!m_pattern)
+        m_type = Invalid;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CanvasStyle::~CanvasStyle()
</span><span class="lines">@@ -144,54 +142,41 @@
</span><span class="cx">         delete m_cmyka;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CanvasStyle&gt; CanvasStyle::createFromString(const String&amp; color, Document* document)
</del><ins>+CanvasStyle CanvasStyle::createFromString(const String&amp; color, Document* document)
</ins><span class="cx"> {
</span><span class="cx">     RGBA32 rgba;
</span><span class="cx">     ColorParseResult parseResult = parseColor(rgba, color, document);
</span><span class="cx">     switch (parseResult) {
</span><span class="cx">     case ParsedRGBA:
</span><span class="cx">     case ParsedSystemColor:
</span><del>-        return adoptRef(new CanvasStyle(rgba));
</del><ins>+        return CanvasStyle(rgba);
</ins><span class="cx">     case ParsedCurrentColor:
</span><del>-        return adoptRef(new CanvasStyle(CurrentColor));
</del><ins>+        return CanvasStyle(ConstructCurrentColor);
</ins><span class="cx">     case ParseFailed:
</span><del>-        return 0;
</del><ins>+        return CanvasStyle();
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return 0;
</del><ins>+        return CanvasStyle();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CanvasStyle&gt; CanvasStyle::createFromStringWithOverrideAlpha(const String&amp; color, float alpha)
</del><ins>+CanvasStyle CanvasStyle::createFromStringWithOverrideAlpha(const String&amp; color, float alpha)
</ins><span class="cx"> {
</span><span class="cx">     RGBA32 rgba;
</span><span class="cx">     ColorParseResult parseResult = parseColor(rgba, color);
</span><span class="cx">     switch (parseResult) {
</span><span class="cx">     case ParsedRGBA:
</span><del>-        return adoptRef(new CanvasStyle(colorWithOverrideAlpha(rgba, alpha)));
</del><ins>+        return CanvasStyle(colorWithOverrideAlpha(rgba, alpha));
</ins><span class="cx">     case ParsedCurrentColor:
</span><del>-        return adoptRef(new CanvasStyle(CurrentColorWithOverrideAlpha, alpha));
</del><ins>+        return CanvasStyle(CurrentColorWithOverrideAlpha, alpha);
</ins><span class="cx">     case ParseFailed:
</span><del>-        return 0;
</del><ins>+        return CanvasStyle();
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return 0;
</del><ins>+        return CanvasStyle();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CanvasStyle&gt; CanvasStyle::createFromGradient(PassRefPtr&lt;CanvasGradient&gt; gradient)
-{
-    if (!gradient)
-        return 0;
-    return adoptRef(new CanvasStyle(gradient));
-}
-PassRefPtr&lt;CanvasStyle&gt; CanvasStyle::createFromPattern(PassRefPtr&lt;CanvasPattern&gt; pattern)
-{
-    if (!pattern)
-        return 0;
-    return adoptRef(new CanvasStyle(pattern));
-}
-
</del><span class="cx"> bool CanvasStyle::isEquivalentColor(const CanvasStyle&amp; other) const
</span><span class="cx"> {
</span><span class="cx">     if (m_type != other.m_type)
</span><span class="lines">@@ -211,6 +196,8 @@
</span><span class="cx">     case CurrentColor:
</span><span class="cx">     case CurrentColorWithOverrideAlpha:
</span><span class="cx">         return false;
</span><ins>+    case Invalid:
+        break;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="lines">@@ -237,8 +224,33 @@
</span><span class="cx">         &amp;&amp; a == m_cmyka-&gt;a;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CanvasStyle::applyStrokeColor(GraphicsContext* context)
</del><ins>+CanvasStyle::CanvasStyle(const CanvasStyle&amp; other)
</ins><span class="cx"> {
</span><ins>+    memcpy(this, &amp;other, sizeof(CanvasStyle));
+    if (m_type == Gradient)
+        m_gradient-&gt;ref();
+    else if (m_type == ImagePattern)
+        m_pattern-&gt;ref();
+    else if (m_type == CMYKA)
+        m_cmyka = new CMYKAValues(other.m_cmyka-&gt;rgba, other.m_cmyka-&gt;c, other.m_cmyka-&gt;m, other.m_cmyka-&gt;y, other.m_cmyka-&gt;k, other.m_cmyka-&gt;a);
+}
+
+CanvasStyle&amp; CanvasStyle::operator=(const CanvasStyle&amp; other)
+{
+    if (this != &amp;other) {
+        memcpy(this, &amp;other, sizeof(CanvasStyle));
+        if (m_type == Gradient)
+            m_gradient-&gt;ref();
+        else if (m_type == ImagePattern)
+            m_pattern-&gt;ref();
+        else if (m_type == CMYKA)
+            m_cmyka = new CMYKAValues(other.m_cmyka-&gt;rgba, other.m_cmyka-&gt;c, other.m_cmyka-&gt;m, other.m_cmyka-&gt;y, other.m_cmyka-&gt;k, other.m_cmyka-&gt;a);
+    }
+    return *this;
+}
+
+void CanvasStyle::applyStrokeColor(GraphicsContext* context) const
+{
</ins><span class="cx">     if (!context)
</span><span class="cx">         return;
</span><span class="cx">     switch (m_type) {
</span><span class="lines">@@ -269,12 +281,13 @@
</span><span class="cx">         break;
</span><span class="cx">     case CurrentColor:
</span><span class="cx">     case CurrentColorWithOverrideAlpha:
</span><ins>+    case Invalid:
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CanvasStyle::applyFillColor(GraphicsContext* context)
</del><ins>+void CanvasStyle::applyFillColor(GraphicsContext* context) const
</ins><span class="cx"> {
</span><span class="cx">     if (!context)
</span><span class="cx">         return;
</span><span class="lines">@@ -306,6 +319,7 @@
</span><span class="cx">         break;
</span><span class="cx">     case CurrentColor:
</span><span class="cx">     case CurrentColorWithOverrideAlpha:
</span><ins>+    case Invalid:
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasStyle.h (149927 => 149928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasStyle.h        2013-05-11 07:56:09 UTC (rev 149927)
+++ trunk/Source/WebCore/html/canvas/CanvasStyle.h        2013-05-11 08:36:42 UTC (rev 149928)
</span><span class="lines">@@ -40,21 +40,21 @@
</span><span class="cx">     class GraphicsContext;
</span><span class="cx">     class HTMLCanvasElement;
</span><span class="cx"> 
</span><del>-    class CanvasStyle : public RefCounted&lt;CanvasStyle&gt; {
-        WTF_MAKE_FAST_ALLOCATED;
-        WTF_MAKE_NONCOPYABLE(CanvasStyle);
</del><ins>+    class CanvasStyle {
</ins><span class="cx">     public:
</span><ins>+        CanvasStyle();
+        explicit CanvasStyle(RGBA32);
+        CanvasStyle(float grayLevel, float alpha);
+        CanvasStyle(float r, float g, float b, float alpha);
+        CanvasStyle(float c, float m, float y, float k, float alpha);
+        explicit CanvasStyle(PassRefPtr&lt;CanvasGradient&gt;);
+        explicit CanvasStyle(PassRefPtr&lt;CanvasPattern&gt;);
</ins><span class="cx">         ~CanvasStyle();
</span><span class="cx"> 
</span><del>-        static PassRefPtr&lt;CanvasStyle&gt; createFromRGBA(RGBA32 rgba) { return adoptRef(new CanvasStyle(rgba)); }
-        static PassRefPtr&lt;CanvasStyle&gt; createFromString(const String&amp; color, Document* = 0);
-        static PassRefPtr&lt;CanvasStyle&gt; createFromStringWithOverrideAlpha(const String&amp; color, float alpha);
-        static PassRefPtr&lt;CanvasStyle&gt; createFromGrayLevelWithAlpha(float grayLevel, float alpha) { return adoptRef(new CanvasStyle(grayLevel, alpha)); }
-        static PassRefPtr&lt;CanvasStyle&gt; createFromRGBAChannels(float r, float g, float b, float a) { return adoptRef(new CanvasStyle(r, g, b, a)); }
-        static PassRefPtr&lt;CanvasStyle&gt; createFromCMYKAChannels(float c, float m, float y, float k, float a) { return adoptRef(new CanvasStyle(c, m, y, k, a)); }
-        static PassRefPtr&lt;CanvasStyle&gt; createFromGradient(PassRefPtr&lt;CanvasGradient&gt;);
-        static PassRefPtr&lt;CanvasStyle&gt; createFromPattern(PassRefPtr&lt;CanvasPattern&gt;);
</del><ins>+        static CanvasStyle createFromString(const String&amp; color, Document* = 0);
+        static CanvasStyle createFromStringWithOverrideAlpha(const String&amp; color, float alpha);
</ins><span class="cx"> 
</span><ins>+        bool isValid() const { return m_type != Invalid; }
</ins><span class="cx">         bool isCurrentColor() const { return m_type == CurrentColor || m_type == CurrentColorWithOverrideAlpha; }
</span><span class="cx">         bool hasOverrideAlpha() const { return m_type == CurrentColorWithOverrideAlpha; }
</span><span class="cx">         float overrideAlpha() const { ASSERT(m_type == CurrentColorWithOverrideAlpha); return m_overrideAlpha; }
</span><span class="lines">@@ -63,15 +63,22 @@
</span><span class="cx">         CanvasGradient* canvasGradient() const;
</span><span class="cx">         CanvasPattern* canvasPattern() const;
</span><span class="cx"> 
</span><del>-        void applyFillColor(GraphicsContext*);
-        void applyStrokeColor(GraphicsContext*);
</del><ins>+        void applyFillColor(GraphicsContext*) const;
+        void applyStrokeColor(GraphicsContext*) const;
</ins><span class="cx"> 
</span><span class="cx">         bool isEquivalentColor(const CanvasStyle&amp;) const;
</span><span class="cx">         bool isEquivalentRGBA(float r, float g, float b, float a) const;
</span><span class="cx">         bool isEquivalentCMYKA(float c, float m, float y, float k, float a) const;
</span><span class="cx"> 
</span><ins>+        CanvasStyle(const CanvasStyle&amp;);
+        CanvasStyle&amp; operator=(const CanvasStyle&amp;);
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+        CanvasStyle(CanvasStyle&amp;&amp;);
+        CanvasStyle&amp; operator=(CanvasStyle&amp;&amp;);
+#endif
+
</ins><span class="cx">     private:
</span><del>-        enum Type { RGBA, CMYKA, Gradient, ImagePattern, CurrentColor, CurrentColorWithOverrideAlpha };
</del><ins>+        enum Type { RGBA, CMYKA, Gradient, ImagePattern, CurrentColor, CurrentColorWithOverrideAlpha, Invalid };
</ins><span class="cx">         struct CMYKAValues {
</span><span class="cx">             WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">             WTF_MAKE_NONCOPYABLE(CMYKAValues);
</span><span class="lines">@@ -86,16 +93,14 @@
</span><span class="cx">             float a;
</span><span class="cx">         };
</span><span class="cx"> 
</span><del>-        CanvasStyle(Type, float overrideAlpha = 0);
-        CanvasStyle(RGBA32 rgba);
-        CanvasStyle(float grayLevel, float alpha);
-        CanvasStyle(float r, float g, float b, float a);
-        CanvasStyle(float c, float m, float y, float k, float a);
-        CanvasStyle(PassRefPtr&lt;CanvasGradient&gt;);
-        CanvasStyle(PassRefPtr&lt;CanvasPattern&gt;);
</del><ins>+        enum ConstructCurrentColorTag { ConstructCurrentColor };
+        CanvasStyle(ConstructCurrentColorTag) : m_type(CurrentColor) { }
+        CanvasStyle(Type type, float overrideAlpha)
+            : m_overrideAlpha(overrideAlpha)
+            , m_type(type)
+        {
+        }
</ins><span class="cx"> 
</span><del>-        Type m_type;
-
</del><span class="cx">         union {
</span><span class="cx">             RGBA32 m_rgba;
</span><span class="cx">             float m_overrideAlpha;
</span><span class="lines">@@ -103,11 +108,17 @@
</span><span class="cx">             CanvasPattern* m_pattern;
</span><span class="cx">             CMYKAValues* m_cmyka;
</span><span class="cx">         };
</span><ins>+        Type m_type;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     RGBA32 currentColor(HTMLCanvasElement*);
</span><span class="cx">     bool parseColorOrCurrentColor(RGBA32&amp; parsedColor, const String&amp; colorString, HTMLCanvasElement*);
</span><span class="cx"> 
</span><ins>+    inline CanvasStyle::CanvasStyle()
+        : m_type(Invalid)
+    {
+    }
+
</ins><span class="cx">     inline CanvasGradient* CanvasStyle::canvasGradient() const
</span><span class="cx">     {
</span><span class="cx">         if (m_type == Gradient)
</span><span class="lines">@@ -130,6 +141,23 @@
</span><span class="cx">         return Color(m_cmyka-&gt;rgba).serialized();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+    inline CanvasStyle::CanvasStyle(CanvasStyle&amp;&amp; other)
+    {
+        memcpy(this, &amp;other, sizeof(CanvasStyle));
+        other.m_type = Invalid;
+    }
+
+    inline CanvasStyle&amp; CanvasStyle::operator=(CanvasStyle&amp;&amp; other)
+    {
+        if (this != &amp;other) {
+            memcpy(this, &amp;other, sizeof(CanvasStyle));
+            other.m_type = Invalid;
+        }
+        return *this;
+    }
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>