Changeset 270784 in webkit


Ignore:
Timestamp:
Dec 14, 2020 10:43:23 AM (19 months ago)
Author:
emilio
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.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270772 r270784  
     12020-12-14  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Implement ::file-selector-button pseudo-element.
     4        https://bugs.webkit.org/show_bug.cgi?id=219836
     5
     6        Reviewed by Simon Fraser.
     7
     8        There are WPTs for this, but WebKit's importer doesn't handle
     9        <link rel="mismatch"> which is used by these. Instead, I adapted UA
     10        sheets to use the standard selector so we should get coverage, and
     11        extended the existing tests for -webkit-file-upload-button.
     12
     13        * fast/css/css-selector-text-expected.txt:
     14        * fast/css/css-selector-text.html: Tweak test to cover new pseudo.
     15
    1162020-12-14  Sihui Liu  <sihui_liu@apple.com>
    217
  • trunk/LayoutTests/fast/css/css-selector-text-expected.txt

    r260338 r270784  
    278278PASS parseThenSerializeRule('::-webkit-search-results-decoration { }') is '::-webkit-search-results-decoration { }'
    279279PASS parseThenSerializeRule('::-webkit-slider-thumb { }') is '::-webkit-slider-thumb { }'
     280PASS parseThenSerializeRule('::file-selector-button { }') is '::file-selector-button { }'
    280281
    281282PASS parseThenSerializeRule('a::-webkit-slider-thumb { }') is 'a::-webkit-slider-thumb { }'
  • trunk/LayoutTests/fast/css/css-selector-text.html

    r260338 r270784  
    369369shouldBe("parseThenSerializeRule('::-webkit-search-results-decoration { }')", "'::-webkit-search-results-decoration { }'");
    370370shouldBe("parseThenSerializeRule('::-webkit-slider-thumb { }')", "'::-webkit-slider-thumb { }'");
     371shouldBe("parseThenSerializeRule('::file-selector-button { }')", "'::file-selector-button { }'");
    371372
    372373debug('');
  • trunk/Source/WebCore/ChangeLog

    r270772 r270784  
     12020-12-14  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Implement ::file-selector-button pseudo-element.
     4        https://bugs.webkit.org/show_bug.cgi?id=219836
     5
     6        Reviewed by Simon Fraser.
     7
     8        Treat it like ::placeholder.
     9
     10        Tests: fast/css/css-selector-text.html (plus see the comment in
     11        changelog).
     12
     13        * css/CSSSelector.cpp:
     14        (WebCore::CSSSelector::selectorText const):
     15        * css/SelectorPseudoElementTypeMap.in:
     16        * css/formControlsIOS.css:
     17        (input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
     18        (input:matches([type="button"], [type="reset"]), input[type="file"]::file-selector-button, button):
     19        * css/html.css:
     20        (input[type="file"]::file-selector-button):
     21        (input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button):
     22        (input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::file-selector-button:active, button:active):
     23        (input:matches([type="button"], [type="submit"], [type="reset"]):active:disabled,):
     24        * css/parser/CSSParserSelector.cpp:
     25        (WebCore::CSSParserSelector::parsePseudoElementSelector):
     26        * css/themeWin.css:
     27        (input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button, button):
     28        * html/FileInputType.cpp:
     29        (WebCore::UploadButtonElement::createInternal):
     30
    1312020-12-14  Sihui Liu  <sihui_liu@apple.com>
    232
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r267172 r270784  
    701701                if (cs->value() == "placeholder")
    702702                    builder.appendLiteral("::-webkit-input-placeholder");
     703                if (cs->value() == "file-selector-button")
     704                    builder.appendLiteral("::-webkit-file-upload-button");
    703705                break;
    704706#if ENABLE(VIDEO)
  • trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in

    r262695 r270784  
    99marker
    1010part
     11file-selector-button, PseudoElementWebKitCustom
    1112placeholder, PseudoElementWebKitCustom
    1213-webkit-input-placeholder, PseudoElementWebKitCustomLegacyPrefixed
     14-webkit-file-upload-button, PseudoElementWebKitCustomLegacyPrefixed
    1315-webkit-resizer
    1416-webkit-scrollbar
  • trunk/Source/WebCore/css/formControlsIOS.css

    r270713 r270784  
    5959}
    6060
    61 input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
     61input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button {
    6262    border: initial;
    6363    font: 11px system-ui;
     
    6868/* FIXME: Add styles for additional button states once final specifications are obtained. */
    6969
    70 input:matches([type="button"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
     70input:matches([type="button"], [type="reset"]), input[type="file"]::file-selector-button, button {
    7171    background-color: rgb(235, 245, 255);
    7272    color: rgb(22, 122, 255);
  • trunk/Source/WebCore/css/html.css

    r270398 r270784  
    792792}
    793793
    794 input[type="file"]::-webkit-file-upload-button {
     794input[type="file"]::file-selector-button {
    795795    -webkit-appearance: push-button;
    796796    white-space: nowrap;
     
    799799}
    800800
    801 input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::-webkit-file-upload-button, button {
     801input:matches([type="button"], [type="submit"], [type="reset"]), input[type="file"]::file-selector-button, button {
    802802    align-items: flex-start;
    803803    text-align: center;
     
    818818}
    819819
    820 input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::-webkit-file-upload-button:active, button:active {
     820input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]::file-selector-button:active, button:active {
    821821    color: ActiveButtonText;
    822822}
     
    871871
    872872input:matches([type="button"], [type="submit"], [type="reset"]):disabled,
    873 input[type="file"]:disabled::-webkit-file-upload-button, button:disabled,
     873input[type="file"]:disabled::file-selector-button, button:disabled,
    874874select:disabled, keygen:disabled, optgroup:disabled, option:disabled,
    875875select[disabled]>option {
     
    878878
    879879#if !(defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY)
    880 input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]:active::-webkit-file-upload-button, button:active {
     880input:matches([type="button"], [type="submit"], [type="reset"]):active, input[type="file"]:active::file-selector-button, button:active {
    881881    border-style: inset;
    882882}
    883883
    884884input:matches([type="button"], [type="submit"], [type="reset"]):active:disabled,
    885 input[type="file"]:active:disabled::-webkit-file-upload-button, button:active:disabled {
     885input[type="file"]:active:disabled::file-selector-button, button:active:disabled {
    886886    border-style: outset;
    887887}
     
    12201220
    12211221input:matches([type="button"], [type="checkbox"], [type="file"], [type="hidden"], [type="image"], [type="radio"], [type="reset"], [type="search"], [type="submit"]):focus,
    1222 input[type="file"]:focus::-webkit-file-upload-button {
     1222input[type="file"]:focus::file-selector-button {
    12231223    outline-offset: 0;
    12241224}
  • trunk/Source/WebCore/css/parser/CSSParserSelector.cpp

    r250643 r270784  
    6464        name = pseudoTypeString.convertToASCIILowercase();
    6565    else {
    66         ASSERT_WITH_MESSAGE(equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-input-placeholder"), "-webkit-input-placeholder is the only LegacyPrefix pseudo type.");
    6766        if (equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-input-placeholder"))
    6867            name = AtomString("placeholder", AtomString::ConstructFromLiteral);
    69         else
     68        else if (equalLettersIgnoringASCIICase(pseudoTypeString, "-webkit-file-upload-button"))
     69            name = AtomString("file-selector-button", AtomString::ConstructFromLiteral);
     70        else {
     71            ASSERT_NOT_REACHED();
    7072            name = pseudoTypeString.convertToASCIILowercase();
     73        }
    7174    }
    7275    selector->m_selector->setValue(name);
  • trunk/Source/WebCore/css/themeWin.css

    r145977 r270784  
    102102}
    103103
    104 input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button {
     104input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button, button {
    105105    padding: 1px 6px;
    106106}
  • trunk/Source/WebCore/html/FileInputType.cpp

    r267074 r270784  
    9494    auto button = adoptRef(*new UploadButtonElement(document));
    9595    static MainThreadNeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
    96     static MainThreadNeverDestroyed<const AtomString> webkitFileUploadButtonName("-webkit-file-upload-button", AtomString::ConstructFromLiteral);
     96    static MainThreadNeverDestroyed<const AtomString> fileSelectorButtonName("file-selector-button", AtomString::ConstructFromLiteral);
    9797    button->setType(buttonName);
    98     button->setPseudo(webkitFileUploadButtonName);
     98    button->setPseudo(fileSelectorButtonName);
    9999    button->setValue(value);
    100100    return button;
Note: See TracChangeset for help on using the changeset viewer.