Title: [220706] trunk
Revision
220706
Author
dba...@webkit.org
Date
2017-08-14 10:29:34 -0700 (Mon, 14 Aug 2017)

Log Message

[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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220705 => 220706)


--- trunk/LayoutTests/ChangeLog	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/ChangeLog	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1,3 +1,43 @@
+2017-08-14  Daniel Bates  <daba...@apple.com>
+
+        [css-ui] Implement caret-color support
+        https://bugs.webkit.org/show_bug.cgi?id=166572
+        <rdar://problem/33852589>
+
+        Reviewed by David Hyatt.
+
+        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.
+
 2017-08-14  Zan Dobersek  <zdober...@igalia.com>
 
         REGRESSION(r220517-r220521) [GTK] Various compositing tests fail

Modified: trunk/LayoutTests/TestExpectations (220705 => 220706)


--- trunk/LayoutTests/TestExpectations	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/TestExpectations	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1432,22 +1432,3 @@
 webkit.org/b/175288 imported/w3c/web-platform-tests/css/css-ui-3/outline-016.html [ ImageOnlyFailure ]
 webkit.org/b/175288 imported/w3c/web-platform-tests/css/css-ui-3/outline-019.html [ ImageOnlyFailure ]
 webkit.org/b/175290 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-005.html [ ImageOnlyFailure ]
-
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-001.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-002.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-003.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-004.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-005.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-006.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-007.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-008.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-009.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-010.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-011.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-012.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-013.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-014.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-015.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-016.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-017.html [ Failure ]
-webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-021.html [ Failure ]

Modified: trunk/LayoutTests/editing/deleting/maintain-style-after-delete-expected.txt (220705 => 220706)


--- trunk/LayoutTests/editing/deleting/maintain-style-after-delete-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/editing/deleting/maintain-style-after-delete-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -4,7 +4,9 @@
 | "H "
 | <font>
 |   color="#0000ff"
-|   "O<#selection-caret>"
+|   <span>
+|     style="caret-color: rgb(0, 0, 255);"
+|     "O<#selection-caret>"
 
 Deleting the blue colored text and the preceding space and then inserting 'W'. 'W' should be not be in blue color in the following markup:
 | "HW<#selection-caret>"

Modified: trunk/LayoutTests/editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt (220705 => 220706)


--- trunk/LayoutTests/editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -15,7 +15,7 @@
 |   <font>
 |     color="#1b6f11"
 |     <span>
-|       style="background-color: rgb(191, 35, 28);"
+|       style="caret-color: rgb(27, 111, 17); background-color: rgb(191, 35, 28);"
 |       "Bar<#selection-caret>"
 |       <br>
 |   <br>

Modified: trunk/LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt (220705 => 220706)


--- trunk/LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -3,5 +3,5 @@
 
 You should not see any borders:
 | <span>
-|   style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 0);"
+|   style="caret-color: rgb(0, 0, 255); color: rgb(0, 0, 255); background-color: rgb(255, 255, 0);"
 |   "Hello<#selection-caret>"

Modified: trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt (220705 => 220706)


--- trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1,5 +1,5 @@
 CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the clipboard during an onpaste event. 
-CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
+CONSOLE MESSAGE: line 23: text/html: <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
 This test verifies that we can get text/html from the clipboard during an onpaste event. This test requires DRT.
 Paste content in this div.This test verifies that we can get text/html from the clipboard during an onpaste event. 
 PASS

Added: trunk/LayoutTests/editing/pasteboard/preserve-caret-color-expected.txt (0 => 220706)


--- trunk/LayoutTests/editing/pasteboard/preserve-caret-color-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/preserve-caret-color-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,8 @@
+This test that CSS property caret-color is preserved when copying and pasting.
+| <span>
+|   style="caret-color: rgb(0, 0, 255);"
+|   "caret-color: blue, "
+| <span>
+|   style="caret-color: magenta;"
+|   "caret-color: magenta<#selection-caret>"
+| <br>

Added: trunk/LayoutTests/editing/pasteboard/preserve-caret-color.html (0 => 220706)


--- trunk/LayoutTests/editing/pasteboard/preserve-caret-color.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/preserve-caret-color.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test that CSS property caret-color is preserved when copying and pasting.</p>
+<p>To manually test, copy "caret-color: blue, caret-color: magenta" and paste it on the second editable region. Then verify that the color of the text insertion caret is blue and magenta when placed inside the substring "caret-color: blue" and "caret-color: magenta", respectively.</p>
+<div id="copy" contenteditable="true"><span style="caret-color: blue">caret-color: blue, <span style="caret-color: magenta">caret-color: magenta</span></span></div>
+<div id="paste" contenteditable="true"><br></div>
+<script src=""
+<script>
+if (!window.testRunner)
+    Markup.noAutoDump();
+else {
+    var copy = document.getElementById("copy");
+    copy.focus();
+    document.execCommand("SelectAll");
+    document.execCommand("Copy");
+    var paste = document.getElementById("paste");
+    paste.focus();
+    document.execCommand("Paste");
+
+    Markup.description(document.getElementsByTagName("p")[0].innerText);
+    Markup.dump("paste");
+}
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt (220705 => 220706)


--- trunk/LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1,5 +1,5 @@
 This test for a bug copy/pasting underlined text. The color of the underline should be the color of the element that has the text-decoration property.
 | <span>
-|   style="color: rgb(255, 0, 0); text-decoration: underline;"
+|   style="caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); text-decoration: underline;"
 |   "This should be underlined.<#selection-caret>"
 | <br>

Added: trunk/LayoutTests/fast/css/caret-color-auto-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-auto-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-auto-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#test {
+    background-color: white;
+    color: red;
+    caret-color: green;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+
+#test > span {
+    background-color: inherit;
+}
+</style>
+</head>
+<body>
+<p>Tests that "caret-color: auto" behaves identical to omitting property caret-color.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">
+        <span>&nbsp;<!-- Needed for the caret to render in Firefox. --></span>
+    </div>
+</div>
+<script>
+document.getElementById("test").focus();
+window.getSelection().modify("move", "left", "character"); // Place the caret at the start of the <span>.
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-auto.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-auto.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-auto.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#test {
+    background-color: white;
+    color: red;
+    caret-color: green;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+
+#test > span {
+    background-color: inherit;
+    caret-color: auto;
+}
+</style>
+</head>
+<body>
+<p>Tests that "caret-color: auto" behaves identical to omitting property caret-color.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">
+        <span>&nbsp;<!-- Needed for the caret to render in Firefox. --></span>
+    </div>
+</div>
+<script>
+document.getElementById("test").focus();
+window.getSelection().modify("move", "left", "character"); // Place the caret at the start of the <span>.
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#mock-caret {
+    height: inherit;
+    width: inherit;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that the text insertion point is rendered with the color caret-color.</p>
+<div id="test-container">
+    <div id="mock-caret"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-fallback-to-color-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-fallback-to-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-fallback-to-color-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#mock-caret {
+    height: inherit;
+    width: inherit;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that caret-color falls back to color.</p>
+<div id="test-container">
+    <div id="mock-caret"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-fallback-to-color.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-fallback-to-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-fallback-to-color.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#test {
+    height: inherit;
+    width: inherit;
+    color: green;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+</style>
+</head>
+<body>
+<p>This tests that caret-color falls back to color.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">&nbsp;<!-- Needed for the caret to render in Firefox. --></div>
+</div>
+<script>
+document.getElementById("test").focus();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-inherit-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-inherit-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-inherit-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#mock-caret {
+    height: inherit;
+    width: inherit;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that caret-color is inherited.</p>
+<div id="test-container">
+    <div id="mock-caret"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-inherit.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-inherit.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-inherit.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+    caret-color: green;
+}
+
+#test {
+    height: inherit;
+    width: inherit;
+    caret-color: inherit;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+</style>
+</head>
+<body>
+<p>This tests that caret-color is inherited.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">&nbsp;<!-- Needed for the caret to render in Firefox. --></div>
+</div>
+<script>
+document.getElementById("test").focus();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#mock-caret {
+    height: inherit;
+    width: inherit;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that the text insertion point color represents the caret-color of the inner-most focused element regardless whether the background color of the inner-most focused element cannot be visibly differentiated from the background color of its root editable element.</p>
+<div id="test-container">
+    <div id="mock-caret"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color-span-inside-editable-parent.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#test {
+    background-color: white;
+    color: red;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+
+#test > span {
+    background-color: inherit;
+    caret-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that the text insertion point color represents the caret-color of the inner-most focused element regardless whether the background color of the inner-most focused element cannot be visibly differentiated from the background color of its root editable element.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">
+        <span>&nbsp;<!-- Needed for the caret to render in Firefox. --></span>
+    </div>
+</div>
+<script>
+document.getElementById("test").focus();
+window.getSelection().modify("move", "left", "character"); // Place the caret at the start of the <span>.
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/caret-color.html (0 => 220706)


--- trunk/LayoutTests/fast/css/caret-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/caret-color.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#test {
+    height: inherit;
+    width: inherit;
+    caret-color: green;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+</style>
+</head>
+<body>
+<p>This tests that the text insertion point is rendered with the color caret-color.</p>
+<div id="test-container">
+    <div id="test" contenteditable="true">&nbsp;<!-- Needed for the caret to render in Firefox. --></div>
+</div>
+<script>
+document.getElementById("test").focus();
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/events/before-input-events-prevent-drag-and-drop-expected.txt (220705 => 220706)


--- trunk/LayoutTests/fast/events/before-input-events-prevent-drag-and-drop-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/fast/events/before-input-events-prevent-drag-and-drop-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -7,4 +7,4 @@
 
 HTML content:
 
-<span style="color: rgb(0, 0, 0); font-family: monospace; font-size: 108px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">input events</span>
+<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: monospace; font-size: 108px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">input events</span>

Modified: trunk/LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt (220705 => 220706)


--- trunk/LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -2,7 +2,7 @@
 
 destination after pasting (text/html):
 | <b>
-|   style="color: rgb(255, 0, 0); font-family: -webkit-standard; font-style: normal; font-variant-caps: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"
+|   style="caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); font-family: -webkit-standard; font-style: normal; font-variant-caps: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"
 |   "LayoutTests"
 |   <i>
 |     "are"

Modified: trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt (220705 => 220706)


--- trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1,4 +1,4 @@
 CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the drag object during an ondrop event. 
-CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
+CONSOLE MESSAGE: line 23: text/html: <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
 This test verifies that we can get text/html from the drag object during an ondrop event. This test requires DRT.
 PASS

Added: trunk/LayoutTests/fast/history/visited-link-caret-color-expected.html (0 => 220706)


--- trunk/LayoutTests/fast/history/visited-link-caret-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/visited-link-caret-color-expected.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+}
+
+#mock-caret {
+    height: inherit;
+    width: inherit;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<p>This tests that we apply caret-color for a visited link.</p>
+<div id="test-container">
+    <div id="mock-caret"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/visited-link-caret-color.html (0 => 220706)


--- trunk/LayoutTests/fast/history/visited-link-caret-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/visited-link-caret-color.html	2017-08-14 17:29:34 UTC (rev 220706)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test-container {
+    height: 50px;
+    width: 50px;
+    overflow: hidden;
+    outline: none;
+}
+
+a {
+    display: block;
+    height: inherit;
+    width: inherit;
+    transform-origin: left top;
+    transform: scale(50, 50);
+    font-size: 10px; /* Needed for the caret to render in Firefox. */
+}
+
+a:link {
+    caret-color: red;
+}
+
+a:visited {
+    caret-color: green;
+}
+</style>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.keepWebHistory();
+}
+
+function waitForStyleChange(failureTime)
+{
+    var aElement = document.querySelector("a");
+    if (internals.computedStyleIncludingVisitedInfo(aElement).caretColor === "rgb(255, 255, 255)")
+        testRunner.notifyDone();
+    else if (Date.now() > failureTime)
+        testRunner.notifyDone();
+    else
+        setTimeout(waitForStyleChange, 5, failureTime);
+}
+
+function doTest()
+{
+    document.querySelector("#test-container").focus();
+    window.getSelection().modify("move", "left", "character"); // Place the caret at the start of the <a>.
+
+    if (window.internals)
+        internals.toggleOverwriteModeEnabled(); // Disables caret blinking
+    if (window.testRunner)
+        waitForStyleChange(Date.now() + 500);
+}
+</script>
+</head>
+<body _onload_="doTest()">
+<p>This tests that we apply caret-color for a visited link.</p>
+<iframe src="" style="display:none"></iframe>
+<div id="test-container" contenteditable="true">
+    <a href="" Needed for the caret to render in Firefox. --></a>
+</div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (220705 => 220706)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-08-14 17:29:34 UTC (rev 220706)
@@ -408,6 +408,13 @@
 svg/animations/animations-paused-when-inserted-in-hidden-document.html [ Skip ]
 svg/animations/animations-paused-when-inserted-in-hidden-document2.html [ Skip ]
 
+# iOS does not enable ENABLE(TEXT_CARET). UIKit renders the text insertion caret.
+fast/css/caret-color-fallback-to-color.html [ Skip ]
+fast/css/caret-color-inherit.html [ Skip ]
+fast/css/caret-color-span-inside-editable-parent.html [ Skip ]
+fast/css/caret-color.html [ Skip ]
+fast/history/visited-link-caret-color.html [ Skip ]
+
 ###
 # Known failures
 ##

Modified: trunk/LayoutTests/platform/ios-wk2/editing/style/5084241-expected.txt (220705 => 220706)


--- trunk/LayoutTests/platform/ios-wk2/editing/style/5084241-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/platform/ios-wk2/editing/style/5084241-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -8,11 +8,12 @@
           text run at (0,0) width 758: "This tests for a bug where deleting everything in a paragraph of colored text would prevent the user from changing the"
           text run at (0,20) width 64: "text color."
       RenderBlock {DIV} at (0,56) size 784x20
-        RenderInline {FONT} at (0,0) size 151x19 [color=#FF0000]
-          RenderText {#text} at (0,0) size 151x19
-            text run at (0,0) width 151: "This text should be red."
-        RenderInline {FONT} at (0,0) size 159x19 [color=#0000FF]
-          RenderText {#text} at (150,0) size 159x19
-            text run at (150,0) width 159: "This text should be blue."
+        RenderInline {SPAN} at (0,0) size 309x19
+          RenderInline {FONT} at (0,0) size 151x19 [color=#FF0000]
+            RenderText {#text} at (0,0) size 151x19
+              text run at (0,0) width 151: "This text should be red."
+          RenderInline {FONT} at (0,0) size 159x19 [color=#0000FF]
+            RenderText {#text} at (150,0) size 159x19
+              text run at (150,0) width 159: "This text should be blue."
       RenderBlock (anonymous) at (0,76) size 784x0
-caret: position 25 of child 0 {#text} of child 1 {FONT} of child 2 {DIV} of body
+caret: position 25 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 2 {DIV} of body

Modified: trunk/LayoutTests/platform/mac/editing/style/5065910-expected.txt (220705 => 220706)


--- trunk/LayoutTests/platform/mac/editing/style/5065910-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/platform/mac/editing/style/5065910-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -12,13 +12,14 @@
             RenderText {#text} at (0,0) size 151x18
               text run at (0,0) width 151: "This text should be red."
         RenderBlock {DIV} at (0,18) size 784x18
-          RenderInline {FONT} at (0,0) size 127x18 [color=#0000FF]
-            RenderText {#text} at (0,0) size 127x18
-              text run at (0,0) width 127: "This text should be "
-          RenderInline {FONT} at (0,0) size 240x18 [color=#008000]
-            RenderText {#text} at (126,0) size 240x18
-              text run at (126,0) width 240: "a combination of green and blue, not "
-          RenderInline {FONT} at (0,0) size 25x18 [color=#0000FF]
-            RenderText {#text} at (365,0) size 25x18
-              text run at (365,0) width 25: "red."
-caret: position 37 of child 0 {#text} of child 1 {FONT} of child 1 {DIV} of child 2 {DIV} of body
+          RenderInline {SPAN} at (0,0) size 390x18
+            RenderInline {FONT} at (0,0) size 127x18 [color=#0000FF]
+              RenderText {#text} at (0,0) size 127x18
+                text run at (0,0) width 127: "This text should be "
+            RenderInline {FONT} at (0,0) size 240x18 [color=#008000]
+              RenderText {#text} at (126,0) size 240x18
+                text run at (126,0) width 240: "a combination of green and blue, not "
+            RenderInline {FONT} at (0,0) size 25x18 [color=#0000FF]
+              RenderText {#text} at (365,0) size 25x18
+                text run at (365,0) width 25: "red."
+caret: position 37 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 1 {DIV} of child 2 {DIV} of body

Modified: trunk/LayoutTests/platform/mac/editing/style/5084241-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/style/5084241-expected.txt (220705 => 220706)


--- trunk/LayoutTests/platform/mac/editing/style/5084241-expected.txt	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/LayoutTests/platform/mac/editing/style/5084241-expected.txt	2017-08-14 17:29:34 UTC (rev 220706)
@@ -8,10 +8,11 @@
           text run at (0,0) width 758: "This tests for a bug where deleting everything in a paragraph of colored text would prevent the user from changing the"
           text run at (0,18) width 64: "text color."
       RenderBlock {DIV} at (0,52) size 784x18
-        RenderInline {FONT} at (0,0) size 151x18 [color=#FF0000]
-          RenderText {#text} at (0,0) size 151x18
-            text run at (0,0) width 151: "This text should be red."
-        RenderInline {FONT} at (0,0) size 159x18 [color=#0000FF]
-          RenderText {#text} at (150,0) size 159x18
-            text run at (150,0) width 159: "This text should be blue."
-caret: position 25 of child 0 {#text} of child 1 {FONT} of child 2 {DIV} of body
+        RenderInline {SPAN} at (0,0) size 309x18
+          RenderInline {FONT} at (0,0) size 151x18 [color=#FF0000]
+            RenderText {#text} at (0,0) size 151x18
+              text run at (0,0) width 151: "This text should be red."
+          RenderInline {FONT} at (0,0) size 159x18 [color=#0000FF]
+            RenderText {#text} at (150,0) size 159x18
+              text run at (150,0) width 159: "This text should be blue."
+caret: position 25 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 2 {DIV} of body

Modified: trunk/Source/WebCore/ChangeLog (220705 => 220706)


--- trunk/Source/WebCore/ChangeLog	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/ChangeLog	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1,3 +1,70 @@
+2017-08-14  Daniel Bates  <daba...@apple.com>
+
+        [css-ui] Implement caret-color support
+        https://bugs.webkit.org/show_bug.cgi?id=166572
+        <rdar://problem/33852589>
+
+        Reviewed by David Hyatt.
+
+        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:
+
 2017-08-14  Zan Dobersek  <zdober...@igalia.com>
 
         REGRESSION(r220517-r220521) [GTK] Various compositing tests fail

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (220705 => 220706)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -137,6 +137,7 @@
     CSSPropertyBoxShadow,
     CSSPropertyBoxSizing,
     CSSPropertyCaptionSide,
+    CSSPropertyCaretColor,
     CSSPropertyClear,
     CSSPropertyClip,
     CSSPropertyColor,
@@ -2891,6 +2892,8 @@
             return valueForShadow(style->boxShadow(), propertyID, *style);
         case CSSPropertyCaptionSide:
             return cssValuePool.createValue(style->captionSide());
+        case CSSPropertyCaretColor:
+            return m_allowVisitedStyle ? cssValuePool.createColorValue(style->visitedDependentColor(CSSPropertyCaretColor)) : currentColorOrValidColor(style, style->caretColor());
         case CSSPropertyClear:
             return cssValuePool.createValue(style->clear());
         case CSSPropertyColor:

Modified: trunk/Source/WebCore/css/CSSProperties.json (220705 => 220706)


--- trunk/Source/WebCore/css/CSSProperties.json	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/css/CSSProperties.json	2017-08-14 17:29:34 UTC (rev 220706)
@@ -89,7 +89,7 @@
         "StyleResolver::applyPropertyToRegularStyle() returns true.",
         "",
         "* no-default-color:",
-        "Should only with used with \"VisitedLinkColorSupport\". It indicates that for",
+        "Should only be used with \"VisitedLinkColorSupport\". It indicates that when",
         "setting the inherited value, it will not fallback to using the parent's",
         "\"color\" property if the inherited color is invalid.",
         "",
@@ -170,6 +170,17 @@
         "to true is chosen for code generation."
     ],
     "properties": {
+        "caret-color" : {
+            "inherited": true,
+            "codegen-properties": {
+                "initial": "invalidColor",
+                "visited-link-color-support": true
+            },
+            "specification": {
+                "category": "css-ui",
+                "url": "https://drafts.csswg.org/css-ui-3/#propdef-caret-color"
+            }
+        },
         "color": {
             "inherited": true,
             "codegen-properties": {

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (220705 => 220706)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1455,6 +1455,7 @@
     case CSSPropertyBorderRightColor:
     case CSSPropertyBorderTopColor:
     case CSSPropertyBorderBottomColor:
+    case CSSPropertyCaretColor:
     case CSSPropertyColor:
     case CSSPropertyOutlineColor:
     case CSSPropertyColumnRuleColor:

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (220705 => 220706)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1317,11 +1317,22 @@
     return parseSimpleTransformList(string.characters16(), string.length());
 }
 
+static RefPtr<CSSValue> parseCaretColor(const String& string, CSSParserMode parserMode)
+{
+    ASSERT(!string.isEmpty());
+    CSSValueID valueID = cssValueKeywordID(string);
+    if (valueID == CSSValueAuto)
+        return CSSValuePool::singleton().createIdentifierValue(valueID);
+    return CSSParserFastPaths::parseColor(string, parserMode);
+}
+
 RefPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
 {
     RefPtr<CSSValue> result = parseSimpleLengthValue(propertyID, string, parserMode);
     if (result)
         return result;
+    if (propertyID == CSSPropertyCaretColor)
+        return parseCaretColor(string, parserMode);
     if (isColorPropertyID(propertyID))
         return parseColor(string, parserMode);
     result = parseKeywordValue(propertyID, string, parserMode);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (220705 => 220706)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1811,6 +1811,13 @@
     return nullptr;
 }
 
+static RefPtr<CSSPrimitiveValue> consumeCaretColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)
+{
+    if (range.peek().id() == CSSValueAuto)
+        return consumeIdent(range);
+    return consumeColor(range, cssParserMode);
+}
+
 static RefPtr<CSSValue> consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)
 {
     // Allow the special focus color even in HTML Standard parsing mode.
@@ -4020,6 +4027,8 @@
     case CSSPropertyLightingColor:
     case CSSPropertyColumnRuleColor:
         return consumeColor(m_range, m_context.mode);
+    case CSSPropertyCaretColor:
+        return consumeCaretColor(m_range, m_context.mode);
     case CSSPropertyColor:
     case CSSPropertyBackgroundColor:
         return consumeColor(m_range, m_context.mode, inQuirksMode());

Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (220705 => 220706)


--- trunk/Source/WebCore/editing/EditingStyle.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -58,6 +58,7 @@
 // Editing style properties must be preserved during editing operation.
 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
 static const CSSPropertyID editingProperties[] = {
+    CSSPropertyCaretColor,
     CSSPropertyColor,
     CSSPropertyFontFamily,
     CSSPropertyFontSize,

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (220705 => 220706)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1713,13 +1713,6 @@
         CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, paintOffset, clipRect);
 }
 
-#if ENABLE(TEXT_CARET)
-static inline bool disappearsIntoBackground(const Color& foreground, const Color& background)
-{
-    return background.blend(foreground) == background;
-}
-#endif
-
 void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const
 {
 #if ENABLE(TEXT_CARET)
@@ -1736,22 +1729,21 @@
 
     Color caretColor = Color::black;
     Element* element = is<Element>(*node) ? downcast<Element>(node) : node->parentElement();
-    Element* rootEditableElement = node->rootEditableElement();
-
     if (element && element->renderer()) {
-        bool setToRootEditableElement = false;
-        if (rootEditableElement && rootEditableElement->renderer()) {
-            const auto& rootEditableStyle = rootEditableElement->renderer()->style();
-            const auto& elementStyle = element->renderer()->style();
-            auto rootEditableBGColor = rootEditableStyle.visitedDependentColor(CSSPropertyBackgroundColor);
-            auto elementBGColor = elementStyle.visitedDependentColor(CSSPropertyBackgroundColor);
-            if (disappearsIntoBackground(elementBGColor, rootEditableBGColor)) {
-                caretColor = rootEditableStyle.visitedDependentColor(CSSPropertyColor);
-                setToRootEditableElement = true;
+        auto computeCaretColor = [] (const RenderStyle& elementStyle, const RenderStyle* rootEditableStyle) {
+            // CSS value "auto" is treated as an invalid color.
+            if (!elementStyle.caretColor().isValid() && rootEditableStyle) {
+                auto rootEditableBackgroundColor = rootEditableStyle->visitedDependentColor(CSSPropertyBackgroundColor);
+                auto elementBackgroundColor = elementStyle.visitedDependentColor(CSSPropertyBackgroundColor);
+                auto disappearsIntoBackground = rootEditableBackgroundColor.blend(elementBackgroundColor) == rootEditableBackgroundColor;
+                if (disappearsIntoBackground)
+                    return rootEditableStyle->visitedDependentColor(CSSPropertyCaretColor);
             }
-        }
-        if (!setToRootEditableElement)
-            caretColor = element->renderer()->style().visitedDependentColor(CSSPropertyColor);
+            return elementStyle.visitedDependentColor(CSSPropertyCaretColor);
+        };
+        auto* rootEditableElement = node->rootEditableElement();
+        auto* rootEditableStyle = rootEditableElement && rootEditableElement->renderer() ? &rootEditableElement->renderer()->style() : nullptr;
+        caretColor = computeCaretColor(element->renderer()->style(), rootEditableStyle);
     }
 
     context.fillRect(caret, caretColor);

Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (220705 => 220706)


--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1493,6 +1493,9 @@
         new LengthPropertyWrapper<Length>(CSSPropertyPaddingRight, &RenderStyle::paddingRight, &RenderStyle::setPaddingRight),
         new LengthPropertyWrapper<Length>(CSSPropertyPaddingTop, &RenderStyle::paddingTop, &RenderStyle::setPaddingTop),
         new LengthPropertyWrapper<Length>(CSSPropertyPaddingBottom, &RenderStyle::paddingBottom, &RenderStyle::setPaddingBottom),
+
+        new PropertyWrapperVisitedAffectedColor(CSSPropertyCaretColor, &RenderStyle::caretColor, &RenderStyle::setCaretColor, &RenderStyle::visitedLinkCaretColor, &RenderStyle::setVisitedLinkCaretColor),
+
         new PropertyWrapperVisitedAffectedColor(CSSPropertyColor, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::visitedLinkColor, &RenderStyle::setVisitedLinkColor),
 
         new PropertyWrapperVisitedAffectedColor(CSSPropertyBackgroundColor, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::visitedLinkBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor),

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (220705 => 220706)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -902,7 +902,8 @@
         || m_rareInheritedData->textStrokeColor != other.m_rareInheritedData->textStrokeColor
         || m_rareInheritedData->textEmphasisColor != other.m_rareInheritedData->textEmphasisColor
         || m_rareInheritedData->textEmphasisFill != other.m_rareInheritedData->textEmphasisFill
-        || m_rareInheritedData->strokeColor != other.m_rareInheritedData->strokeColor)
+        || m_rareInheritedData->strokeColor != other.m_rareInheritedData->strokeColor
+        || m_rareInheritedData->caretColor != other.m_rareInheritedData->caretColor)
         return true;
 
     return false;
@@ -1749,6 +1750,9 @@
         result = visitedLink ? visitedLinkBorderBottomColor() : borderBottomColor();
         borderStyle = borderBottomStyle();
         break;
+    case CSSPropertyCaretColor:
+        result = visitedLink ? visitedLinkCaretColor() : caretColor();
+        break;
     case CSSPropertyColor:
         result = visitedLink ? visitedLinkColor() : color();
         break;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (220705 => 220706)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2017-08-14 17:29:34 UTC (rev 220706)
@@ -1036,6 +1036,7 @@
     void setTextStrokeColor(const Color& c) { SET_VAR(m_rareInheritedData, textStrokeColor, c); }
     void setTextStrokeWidth(float w) { SET_VAR(m_rareInheritedData, textStrokeWidth, w); }
     void setTextFillColor(const Color& c) { SET_VAR(m_rareInheritedData, textFillColor, c); }
+    void setCaretColor(const Color& c) { SET_VAR(m_rareInheritedData, caretColor, c); }
     void setOpacity(float f) { float v = clampTo<float>(f, 0, 1); SET_VAR(m_rareNonInheritedData, opacity, v); }
     void setAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, appearance, a); }
     // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
@@ -1695,6 +1696,7 @@
     void setVisitedLinkTextEmphasisColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkTextEmphasisColor, v); }
     void setVisitedLinkTextFillColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkTextFillColor, v); }
     void setVisitedLinkTextStrokeColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkTextStrokeColor, v); }
+    void setVisitedLinkCaretColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkCaretColor, v); }
 
     void inheritUnicodeBidiFrom(const RenderStyle* parent) { m_nonInheritedFlags.setUnicodeBidi(parent->m_nonInheritedFlags.unicodeBidi()); }
     void getShadowExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const;
@@ -1715,6 +1717,7 @@
     const Color& textEmphasisColor() const { return m_rareInheritedData->textEmphasisColor; }
     const Color& textFillColor() const { return m_rareInheritedData->textFillColor; }
     const Color& textStrokeColor() const { return m_rareInheritedData->textStrokeColor; }
+    const Color& caretColor() const { return m_rareInheritedData->caretColor; }
     const Color& visitedLinkColor() const;
     const Color& visitedLinkBackgroundColor() const { return m_rareNonInheritedData->visitedLinkBackgroundColor; }
     const Color& visitedLinkBorderLeftColor() const { return m_rareNonInheritedData->visitedLinkBorderLeftColor; }
@@ -1728,6 +1731,7 @@
     const Color& visitedLinkTextEmphasisColor() const { return m_rareInheritedData->visitedLinkTextEmphasisColor; }
     const Color& visitedLinkTextFillColor() const { return m_rareInheritedData->visitedLinkTextFillColor; }
     const Color& visitedLinkTextStrokeColor() const { return m_rareInheritedData->visitedLinkTextStrokeColor; }
+    const Color& visitedLinkCaretColor() const { return m_rareInheritedData->visitedLinkCaretColor; }
 
     const Color& stopColor() const { return svgStyle().stopColor(); }
     const Color& floodColor() const { return svgStyle().floodColor(); }

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (220705 => 220706)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2017-08-14 17:29:34 UTC (rev 220706)
@@ -38,7 +38,7 @@
     void* styleImage;
     Color firstColor;
     float firstFloat;
-    Color colors[7];
+    Color colors[9];
     void* ownPtrs[1];
     AtomicString atomicStrings[5];
     void* refPtrs[2];
@@ -160,6 +160,8 @@
     , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor)
     , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
     , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
+    , caretColor(o.caretColor)
+    , visitedLinkCaretColor(o.visitedLinkCaretColor)
     , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
     , cursorData(o.cursorData)
     , indent(o.indent)
@@ -261,6 +263,8 @@
         && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor
         && visitedLinkTextFillColor == o.visitedLinkTextFillColor
         && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
+        && caretColor == o.caretColor
+        && visitedLinkCaretColor == o.visitedLinkCaretColor
 #if ENABLE(TOUCH_EVENTS)
         && tapHighlightColor == o.tapHighlightColor
 #endif

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (220705 => 220706)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2017-08-14 17:25:18 UTC (rev 220705)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2017-08-14 17:29:34 UTC (rev 220706)
@@ -66,8 +66,11 @@
     
     Color visitedLinkTextStrokeColor;
     Color visitedLinkTextFillColor;
-    Color visitedLinkTextEmphasisColor;    
+    Color visitedLinkTextEmphasisColor;
 
+    Color caretColor;
+    Color visitedLinkCaretColor;
+
     std::unique_ptr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
     
     RefPtr<CursorList> cursorData;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to