<!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>[200685] branches/safari-602.1.32-branch</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/200685">200685</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-05-11 01:20:27 -0700 (Wed, 11 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/200659">r200659</a>. rdar://problem/26125909</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602132branchSourceWebCoreChangeLog">branches/safari-602.1.32-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreeditingcocoaDataDetectionmm">branches/safari-602.1.32-branch/Source/WebCore/editing/cocoa/DataDetection.mm</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreplatformgraphicsColorcpp">branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.cpp</a></li>
<li><a href="#branchessafari602132branchSourceWebCoreplatformgraphicsColorh">branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.h</a></li>
<li><a href="#branchessafari602132branchToolsChangeLog">branches/safari-602.1.32-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari602132branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">branches/safari-602.1.32-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari602132branchToolsTestWebKitAPITestsWebCoreColorcpp">branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602132branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/ChangeLog (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/ChangeLog        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Source/WebCore/ChangeLog        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-05-11 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r200659.
+
+ 2016-05-10 Sam Weinig <sam@webkit.org>
+
+ Tweak underline style for data detected links
+ https://bugs.webkit.org/show_bug.cgi?id=157546
+
+ Reviewed by Tim Horton.
+
+ Added API Tests in Color.cpp.
+
+ * editing/cocoa/DataDetection.mm:
+ (WebCore::DataDetection::detectContentInRange):
+ Tweak the underline's opacity based on the text color. White-ish text gets
+ 46% opacity, everything else gets 26% opacity.
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::getHSV):
+ * platform/graphics/Color.h:
+ Add support for getting the HSV (also know as HSB) computation of the color
+ to help determine the "whiteness" of a color.
+
</ins><span class="cx"> 2016-05-09 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Add injected bundle SPI for getting favicon and touch icon URLs
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreeditingcocoaDataDetectionmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/editing/cocoa/DataDetection.mm (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/editing/cocoa/DataDetection.mm        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Source/WebCore/editing/cocoa/DataDetection.mm        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -639,8 +639,17 @@
</span><span class="cx"> if (renderStyle) {
</span><span class="cx"> auto textColor = renderStyle->visitedDependentColor(CSSPropertyColor);
</span><span class="cx"> if (textColor.isValid()) {
</span><del>- auto underlineColor = Color(colorWithOverrideAlpha(textColor.rgb(), 0.2));
</del><ins>+ double h = 0;
+ double s = 0;
+ double v = 0;
+ textColor.getHSV(h, s, v);
</ins><span class="cx">
</span><ins>+ // Set the alpha of the underline to 46% if the text color is white-ish (defined
+ // as having a saturation of less than 2% and a value/brightness or greater than
+ // 98%). Otherwise, set the alpha of the underline to 26%.
+ double overrideAlpha = (s < 0.02 && v > 0.98) ? 0.46 : 0.26;
+ auto underlineColor = Color(colorWithOverrideAlpha(textColor.rgb(), overrideAlpha));
+
</ins><span class="cx"> anchorElement->setInlineStyleProperty(CSSPropertyColor, textColor.cssText());
</span><span class="cx"> anchorElement->setInlineStyleProperty(CSSPropertyWebkitTextDecorationColor, underlineColor.cssText());
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreplatformgraphicsColorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.cpp (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.cpp        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.cpp        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -422,15 +422,16 @@
</span><span class="cx"> double b = static_cast<double>(blue()) / 255.0;
</span><span class="cx"> double max = std::max(std::max(r, g), b);
</span><span class="cx"> double min = std::min(std::min(r, g), b);
</span><ins>+ double chroma = max - min;
</ins><span class="cx">
</span><del>- if (max == min)
</del><ins>+ if (!chroma)
</ins><span class="cx"> hue = 0.0;
</span><span class="cx"> else if (max == r)
</span><del>- hue = (60.0 * ((g - b) / (max - min))) + 360.0;
</del><ins>+ hue = (60.0 * ((g - b) / chroma)) + 360.0;
</ins><span class="cx"> else if (max == g)
</span><del>- hue = (60.0 * ((b - r) / (max - min))) + 120.0;
</del><ins>+ hue = (60.0 * ((b - r) / chroma)) + 120.0;
</ins><span class="cx"> else
</span><del>- hue = (60.0 * ((r - g) / (max - min))) + 240.0;
</del><ins>+ hue = (60.0 * ((r - g) / chroma)) + 240.0;
</ins><span class="cx">
</span><span class="cx"> if (hue >= 360.0)
</span><span class="cx"> hue -= 360.0;
</span><span class="lines">@@ -439,14 +440,45 @@
</span><span class="cx"> hue /= 360.0;
</span><span class="cx">
</span><span class="cx"> lightness = 0.5 * (max + min);
</span><del>- if (max == min)
</del><ins>+ if (!chroma)
</ins><span class="cx"> saturation = 0.0;
</span><span class="cx"> else if (lightness <= 0.5)
</span><del>- saturation = ((max - min) / (max + min));
</del><ins>+ saturation = (chroma / (max + min));
</ins><span class="cx"> else
</span><del>- saturation = ((max - min) / (2.0 - (max + min)));
</del><ins>+ saturation = (chroma / (2.0 - (max + min)));
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void Color::getHSV(double& hue, double& saturation, double& value) const
+{
+ double r = static_cast<double>(red()) / 255.0;
+ double g = static_cast<double>(green()) / 255.0;
+ double b = static_cast<double>(blue()) / 255.0;
+ double max = std::max(std::max(r, g), b);
+ double min = std::min(std::min(r, g), b);
+ double chroma = max - min;
+
+ if (!chroma)
+ hue = 0.0;
+ else if (max == r)
+ hue = (60.0 * ((g - b) / chroma)) + 360.0;
+ else if (max == g)
+ hue = (60.0 * ((b - r) / chroma)) + 120.0;
+ else
+ hue = (60.0 * ((r - g) / chroma)) + 240.0;
+
+ if (hue >= 360.0)
+ hue -= 360.0;
+
+ hue /= 360.0;
+
+ if (!max)
+ saturation = 0;
+ else
+ saturation = chroma / max;
+
+ value = max;
+}
+
</ins><span class="cx"> Color colorFromPremultipliedARGB(RGBA32 pixelColor)
</span><span class="cx"> {
</span><span class="cx"> int alpha = alphaChannel(pixelColor);
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebCoreplatformgraphicsColorh"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.h (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.h        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Source/WebCore/platform/graphics/Color.h        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx"> WEBCORE_EXPORT void getRGBA(float& r, float& g, float& b, float& a) const;
</span><span class="cx"> WEBCORE_EXPORT void getRGBA(double& r, double& g, double& b, double& a) const;
</span><span class="cx"> WEBCORE_EXPORT void getHSL(double& h, double& s, double& l) const;
</span><ins>+ WEBCORE_EXPORT void getHSV(double& h, double& s, double& v) const;
</ins><span class="cx">
</span><span class="cx"> Color light() const;
</span><span class="cx"> Color dark() const;
</span></span></pre></div>
<a id="branchessafari602132branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Tools/ChangeLog (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/ChangeLog        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Tools/ChangeLog        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-05-11 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r200659.
+
+ 2016-05-10 Sam Weinig <sam@webkit.org>
+
+ Tweak underline style for data detected links
+ https://bugs.webkit.org/show_bug.cgi?id=157546
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/Color.cpp: Added.
+ (TestWebKitAPI::TEST):
+ Add tests for the new Color::getHSV() function.
+
</ins><span class="cx"> 2016-05-09 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove testRunner.setTextAutosizingEnabled and migrate the one test that uses it
</span></span></pre></div>
<a id="branchessafari602132branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (200684 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-05-11 08:19:22 UTC (rev 200684)
+++ branches/safari-602.1.32-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -110,6 +110,7 @@
</span><span class="cx">                 7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA021BA1AB09EA70052953F /* DateMath.cpp */; };
</span><span class="cx">                 7AA6A1521AAC0B31002B2ED3 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */; };
</span><span class="cx">                 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; };
</span><ins>+                7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* Color.cpp */; };
</ins><span class="cx">                 7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C486BA01AA1254B003F6F9B /* bundle-file.html */; };
</span><span class="cx">                 7C54A4BE1AA11CCA00380F78 /* WKBundleFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */; };
</span><span class="cx">                 7C54A4C11AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */; };
</span><span class="lines">@@ -694,6 +695,7 @@
</span><span class="cx">                 7AA021BA1AB09EA70052953F /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = "<group>"; };
</span><ins>+                7C3965051CDD74F90094DBB8 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 7C486BA01AA1254B003F6F9B /* bundle-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "bundle-file.html"; sourceTree = "<group>"; };
</span><span class="cx">                 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -1102,6 +1104,7 @@
</span><span class="cx">                                 41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */,
</span><span class="cx">                                 CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
</span><span class="cx">                                 440A1D3814A0103A008A66F2 /* URL.cpp */,
</span><ins>+                                7C3965051CDD74F90094DBB8 /* Color.cpp */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = WebCore;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -1726,10 +1729,18 @@
</span><span class="cx">                                 TargetAttributes = {
</span><span class="cx">                                         7CCE7E8B1A41144E00447C4C = {
</span><span class="cx">                                                 CreatedOnToolsVersion = 6.3;
</span><ins>+                                                ProvisioningStyle = Manual;
</ins><span class="cx">                                         };
</span><ins>+                                        8DD76F960486AA7600D96B5E = {
+                                                ProvisioningStyle = Manual;
+                                        };
</ins><span class="cx">                                         A13EBB481B87339E00097110 = {
</span><span class="cx">                                                 CreatedOnToolsVersion = 7.0;
</span><ins>+                                                ProvisioningStyle = Manual;
</ins><span class="cx">                                         };
</span><ins>+                                        BC57597F126E74AF006F0F12 = {
+                                                ProvisioningStyle = Manual;
+                                        };
</ins><span class="cx">                                 };
</span><span class="cx">                         };
</span><span class="cx">                         buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */;
</span><span class="lines">@@ -1895,6 +1906,7 @@
</span><span class="cx">                                 7CCE7F3F1A411B8E00447C4C /* Ref.cpp in Sources */,
</span><span class="cx">                                 7CCE7F401A411B8E00447C4C /* RefCounter.cpp in Sources */,
</span><span class="cx">                                 7CCE7F411A411B8E00447C4C /* RefPtr.cpp in Sources */,
</span><ins>+                                7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */,
</ins><span class="cx">                                 7CCE7F0D1A411AE600447C4C /* ReloadPageAfterCrash.cpp in Sources */,
</span><span class="cx">                                 7CCE7EC91A411A7E00447C4C /* RenderedImageFromDOMNode.mm in Sources */,
</span><span class="cx">                                 83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */,
</span></span></pre></div>
<a id="branchessafari602132branchToolsTestWebKitAPITestsWebCoreColorcppfromrev200659trunkToolsTestWebKitAPITestsWebCoreColorcpp"></a>
<div class="copfile"><h4>Copied: branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp (from rev 200659, trunk/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp) (0 => 200685)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp         (rev 0)
+++ branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebCore/Color.cpp        2016-05-11 08:20:27 UTC (rev 200685)
</span><span class="lines">@@ -0,0 +1,147 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "Test.h"
+#include <WebCore/Color.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST(Color, RGBToHSV_White)
+{
+ Color color = Color::white;
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(0, s);
+ EXPECT_DOUBLE_EQ(1, v);
+}
+
+TEST(Color, RGBToHSV_Black)
+{
+ Color color = Color::black;
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(0, s);
+ EXPECT_DOUBLE_EQ(0, v);
+}
+
+TEST(Color, RGBToHSV_Red)
+{
+ Color color(255, 0, 0);
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(1, s);
+ EXPECT_DOUBLE_EQ(1, v);
+}
+
+TEST(Color, RGBToHSV_Green)
+{
+ Color color(0, 255, 0);
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0.33333333333333331, h);
+ EXPECT_DOUBLE_EQ(1, s);
+ EXPECT_DOUBLE_EQ(1, v);
+}
+
+TEST(Color, RGBToHSV_Blue)
+{
+ Color color(0, 0, 255);
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0.66666666666666663, h);
+ EXPECT_DOUBLE_EQ(1, s);
+ EXPECT_DOUBLE_EQ(1, v);
+}
+
+TEST(Color, RGBToHSV_DarkGray)
+{
+ Color color = Color::darkGray;
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(0, s);
+ EXPECT_DOUBLE_EQ(0.50196078431372548, v);
+}
+
+TEST(Color, RGBToHSV_Gray)
+{
+ Color color = Color::gray;
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(0, s);
+ EXPECT_DOUBLE_EQ(0.62745098039215685, v);
+}
+
+TEST(Color, RGBToHSV_LightGray)
+{
+ Color color = Color::lightGray;
+
+ double h = 0;
+ double s = 0;
+ double v = 0;
+ color.getHSV(h, s, v);
+
+ EXPECT_DOUBLE_EQ(0, h);
+ EXPECT_DOUBLE_EQ(0, s);
+ EXPECT_DOUBLE_EQ(0.75294117647058822, v);
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>
</body>
</html>