Title: [229147] trunk
Revision
229147
Author
[email protected]
Date
2018-03-01 14:35:38 -0800 (Thu, 01 Mar 2018)

Log Message

CSS ::selection stroke-color and stroke-width are not applied to selected text in text fields
and ::selection:window-inactive stroke-color and stroke-width are never applied
https://bugs.webkit.org/show_bug.cgi?id=183178

Reviewed by David Hyatt.

Source/WebCore:

This change fixes the following two issues:
    1. Properties stroke-color and stroke-width are not applied to the ::selection pseudo-
       element of text fields.
    2. Properties stroke-color and stroke-width are never applied to ::selection:window-inactive
       pseudo elements.

Currently when computing the paint styles for selected text we query the cached styles for
the ::selection pseudo element on the renderer. Text fields are implemented using a User Agent
shadow DOM. With regards to issue (1) the renderer queried was the inner most renderer for
the text in the text field. But it should have been the shadow host renderer (i.e. the renderer
for the <input>). With regards to issue (2) we cannot retrieve cached styles for the
::selection pseudo element because it can be effected by a pseudo class, :window-inactive,
which matches when the page is deactivated (i.e. the window is in the background as the user
made another window the frontmost window). Both of these issues are fixed by making use
of RenderElement::selectionPseudoStyle().

Tests: fast/selectors/selection-window-inactive-stroke-color.html
       fast/selectors/selection-window-inactive-text-shadow.html
       fast/selectors/text-field-selection-stroke-color.html
       fast/selectors/text-field-selection-text-shadow.html
       fast/selectors/text-field-selection-window-inactive-stroke-color.html
       fast/selectors/text-field-selection-window-inactive-text-shadow.html

* rendering/RenderText.h:
(WebCore::RenderText::selectionPseudoStyle const): Add a convenience function that turns
around and calls the function of the same name on its parent.
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextSelectionPaintStyle): Modified to use RenderText::selectionPseudoStyle()
instead of directly querying for the cached styles for the ::selection pseudo element.

LayoutTests:

Add tests to ensure that we paint ::selection stroke-color and stroke-width for selected text
in text fields. Add tests to ensure that we apply ::selection:window-inactive stroke-color
and stroke-width to selected text when the page is deactivated.

* fast/selectors/selection-window-inactive-stroke-color-expected.html: Added.
* fast/selectors/selection-window-inactive-stroke-color.html: Added.
* fast/selectors/selection-window-inactive-text-shadow-expected.html: Added.
* fast/selectors/selection-window-inactive-text-shadow.html: Added.
* fast/selectors/text-field-selection-stroke-color-expected.html: Added.
* fast/selectors/text-field-selection-stroke-color.html: Added.
* fast/selectors/text-field-selection-text-shadow-expected.html: Added.
* fast/selectors/text-field-selection-text-shadow.html: Added.
* fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html: Added.
* fast/selectors/text-field-selection-window-inactive-stroke-color.html: Added.
* fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html: Added.
* fast/selectors/text-field-selection-window-inactive-text-shadow.html: Added.
* platform/gtk/TestExpectations: Skip the ::selection:window-inactive tests until we fix
<https://bugs.webkit.org/show_bug.cgi?id=183143>.
* platform/ios/TestExpectations: Mark the tests as won't fix since UIKit draws selection on iOS.
* platform/win/TestExpectations: Mark tests as image failures an associated with <https://bugs.webkit.org/show_bug.cgi?id=117322>.
Windows does not seem to be updating selectors when the window is deactivated or window deactivation,
testRunner.setWindowIsKey() is broken.
* platform/wpe/TestExpectations: Skip the ::selection:window-inactive tests until we fix
<https://bugs.webkit.org/show_bug.cgi?id=183144>.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229146 => 229147)


--- trunk/LayoutTests/ChangeLog	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/LayoutTests/ChangeLog	2018-03-01 22:35:38 UTC (rev 229147)
@@ -1,3 +1,36 @@
+2018-03-01  Daniel Bates  <[email protected]>
+
+        CSS ::selection stroke-color and stroke-width are not applied to selected text in text fields
+        and ::selection:window-inactive stroke-color and stroke-width are never applied
+        https://bugs.webkit.org/show_bug.cgi?id=183178
+
+        Reviewed by David Hyatt.
+
+        Add tests to ensure that we paint ::selection stroke-color and stroke-width for selected text
+        in text fields. Add tests to ensure that we apply ::selection:window-inactive stroke-color
+        and stroke-width to selected text when the page is deactivated.
+
+        * fast/selectors/selection-window-inactive-stroke-color-expected.html: Added.
+        * fast/selectors/selection-window-inactive-stroke-color.html: Added.
+        * fast/selectors/selection-window-inactive-text-shadow-expected.html: Added.
+        * fast/selectors/selection-window-inactive-text-shadow.html: Added.
+        * fast/selectors/text-field-selection-stroke-color-expected.html: Added.
+        * fast/selectors/text-field-selection-stroke-color.html: Added.
+        * fast/selectors/text-field-selection-text-shadow-expected.html: Added.
+        * fast/selectors/text-field-selection-text-shadow.html: Added.
+        * fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html: Added.
+        * fast/selectors/text-field-selection-window-inactive-stroke-color.html: Added.
+        * fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html: Added.
+        * fast/selectors/text-field-selection-window-inactive-text-shadow.html: Added.
+        * platform/gtk/TestExpectations: Skip the ::selection:window-inactive tests until we fix
+        <https://bugs.webkit.org/show_bug.cgi?id=183143>.
+        * platform/ios/TestExpectations: Mark the tests as won't fix since UIKit draws selection on iOS.
+        * platform/win/TestExpectations: Mark tests as image failures an associated with <https://bugs.webkit.org/show_bug.cgi?id=117322>.
+        Windows does not seem to be updating selectors when the window is deactivated or window deactivation,
+        testRunner.setWindowIsKey() is broken.
+        * platform/wpe/TestExpectations: Skip the ::selection:window-inactive tests until we fix
+        <https://bugs.webkit.org/show_bug.cgi?id=183144>.
+
 2018-03-01  Ross Kirsling  <[email protected]>
 
         [Win][DRT] Implement setSpatialNavigationEnabled.

Added: trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+span {
+    font-size: 3em;
+    stroke-color: rgba(63, 128, 33, 0.95);
+    stroke-width: 2px;
+}
+</style>
+<span>Any textual selection in this sentence should have a green stroke color when the window is inactive.</span>

Added: trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/selection-window-inactive-stroke-color.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<style>
+span { font-size: 3em; }
+::selection {
+    stroke-color: blue;
+    stroke-width: 2px;
+}
+::selection:window-inactive {
+    stroke-color: rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<span>Any textual selection in this sentence should have a green stroke color when the window is inactive.</span>
+<script>
+var span = document.querySelector("span");
+window.getSelection().setBaseAndExtent(span, 0, span, 1);
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Added: trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+span {
+    font-size: 3em;
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95);
+}
+</style>
+<span>Any textual selection in this sentence should have a green shadow when the window is inactive.</span>

Added: trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/selection-window-inactive-text-shadow.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<style>
+span { font-size: 3em; }
+::selection { text-shadow: 1px 1px 2px blue; }
+::selection:window-inactive {
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<span>Any textual selection in this sentence should have a green shadow when the window is inactive.</span>
+<script>
+var span = document.querySelector("span");
+window.getSelection().setBaseAndExtent(span, 0, span, 1);
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    stroke-color: rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+    stroke-width: 2px;
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green stroke color.</textarea>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-stroke-color.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    outline: none;
+}
+::selection {
+    stroke-color: rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+    stroke-width: 2px;
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green stroke color.</textarea>
+<script>
+var textarea = document.querySelector("textarea");
+textarea.select();
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green shadow.</textarea>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-text-shadow.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    outline: none;
+}
+::selection {
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green shadow.</textarea>
+<script>
+var textarea = document.querySelector("textarea");
+textarea.select();
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    stroke-color: rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+    stroke-width: 2px;
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green stroke color when the window is inactive.</textarea>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-stroke-color.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    outline: none;
+}
+::selection {
+    stroke-color: blue;
+    stroke-width: 2px;
+}
+::selection:window-inactive {
+    stroke-color: rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green stroke color when the window is inactive.</textarea>
+<script>
+var textarea = document.querySelector("textarea");
+textarea.select();
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green shadow when the window is inactive.</textarea>

Added: trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow.html (0 => 229147)


--- trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/text-field-selection-window-inactive-text-shadow.html	2018-03-01 22:35:38 UTC (rev 229147)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+textarea {
+    font-size: 3em;
+    height: 300px;
+    outline: none;
+}
+::selection { text-shadow: 1px 1px 2px blue; }
+::selection:window-inactive {
+    text-shadow: 1px 1px 2px rgba(63, 128, 33, 0.95); /* green; alpha < 1 so that we don't blend the background color with white. */
+}
+</style>
+<textarea>Any textual selection in this sentence should have a green shadow when the window is inactive.</textarea>
+<script>
+var textarea = document.querySelector("textarea");
+textarea.select();
+if (window.testRunner)
+    testRunner.setWindowIsKey(false);
+</script>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (229146 => 229147)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2018-03-01 22:35:38 UTC (rev 229147)
@@ -2389,6 +2389,14 @@
 webkit.org/b/183143 fast/selectors/querySelector-window-inactive.html
 webkit.org/b/183143 fast/selectors/selection-window-inactive.html
 webkit.org/b/183143 scrollbars/corner-resizer-window-inactive.html
+webkit.org/b/183143 fast/selectors/selection-window-inactive-stroke-color-expected.html
+webkit.org/b/183143 fast/selectors/selection-window-inactive-stroke-color.html
+webkit.org/b/183143 fast/selectors/selection-window-inactive-text-shadow-expected.html
+webkit.org/b/183143 fast/selectors/selection-window-inactive-text-shadow.html
+webkit.org/b/183143 fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html
+webkit.org/b/183143 fast/selectors/text-field-selection-window-inactive-stroke-color.html
+webkit.org/b/183143 fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html
+webkit.org/b/183143 fast/selectors/text-field-selection-window-inactive-text-shadow.html
 
 # Need support for internals.settings.setDeviceSupportsMouse
 fast/events/touch/scroll-without-mouse-lacks-mousemove-events.html

Modified: trunk/LayoutTests/platform/ios/TestExpectations (229146 => 229147)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-03-01 22:35:38 UTC (rev 229147)
@@ -105,6 +105,16 @@
 fast/writing-mode/english-bt-text-with-spelling-marker.html [ WontFix ]
 fast/writing-mode/english-rl-text-with-spelling-marker.html [ WontFix ]
 
+# UIKit draws selection on iOS
+fast/selectors/input-with-selection-pseudo-element.html [ WontFix ]
+fast/selectors/selection-window-inactive.html [ WontFix ]
+fast/selectors/selection-window-inactive-stroke-color.html  [ WontFix ]
+fast/selectors/selection-window-inactive-text-shadow.html  [ WontFix ]
+fast/selectors/text-field-selection-stroke-color.html  [ WontFix ]
+fast/selectors/text-field-selection-text-shadow.html  [ WontFix ]
+fast/selectors/text-field-selection-window-inactive-stroke-color.html  [ WontFix ]
+fast/selectors/text-field-selection-window-inactive-text-shadow.html  [ WontFix ]
+
 # Plugins are not supported on iOS
 plugins
 compositing/plugins
@@ -1940,9 +1950,7 @@
 fast/ruby/ruby-inline-style-not-updated.html [ Failure ]
 fast/ruby/ruby-justification.html [ ImageOnlyFailure ]
 fast/ruby/ruby-line-height.html [ Failure ]
-fast/selectors/input-with-selection-pseudo-element.html [ ImageOnlyFailure ]
 fast/selectors/read-only-read-write-input-basics.html [ Failure ]
-fast/selectors/selection-window-inactive.html [ ImageOnlyFailure ]
 fast/shapes/shape-outside-floats/shape-outside-floats-shape-margin-percent.html [ ImageOnlyFailure ]
 fast/spatial-navigation/snav-1st-stop.html [ Failure ]
 fast/spatial-navigation/snav-clipped-overflowed-content.html [ Failure ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (229146 => 229147)


--- trunk/LayoutTests/platform/win/TestExpectations	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/LayoutTests/platform/win/TestExpectations	2018-03-01 22:35:38 UTC (rev 229147)
@@ -2797,6 +2797,10 @@
 
 # Selectors don't seem to work properly
 webkit.org/b/117322 fast/selectors/selection-window-inactive.html [ ImageOnlyFailure ]
+webkit.org/b/117322 fast/selectors/selection-window-inactive-stroke-color.html  [ ImageOnlyFailure ]
+webkit.org/b/117322 fast/selectors/selection-window-inactive-text-shadow.html  [ ImageOnlyFailure ]
+webkit.org/b/117322 fast/selectors/text-field-selection-window-inactive-stroke-color.html  [ ImageOnlyFailure ]
+webkit.org/b/117322 fast/selectors/text-field-selection-window-inactive-text-shadow.html  [ ImageOnlyFailure ]
 webkit.org/b/140519 [ Debug ] fast/selectors/querySelector-id-with-multiple-elements-with-same-id.html [ Skip ]  # Crashing
 fast/selectors/querySelector-window-inactive.html [ Failure ]
 fast/selectors/read-only-read-write-input-basics.html [ Failure ]

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (229146 => 229147)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2018-03-01 22:35:38 UTC (rev 229147)
@@ -628,8 +628,19 @@
 fast/events/ime-composition-events-001.html
 
 # testRunner.setWindowIsKey() has no effect on the web process side in WebKit2
-# https://bugs.webkit.org/show_bug.cgi?id=81736 rdar://problem/11088268
-fast/events/blur-focus-window-should-blur-focus-element.html
+webkit.org/b/183144 fast/dom/Window/window-focus-self.html
+webkit.org/b/183144 fast/events/blur-focus-window-should-blur-focus-element.html
+webkit.org/b/183144 fast/selectors/querySelector-window-inactive.html
+webkit.org/b/183144 fast/selectors/selection-window-inactive.html
+webkit.org/b/183144 scrollbars/corner-resizer-window-inactive.html
+webkit.org/b/183144 fast/selectors/selection-window-inactive-stroke-color-expected.html
+webkit.org/b/183144 fast/selectors/selection-window-inactive-stroke-color.html
+webkit.org/b/183144 fast/selectors/selection-window-inactive-text-shadow-expected.html
+webkit.org/b/183144 fast/selectors/selection-window-inactive-text-shadow.html
+webkit.org/b/183144 fast/selectors/text-field-selection-window-inactive-stroke-color-expected.html
+webkit.org/b/183144 fast/selectors/text-field-selection-window-inactive-stroke-color.html
+webkit.org/b/183144 fast/selectors/text-field-selection-window-inactive-text-shadow-expected.html
+webkit.org/b/183144 fast/selectors/text-field-selection-window-inactive-text-shadow.html
 
 # eventSender.dragMode is unimplemented in WKTR
 # Mac: https://bugs.webkit.org/show_bug.cgi?id=68552
@@ -1160,9 +1171,3 @@
 
 webkit.org/b/181139 imported/w3c/web-platform-tests/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.https.html [ Pass Failure ]
 
-# testRunner.setWindowIsKey() has no effect on the web process side in WebKit2
-webkit.org/b/183144 fast/dom/Window/window-focus-self.html
-webkit.org/b/183144 fast/events/blur-focus-window-should-blur-focus-element.html
-webkit.org/b/183144 fast/selectors/querySelector-window-inactive.html
-webkit.org/b/183144 fast/selectors/selection-window-inactive.html
-webkit.org/b/183144 scrollbars/corner-resizer-window-inactive.html

Modified: trunk/Source/WebCore/ChangeLog (229146 => 229147)


--- trunk/Source/WebCore/ChangeLog	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/Source/WebCore/ChangeLog	2018-03-01 22:35:38 UTC (rev 229147)
@@ -1,3 +1,41 @@
+2018-03-01  Daniel Bates  <[email protected]>
+
+        CSS ::selection stroke-color and stroke-width are not applied to selected text in text fields
+        and ::selection:window-inactive stroke-color and stroke-width are never applied
+        https://bugs.webkit.org/show_bug.cgi?id=183178
+
+        Reviewed by David Hyatt.
+
+        This change fixes the following two issues:
+            1. Properties stroke-color and stroke-width are not applied to the ::selection pseudo-
+               element of text fields.
+            2. Properties stroke-color and stroke-width are never applied to ::selection:window-inactive
+               pseudo elements.
+
+        Currently when computing the paint styles for selected text we query the cached styles for
+        the ::selection pseudo element on the renderer. Text fields are implemented using a User Agent
+        shadow DOM. With regards to issue (1) the renderer queried was the inner most renderer for
+        the text in the text field. But it should have been the shadow host renderer (i.e. the renderer
+        for the <input>). With regards to issue (2) we cannot retrieve cached styles for the
+        ::selection pseudo element because it can be effected by a pseudo class, :window-inactive,
+        which matches when the page is deactivated (i.e. the window is in the background as the user
+        made another window the frontmost window). Both of these issues are fixed by making use
+        of RenderElement::selectionPseudoStyle().
+
+        Tests: fast/selectors/selection-window-inactive-stroke-color.html
+               fast/selectors/selection-window-inactive-text-shadow.html
+               fast/selectors/text-field-selection-stroke-color.html
+               fast/selectors/text-field-selection-text-shadow.html
+               fast/selectors/text-field-selection-window-inactive-stroke-color.html
+               fast/selectors/text-field-selection-window-inactive-text-shadow.html
+
+        * rendering/RenderText.h:
+        (WebCore::RenderText::selectionPseudoStyle const): Add a convenience function that turns
+        around and calls the function of the same name on its parent.
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::computeTextSelectionPaintStyle): Modified to use RenderText::selectionPseudoStyle()
+        instead of directly querying for the cached styles for the ::selection pseudo element.
+
 2018-03-01  Per Arne Vollan  <[email protected]>
 
         Scrollbar preferences are ignored when the WebContent process doesn't have access to the WindowServer.

Modified: trunk/Source/WebCore/rendering/RenderText.h (229146 => 229147)


--- trunk/Source/WebCore/rendering/RenderText.h	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/Source/WebCore/rendering/RenderText.h	2018-03-01 22:35:38 UTC (rev 229147)
@@ -54,6 +54,7 @@
     Color selectionBackgroundColor() const;
     Color selectionForegroundColor() const;
     Color selectionEmphasisMarkColor() const;
+    std::unique_ptr<RenderStyle> selectionPseudoStyle() const;
 
     virtual String originalText() const;
 
@@ -292,6 +293,11 @@
     return parent()->selectionEmphasisMarkColor();
 }
 
+inline std::unique_ptr<RenderStyle> RenderText::selectionPseudoStyle() const
+{
+    return parent()->selectionPseudoStyle();
+}
+
 inline RenderText* Text::renderer() const
 {
     return downcast<RenderText>(Node::renderer());

Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (229146 => 229147)


--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2018-03-01 22:21:29 UTC (rev 229146)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2018-03-01 22:35:38 UTC (rev 229147)
@@ -147,7 +147,7 @@
     if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionPaintStyle.emphasisMarkColor)
         selectionPaintStyle.emphasisMarkColor = emphasisMarkForeground;
 
-    if (auto* pseudoStyle = renderer.getCachedPseudoStyle(SELECTION)) {
+    if (auto pseudoStyle = renderer.selectionPseudoStyle()) {
         const ShadowData* shadow = paintInfo.forceTextColor() ? nullptr : pseudoStyle->textShadow();
         if (shadow != selectionShadow)
             selectionShadow = shadow;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to