Tidy handling of type=color in HTMLInputElement a bit
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Nov 2015 06:01:37 +0000 (06:01 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Nov 2015 06:01:37 +0000 (06:01 +0000)
commit300ec76aed40d898f1075454b0e97e23be84fc0a
tree596e98f9224091bb989ceb9c08d2a7effbcf5444
parent24e179bc24cfc61bc5996868c8fe2d4426d80ac8
Tidy handling of type=color in HTMLInputElement a bit
https://bugs.webkit.org/show_bug.cgi?id=150786

Reviewed by Andreas Kling.

* html/ColorInputType.cpp: Fix formatting.
(WebCore::ColorInputType::fallbackValue): Use ASCIILiteral for slightly
better performance.
(WebCore::ColorInputType::sanitizeValue): Use convertToASCIILowercase,
since there is no need for the general purpose Unicode lowercasing here;
those non-ASCII characters aren't allowed by isValidColorString.
(WebCore::ColorInputType::suggestions): Rewrote data list code to remove
peculiarities such as using a null check to terminate the loop instead of
the collection length, calling back to HTMLInputElement just to get the
isValidColorString function called. Also used reserveInitialCapacity and
uncheckedAppend for better memory use in the result vector.
(WebCore::ColorInputType::selectColor): Added.

* html/ColorInputType.h: Made derivation from ColorChooserClient private.
Made most functions private. Added overrides for valueAsColor and selectColor,
now both virtual functions in InputType.

* html/HTMLInputElement.cpp: Removed now-unneeded include of ColorInputType.h.
(WebCore::HTMLInputElement::valueAsColor): Added. Calls through to the InputType.
In a later patch, will be used by accessibility code to get the color so it
does not have to replicate the color parsing logic from this element.
(WebCore::HTMLInputElement::selectColor): Renamed from selectColorInColorChooser,
because the longer name is not clearer. Also made this non-conditional.

* html/HTMLInputElement.h: Added valueAsColor, renamed selectColorInColorChooser
to selectColor and made it available unconditionally.

* html/InputType.cpp:
(WebCore::InputType::valueAsColor): Added. Returns transparent color.
(WebCore::InputType::selectColor): Added. Does nothing by default.

* html/InputType.h: Added virtual valueAsColor and selectColor. Also tidied
up the header a bit and removed unneeded Noncopyable (since this class has
a reference for one of the data members and so is intrinsically not copyable).
Made isColorControl available unconditionally.

* testing/Internals.cpp:
(WebCore::Internals::selectColorInColorChooser): Removed conditionals and
made this call selectColor rather than selectColorInColorChooser.

* testing/Internals.h: Made selectColorInColorChooser unconditional.

* testing/Internals.idl: Made selectColorInColorChooser unconditionally
present. Not important to optimize the test internals class by leaving it
out when INPUT_TYPE_COLOR is not enabled.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191876 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
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
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl