[css-ui] Implement caret-color support
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Aug 2017 17:29:34 +0000 (17:29 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Aug 2017 17:29:34 +0000 (17:29 +0000)
commit58298bc5a7412d455d316f4cc40804305c82e405
tree65fcbe00d5d6f5a195fabcc2c8c44b59027182d1
parent6fe2123f97aeabb74c3dce5fa9bbac4291a3c5b9
[css-ui] Implement caret-color support
https://bugs.webkit.org/show_bug.cgi?id=166572
<rdar://problem/33852589>

Reviewed by David Hyatt.

Source/WebCore:

Add support for the CSS property caret-color as per <https://www.w3.org/TR/css-ui-3/#caret-color> (02 March 2017).
The property caret-color specifies the color of the text insertion caret in an editable element,
say an HTML textarea element.

Unlike other CSS color properties caret-color can have value "auto" and this is its initial
value. Internally we treat value "auto" as an invalid caret color to simplify the code.

Tests: editing/pasteboard/preserve-caret-color.html
       fast/css/caret-color-auto.html
       fast/css/caret-color-fallback-to-color.html
       fast/css/caret-color-inherit.html
       fast/css/caret-color-span-inside-editable-parent.html
       fast/css/caret-color.html
       fast/history/visited-link-caret-color.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSProperties.json: Add property caret-color. We represent the initial  "auto" Also, fix up
wording in a comment while I am here.
* css/StyleResolver.cpp:
(WebCore::isValidVisitedLinkProperty): Add caret-color to the list of properties that can be
applied to visited hyperlinks.
* css/parser/CSSParserFastPaths.cpp:
(WebCore::parseCaretColor): Added.
(WebCore::CSSParserFastPaths::maybeParseValue): Unlike other CSS color properties caret-color
can be defined to be "auto". We explicitly check if the property is caret-color and use
parseCaretColor() to parse its value.
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeCaretColor): Added.
(WebCore::CSSPropertyParser::parseSingleValue): Similar to the change to CSSParserFastPaths::maybeParseValue()
use a dedicated code path to parse caret-color.
* editing/EditingStyle.cpp: Preserve caret-color during editing operations.
* editing/FrameSelection.cpp:
(WebCore::CaretBase::paintCaret const): Modified code to query property caret-color instead of
color for the color of the text insertion caret. Always honor the caret-color of the editable
element if it is valid color. Note that "caret-color: auto" is treated as an invalid color
internally. A caret-color can have an invalid color if its inherits from the CSS color property
with an invalid color. If caret-color is a valid color then we take it to be the color of the
text insertion caret. Otherwise, we do what we do today and use a heuristic to determine the
color of the text-insertion caret.
(WebCore::disappearsIntoBackground): Deleted; moved logic into CaretBase::paintCaret().
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap): Add property wrapper
to support animating caret-color.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline const): Modified to consider
changes to caret color.
(WebCore::RenderStyle::colorIncludingFallback const): Modified to compute the appropriate
color for property caret-color with respect to an unvisited or visited link.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::setCaretColor): Added.
(WebCore::RenderStyle::setVisitedLinkCaretColor): Added.
(WebCore::RenderStyle::caretColor const): Added.
(WebCore::RenderStyle::visitedLinkCaretColor const): Added.
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData): Modified to consider caret color.
(WebCore::StyleRareInheritedData::operator== const): Ditto.
* rendering/style/StyleRareInheritedData.h:

LayoutTests:

Add reference tests to ensure that we do not regress CSS property caret-color.

* TestExpectations: Unskip Web Platform Tests that now pass.
* editing/deleting/maintain-style-after-delete-expected.txt: Updated expected result.
* editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt: Ditto.
* editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt: Ditto.
* editing/pasteboard/onpaste-text-html-expected.txt: Ditto.
* editing/pasteboard/preserve-caret-color-expected.txt: Added.
* editing/pasteboard/preserve-caret-color.html: Added.
* editing/pasteboard/preserve-underline-color-expected.txt:
* fast/css/caret-color-auto-expected.html: Added.
* fast/css/caret-color-auto.html: Added.
* fast/css/caret-color-expected.html: Added.
* fast/css/caret-color-fallback-to-color-expected.html: Added.
* fast/css/caret-color-fallback-to-color.html: Added.
* fast/css/caret-color-inherit-expected.html: Added.
* fast/css/caret-color-inherit.html: Added.
* fast/css/caret-color-span-inside-editable-parent-expected.html: Added.
* fast/css/caret-color-span-inside-editable-parent.html: Added.
* fast/css/caret-color.html: Added.
* fast/events/before-input-events-prevent-drag-and-drop-expected.txt: Updated expected result.
* fast/events/input-events-paste-rich-datatransfer-expected.txt: Ditto.
* fast/events/ondrop-text-html-expected.txt: Ditto.
* fast/history/visited-link-caret-color-expected.html: Added.
* fast/history/visited-link-caret-color.html: Added.
* platform/ios/TestExpectations: Skip the tests on iOS as iOS does not enable
ENABLE(TEXT_CARET). UIKit renders the text insertion caret on iOS.
* platform/mac/editing/style/5065910-expected.txt: Updated expected result.
* platform/mac/editing/style/5084241-expected.png: Ditto.
* platform/mac/editing/style/5084241-expected.txt: Ditto.
* platform/ios-wk2/editing/style/5084241-expected.txt: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
42 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/editing/deleting/maintain-style-after-delete-expected.txt
LayoutTests/editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt
LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt
LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt
LayoutTests/editing/pasteboard/preserve-caret-color-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/preserve-caret-color.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt
LayoutTests/fast/css/caret-color-auto-expected.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-auto.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-expected.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-fallback-to-color-expected.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-fallback-to-color.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-inherit-expected.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-inherit.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-span-inside-editable-parent-expected.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color-span-inside-editable-parent.html [new file with mode: 0644]
LayoutTests/fast/css/caret-color.html [new file with mode: 0644]
LayoutTests/fast/events/before-input-events-prevent-drag-and-drop-expected.txt
LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt
LayoutTests/fast/events/ondrop-text-html-expected.txt
LayoutTests/fast/history/visited-link-caret-color-expected.html [new file with mode: 0644]
LayoutTests/fast/history/visited-link-caret-color.html [new file with mode: 0644]
LayoutTests/platform/ios-wk2/editing/style/5084241-expected.txt
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac/editing/style/5065910-expected.txt
LayoutTests/platform/mac/editing/style/5084241-expected.png
LayoutTests/platform/mac/editing/style/5084241-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSProperties.json
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/parser/CSSParserFastPaths.cpp
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h