Created attachment 246852 [details] Testcase Steps to reproduce: Select a text with a `text-decoration: underline` part while the following CSS rule is active: ::selection { color: red; } Actual results: The selected text, excluding the underline, is colored red. Expected results: The selected text, including the underline, is colored red. I also reported this bug on the Mozilla Bugzilla, as it happens in Firefox too (with ::-moz-selection): https://bugzilla.mozilla.org/show_bug.cgi?id=1134444
Retitling bug as this bug represents a more general problem: text decorations are not painted for ::selection. When painting selection we paint the text decoration for the line only accounting for the pseudo element ::first-line.
The CSS text-decorations property is not an inherited property. Even if we substituted ::selection for ::-moz-selection in the attached test case (attachment #246852 [details]), a text decoration would not be expected to paint when selecting the underlined test because text-decoration is not inherited. If we changed the following snippet in the test case from: ::-moz-selection { color: red; } to ::selection { color: red; text-decoration: inherit; } then the text-decoration would be inherited.
Created attachment 353312 [details] Patch and layout test
Attachment 353312 [details] did not pass style-queue: ERROR: Source/WebCore/rendering/InlineTextBox.cpp:588: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Oops! Ignore iOS EWS. Selection is painted by UIKit. So, will skip the text on iOS.
Comment on attachment 353312 [details] Patch and layout test Attachment 353312 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/9771564 New failing tests: http/wpt/css/css-pseudo/selection-text-decoration.html
Created attachment 353325 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Created attachment 353434 [details] Patch and layout test
Attachment 353434 [details] did not pass style-queue: ERROR: Source/WebCore/rendering/InlineTextBox.cpp:588: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
If the patch for bug #191040 lands before the patch for this bug. Then I will update the patch for this bug to include the following diff: [[ diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp index fbc1143ab65..ce22d4cd8a5 100644 --- a/Source/WebCore/rendering/InlineTextBox.cpp +++ b/Source/WebCore/rendering/InlineTextBox.cpp @@ -784,7 +784,7 @@ auto InlineTextBox::resolveStyleForMarkedText(const MarkedText& markedText, cons style.overlappedPseudoStyles.add(PseudoId::Selection); style.textDecorationsInEffect = ([&] { - if (auto pseudoStyle = renderer().selectionPseudoStyle()) + if (auto pseudoStyle = renderer().selectionPseudoStyle(&lineStyle())) return pseudoStyle->textDecorationsInEffect(); return lineStyle().textDecorationsInEffect(); })(); ]]
Comment on attachment 353434 [details] Patch and layout test This has been requesting review for more than one year. If this is still needed, please rebase and re-request review.
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.