Changeset 220706 in webkit


Ignore:
Timestamp:
Aug 14, 2017 10:29:34 AM (7 years ago)
Author:
dbates@webkit.org
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.
Location:
trunk
Files:
14 added
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r220699 r220706  
     12017-08-14  Daniel Bates  <dabates@apple.com>
     2
     3        [css-ui] Implement caret-color support
     4        https://bugs.webkit.org/show_bug.cgi?id=166572
     5        <rdar://problem/33852589>
     6
     7        Reviewed by David Hyatt.
     8
     9        Add reference tests to ensure that we do not regress CSS property caret-color.
     10
     11        * TestExpectations: Unskip Web Platform Tests that now pass.
     12        * editing/deleting/maintain-style-after-delete-expected.txt: Updated expected result.
     13        * editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt: Ditto.
     14        * editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt: Ditto.
     15        * editing/pasteboard/onpaste-text-html-expected.txt: Ditto.
     16        * editing/pasteboard/preserve-caret-color-expected.txt: Added.
     17        * editing/pasteboard/preserve-caret-color.html: Added.
     18        * editing/pasteboard/preserve-underline-color-expected.txt:
     19        * fast/css/caret-color-auto-expected.html: Added.
     20        * fast/css/caret-color-auto.html: Added.
     21        * fast/css/caret-color-expected.html: Added.
     22        * fast/css/caret-color-fallback-to-color-expected.html: Added.
     23        * fast/css/caret-color-fallback-to-color.html: Added.
     24        * fast/css/caret-color-inherit-expected.html: Added.
     25        * fast/css/caret-color-inherit.html: Added.
     26        * fast/css/caret-color-span-inside-editable-parent-expected.html: Added.
     27        * fast/css/caret-color-span-inside-editable-parent.html: Added.
     28        * fast/css/caret-color.html: Added.
     29        * fast/events/before-input-events-prevent-drag-and-drop-expected.txt: Updated expected result.
     30        * fast/events/input-events-paste-rich-datatransfer-expected.txt: Ditto.
     31        * fast/events/ondrop-text-html-expected.txt: Ditto.
     32        * fast/history/visited-link-caret-color-expected.html: Added.
     33        * fast/history/visited-link-caret-color.html: Added.
     34        * platform/ios/TestExpectations: Skip the tests on iOS as iOS does not enable
     35        ENABLE(TEXT_CARET). UIKit renders the text insertion caret on iOS.
     36        * platform/mac/editing/style/5065910-expected.txt: Updated expected result.
     37        * platform/mac/editing/style/5084241-expected.png: Ditto.
     38        * platform/mac/editing/style/5084241-expected.txt: Ditto.
     39        * platform/ios-wk2/editing/style/5084241-expected.txt: Ditto.
     40
    1412017-08-14  Zan Dobersek  <zdobersek@igalia.com>
    242
  • trunk/LayoutTests/TestExpectations

    r220626 r220706  
    14331433webkit.org/b/175288 imported/w3c/web-platform-tests/css/css-ui-3/outline-019.html [ ImageOnlyFailure ]
    14341434webkit.org/b/175290 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-005.html [ ImageOnlyFailure ]
    1435 
    1436 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-001.html [ Failure ]
    1437 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-002.html [ Failure ]
    1438 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-003.html [ Failure ]
    1439 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-004.html [ Failure ]
    1440 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-005.html [ Failure ]
    1441 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-006.html [ Failure ]
    1442 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-007.html [ Failure ]
    1443 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-008.html [ Failure ]
    1444 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-009.html [ Failure ]
    1445 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-010.html [ Failure ]
    1446 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-011.html [ Failure ]
    1447 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-012.html [ Failure ]
    1448 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-013.html [ Failure ]
    1449 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-014.html [ Failure ]
    1450 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-015.html [ Failure ]
    1451 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-016.html [ Failure ]
    1452 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-017.html [ Failure ]
    1453 webkit.org/b/166572 imported/w3c/web-platform-tests/css/css-ui-3/caret-color-021.html [ Failure ]
  • trunk/LayoutTests/editing/deleting/maintain-style-after-delete-expected.txt

    r155425 r220706  
    55| <font>
    66|   color="#0000ff"
    7 |   "O<#selection-caret>"
     7|   <span>
     8|     style="caret-color: rgb(0, 0, 255);"
     9|     "O<#selection-caret>"
    810
    911Deleting the blue colored text and the preceding space and then inserting 'W'. 'W' should be not be in blue color in the following markup:
  • trunk/LayoutTests/editing/inserting/insert-paragraph-with-font-and-background-color-expected.txt

    r151612 r220706  
    1616|     color="#1b6f11"
    1717|     <span>
    18 |       style="background-color: rgb(191, 35, 28);"
     18|       style="caret-color: rgb(27, 111, 17); background-color: rgb(191, 35, 28);"
    1919|       "Bar<#selection-caret>"
    2020|       <br>
  • trunk/LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt

    r126656 r220706  
    44You should not see any borders:
    55| <span>
    6 |   style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 0);"
     6|   style="caret-color: rgb(0, 0, 255); color: rgb(0, 0, 255); background-color: rgb(255, 255, 0);"
    77|   "Hello<#selection-caret>"
  • trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt

    r207797 r220706  
    11CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the clipboard during an onpaste event.
    2 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>
     2CONSOLE 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>
    33This test verifies that we can get text/html from the clipboard during an onpaste event. This test requires DRT.
    44Paste content in this div.This test verifies that we can get text/html from the clipboard during an onpaste event. 
  • trunk/LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt

    r126656 r220706  
    11This 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.
    22| <span>
    3 |   style="color: rgb(255, 0, 0); text-decoration: underline;"
     3|   style="caret-color: rgb(255, 0, 0); color: rgb(255, 0, 0); text-decoration: underline;"
    44|   "This should be underlined.<#selection-caret>"
    55| <br>
  • trunk/LayoutTests/fast/events/before-input-events-prevent-drag-and-drop-expected.txt

    r208014 r220706  
    88HTML content:
    99
    10 <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>
     10<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>
  • trunk/LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt

    r207841 r220706  
    33destination after pasting (text/html):
    44| <b>
    5 |   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;"
     5|   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;"
    66|   "LayoutTests"
    77|   <i>
  • trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt

    r207797 r220706  
    11CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the drag object during an ondrop event.
    2 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>
     2CONSOLE 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>
    33This test verifies that we can get text/html from the drag object during an ondrop event. This test requires DRT.
    44PASS
  • trunk/LayoutTests/platform/ios-wk2/editing/style/5084241-expected.txt

    r220443 r220706  
    99          text run at (0,20) width 64: "text color."
    1010      RenderBlock {DIV} at (0,56) size 784x20
    11         RenderInline {FONT} at (0,0) size 151x19 [color=#FF0000]
    12           RenderText {#text} at (0,0) size 151x19
    13             text run at (0,0) width 151: "This text should be red."
    14         RenderInline {FONT} at (0,0) size 159x19 [color=#0000FF]
    15           RenderText {#text} at (150,0) size 159x19
    16             text run at (150,0) width 159: "This text should be blue."
     11        RenderInline {SPAN} at (0,0) size 309x19
     12          RenderInline {FONT} at (0,0) size 151x19 [color=#FF0000]
     13            RenderText {#text} at (0,0) size 151x19
     14              text run at (0,0) width 151: "This text should be red."
     15          RenderInline {FONT} at (0,0) size 159x19 [color=#0000FF]
     16            RenderText {#text} at (150,0) size 159x19
     17              text run at (150,0) width 159: "This text should be blue."
    1718      RenderBlock (anonymous) at (0,76) size 784x0
    18 caret: position 25 of child 0 {#text} of child 1 {FONT} of child 2 {DIV} of body
     19caret: position 25 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 2 {DIV} of body
  • trunk/LayoutTests/platform/ios/TestExpectations

    r220530 r220706  
    408408svg/animations/animations-paused-when-inserted-in-hidden-document.html [ Skip ]
    409409svg/animations/animations-paused-when-inserted-in-hidden-document2.html [ Skip ]
     410
     411# iOS does not enable ENABLE(TEXT_CARET). UIKit renders the text insertion caret.
     412fast/css/caret-color-fallback-to-color.html [ Skip ]
     413fast/css/caret-color-inherit.html [ Skip ]
     414fast/css/caret-color-span-inside-editable-parent.html [ Skip ]
     415fast/css/caret-color.html [ Skip ]
     416fast/history/visited-link-caret-color.html [ Skip ]
    410417
    411418###
  • trunk/LayoutTests/platform/mac/editing/style/5065910-expected.txt

    r177774 r220706  
    1313              text run at (0,0) width 151: "This text should be red."
    1414        RenderBlock {DIV} at (0,18) size 784x18
    15           RenderInline {FONT} at (0,0) size 127x18 [color=#0000FF]
    16             RenderText {#text} at (0,0) size 127x18
    17               text run at (0,0) width 127: "This text should be "
    18           RenderInline {FONT} at (0,0) size 240x18 [color=#008000]
    19             RenderText {#text} at (126,0) size 240x18
    20               text run at (126,0) width 240: "a combination of green and blue, not "
    21           RenderInline {FONT} at (0,0) size 25x18 [color=#0000FF]
    22             RenderText {#text} at (365,0) size 25x18
    23               text run at (365,0) width 25: "red."
    24 caret: position 37 of child 0 {#text} of child 1 {FONT} of child 1 {DIV} of child 2 {DIV} of body
     15          RenderInline {SPAN} at (0,0) size 390x18
     16            RenderInline {FONT} at (0,0) size 127x18 [color=#0000FF]
     17              RenderText {#text} at (0,0) size 127x18
     18                text run at (0,0) width 127: "This text should be "
     19            RenderInline {FONT} at (0,0) size 240x18 [color=#008000]
     20              RenderText {#text} at (126,0) size 240x18
     21                text run at (126,0) width 240: "a combination of green and blue, not "
     22            RenderInline {FONT} at (0,0) size 25x18 [color=#0000FF]
     23              RenderText {#text} at (365,0) size 25x18
     24                text run at (365,0) width 25: "red."
     25caret: position 37 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 1 {DIV} of child 2 {DIV} of body
  • trunk/LayoutTests/platform/mac/editing/style/5084241-expected.txt

    r177774 r220706  
    99          text run at (0,18) width 64: "text color."
    1010      RenderBlock {DIV} at (0,52) size 784x18
    11         RenderInline {FONT} at (0,0) size 151x18 [color=#FF0000]
    12           RenderText {#text} at (0,0) size 151x18
    13             text run at (0,0) width 151: "This text should be red."
    14         RenderInline {FONT} at (0,0) size 159x18 [color=#0000FF]
    15           RenderText {#text} at (150,0) size 159x18
    16             text run at (150,0) width 159: "This text should be blue."
    17 caret: position 25 of child 0 {#text} of child 1 {FONT} of child 2 {DIV} of body
     11        RenderInline {SPAN} at (0,0) size 309x18
     12          RenderInline {FONT} at (0,0) size 151x18 [color=#FF0000]
     13            RenderText {#text} at (0,0) size 151x18
     14              text run at (0,0) width 151: "This text should be red."
     15          RenderInline {FONT} at (0,0) size 159x18 [color=#0000FF]
     16            RenderText {#text} at (150,0) size 159x18
     17              text run at (150,0) width 159: "This text should be blue."
     18caret: position 25 of child 0 {#text} of child 1 {FONT} of child 0 {SPAN} of child 2 {DIV} of body
  • trunk/Source/WebCore/ChangeLog

    r220699 r220706  
     12017-08-14  Daniel Bates  <dabates@apple.com>
     2
     3        [css-ui] Implement caret-color support
     4        https://bugs.webkit.org/show_bug.cgi?id=166572
     5        <rdar://problem/33852589>
     6
     7        Reviewed by David Hyatt.
     8
     9        Add support for the CSS property caret-color as per <https://www.w3.org/TR/css-ui-3/#caret-color> (02 March 2017).
     10        The property caret-color specifies the color of the text insertion caret in an editable element,
     11        say an HTML textarea element.
     12
     13        Unlike other CSS color properties caret-color can have value "auto" and this is its initial
     14        value. Internally we treat value "auto" as an invalid caret color to simplify the code.
     15
     16        Tests: editing/pasteboard/preserve-caret-color.html
     17               fast/css/caret-color-auto.html
     18               fast/css/caret-color-fallback-to-color.html
     19               fast/css/caret-color-inherit.html
     20               fast/css/caret-color-span-inside-editable-parent.html
     21               fast/css/caret-color.html
     22               fast/history/visited-link-caret-color.html
     23
     24        * css/CSSComputedStyleDeclaration.cpp:
     25        (WebCore::ComputedStyleExtractor::propertyValue):
     26        * css/CSSProperties.json: Add property caret-color. We represent the initial  "auto" Also, fix up
     27        wording in a comment while I am here.
     28        * css/StyleResolver.cpp:
     29        (WebCore::isValidVisitedLinkProperty): Add caret-color to the list of properties that can be
     30        applied to visited hyperlinks.
     31        * css/parser/CSSParserFastPaths.cpp:
     32        (WebCore::parseCaretColor): Added.
     33        (WebCore::CSSParserFastPaths::maybeParseValue): Unlike other CSS color properties caret-color
     34        can be defined to be "auto". We explicitly check if the property is caret-color and use
     35        parseCaretColor() to parse its value.
     36        * css/parser/CSSPropertyParser.cpp:
     37        (WebCore::consumeCaretColor): Added.
     38        (WebCore::CSSPropertyParser::parseSingleValue): Similar to the change to CSSParserFastPaths::maybeParseValue()
     39        use a dedicated code path to parse caret-color.
     40        * editing/EditingStyle.cpp: Preserve caret-color during editing operations.
     41        * editing/FrameSelection.cpp:
     42        (WebCore::CaretBase::paintCaret const): Modified code to query property caret-color instead of
     43        color for the color of the text insertion caret. Always honor the caret-color of the editable
     44        element if it is valid color. Note that "caret-color: auto" is treated as an invalid color
     45        internally. A caret-color can have an invalid color if its inherits from the CSS color property
     46        with an invalid color. If caret-color is a valid color then we take it to be the color of the
     47        text insertion caret. Otherwise, we do what we do today and use a heuristic to determine the
     48        color of the text-insertion caret.
     49        (WebCore::disappearsIntoBackground): Deleted; moved logic into CaretBase::paintCaret().
     50        * page/animation/CSSPropertyAnimation.cpp:
     51        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap): Add property wrapper
     52        to support animating caret-color.
     53        * rendering/style/RenderStyle.cpp:
     54        (WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline const): Modified to consider
     55        changes to caret color.
     56        (WebCore::RenderStyle::colorIncludingFallback const): Modified to compute the appropriate
     57        color for property caret-color with respect to an unvisited or visited link.
     58        * rendering/style/RenderStyle.h:
     59        (WebCore::RenderStyle::setCaretColor): Added.
     60        (WebCore::RenderStyle::setVisitedLinkCaretColor): Added.
     61        (WebCore::RenderStyle::caretColor const): Added.
     62        (WebCore::RenderStyle::visitedLinkCaretColor const): Added.
     63        * rendering/style/StyleRareInheritedData.cpp:
     64        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Modified to consider caret color.
     65        (WebCore::StyleRareInheritedData::operator== const): Ditto.
     66        * rendering/style/StyleRareInheritedData.h:
     67
    1682017-08-14  Zan Dobersek  <zdobersek@igalia.com>
    269
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r220354 r220706  
    138138    CSSPropertyBoxSizing,
    139139    CSSPropertyCaptionSide,
     140    CSSPropertyCaretColor,
    140141    CSSPropertyClear,
    141142    CSSPropertyClip,
     
    28922893        case CSSPropertyCaptionSide:
    28932894            return cssValuePool.createValue(style->captionSide());
     2895        case CSSPropertyCaretColor:
     2896            return m_allowVisitedStyle ? cssValuePool.createColorValue(style->visitedDependentColor(CSSPropertyCaretColor)) : currentColorOrValidColor(style, style->caretColor());
    28942897        case CSSPropertyClear:
    28952898            return cssValuePool.createValue(style->clear());
  • trunk/Source/WebCore/css/CSSProperties.json

    r217272 r220706  
    9090        "",
    9191        "* no-default-color:",
    92         "Should only with used with \"VisitedLinkColorSupport\". It indicates that for",
     92        "Should only be used with \"VisitedLinkColorSupport\". It indicates that when",
    9393        "setting the inherited value, it will not fallback to using the parent's",
    9494        "\"color\" property if the inherited color is invalid.",
     
    171171    ],
    172172    "properties": {
     173        "caret-color" : {
     174            "inherited": true,
     175            "codegen-properties": {
     176                "initial": "invalidColor",
     177                "visited-link-color-support": true
     178            },
     179            "specification": {
     180                "category": "css-ui",
     181                "url": "https://drafts.csswg.org/css-ui-3/#propdef-caret-color"
     182            }
     183        },
    173184        "color": {
    174185            "inherited": true,
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r220207 r220706  
    14561456    case CSSPropertyBorderTopColor:
    14571457    case CSSPropertyBorderBottomColor:
     1458    case CSSPropertyCaretColor:
    14581459    case CSSPropertyColor:
    14591460    case CSSPropertyOutlineColor:
  • trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp

    r220382 r220706  
    13181318}
    13191319
     1320static RefPtr<CSSValue> parseCaretColor(const String& string, CSSParserMode parserMode)
     1321{
     1322    ASSERT(!string.isEmpty());
     1323    CSSValueID valueID = cssValueKeywordID(string);
     1324    if (valueID == CSSValueAuto)
     1325        return CSSValuePool::singleton().createIdentifierValue(valueID);
     1326    return CSSParserFastPaths::parseColor(string, parserMode);
     1327}
     1328
    13201329RefPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
    13211330{
     
    13231332    if (result)
    13241333        return result;
     1334    if (propertyID == CSSPropertyCaretColor)
     1335        return parseCaretColor(string, parserMode);
    13251336    if (isColorPropertyID(propertyID))
    13261337        return parseColor(string, parserMode);
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r219642 r220706  
    18101810        return shape;
    18111811    return nullptr;
     1812}
     1813
     1814static RefPtr<CSSPrimitiveValue> consumeCaretColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1815{
     1816    if (range.peek().id() == CSSValueAuto)
     1817        return consumeIdent(range);
     1818    return consumeColor(range, cssParserMode);
    18121819}
    18131820
     
    40214028    case CSSPropertyColumnRuleColor:
    40224029        return consumeColor(m_range, m_context.mode);
     4030    case CSSPropertyCaretColor:
     4031        return consumeCaretColor(m_range, m_context.mode);
    40234032    case CSSPropertyColor:
    40244033    case CSSPropertyBackgroundColor:
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r220531 r220706  
    5959// e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
    6060static const CSSPropertyID editingProperties[] = {
     61    CSSPropertyCaretColor,
    6162    CSSPropertyColor,
    6263    CSSPropertyFontFamily,
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r218998 r220706  
    17141714}
    17151715
    1716 #if ENABLE(TEXT_CARET)
    1717 static inline bool disappearsIntoBackground(const Color& foreground, const Color& background)
    1718 {
    1719     return background.blend(foreground) == background;
    1720 }
    1721 #endif
    1722 
    17231716void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const
    17241717{
     
    17371730    Color caretColor = Color::black;
    17381731    Element* element = is<Element>(*node) ? downcast<Element>(node) : node->parentElement();
    1739     Element* rootEditableElement = node->rootEditableElement();
    1740 
    17411732    if (element && element->renderer()) {
    1742         bool setToRootEditableElement = false;
    1743         if (rootEditableElement && rootEditableElement->renderer()) {
    1744             const auto& rootEditableStyle = rootEditableElement->renderer()->style();
    1745             const auto& elementStyle = element->renderer()->style();
    1746             auto rootEditableBGColor = rootEditableStyle.visitedDependentColor(CSSPropertyBackgroundColor);
    1747             auto elementBGColor = elementStyle.visitedDependentColor(CSSPropertyBackgroundColor);
    1748             if (disappearsIntoBackground(elementBGColor, rootEditableBGColor)) {
    1749                 caretColor = rootEditableStyle.visitedDependentColor(CSSPropertyColor);
    1750                 setToRootEditableElement = true;
     1733        auto computeCaretColor = [] (const RenderStyle& elementStyle, const RenderStyle* rootEditableStyle) {
     1734            // CSS value "auto" is treated as an invalid color.
     1735            if (!elementStyle.caretColor().isValid() && rootEditableStyle) {
     1736                auto rootEditableBackgroundColor = rootEditableStyle->visitedDependentColor(CSSPropertyBackgroundColor);
     1737                auto elementBackgroundColor = elementStyle.visitedDependentColor(CSSPropertyBackgroundColor);
     1738                auto disappearsIntoBackground = rootEditableBackgroundColor.blend(elementBackgroundColor) == rootEditableBackgroundColor;
     1739                if (disappearsIntoBackground)
     1740                    return rootEditableStyle->visitedDependentColor(CSSPropertyCaretColor);
    17511741            }
    1752         }
    1753         if (!setToRootEditableElement)
    1754             caretColor = element->renderer()->style().visitedDependentColor(CSSPropertyColor);
     1742            return elementStyle.visitedDependentColor(CSSPropertyCaretColor);
     1743        };
     1744        auto* rootEditableElement = node->rootEditableElement();
     1745        auto* rootEditableStyle = rootEditableElement && rootEditableElement->renderer() ? &rootEditableElement->renderer()->style() : nullptr;
     1746        caretColor = computeCaretColor(element->renderer()->style(), rootEditableStyle);
    17551747    }
    17561748
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r220503 r220706  
    14941494        new LengthPropertyWrapper<Length>(CSSPropertyPaddingTop, &RenderStyle::paddingTop, &RenderStyle::setPaddingTop),
    14951495        new LengthPropertyWrapper<Length>(CSSPropertyPaddingBottom, &RenderStyle::paddingBottom, &RenderStyle::setPaddingBottom),
     1496
     1497        new PropertyWrapperVisitedAffectedColor(CSSPropertyCaretColor, &RenderStyle::caretColor, &RenderStyle::setCaretColor, &RenderStyle::visitedLinkCaretColor, &RenderStyle::setVisitedLinkCaretColor),
     1498
    14961499        new PropertyWrapperVisitedAffectedColor(CSSPropertyColor, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::visitedLinkColor, &RenderStyle::setVisitedLinkColor),
    14971500
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r220383 r220706  
    903903        || m_rareInheritedData->textEmphasisColor != other.m_rareInheritedData->textEmphasisColor
    904904        || m_rareInheritedData->textEmphasisFill != other.m_rareInheritedData->textEmphasisFill
    905         || m_rareInheritedData->strokeColor != other.m_rareInheritedData->strokeColor)
     905        || m_rareInheritedData->strokeColor != other.m_rareInheritedData->strokeColor
     906        || m_rareInheritedData->caretColor != other.m_rareInheritedData->caretColor)
    906907        return true;
    907908
     
    17501751        borderStyle = borderBottomStyle();
    17511752        break;
     1753    case CSSPropertyCaretColor:
     1754        result = visitedLink ? visitedLinkCaretColor() : caretColor();
     1755        break;
    17521756    case CSSPropertyColor:
    17531757        result = visitedLink ? visitedLinkColor() : color();
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r219755 r220706  
    10371037    void setTextStrokeWidth(float w) { SET_VAR(m_rareInheritedData, textStrokeWidth, w); }
    10381038    void setTextFillColor(const Color& c) { SET_VAR(m_rareInheritedData, textFillColor, c); }
     1039    void setCaretColor(const Color& c) { SET_VAR(m_rareInheritedData, caretColor, c); }
    10391040    void setOpacity(float f) { float v = clampTo<float>(f, 0, 1); SET_VAR(m_rareNonInheritedData, opacity, v); }
    10401041    void setAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, appearance, a); }
     
    16961697    void setVisitedLinkTextFillColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkTextFillColor, v); }
    16971698    void setVisitedLinkTextStrokeColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkTextStrokeColor, v); }
     1699    void setVisitedLinkCaretColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkCaretColor, v); }
    16981700
    16991701    void inheritUnicodeBidiFrom(const RenderStyle* parent) { m_nonInheritedFlags.setUnicodeBidi(parent->m_nonInheritedFlags.unicodeBidi()); }
     
    17161718    const Color& textFillColor() const { return m_rareInheritedData->textFillColor; }
    17171719    const Color& textStrokeColor() const { return m_rareInheritedData->textStrokeColor; }
     1720    const Color& caretColor() const { return m_rareInheritedData->caretColor; }
    17181721    const Color& visitedLinkColor() const;
    17191722    const Color& visitedLinkBackgroundColor() const { return m_rareNonInheritedData->visitedLinkBackgroundColor; }
     
    17291732    const Color& visitedLinkTextFillColor() const { return m_rareInheritedData->visitedLinkTextFillColor; }
    17301733    const Color& visitedLinkTextStrokeColor() const { return m_rareInheritedData->visitedLinkTextStrokeColor; }
     1734    const Color& visitedLinkCaretColor() const { return m_rareInheritedData->visitedLinkCaretColor; }
    17311735
    17321736    const Color& stopColor() const { return svgStyle().stopColor(); }
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r219755 r220706  
    3939    Color firstColor;
    4040    float firstFloat;
    41     Color colors[7];
     41    Color colors[9];
    4242    void* ownPtrs[1];
    4343    AtomicString atomicStrings[5];
     
    161161    , visitedLinkTextFillColor(o.visitedLinkTextFillColor)
    162162    , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor)
     163    , caretColor(o.caretColor)
     164    , visitedLinkCaretColor(o.visitedLinkCaretColor)
    163165    , textShadow(o.textShadow ? std::make_unique<ShadowData>(*o.textShadow) : nullptr)
    164166    , cursorData(o.cursorData)
     
    262264        && visitedLinkTextFillColor == o.visitedLinkTextFillColor
    263265        && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor
     266        && caretColor == o.caretColor
     267        && visitedLinkCaretColor == o.visitedLinkCaretColor
    264268#if ENABLE(TOUCH_EVENTS)
    265269        && tapHighlightColor == o.tapHighlightColor
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r215261 r220706  
    6767    Color visitedLinkTextStrokeColor;
    6868    Color visitedLinkTextFillColor;
    69     Color visitedLinkTextEmphasisColor;   
     69    Color visitedLinkTextEmphasisColor;
     70
     71    Color caretColor;
     72    Color visitedLinkCaretColor;
    7073
    7174    std::unique_ptr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
Note: See TracChangeset for help on using the changeset viewer.