Title: [270784] trunk
Revision
270784
Author
[email protected]
Date
2020-12-14 10:43:23 -0800 (Mon, 14 Dec 2020)

Log Message

Implement ::file-selector-button pseudo-element.
https://bugs.webkit.org/show_bug.cgi?id=219836

Reviewed by Simon Fraser.

Source/WebCore:

Treat it like ::placeholder.

Tests: fast/css/css-selector-text.html (plus see the comment in
changelog).

* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/SelectorPseudoElementTypeMap.in:
* css/formControlsIOS.css:
(input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
(input:matches([type="button"], [type="reset"]), input[type="file"]::file-selector-button, button):
* css/html.css:
(input[type="file"]::file-selector-button):
(input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
(input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::file-selector-button:active, button:active):
(input:matches([type="button"], [type="submit"], [type="reset"]):active:disabled,):
* css/parser/CSSParserSelector.cpp:
(WebCore::CSSParserSelector::parsePseudoElementSelector):
* css/themeWin.css:
(input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button, button):
* html/FileInputType.cpp:
(WebCore::UploadButtonElement::createInternal):

LayoutTests:

There are WPTs for this, but WebKit's importer doesn't handle
<link rel="mismatch"> which is used by these. Instead, I adapted UA
sheets to use the standard selector so we should get coverage, and
extended the existing tests for -webkit-file-upload-button.

* fast/css/css-selector-text-expected.txt:
* fast/css/css-selector-text.html: Tweak test to cover new pseudo.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270783 => 270784)


--- trunk/LayoutTests/ChangeLog	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/LayoutTests/ChangeLog	2020-12-14 18:43:23 UTC (rev 270784)
@@ -1,3 +1,18 @@
+2020-12-14  Emilio Cobos Álvarez  <[email protected]>
+
+        Implement ::file-selector-button pseudo-element.
+        https://bugs.webkit.org/show_bug.cgi?id=219836
+
+        Reviewed by Simon Fraser.
+
+        There are WPTs for this, but WebKit's importer doesn't handle
+        <link rel="mismatch"> which is used by these. Instead, I adapted UA
+        sheets to use the standard selector so we should get coverage, and
+        extended the existing tests for -webkit-file-upload-button.
+
+        * fast/css/css-selector-text-expected.txt:
+        * fast/css/css-selector-text.html: Tweak test to cover new pseudo.
+
 2020-12-14  Sihui Liu  <[email protected]>
 
         Implement recognizer for SpeechRecognition

Modified: trunk/LayoutTests/fast/css/css-selector-text-expected.txt (270783 => 270784)


--- trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2020-12-14 18:43:23 UTC (rev 270784)
@@ -277,6 +277,7 @@
 PASS parseThenSerializeRule('::-webkit-search-results-button { }') is '::-webkit-search-results-button { }'
 PASS parseThenSerializeRule('::-webkit-search-results-decoration { }') is '::-webkit-search-results-decoration { }'
 PASS parseThenSerializeRule('::-webkit-slider-thumb { }') is '::-webkit-slider-thumb { }'
+PASS parseThenSerializeRule('::file-selector-button { }') is '::file-selector-button { }'
 
 PASS parseThenSerializeRule('a::-webkit-slider-thumb { }') is 'a::-webkit-slider-thumb { }'
 PASS parseThenSerializeRule('a ::-webkit-slider-thumb { }') is 'a ::-webkit-slider-thumb { }'

Modified: trunk/LayoutTests/fast/css/css-selector-text.html (270783 => 270784)


--- trunk/LayoutTests/fast/css/css-selector-text.html	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/LayoutTests/fast/css/css-selector-text.html	2020-12-14 18:43:23 UTC (rev 270784)
@@ -368,6 +368,7 @@
 shouldBe("parseThenSerializeRule('::-webkit-search-results-button { }')", "'::-webkit-search-results-button { }'");
 shouldBe("parseThenSerializeRule('::-webkit-search-results-decoration { }')", "'::-webkit-search-results-decoration { }'");
 shouldBe("parseThenSerializeRule('::-webkit-slider-thumb { }')", "'::-webkit-slider-thumb { }'");
+shouldBe("parseThenSerializeRule('::file-selector-button { }')", "'::file-selector-button { }'");
 
 debug('');
 

Modified: trunk/Source/WebCore/ChangeLog (270783 => 270784)


--- trunk/Source/WebCore/ChangeLog	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/ChangeLog	2020-12-14 18:43:23 UTC (rev 270784)
@@ -1,3 +1,33 @@
+2020-12-14  Emilio Cobos Álvarez  <[email protected]>
+
+        Implement ::file-selector-button pseudo-element.
+        https://bugs.webkit.org/show_bug.cgi?id=219836
+
+        Reviewed by Simon Fraser.
+
+        Treat it like ::placeholder.
+
+        Tests: fast/css/css-selector-text.html (plus see the comment in
+        changelog).
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::selectorText const):
+        * css/SelectorPseudoElementTypeMap.in:
+        * css/formControlsIOS.css:
+        (input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
+        (input:matches([type="button"], [type="reset"]), input[type="file"]::file-selector-button, button):
+        * css/html.css:
+        (input[type="file"]::file-selector-button):
+        (input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
+        (input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::file-selector-button:active, button:active):
+        (input:matches([type="button"], [type="submit"], [type="reset"]):active:disabled,):
+        * css/parser/CSSParserSelector.cpp:
+        (WebCore::CSSParserSelector::parsePseudoElementSelector):
+        * css/themeWin.css:
+        (input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button, button):
+        * html/FileInputType.cpp:
+        (WebCore::UploadButtonElement::createInternal):
+
 2020-12-14  Sihui Liu  <[email protected]>
 
         Implement recognizer for SpeechRecognition

Modified: trunk/Source/WebCore/css/CSSSelector.cpp (270783 => 270784)


--- trunk/Source/WebCore/css/CSSSelector.cpp	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/CSSSelector.cpp	2020-12-14 18:43:23 UTC (rev 270784)
@@ -700,6 +700,8 @@
             case CSSSelector::PseudoElementWebKitCustomLegacyPrefixed:
                 if (cs->value() == "placeholder")
                     builder.appendLiteral("::-webkit-input-placeholder");
+                if (cs->value() == "file-selector-button")
+                    builder.appendLiteral("::-webkit-file-upload-button");
                 break;
 #if ENABLE(VIDEO)
             case CSSSelector::PseudoElementCue: {

Modified: trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in (270783 => 270784)


--- trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2020-12-14 18:43:23 UTC (rev 270784)
@@ -8,8 +8,10 @@
 highlight
 marker
 part
+file-selector-button, PseudoElementWebKitCustom
 placeholder, PseudoElementWebKitCustom
 -webkit-input-placeholder, PseudoElementWebKitCustomLegacyPrefixed
+-webkit-file-upload-button, PseudoElementWebKitCustomLegacyPrefixed
 -webkit-resizer
 -webkit-scrollbar
 -webkit-scrollbar-button

Modified: trunk/Source/WebCore/css/formControlsIOS.css (270783 => 270784)


--- trunk/Source/WebCore/css/formControlsIOS.css	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/formControlsIOS.css	2020-12-14 18:43:23 UTC (rev 270784)
@@ -58,7 +58,7 @@
     -webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 73 73"><path fill="darkgray" d="M29.6875 59.375c6.2988 0 12.1094-1.953 16.9434-5.3222l17.334 17.334c.9277.9277 2.1484 1.3672 3.418 1.3672 2.7343 0 4.7362-2.0996 4.7362-4.7852 0-1.2695-.4394-2.4902-1.3672-3.418L53.5644 47.3145c3.6622-4.9316 5.8106-11.0352 5.8106-17.627C59.375 13.3301 46.045 0 29.6875 0 13.3301 0 0 13.3301 0 29.6875 0 46.045 13.33 59.375 29.6875 59.375zm0-7.2753c-12.2559 0-22.4121-10.1563-22.4121-22.4122 0-12.3046 10.1562-22.4121 22.4121-22.4121C41.9922 7.2754 52.1 17.3829 52.1 29.6875c0 12.256-10.1078 22.4122-22.4125 22.4122z"/></svg>');
 }
 
-input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
+input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button {
     border: initial;
     font: 11px system-ui;
     font-weight: bold;
@@ -67,7 +67,7 @@
 /* FIXME: Use semantic colors once final specifications are obtained. */
 /* FIXME: Add styles for additional button states once final specifications are obtained. */
 
-input:matches([type="button"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
+input:matches([type="button"], [type="reset"]), input[type="file"]::file-selector-button, button {
     background-color: rgb(235, 245, 255);
     color: rgb(22, 122, 255);
 }

Modified: trunk/Source/WebCore/css/html.css (270783 => 270784)


--- trunk/Source/WebCore/css/html.css	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/html.css	2020-12-14 18:43:23 UTC (rev 270784)
@@ -791,7 +791,7 @@
     white-space: pre;
 }
 
-input[type="file"]::-webkit-file-upload-button {
+input[type="file"]::file-selector-button {
     -webkit-appearance: push-button;
     white-space: nowrap;
     margin: 0;
@@ -798,7 +798,7 @@
     font-size: inherit;
 }
 
-input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
+input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button {
     align-items: flex-start;
     text-align: center;
     cursor: default;
@@ -817,7 +817,7 @@
     box-sizing: border-box;
 }
 
-input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::-webkit-file-upload-button:active, button:active {
+input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::file-selector-button:active, button:active {
     color: ActiveButtonText;
 }
 
@@ -870,7 +870,7 @@
 #endif
 
 input:matches([type="button"], [type="submit"], [type="reset"]):disabled,
-input[type="file"]:disabled::-webkit-file-upload-button, button:disabled,
+input[type="file"]:disabled::file-selector-button, button:disabled,
 select:disabled, keygen:disabled, optgroup:disabled, option:disabled,
 select[disabled]>option {
     color: GrayText;
@@ -877,12 +877,12 @@
 }
 
 #if !(defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY)
-input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]:active::-webkit-file-upload-button, button:active {
+input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]:active::file-selector-button, button:active {
     border-style: inset;
 }
 
 input:matches([type="button"], [type="submit"], [type="reset"]):active:disabled,
-input[type="file"]:active:disabled::-webkit-file-upload-button, button:active:disabled {
+input[type="file"]:active:disabled::file-selector-button, button:active:disabled {
     border-style: outset;
 }
 #endif
@@ -1219,7 +1219,7 @@
 #endif
 
 input:matches([type="button"], [type="checkbox"], [type="file"], [type="hidden"], [type="image"], [type="radio"], [type="reset"], [type="search"], [type="submit"]):focus,
-input[type="file"]:focus::-webkit-file-upload-button {
+input[type="file"]:focus::file-selector-button {
     outline-offset: 0;
 }
 

Modified: trunk/Source/WebCore/css/parser/CSSParserSelector.cpp (270783 => 270784)


--- trunk/Source/WebCore/css/parser/CSSParserSelector.cpp	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/parser/CSSParserSelector.cpp	2020-12-14 18:43:23 UTC (rev 270784)
@@ -63,11 +63,14 @@
     if (pseudoType != CSSSelector::PseudoElementWebKitCustomLegacyPrefixed)
         name = pseudoTypeString.convertToASCIILowercase();
     else {
-        ASSERT_WITH_MESSAGE(equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-input-placeholder"), "-webkit-input-placeholder is the only LegacyPrefix pseudo type.");
         if (equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-input-placeholder"))
             name = AtomString("placeholder", AtomString::ConstructFromLiteral);
-        else
+        else if (equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-file-upload-button"))
+            name = AtomString("file-selector-button", AtomString::ConstructFromLiteral);
+        else {
+            ASSERT_NOT_REACHED();
             name = pseudoTypeString.convertToASCIILowercase();
+        }
     }
     selector->m_selector->setValue(name);
     return selector;

Modified: trunk/Source/WebCore/css/themeWin.css (270783 => 270784)


--- trunk/Source/WebCore/css/themeWin.css	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/css/themeWin.css	2020-12-14 18:43:23 UTC (rev 270784)
@@ -101,7 +101,7 @@
     margin: 0;
 }
 
-input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button {
+input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button, button {
     padding: 1px 6px;
 }
 

Modified: trunk/Source/WebCore/html/FileInputType.cpp (270783 => 270784)


--- trunk/Source/WebCore/html/FileInputType.cpp	2020-12-14 18:36:44 UTC (rev 270783)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2020-12-14 18:43:23 UTC (rev 270784)
@@ -93,9 +93,9 @@
 {
     auto button = adoptRef(*new UploadButtonElement(document));
     static MainThreadNeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
-    static MainThreadNeverDestroyed<const AtomString> webkitFileUploadButtonName("-webkit-file-upload-button", AtomString::ConstructFromLiteral);
+    static MainThreadNeverDestroyed<const AtomString> fileSelectorButtonName("file-selector-button", AtomString::ConstructFromLiteral);
     button->setType(buttonName);
-    button->setPseudo(webkitFileUploadButtonName);
+    button->setPseudo(fileSelectorButtonName);
     button->setValue(value);
     return button;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to