Simplify and streamline some Color-related code to prepare for some Color/ExtendedCol...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 17:26:58 +0000 (17:26 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 17:26:58 +0000 (17:26 +0000)
commit92907832588dc60714a5cca42ed4d26efdc24bc2
tree4f0e07c2daa7aa5d8235a4e6890084ca10ffe2cb
parent13325f49b035ce04c33435e1a440d37f7da71422
Simplify and streamline some Color-related code to prepare for some Color/ExtendedColor work
https://bugs.webkit.org/show_bug.cgi?id=180569

Reviewed by Sam Weinig.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::colorValue const): Use valueAsColor instead of
having custom code here to parse the color string.

* css/CSSGradientValue.cpp:
(WebCore::interpolate): Deleted.
(WebCore::CSSGradientValue::computeStops): Call blend instead of interpolate. The only
difference is that the interpolate function truncated when converting from floating point
to integer, and the blend function rounds instead.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::colorFromPrimitiveValue const): Removed unneeded special case
for identifier of 0, since StyleColor::colorFromKeyword already handles that correctly.
Also got rid of unneded local variable "state".

* html/ColorInputType.cpp:
(WebCore::isValidSimpleColor): Rewrote to take a StringView instead of a String and
to stay with a single loop since this does not need the extra efficiency of a separate
8-bit and 16-bit character version. Renamed to more closely match what the specification
calls this algorithm.
(WebCore::parseSimpleColorValue): Added. To be used instead of relying on the behavior of
the Color constructor that takes a String, so we can remove that later.
(WebCore::ColorInputType::sanitizeValue const): Updated for name change.
(WebCore::ColorInputType::valueAsColor const): Use parseSimpleColorValue instead of the
Color constructor that takes a string.
(WebCore::ColorInputType::typeMismatchFor const): Updated for name change.
(WebCore::ColorInputType::selectColor): Updated to take a StringView instead of a Color.
Note that this function is used for testing only.

* html/ColorInputType.h: Marked everything final instead of override. Updated the
selectColor function to take a StringView instead of a Color.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::selectColor): Take a StringView instead of a Color.
* html/HTMLInputElement.h: Ditto.

* html/InputType.cpp:
(WebCore::InputType::selectColor): Take a StringView instead of a Color.
* html/InputType.h: Ditto.

* testing/Internals.cpp:
(WebCore::Internals::selectColorInColorChooser): Pass the string directly instead of
constructing a Color with it.
(WebCore::Internals::setViewBaseBackgroundColor): Instead of pasring the passed in string
with the Color constructor, implemented the two names that are actually used with this
function in tests: "transparent" and "white".

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/ColorInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/testing/Internals.cpp