<!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>[190003] 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/190003">190003</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2015-09-18 18:25:35 -0700 (Fri, 18 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Refine and simplify some color-related code
https://bugs.webkit.org/show_bug.cgi?id=148961

Reviewed by Anders Carlsson.

Refactoring code that seems to be covered by existing tests.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseColor): Handle the empty string efficiently so that
callers don't need to do that.

* platform/graphics/Color.h: Started adding comments about deprecation.
Added RGBA class for future use whenever we need an RGBA quadruplet rather than
a color with a color space. Added FIXME about future evoluation of the classes here.
Added OptionalColor so we can start removing the &quot;invalid color&quot; feature from Color.
Added roundAndClampColorChannel function.

* svg/ColorDistance.cpp: Removed.
* svg/ColorDistance.h: Removed.

* CMakeLists.txt: Removed ColorDistance.
* WebCore.vcxproj/WebCore.vcxproj: Ditto.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* svg/SVGAllInOne.cpp: Ditto.

* svg/SVGAnimatedColor.cpp:
(WebCore::SVGAnimatedColorAnimator::SVGAnimatedColorAnimator): Changed to take
a reference instead of a pointer.
(WebCore::SVGAnimatedColorAnimator::constructFromString): Simplified since the
SVGColor::colorFromRGBColorString will handle the empty string.
(WebCore::SVGAnimatedColorAnimator::addAnimatedTypes): Moved the code to add the
RGB channels of two colors here from ColorDistance::addColors since this is the
only place it was used.
(WebCore::currentColor): Refactored adjustForCurrentColor function into this.
Helper for the code below.
(WebCore::SVGAnimatedColorAnimator::calculateAnimatedValue): Refactored to use
the new currentColor function and replaced the use of the ColorDistance::clampColor
function here with a bit of code here in the one place it was used.
(WebCore::SVGAnimatedColorAnimator::calculateDistance): Moved the distance algorithm
here from ColorDistance::distance.

* svg/SVGAnimatedColor.h: Removed unneeded forward declaration, changed constructor
to take references instead of pointers, and made all class member functions private.

* svg/SVGAnimatedType.cpp:
(WebCore::SVGAnimatedType::setValueAsString): Removed special case for empty string,
since SVGColor::colorFromRGBColorString does the same thing.

* svg/SVGAnimatorFactory.h:
(WebCore::SVGAnimatorFactory::create): Pass references rather tha pointers to the
SVGAnimatedColorAnimator constructor.

* svg/SVGColor.cpp:
(WebCore::SVGColor::colorFromRGBColorString): Added more FIXMEs about the future of
this function.
(WebCore::SVGColor::setRGBColor): Fixed confusing verb tense.
(WebCore::SVGColor::customCSSText): Use ASCII literal for an ASCII literal.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorh">trunk/Source/WebCore/platform/graphics/Color.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAllInOnecpp">trunk/Source/WebCore/svg/SVGAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAnimatedColorcpp">trunk/Source/WebCore/svg/SVGAnimatedColor.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAnimatedColorh">trunk/Source/WebCore/svg/SVGAnimatedColor.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAnimatedTypecpp">trunk/Source/WebCore/svg/SVGAnimatedType.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAnimatorFactoryh">trunk/Source/WebCore/svg/SVGAnimatorFactory.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGColorcpp">trunk/Source/WebCore/svg/SVGColor.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoresvgColorDistancecpp">trunk/Source/WebCore/svg/ColorDistance.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgColorDistanceh">trunk/Source/WebCore/svg/ColorDistance.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -2593,7 +2593,6 @@
</span><span class="cx">     style/StyleResolveForDocument.cpp
</span><span class="cx">     style/StyleResolveTree.cpp
</span><span class="cx"> 
</span><del>-    svg/ColorDistance.cpp
</del><span class="cx">     svg/SVGAElement.cpp
</span><span class="cx">     svg/SVGAltGlyphDefElement.cpp
</span><span class="cx">     svg/SVGAltGlyphElement.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/ChangeLog        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2015-09-08  Darin Adler  &lt;darin@apple.com&gt;
+
+        Refine and simplify some color-related code
+        https://bugs.webkit.org/show_bug.cgi?id=148961
+
+        Reviewed by Anders Carlsson.
+
+        Refactoring code that seems to be covered by existing tests.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseColor): Handle the empty string efficiently so that
+        callers don't need to do that.
+
+        * platform/graphics/Color.h: Started adding comments about deprecation.
+        Added RGBA class for future use whenever we need an RGBA quadruplet rather than
+        a color with a color space. Added FIXME about future evoluation of the classes here.
+        Added OptionalColor so we can start removing the &quot;invalid color&quot; feature from Color.
+        Added roundAndClampColorChannel function.
+
+        * svg/ColorDistance.cpp: Removed.
+        * svg/ColorDistance.h: Removed.
+
+        * CMakeLists.txt: Removed ColorDistance.
+        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * svg/SVGAllInOne.cpp: Ditto.
+
+        * svg/SVGAnimatedColor.cpp:
+        (WebCore::SVGAnimatedColorAnimator::SVGAnimatedColorAnimator): Changed to take
+        a reference instead of a pointer.
+        (WebCore::SVGAnimatedColorAnimator::constructFromString): Simplified since the
+        SVGColor::colorFromRGBColorString will handle the empty string.
+        (WebCore::SVGAnimatedColorAnimator::addAnimatedTypes): Moved the code to add the
+        RGB channels of two colors here from ColorDistance::addColors since this is the
+        only place it was used.
+        (WebCore::currentColor): Refactored adjustForCurrentColor function into this.
+        Helper for the code below.
+        (WebCore::SVGAnimatedColorAnimator::calculateAnimatedValue): Refactored to use
+        the new currentColor function and replaced the use of the ColorDistance::clampColor
+        function here with a bit of code here in the one place it was used.
+        (WebCore::SVGAnimatedColorAnimator::calculateDistance): Moved the distance algorithm
+        here from ColorDistance::distance.
+
+        * svg/SVGAnimatedColor.h: Removed unneeded forward declaration, changed constructor
+        to take references instead of pointers, and made all class member functions private.
+
+        * svg/SVGAnimatedType.cpp:
+        (WebCore::SVGAnimatedType::setValueAsString): Removed special case for empty string,
+        since SVGColor::colorFromRGBColorString does the same thing.
+
+        * svg/SVGAnimatorFactory.h:
+        (WebCore::SVGAnimatorFactory::create): Pass references rather tha pointers to the
+        SVGAnimatedColorAnimator constructor.
+
+        * svg/SVGColor.cpp:
+        (WebCore::SVGColor::colorFromRGBColorString): Added more FIXMEs about the future of
+        this function.
+        (WebCore::SVGColor::setRGBColor): Fixed confusing verb tense.
+        (WebCore::SVGColor::customCSSText): Use ASCII literal for an ASCII literal.
+
</ins><span class="cx"> 2015-09-18  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         UserMediaClientMock leaks every test run
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -22488,7 +22488,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\plugins\npfunctions.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\plugins\npruntime.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\plugins\PluginData.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\svg\ColorDistance.h&quot; /&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\svg\SVGAElement.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\svg\SVGAltGlyphDefElement.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\svg\SVGAltGlyphElement.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -14578,9 +14578,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\opentype\OpenTypeVerticalData.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics\opentype&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\svg\ColorDistance.h&quot;&gt;
-      &lt;Filter&gt;svg&lt;/Filter&gt;
-    &lt;/ClInclude&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\svg\SVGAElement.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;svg&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -4555,8 +4555,6 @@
</span><span class="cx">                 B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */; };
</span><span class="cx">                 B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */; };
</span><span class="cx">                 B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B20111060AB7740500DB0E68 /* JSSVGAElement.h */; };
</span><del>-                B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277CB0D00BF1F0071B782 /* ColorDistance.cpp */; };
-                B22279630D00BF220071B782 /* ColorDistance.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CC0D00BF1F0071B782 /* ColorDistance.h */; };
</del><span class="cx">                 B22279640D00BF220071B782 /* GradientAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CD0D00BF1F0071B782 /* GradientAttributes.h */; };
</span><span class="cx">                 B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CE0D00BF1F0071B782 /* LinearGradientAttributes.h */; };
</span><span class="cx">                 B22279710D00BF220071B782 /* PatternAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277DB0D00BF1F0071B782 /* PatternAttributes.h */; };
</span><span class="lines">@@ -12028,8 +12026,6 @@
</span><span class="cx">                 B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallbackFunction.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B20111060AB7740500DB0E68 /* JSSVGAElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                B22277CB0D00BF1F0071B782 /* ColorDistance.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ColorDistance.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                B22277CC0D00BF1F0071B782 /* ColorDistance.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ColorDistance.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 B22277CD0D00BF1F0071B782 /* GradientAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GradientAttributes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B22277CE0D00BF1F0071B782 /* LinearGradientAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LinearGradientAttributes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 B22277DB0D00BF1F0071B782 /* PatternAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PatternAttributes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20474,8 +20470,6 @@
</span><span class="cx">                                 E46E97860DAAD61B0071E894 /* animation */,
</span><span class="cx">                                 B25598860D00D8B800BB825C /* graphics */,
</span><span class="cx">                                 081CDFBD126ECFE800D215CA /* properties */,
</span><del>-                                B22277CB0D00BF1F0071B782 /* ColorDistance.cpp */,
-                                B22277CC0D00BF1F0071B782 /* ColorDistance.h */,
</del><span class="cx">                                 B22277CD0D00BF1F0071B782 /* GradientAttributes.h */,
</span><span class="cx">                                 B22277CE0D00BF1F0071B782 /* LinearGradientAttributes.h */,
</span><span class="cx">                                 B22277DB0D00BF1F0071B782 /* PatternAttributes.h */,
</span><span class="lines">@@ -24326,7 +24320,6 @@
</span><span class="cx">                                 B27535670B053814002CE64F /* Color.h in Headers */,
</span><span class="cx">                                 C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
</span><span class="cx">                                 C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
</span><del>-                                B22279630D00BF220071B782 /* ColorDistance.h in Headers */,
</del><span class="cx">                                 F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
</span><span class="cx">                                 EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
</span><span class="cx">                                 9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
</span><span class="lines">@@ -28128,7 +28121,6 @@
</span><span class="cx">                                 B27535660B053814002CE64F /* Color.cpp in Sources */,
</span><span class="cx">                                 0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
</span><span class="cx">                                 1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
</span><del>-                                B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */,
</del><span class="cx">                                 BC29935D17A1DD5800BCE880 /* ColorInputType.cpp in Sources */,
</span><span class="cx">                                 B27535770B053814002CE64F /* ColorMac.mm in Sources */,
</span><span class="cx">                                 26E944D81AC4B2DD007B85B5 /* CombinedURLFilters.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -1364,6 +1364,9 @@
</span><span class="cx"> // can set it to a default color and ignore the boolean result.
</span><span class="cx"> bool CSSParser::parseColor(RGBA32&amp; color, const String&amp; string, bool strict)
</span><span class="cx"> {
</span><ins>+    if (string.isEmpty())
+        return false;
+
</ins><span class="cx">     // First try creating a color specified by name, rgba(), rgb() or &quot;#&quot; syntax.
</span><span class="cx">     if (fastParseColor(color, string, strict))
</span><span class="cx">         return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Color.h (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Color.h        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/platform/graphics/Color.h        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2003-2006, 2010, 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,17 +26,15 @@
</span><span class="cx"> #ifndef Color_h
</span><span class="cx"> #define Color_h
</span><span class="cx"> 
</span><ins>+#include &quot;ColorSpace.h&quot;
+#include &lt;algorithm&gt;
+#include &lt;cmath&gt;
</ins><span class="cx"> #include &lt;unicode/uchar.h&gt;
</span><del>-#include &lt;wtf/FastMalloc.h&gt;
</del><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/text/LChar.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if USE(CG)
</span><del>-#include &quot;ColorSpace.h&quot;
</del><span class="cx"> typedef struct CGColor* CGColorRef;
</span><del>-#if PLATFORM(IOS)
-typedef struct CGColorSpace* CGColorSpaceRef;
-#endif // PLATFORM(IOS)
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="lines">@@ -48,10 +46,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class Color;
</del><ins>+typedef unsigned RGBA32; // Deprecated: Type for an RGBA quadruplet. Use RGBA class instead.
</ins><span class="cx"> 
</span><del>-typedef unsigned RGBA32;        // RGBA quadruplet
-
</del><span class="cx"> WEBCORE_EXPORT RGBA32 makeRGB(int r, int g, int b);
</span><span class="cx"> WEBCORE_EXPORT RGBA32 makeRGBA(int r, int g, int b, int a);
</span><span class="cx"> 
</span><span class="lines">@@ -60,17 +56,43 @@
</span><span class="cx"> RGBA32 makeRGBAFromHSLA(double h, double s, double l, double a);
</span><span class="cx"> RGBA32 makeRGBAFromCMYKA(float c, float m, float y, float k, float a);
</span><span class="cx"> 
</span><del>-int differenceSquared(const Color&amp;, const Color&amp;);
-
</del><span class="cx"> inline int redChannel(RGBA32 color) { return (color &gt;&gt; 16) &amp; 0xFF; }
</span><span class="cx"> inline int greenChannel(RGBA32 color) { return (color &gt;&gt; 8) &amp; 0xFF; }
</span><span class="cx"> inline int blueChannel(RGBA32 color) { return color &amp; 0xFF; }
</span><span class="cx"> inline int alphaChannel(RGBA32 color) { return (color &gt;&gt; 24) &amp; 0xFF; }
</span><span class="cx"> 
</span><ins>+uint8_t roundAndClampColorChannel(int);
+uint8_t roundAndClampColorChannel(float);
+
+class RGBA {
+public:
+    RGBA(); // all channels zero, including alpha
+    RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
+    RGBA(uint8_t red, uint8_t green, uint8_t blue); // opaque, alpha of 1
+
+    uint8_t red() const;
+    uint8_t green() const;
+    uint8_t blue() const;
+    uint8_t alpha() const;
+
+    bool hasAlpha() const;
+
+private:
+    friend class Color;
+
+    unsigned m_integer { 0 };
+};
+
+bool operator==(const RGBA&amp;, const RGBA&amp;);
+bool operator!=(const RGBA&amp;, const RGBA&amp;);
+
</ins><span class="cx"> class Color {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     Color() : m_color(0), m_valid(false) { }
</span><ins>+    Color(RGBA, ColorSpace);
+
+    // FIXME: Remove all these constructors and creation functions and replace the ones that are still needed with free functions.
</ins><span class="cx">     Color(RGBA32 color, bool valid = true) : m_color(color), m_valid(valid) { ASSERT(!m_color || m_valid); }
</span><span class="cx">     Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { }
</span><span class="cx">     Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { }
</span><span class="lines">@@ -80,7 +102,6 @@
</span><span class="cx">     Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)), m_valid(true) { }
</span><span class="cx">     WEBCORE_EXPORT explicit Color(const String&amp;);
</span><span class="cx">     explicit Color(const char*);
</span><del>-
</del><span class="cx">     static Color createUnchecked(int r, int g, int b)
</span><span class="cx">     {
</span><span class="cx">         RGBA32 color = 0xFF000000 | r &lt;&lt; 16 | g &lt;&lt; 8 | b;
</span><span class="lines">@@ -104,6 +125,7 @@
</span><span class="cx"> 
</span><span class="cx">     void setNamedColor(const String&amp;);
</span><span class="cx"> 
</span><ins>+    // FIXME: Remove this after moving clients to all use OptionalColor instead.
</ins><span class="cx">     bool isValid() const { return m_valid; }
</span><span class="cx"> 
</span><span class="cx">     bool hasAlpha() const { return alpha() &lt; 255; }
</span><span class="lines">@@ -165,6 +187,82 @@
</span><span class="cx">     bool m_valid;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class OptionalColor : public Color {
+public:
+    OptionalColor();
+    OptionalColor(const Color&amp;);
+
+    explicit operator bool() const;
+
+private:
+    // FIXME: Change to use Optional&lt;Color&gt;?
+    // FIXME: Convert all callers to use Optional&lt;Color&gt;?
+    bool m_isEngaged;
+    Color m_color;
+};
+
+bool operator==(const Color&amp;, const Color&amp;);
+bool operator!=(const Color&amp;, const Color&amp;);
+
+Color colorFromPremultipliedARGB(RGBA32);
+RGBA32 premultipliedARGBFromColor(const Color&amp;);
+
+Color blend(const Color&amp; from, const Color&amp; to, double progress, bool blendPremultiplied = true);
+
+int differenceSquared(const Color&amp;, const Color&amp;);
+
+uint16_t fastDivideBy255(uint16_t);
+
+#if USE(CG)
+WEBCORE_EXPORT CGColorRef cachedCGColor(const Color&amp;, ColorSpace);
+#endif
+
+inline RGBA::RGBA()
+{
+}
+
+inline RGBA::RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
+    : m_integer(alpha &lt;&lt; 24 | red &lt;&lt; 16 | green &lt;&lt; 8 | blue)
+{
+}
+
+inline RGBA::RGBA(uint8_t red, uint8_t green, uint8_t blue)
+    : m_integer(0xFF000000 | red &lt;&lt; 16 | green &lt;&lt; 8 | blue)
+{
+}
+
+inline uint8_t RGBA::red() const
+{
+    return m_integer &gt;&gt; 16;
+}
+
+inline uint8_t RGBA::green() const
+{
+    return m_integer &gt;&gt; 8;
+}
+
+inline uint8_t RGBA::blue() const
+{
+    return m_integer;
+}
+
+inline uint8_t RGBA::alpha() const
+{
+    return m_integer &gt;&gt; 24;
+}
+
+inline bool RGBA::hasAlpha() const
+{
+    return (m_integer &amp; 0xFF000000) != 0xFF000000;
+}
+
+inline Color::Color(RGBA color, ColorSpace space)
+    : m_color(color.m_integer)
+    , m_valid(true)
+{
+    ASSERT_UNUSED(space, space == ColorSpaceSRGB);
+}
+
</ins><span class="cx"> inline bool operator==(const Color&amp; a, const Color&amp; b)
</span><span class="cx"> {
</span><span class="cx">     return a.rgb() == b.rgb() &amp;&amp; a.isValid() == b.isValid();
</span><span class="lines">@@ -175,22 +273,25 @@
</span><span class="cx">     return !(a == b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Color colorFromPremultipliedARGB(RGBA32);
-RGBA32 premultipliedARGBFromColor(const Color&amp;);
-Color blend(const Color&amp; from, const Color&amp; to, double progress, bool blendPremultiplied = true);
</del><ins>+inline uint8_t roundAndClampColorChannel(int value)
+{
+    return std::max(0, std::min(255, value));
+}
</ins><span class="cx"> 
</span><ins>+inline uint8_t roundAndClampColorChannel(float value)
+{
+    return std::max(0.f, std::min(255.f, std::round(value)));
+}
+
</ins><span class="cx"> inline uint16_t fastDivideBy255(uint16_t value)
</span><span class="cx"> {
</span><del>-    // This is an approximate algorithm for division by 255, but it gives accurate results for 16bit values.
</del><ins>+    // While this is an approximate algorithm for division by 255, it gives perfectly accurate results for 16-bit values.
+    // FIXME: Since this gives accurate results for 16-bit values, we should get this optimization into compilers like clang.
</ins><span class="cx">     uint16_t approximation = value &gt;&gt; 8;
</span><span class="cx">     uint16_t remainder = value - (approximation * 255) + 1;
</span><span class="cx">     return approximation + (remainder &gt;&gt; 8);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(CG)
-WEBCORE_EXPORT CGColorRef cachedCGColor(const Color&amp;, ColorSpace);
-#endif
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // Color_h
</span></span></pre></div>
<a id="trunkSourceWebCoresvgColorDistancecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/svg/ColorDistance.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/ColorDistance.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/ColorDistance.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -1,91 +0,0 @@
</span><del>-/*
- * Copyright (C) 2007 Eric Seidel &lt;eric@webkit.org&gt;
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include &quot;config.h&quot;
-#include &quot;ColorDistance.h&quot;
-
-#include &quot;Color.h&quot;
-#include &lt;wtf/MathExtras.h&gt;
-
-namespace WebCore {
-
-ColorDistance::ColorDistance()
-    : m_redDiff(0)
-    , m_greenDiff(0)
-    , m_blueDiff(0)
-{
-}
-
-ColorDistance::ColorDistance(const Color&amp; fromColor, const Color&amp; toColor)
-    : m_redDiff(toColor.red() - fromColor.red())
-    , m_greenDiff(toColor.green() - fromColor.green())
-    , m_blueDiff(toColor.blue() - fromColor.blue())
-{
-}
-
-ColorDistance::ColorDistance(int redDiff, int greenDiff, int blueDiff)
-    : m_redDiff(redDiff)
-    , m_greenDiff(greenDiff)
-    , m_blueDiff(blueDiff)
-{
-}
-
-static inline int clampColorValue(int v)
-{
-    if (v &gt; 255)
-        v = 255;
-    else if (v &lt; 0)
-        v = 0;
-    return v;
-}
-
-ColorDistance ColorDistance::scaledDistance(float scaleFactor) const
-{
-    return ColorDistance(static_cast&lt;int&gt;(scaleFactor * m_redDiff),
-                         static_cast&lt;int&gt;(scaleFactor * m_greenDiff),
-                         static_cast&lt;int&gt;(scaleFactor * m_blueDiff));
-}
-
-Color ColorDistance::clampColor(int red, int green, int blue, int alpha)
-{
-    return Color(clampColorValue(red), clampColorValue(green), clampColorValue(blue), clampColorValue(alpha));
-}
-
-Color ColorDistance::addColors(const Color&amp; first, const Color&amp; second)
-{
-    return Color(first.red() + second.red(), first.green() + second.green(), first.blue() + second.blue());
-}
-
-Color ColorDistance::addToColor(const Color&amp; color) const
-{
-    return Color(color.red() + m_redDiff, color.green() + m_greenDiff, color.blue() + m_blueDiff);
-}
-
-bool ColorDistance::isZero() const
-{
-    return !m_redDiff &amp;&amp; !m_blueDiff &amp;&amp; !m_greenDiff;
-}
-
-float ColorDistance::distance() const
-{
-    // This is just a simple distance calculation, not respecting color spaces
-    return sqrtf(m_redDiff * m_redDiff + m_blueDiff * m_blueDiff + m_greenDiff * m_greenDiff);
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCoresvgColorDistanceh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/svg/ColorDistance.h (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/ColorDistance.h        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/ColorDistance.h        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -1,50 +0,0 @@
</span><del>-/*
- * Copyright (C) 2007 Eric Seidel &lt;eric@webkit.org&gt;
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ColorDistance_h
-#define ColorDistance_h
-
-namespace WebCore {
-    
-class Color;
-    
-class ColorDistance {
-public:
-    ColorDistance();
-    ColorDistance(const Color&amp; fromColor, const Color&amp; toColor);
-    ColorDistance(int redDiff, int blueDiff, int greenDiff);
-
-    ColorDistance scaledDistance(float scaleFactor) const;
-    Color addToColor(const Color&amp;) const;
-        
-    static Color addColors(const Color&amp;, const Color&amp;);
-    static Color clampColor(int red, int green, int blue, int alpha);
-
-    bool isZero() const;
-
-    float distance() const;
-        
-private:
-    int m_redDiff;
-    int m_greenDiff;
-    int m_blueDiff;
-};
-}
-
-#endif // ColorDistance_h
</del></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAllInOne.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx"> 
</span><span class="cx"> // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
</span><span class="cx"> 
</span><del>-#include &quot;ColorDistance.cpp&quot;
</del><span class="cx"> #include &quot;SVGAElement.cpp&quot;
</span><span class="cx"> #include &quot;SVGAltGlyphDefElement.cpp&quot;
</span><span class="cx"> #include &quot;SVGAltGlyphElement.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAnimatedColorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAnimatedColor.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAnimatedColor.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGAnimatedColor.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -20,40 +20,43 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;SVGAnimatedColor.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;ColorDistance.h&quot;
</del><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="cx"> #include &quot;SVGAnimateElementBase.h&quot;
</span><span class="cx"> #include &quot;SVGColor.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-SVGAnimatedColorAnimator::SVGAnimatedColorAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
-    : SVGAnimatedTypeAnimator(AnimatedColor, animationElement, contextElement)
</del><ins>+SVGAnimatedColorAnimator::SVGAnimatedColorAnimator(SVGAnimationElement&amp; animationElement, SVGElement&amp; contextElement)
+    : SVGAnimatedTypeAnimator(AnimatedColor, &amp;animationElement, &amp;contextElement)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;SVGAnimatedType&gt; SVGAnimatedColorAnimator::constructFromString(const String&amp; string)
</span><span class="cx"> {
</span><del>-    auto animatedType = SVGAnimatedType::createColor(std::make_unique&lt;Color&gt;());
-    animatedType-&gt;color() = string.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(string);
-    return animatedType;
</del><ins>+    return SVGAnimatedType::createColor(std::make_unique&lt;Color&gt;(SVGColor::colorFromRGBColorString(string)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SVGAnimatedColorAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
</span><span class="cx"> {
</span><ins>+    ASSERT(from);
+    ASSERT(to);
</ins><span class="cx">     ASSERT(from-&gt;type() == AnimatedColor);
</span><del>-    ASSERT(from-&gt;type() == to-&gt;type());
-    to-&gt;color() = ColorDistance::addColors(from-&gt;color(), to-&gt;color());
</del><ins>+    ASSERT(to-&gt;type() == AnimatedColor);
+
+    // Ignores any alpha and sets alpha on result to 100% opaque.
+    auto&amp; fromColor = from-&gt;color();
+    auto&amp; toColor = to-&gt;color();
+    toColor = { roundAndClampColorChannel(toColor.red() + fromColor.red()),
+        roundAndClampColorChannel(toColor.green() + fromColor.green()),
+        roundAndClampColorChannel(toColor.blue() + fromColor.blue()) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline void adjustForCurrentColor(SVGElement* targetElement, Color&amp; color)
</del><ins>+static inline Color currentColor(SVGElement&amp; targetElement)
</ins><span class="cx"> {
</span><del>-    ASSERT(targetElement);
-
-    if (RenderElement* targetRenderer = targetElement-&gt;renderer())
-        color = targetRenderer-&gt;style().visitedDependentColor(CSSPropertyColor);
-    else
-        color = Color();
</del><ins>+    RenderElement* targetRenderer = targetElement.renderer();
+    if (!targetRenderer)
+        return { };
+    return targetRenderer-&gt;style().visitedDependentColor(CSSPropertyColor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static Color parseColorFromString(SVGAnimationElement*, const String&amp; string)
</span><span class="lines">@@ -68,8 +71,6 @@
</span><span class="cx"> 
</span><span class="cx">     Color fromColor = m_animationElement-&gt;animationMode() == ToAnimation ? animated-&gt;color() : from-&gt;color();
</span><span class="cx">     Color toColor = to-&gt;color();
</span><del>-    const Color&amp; toAtEndOfDurationColor = toAtEndOfDuration-&gt;color();
-    Color&amp; animatedColor = animated-&gt;color();
</del><span class="cx"> 
</span><span class="cx">     // Apply CSS inheritance rules.
</span><span class="cx">     m_animationElement-&gt;adjustForInheritance&lt;Color&gt;(parseColorFromString, m_animationElement-&gt;fromPropertyValueType(), fromColor, m_contextElement);
</span><span class="lines">@@ -77,35 +78,40 @@
</span><span class="cx"> 
</span><span class="cx">     // Apply &lt;animateColor&gt; rules.
</span><span class="cx">     if (m_animationElement-&gt;fromPropertyValueType() == CurrentColorValue)
</span><del>-        adjustForCurrentColor(m_contextElement, fromColor);
</del><ins>+        fromColor = currentColor(*m_contextElement);
</ins><span class="cx">     if (m_animationElement-&gt;toPropertyValueType() == CurrentColorValue)
</span><del>-        adjustForCurrentColor(m_contextElement, toColor);
</del><ins>+        toColor = currentColor(*m_contextElement);
</ins><span class="cx"> 
</span><del>-    float animatedRed = animatedColor.red();
-    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed);
</del><ins>+    auto&amp; toAtEndOfDurationColor = toAtEndOfDuration-&gt;color();
+    auto&amp; animatedColor = animated-&gt;color();
</ins><span class="cx"> 
</span><del>-    float animatedGreen = animatedColor.green();
-    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen);
</del><ins>+    float red = animatedColor.red();
+    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), red);
</ins><span class="cx"> 
</span><del>-    float animatedBlue = animatedColor.blue();
-    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue);
</del><ins>+    float green = animatedColor.green();
+    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), green);
</ins><span class="cx"> 
</span><del>-    float animatedAlpha = animatedColor.alpha();
-    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha);
</del><ins>+    float blue = animatedColor.blue();
+    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), blue);
</ins><span class="cx"> 
</span><del>-    animatedColor = ColorDistance::clampColor(static_cast&lt;int&gt;(roundf(animatedRed)), static_cast&lt;int&gt;(roundf(animatedGreen)), static_cast&lt;int&gt;(roundf(animatedBlue)), static_cast&lt;int&gt;(roundf(animatedAlpha)));
</del><ins>+    float alpha = animatedColor.alpha();
+    m_animationElement-&gt;animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), alpha);
+
+    animatedColor = { { roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha) }, ColorSpaceSRGB };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float SVGAnimatedColorAnimator::calculateDistance(const String&amp; fromString, const String&amp; toString)
</span><span class="cx"> {
</span><del>-    ASSERT(m_contextElement);
</del><span class="cx">     Color from = SVGColor::colorFromRGBColorString(fromString);
</span><span class="cx">     if (!from.isValid())
</span><span class="cx">         return -1;
</span><span class="cx">     Color to = SVGColor::colorFromRGBColorString(toString);
</span><span class="cx">     if (!to.isValid())
</span><span class="cx">         return -1;
</span><del>-    return ColorDistance(from, to).distance();
</del><ins>+    float red = from.red() - to.red();
+    float green = from.green() - to.green();
+    float blue = from.blue() - to.blue();
+    return sqrtf(red * red + green * green + blue * blue);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAnimatedColorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAnimatedColor.h (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAnimatedColor.h        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGAnimatedColor.h        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -24,23 +24,22 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class SVGAnimationElement;
-
</del><span class="cx"> class SVGAnimatedColorAnimator final : public SVGAnimatedTypeAnimator {
</span><span class="cx"> public:
</span><del>-    SVGAnimatedColorAnimator(SVGAnimationElement*, SVGElement*);
</del><ins>+    SVGAnimatedColorAnimator(SVGAnimationElement&amp;, SVGElement&amp;);
</ins><span class="cx"> 
</span><del>-    virtual std::unique_ptr&lt;SVGAnimatedType&gt; constructFromString(const String&amp;) override;
-    virtual std::unique_ptr&lt;SVGAnimatedType&gt; startAnimValAnimation(const SVGElementAnimatedPropertyList&amp;) override { return nullptr; }
-    virtual void stopAnimValAnimation(const SVGElementAnimatedPropertyList&amp;) override { }
-    virtual void resetAnimValToBaseVal(const SVGElementAnimatedPropertyList&amp;, SVGAnimatedType*) override { }
-    virtual void animValWillChange(const SVGElementAnimatedPropertyList&amp;) override { }
-    virtual void animValDidChange(const SVGElementAnimatedPropertyList&amp;) override { }
-
-    virtual void addAnimatedTypes(SVGAnimatedType*, SVGAnimatedType*) override;
-    virtual void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*) override;
-    virtual float calculateDistance(const String&amp; fromString, const String&amp; toString) override;
</del><ins>+private:
+    std::unique_ptr&lt;SVGAnimatedType&gt; constructFromString(const String&amp;) override;
+    std::unique_ptr&lt;SVGAnimatedType&gt; startAnimValAnimation(const SVGElementAnimatedPropertyList&amp;) override { return nullptr; }
+    void stopAnimValAnimation(const SVGElementAnimatedPropertyList&amp;) override { }
+    void resetAnimValToBaseVal(const SVGElementAnimatedPropertyList&amp;, SVGAnimatedType*) override { }
+    void animValWillChange(const SVGElementAnimatedPropertyList&amp;) override { }
+    void animValDidChange(const SVGElementAnimatedPropertyList&amp;) override { }
+    void addAnimatedTypes(SVGAnimatedType*, SVGAnimatedType*) override;
+    void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*) override;
+    float calculateDistance(const String&amp; fromString, const String&amp; toString) override;
</ins><span class="cx"> };
</span><ins>+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAnimatedTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case AnimatedColor:
</span><span class="cx">         ASSERT(m_data.color);
</span><del>-        *m_data.color = value.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(value);
</del><ins>+        *m_data.color = SVGColor::colorFromRGBColorString(value);
</ins><span class="cx">         break;
</span><span class="cx">     case AnimatedLength: {
</span><span class="cx">         ASSERT(m_data.length);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAnimatorFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAnimatorFactory.h (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAnimatorFactory.h        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGAnimatorFactory.h        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">         case AnimatedBoolean:
</span><span class="cx">             return std::make_unique&lt;SVGAnimatedBooleanAnimator&gt;(animationElement, contextElement);
</span><span class="cx">         case AnimatedColor:
</span><del>-            return std::make_unique&lt;SVGAnimatedColorAnimator&gt;(animationElement, contextElement);
</del><ins>+            return std::make_unique&lt;SVGAnimatedColorAnimator&gt;(*animationElement, *contextElement);
</ins><span class="cx">         case AnimatedEnumeration:
</span><span class="cx">             return std::make_unique&lt;SVGAnimatedEnumerationAnimator&gt;(animationElement, contextElement);
</span><span class="cx">         case AnimatedInteger:
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGColorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGColor.cpp (190002 => 190003)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGColor.cpp        2015-09-19 00:31:04 UTC (rev 190002)
+++ trunk/Source/WebCore/svg/SVGColor.cpp        2015-09-19 01:25:35 UTC (rev 190003)
</span><span class="lines">@@ -47,7 +47,10 @@
</span><span class="cx"> 
</span><span class="cx"> Color SVGColor::colorFromRGBColorString(const String&amp; colorString)
</span><span class="cx"> {
</span><del>-    // FIXME: Rework css parser so it is more SVG aware.
</del><ins>+    // FIXME: Rename to parseSVGColor? There's already a parseSVGColor in the CSS parser. How is it different?
+    // FIXME: Rework CSS parser so it exactly matches what the SVG specification requires?
+    // FIXME: Move this out of the SVGColor class?
+    // FIXME: Is it really OK to do stripWhitespace here instead of stripLeadingAndTrailingHTMLSpaces?
</ins><span class="cx">     RGBA32 color;
</span><span class="cx">     if (CSSParser::parseColor(color, colorString.stripWhiteSpace()))
</span><span class="cx">         return color;
</span><span class="lines">@@ -57,7 +60,7 @@
</span><span class="cx"> void SVGColor::setRGBColor(const String&amp;, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     // The whole SVGColor interface is deprecated in SVG 1.1 (2nd edition).
</span><del>-    // The setters are the most problematic part so we remove the support for those first.
</del><ins>+    // Since the setters are the most problematic part, we removed the support for those first.
</ins><span class="cx">     ec = NO_MODIFICATION_ALLOWED_ERR;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -83,7 +86,7 @@
</span><span class="cx">     case SVG_COLORTYPE_CURRENTCOLOR:
</span><span class="cx">         if (m_color.isValid())
</span><span class="cx">             return m_color.cssText();
</span><del>-        return &quot;currentColor&quot;;
</del><ins>+        return ASCIILiteral(&quot;currentColor&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span></span></pre>
</div>
</div>

</body>
</html>