haikuwebkit/LayoutTests/fast/selectors/text-field-selection-text-s...

19 lines
491 B
HTML
Raw Permalink Normal View History

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>. Canonical link: https://commits.webkit.org/198934@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-01 22:35:38 +00:00
<!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>