Title: [231159] trunk
Revision
231159
Author
[email protected]
Date
2018-04-30 10:51:51 -0700 (Mon, 30 Apr 2018)

Log Message

Make color-filter affect caret-color
https://bugs.webkit.org/show_bug.cgi?id=185129
rdar://problem/39829066

Reviewed by Tim Horton.
Source/WebCore:

Transform the colors used to compare the caret color with the background through
color-filter (since we want contrasting colors after filters are applied), and
transform caret-color itself.

Test: css3/color-filters/color-filter-caret-color.html

* editing/FrameSelection.cpp:
(WebCore::CaretBase::paintCaret const):

LayoutTests:

* css3/color-filters/color-filter-caret-color-expected.html: Added.
* css3/color-filters/color-filter-caret-color.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231158 => 231159)


--- trunk/LayoutTests/ChangeLog	2018-04-30 17:30:26 UTC (rev 231158)
+++ trunk/LayoutTests/ChangeLog	2018-04-30 17:51:51 UTC (rev 231159)
@@ -1,3 +1,14 @@
+2018-04-30  Simon Fraser  <[email protected]>
+
+        Make color-filter affect caret-color
+        https://bugs.webkit.org/show_bug.cgi?id=185129
+        rdar://problem/39829066
+
+        Reviewed by Tim Horton.
+
+        * css3/color-filters/color-filter-caret-color-expected.html: Added.
+        * css3/color-filters/color-filter-caret-color.html: Added.
+
 2018-04-28  Simon Fraser  <[email protected]>
 
         Fix color-filter to apply to SVG colors

Added: trunk/LayoutTests/css3/color-filters/color-filter-caret-color-expected.html (0 => 231159)


--- trunk/LayoutTests/css3/color-filters/color-filter-caret-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css3/color-filters/color-filter-caret-color-expected.html	2018-04-30 17:51:51 UTC (rev 231159)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>CSS Test: color-filter reference</title>
+        <link rel="author" title="Apple" href=""
+
+        <style>
+        #test-container {
+            height: 50px;
+            width: 50px;
+            overflow: hidden;
+            border: 1px solid black;
+        }
+
+        #test {
+            background-color: white;
+            transform-origin: left top;
+            transform: scale(50, 50);
+            font-size: 10px; /* Needed for the caret to render in Firefox. */
+            caret-color: green;
+        }
+
+        </style>
+    </head>
+    <body>
+        <p>The caret should show as a green flashing square below.</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/css3/color-filters/color-filter-caret-color.html (0 => 231159)


--- trunk/LayoutTests/css3/color-filters/color-filter-caret-color.html	                        (rev 0)
+++ trunk/LayoutTests/css3/color-filters/color-filter-caret-color.html	2018-04-30 17:51:51 UTC (rev 231159)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>CSS Test: color-filter affects caret-color</title>
+        <link rel="author" title="Apple" href=""
+        <link rel="match" href=""
+
+        <meta name="assert" content="color-filter affects caret-color">
+        <style>
+        #test-container {
+            height: 50px;
+            width: 50px;
+            overflow: hidden;
+            border: 1px solid black;
+        }
+
+        #test {
+            color-filter: invert();
+            background-color: white;
+            transform-origin: left top;
+            transform: scale(50, 50);
+            font-size: 10px; /* Needed for the caret to render in Firefox. */
+            caret-color: rgb(255, 128, 255);
+        }
+
+        </style>
+    </head>
+    <body>
+        <p>The caret should show as a green flashing square below.</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>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (231158 => 231159)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-04-30 17:30:26 UTC (rev 231158)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-04-30 17:51:51 UTC (rev 231159)
@@ -1045,6 +1045,7 @@
 fast/css/caret-color-span-inside-editable-parent.html [ Skip ]
 fast/css/caret-color.html [ Skip ]
 fast/history/visited-link-caret-color.html [ Skip ]
+css3/color-filters/color-filter-caret-color [ Skip ]
 
 # Run webrtc tests on iOS 11
 imported/w3c/web-platform-tests/webrtc [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (231158 => 231159)


--- trunk/Source/WebCore/ChangeLog	2018-04-30 17:30:26 UTC (rev 231158)
+++ trunk/Source/WebCore/ChangeLog	2018-04-30 17:51:51 UTC (rev 231159)
@@ -1,3 +1,20 @@
+2018-04-30  Simon Fraser  <[email protected]>
+
+        Make color-filter affect caret-color
+        https://bugs.webkit.org/show_bug.cgi?id=185129
+        rdar://problem/39829066
+
+        Reviewed by Tim Horton.
+        
+        Transform the colors used to compare the caret color with the background through
+        color-filter (since we want contrasting colors after filters are applied), and
+        transform caret-color itself.
+
+        Test: css3/color-filters/color-filter-caret-color.html
+
+        * editing/FrameSelection.cpp:
+        (WebCore::CaretBase::paintCaret const):
+
 2018-04-30  Michael Catanzaro  <[email protected]>
 
         [GTK] Webkit should spoof as Safari on a Mac when on Chase.com

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (231158 => 231159)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2018-04-30 17:30:26 UTC (rev 231158)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2018-04-30 17:51:51 UTC (rev 231159)
@@ -1754,13 +1754,13 @@
         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 rootEditableBackgroundColor = rootEditableStyle->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
+                auto elementBackgroundColor = elementStyle.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
                 auto disappearsIntoBackground = rootEditableBackgroundColor.blend(elementBackgroundColor) == rootEditableBackgroundColor;
                 if (disappearsIntoBackground)
-                    return rootEditableStyle->visitedDependentColor(CSSPropertyCaretColor);
+                    return rootEditableStyle->visitedDependentColorWithColorFilter(CSSPropertyCaretColor);
             }
-            return elementStyle.visitedDependentColor(CSSPropertyCaretColor);
+            return elementStyle.visitedDependentColorWithColorFilter(CSSPropertyCaretColor);
         };
         auto* rootEditableElement = node->rootEditableElement();
         auto* rootEditableStyle = rootEditableElement && rootEditableElement->renderer() ? &rootEditableElement->renderer()->style() : nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to