Title: [202066] trunk
Revision
202066
Author
[email protected]
Date
2016-06-14 15:09:33 -0700 (Tue, 14 Jun 2016)

Log Message

Add the unprefixed version of the pseudo element ::placeholder
https://bugs.webkit.org/show_bug.cgi?id=158653

Patch by Benjamin Poulain <[email protected]> on 2016-06-14
Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/forms/placeholder-pseudo-element-with-webkit-prefix.html

The pseudo element ::-webkit-input-placeholder is stupidly popular
which forces other engines to support this exact name.

The pseudo-element spec provides a new standard name we can adopt
to drop the prefix: https://drafts.csswg.org/css-pseudo-4/#placeholder-pseudo

This patch does just that, make ::placeholder the standard name to select
the placeholder element in the shadow dom of input elements.

Unlike pseudo classes, we did not have any support for prefixes and aliasing.
I want to keep the absurdly efficient matching we currently use for styling
because style updates are more common than stylesheet updates.
With that constraint in mind, the value of CSSSelector has to be the unprefixed
version for both forms of input.

This leaves us with the problem of displaying the CSSSelector for CSSOM.
To differentiate the legacy form from the standard form, I added
a new type of PseudoElement: PseudoElementWebKitCustomLegacyPrefixed.
When parsing, PseudoElementWebKitCustomLegacyPrefixed let us replace
the original value "-webkit-input-placeholder" by the standard value.
When creating the selectorText for CSSOM, PseudoElementWebKitCustomLegacyPrefixed
let us replace the standard for by the legacy form.

* css/CSSParserValues.cpp:
(WebCore::CSSParserSelector::parsePseudoElementSelector):
* css/CSSSelector.cpp:
(WebCore::CSSSelector::pseudoId):
(WebCore::CSSSelector::selectorText):
* css/CSSSelector.h:
(WebCore::CSSSelector::isCustomPseudoElement):
(WebCore::CSSSelector::isWebKitCustomPseudoElement):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
* css/SelectorPseudoElementTypeMap.in:
* css/html.css:
(::placeholder):
(input::placeholder, isindex::placeholder):
(textarea::placeholder):
(::-webkit-input-placeholder): Deleted.
(input::-webkit-input-placeholder, isindex::-webkit-input-placeholder): Deleted.
(textarea::-webkit-input-placeholder): Deleted.
* features.json:
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):

Source/WebInspectorUI:

* UserInterface/Views/FilterBar.css:
(.filter-bar > input[type="search"]::placeholder):
(.filter-bar > input[type="search"]::-webkit-input-placeholder): Deleted.
* UserInterface/Views/FindBanner.css:
(.find-banner.console-find-banner > input[type="search"]::placeholder):
(.find-banner.console-find-banner > input[type="search"]::-webkit-input-placeholder): Deleted.
* UserInterface/Views/GoToLineDialog.css:
(.go-to-line-dialog > div > input::placeholder):
(.go-to-line-dialog > div > input::-webkit-input-placeholder): Deleted.
* UserInterface/Views/OpenResourceDialog.css:
(.open-resource-dialog > .field > input::placeholder):
(.open-resource-dialog > .field > input::-webkit-input-placeholder): Deleted.
* UserInterface/Views/SearchBar.css:
(.search-bar > input[type="search"]::placeholder):
(.search-bar > input[type="search"]::-webkit-input-placeholder): Deleted.
* UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.css:

LayoutTests:

* fast/css/css-selector-text-expected.txt:
* fast/css/css-selector-text.html:
* fast/css/css-set-selector-text-expected.txt:
* fast/css/css-set-selector-text.html:
This covers CSSOM for the prefixed version.

* fast/forms/placeholder-pseudo-element-with-webkit-prefix-expected.html: Added.
* fast/forms/placeholder-pseudo-element-with-webkit-prefix.html: Added.
This verifies both version of the pseudo elements are equivalent.

* fast/css/pseudo-cache-stale-expected.html:
* fast/css/pseudo-cache-stale.html:
* fast/forms/input-placeholder-paint-order-2-expected.html:
* fast/forms/input-placeholder-paint-order-2.html:
* fast/forms/input-placeholder-paint-order.html:
* fast/forms/input-placeholder-text-indent.html:
* fast/forms/input-user-modify.html:
* fast/forms/isindex-placeholder.html:
* fast/forms/placeholder-position.html:
* fast/forms/placeholder-pseudo-style.html:
* fast/forms/textarea-placeholder-pseudo-style.html:
* fast/forms/textarea/textarea-placeholder-paint-order-2-expected.html:
* fast/forms/textarea/textarea-placeholder-paint-order-2.html:
* fast/forms/textarea/textarea-placeholder-paint-order.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202065 => 202066)


--- trunk/LayoutTests/ChangeLog	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/ChangeLog	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,3 +1,35 @@
+2016-06-14  Benjamin Poulain  <[email protected]>
+
+        Add the unprefixed version of the pseudo element ::placeholder
+        https://bugs.webkit.org/show_bug.cgi?id=158653
+
+        Reviewed by Dean Jackson.
+
+        * fast/css/css-selector-text-expected.txt:
+        * fast/css/css-selector-text.html:
+        * fast/css/css-set-selector-text-expected.txt:
+        * fast/css/css-set-selector-text.html:
+        This covers CSSOM for the prefixed version.
+
+        * fast/forms/placeholder-pseudo-element-with-webkit-prefix-expected.html: Added.
+        * fast/forms/placeholder-pseudo-element-with-webkit-prefix.html: Added.
+        This verifies both version of the pseudo elements are equivalent.
+
+        * fast/css/pseudo-cache-stale-expected.html:
+        * fast/css/pseudo-cache-stale.html:
+        * fast/forms/input-placeholder-paint-order-2-expected.html:
+        * fast/forms/input-placeholder-paint-order-2.html:
+        * fast/forms/input-placeholder-paint-order.html:
+        * fast/forms/input-placeholder-text-indent.html:
+        * fast/forms/input-user-modify.html:
+        * fast/forms/isindex-placeholder.html:
+        * fast/forms/placeholder-position.html:
+        * fast/forms/placeholder-pseudo-style.html:
+        * fast/forms/textarea-placeholder-pseudo-style.html:
+        * fast/forms/textarea/textarea-placeholder-paint-order-2-expected.html:
+        * fast/forms/textarea/textarea-placeholder-paint-order-2.html:
+        * fast/forms/textarea/textarea-placeholder-paint-order.html:
+
 2016-06-14  Doug Russell  <[email protected]>
 
         AX: Form label text should be exposed as static text if it contains only static text

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


--- trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2016-06-14 22:09:33 UTC (rev 202066)
@@ -207,6 +207,15 @@
 PASS parseThenSerializeRule('a#b::-webkit-slider-thumb { }') is 'a#b::-webkit-slider-thumb { }'
 PASS parseThenSerializeRule('a[b].c#d::-webkit-slider-thumb { }') is 'a[b].c#d::-webkit-slider-thumb { }'
 
+PASS parseThenSerializeRule('a[b]::placeholder { }') is 'a[b]::placeholder { }'
+PASS parseThenSerializeRule('a.b::placeholder { }') is 'a.b::placeholder { }'
+PASS parseThenSerializeRule('a#b::placeholder { }') is 'a#b::placeholder { }'
+PASS parseThenSerializeRule('a[b].c#d::placeholder { }') is 'a[b].c#d::placeholder { }'
+PASS parseThenSerializeRule('a[b]::-webkit-input-placeholder { }') is 'a[b]::-webkit-input-placeholder { }'
+PASS parseThenSerializeRule('a.b::-webkit-input-placeholder { }') is 'a.b::-webkit-input-placeholder { }'
+PASS parseThenSerializeRule('a#b::-webkit-input-placeholder { }') is 'a#b::-webkit-input-placeholder { }'
+PASS parseThenSerializeRule('a[b].c#d::-webkit-input-placeholder { }') is 'a[b].c#d::-webkit-input-placeholder { }'
+
 PASS parseThenSerializeRule('input:not([type="file"]):focus { }') is 'input:not([type="file"]):focus { }'
 PASS parseThenSerializeRule(':-webkit-any([type="file"]) { }') is ':-webkit-any([type="file"]) { }'
 PASS parseThenSerializeRule(':-webkit-any(:hover) { }') is ':-webkit-any(:hover) { }'

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


--- trunk/LayoutTests/fast/css/css-selector-text.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/css-selector-text.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -296,6 +296,17 @@
 
 debug('');
 
+testSelectorRoundTrip("a[b]::placeholder");
+testSelectorRoundTrip("a.b::placeholder");
+testSelectorRoundTrip("a#b::placeholder");
+testSelectorRoundTrip("a[b].c#d::placeholder");
+testSelectorRoundTrip("a[b]::-webkit-input-placeholder");
+testSelectorRoundTrip("a.b::-webkit-input-placeholder");
+testSelectorRoundTrip("a#b::-webkit-input-placeholder");
+testSelectorRoundTrip("a[b].c#d::-webkit-input-placeholder");
+
+debug('');
+
 testSelectorRoundTrip('input:not([type="file"]):focus');
 testSelectorRoundTrip(':-webkit-any([type="file"])');
 testSelectorRoundTrip(':-webkit-any(:hover)');

Modified: trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt (202065 => 202066)


--- trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt	2016-06-14 22:09:33 UTC (rev 202066)
@@ -209,6 +209,15 @@
 PASS setThenReadSelectorText('a#b::-webkit-slider-thumb') is 'a#b::-webkit-slider-thumb'
 PASS setThenReadSelectorText('a[b].c#d::-webkit-slider-thumb') is 'a[b].c#d::-webkit-slider-thumb'
 
+PASS setThenReadSelectorText('a[b]::placeholder') is 'a[b]::placeholder'
+PASS setThenReadSelectorText('a.b::placeholder') is 'a.b::placeholder'
+PASS setThenReadSelectorText('a#b::placeholder') is 'a#b::placeholder'
+PASS setThenReadSelectorText('a[b].c#d::placeholder') is 'a[b].c#d::placeholder'
+PASS setThenReadSelectorText('a[b]::-webkit-input-placeholder') is 'a[b]::-webkit-input-placeholder'
+PASS setThenReadSelectorText('a.b::-webkit-input-placeholder') is 'a.b::-webkit-input-placeholder'
+PASS setThenReadSelectorText('a#b::-webkit-input-placeholder') is 'a#b::-webkit-input-placeholder'
+PASS setThenReadSelectorText('a[b].c#d::-webkit-input-placeholder') is 'a[b].c#d::-webkit-input-placeholder'
+
 PASS setThenReadSelectorText('input:not([type="file"]):focus') is 'input:not([type="file"]):focus'
 PASS setThenReadSelectorText(':-webkit-any([type="file"])') is ':-webkit-any([type="file"])'
 PASS setThenReadSelectorText(':-webkit-any(:hover)') is ':-webkit-any(:hover)'

Modified: trunk/LayoutTests/fast/css/css-set-selector-text.html (202065 => 202066)


--- trunk/LayoutTests/fast/css/css-set-selector-text.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/css-set-selector-text.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -300,6 +300,17 @@
 
 debug('');
 
+testSelectorRoundTrip("a[b]::placeholder");
+testSelectorRoundTrip("a.b::placeholder");
+testSelectorRoundTrip("a#b::placeholder");
+testSelectorRoundTrip("a[b].c#d::placeholder");
+testSelectorRoundTrip("a[b]::-webkit-input-placeholder");
+testSelectorRoundTrip("a.b::-webkit-input-placeholder");
+testSelectorRoundTrip("a#b::-webkit-input-placeholder");
+testSelectorRoundTrip("a[b].c#d::-webkit-input-placeholder");
+
+debug('');
+
 testSelectorRoundTrip('input:not([type="file"]):focus');
 testSelectorRoundTrip(':-webkit-any([type="file"])');
 testSelectorRoundTrip(':-webkit-any(:hover)');

Modified: trunk/LayoutTests/fast/css/pseudo-cache-stale-expected.html (202065 => 202066)


--- trunk/LayoutTests/fast/css/pseudo-cache-stale-expected.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/pseudo-cache-stale-expected.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,5 +1,5 @@
 <style>
-::-webkit-input-placeholder {
+::placeholder {
     color: green;
 }
 </style>

Modified: trunk/LayoutTests/fast/css/pseudo-cache-stale.html (202065 => 202066)


--- trunk/LayoutTests/fast/css/pseudo-cache-stale.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/css/pseudo-cache-stale.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -15,7 +15,7 @@
         font-size: xx-large;
     }
 
-    .green input::-webkit-input-placeholder {
+    .green input::placeholder {
         color: green;
     }
 </style>

Modified: trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2-expected.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2-expected.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2-expected.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -7,7 +7,7 @@
     zoom: 8;
 }
 
-input::-webkit-input-placeholder {
+input::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/input-placeholder-paint-order-2.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -7,7 +7,7 @@
     zoom: 8;
 }
 
-input::-webkit-input-placeholder {
+input::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/input-placeholder-paint-order.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/input-placeholder-paint-order.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/input-placeholder-paint-order.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -12,7 +12,7 @@
     zoom: 8;
 }
 
-input::-webkit-input-placeholder {
+input::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/input-placeholder-text-indent.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/input-placeholder-text-indent.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/input-placeholder-text-indent.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,10 +1,10 @@
 <style>
 input { font-size: 30px; width: 500px; }
-input.a::-webkit-input-placeholder { text-indent: 0px; }
-input.b::-webkit-input-placeholder { text-indent: 10px; }
-input.c::-webkit-input-placeholder { text-indent: 200px; }
-input.d::-webkit-input-placeholder { text-indent: -10px; }
-input.e::-webkit-input-placeholder { text-indent: 50%; }
+input.a::placeholder { text-indent: 0px; }
+input.b::placeholder { text-indent: 10px; }
+input.c::placeholder { text-indent: 200px; }
+input.d::placeholder { text-indent: -10px; }
+input.e::placeholder { text-indent: 50%; }
 </style>
 
 <div style="direction:ltr">

Modified: trunk/LayoutTests/fast/forms/input-user-modify.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/input-user-modify.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/input-user-modify.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -8,9 +8,9 @@
 input[type="search"]::-webkit-search-decoration,
 input[type="search"]::-webkit-search-results-decoration,
 input[type="search"]::-webkit-search-results-button,
-::-webkit-input-placeholder,
-input::-webkit-input-placeholder,
-isindex::-webkit-input-placeholder,
+::placeholder,
+input::placeholder,
+isindex::placeholder,
 input[type="button"], input[type="submit"], input[type="reset"],
 input[type="file"]::-webkit-file-upload-button,
 button,

Modified: trunk/LayoutTests/fast/forms/isindex-placeholder.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/isindex-placeholder.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/isindex-placeholder.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,5 +1,5 @@
 <style>
-    #green-placeholder::-webkit-input-placeholder { color: green; }
+    #green-placeholder::placeholder { color: green; }
 </style>
 <p>
     Test <tt>&lt;isindex></tt> placeholder styling.

Modified: trunk/LayoutTests/fast/forms/placeholder-position.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/placeholder-position.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/placeholder-position.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,5 +1,5 @@
 <style>
-.center::-webkit-input-placeholder {
+.center::placeholder {
     text-align: center;
 }
 </style>

Added: trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix-expected.html (0 => 202066)


--- trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix-expected.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+    <style>
+        [placeholder=first]::-webkit-input-placeholder {
+            color: red;
+            background-color: green;
+        }
+        [placeholder=second]::placeholder {
+            color: pink;
+            background-color: blue;
+        }
+
+    </style>
+    <body>
+        <p>This test verifies that ::placeholder and ::-webkit-input-placeholder are styled the same.</p>
+        <div>
+            <input placeholder=first>
+            <input placeholder=second>
+        </div>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix.html (0 => 202066)


--- trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/placeholder-pseudo-element-with-webkit-prefix.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+    <style>
+        [placeholder=first]::placeholder {
+            color: red;
+            background-color: green;
+        }
+        [placeholder=second]::-webkit-input-placeholder {
+            color: pink;
+            background-color: blue;
+        }
+
+    </style>
+    <body>
+        <p>This test verifies that ::placeholder and ::-webkit-input-placeholder are styled the same.</p>
+        <div>
+            <input placeholder=first>
+            <input placeholder=second>
+        </div>
+    </body>
+</html>

Modified: trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/placeholder-pseudo-style.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,5 +1,5 @@
 <style>
-input.red::-webkit-input-placeholder {
+input.red::placeholder {
     color: rgb(100, 0, 0);
 }
 </style>

Modified: trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2-expected.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2-expected.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2-expected.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -7,7 +7,7 @@
     zoom: 8;
 }
 
-textarea::-webkit-input-placeholder {
+textarea::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order-2.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -7,7 +7,7 @@
     zoom: 8;
 }
 
-textarea::-webkit-input-placeholder {
+textarea::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-placeholder-paint-order.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -12,7 +12,7 @@
     zoom: 8;
 }
 
-textarea::-webkit-input-placeholder {
+textarea::placeholder {
     text-indent: -1px;
     font-weight: bold;
     color: red;

Modified: trunk/LayoutTests/fast/forms/textarea-placeholder-pseudo-style.html (202065 => 202066)


--- trunk/LayoutTests/fast/forms/textarea-placeholder-pseudo-style.html	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/LayoutTests/fast/forms/textarea-placeholder-pseudo-style.html	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,5 +1,5 @@
 <style>
-textarea.red::-webkit-input-placeholder {
+textarea.red::placeholder {
     color: rgb(100, 0, 0);
 }
 </style>

Modified: trunk/Source/WebCore/ChangeLog (202065 => 202066)


--- trunk/Source/WebCore/ChangeLog	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/ChangeLog	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,3 +1,57 @@
+2016-06-14  Benjamin Poulain  <[email protected]>
+
+        Add the unprefixed version of the pseudo element ::placeholder
+        https://bugs.webkit.org/show_bug.cgi?id=158653
+
+        Reviewed by Dean Jackson.
+
+        Test: fast/forms/placeholder-pseudo-element-with-webkit-prefix.html
+
+        The pseudo element ::-webkit-input-placeholder is stupidly popular
+        which forces other engines to support this exact name.
+
+        The pseudo-element spec provides a new standard name we can adopt
+        to drop the prefix: https://drafts.csswg.org/css-pseudo-4/#placeholder-pseudo
+
+        This patch does just that, make ::placeholder the standard name to select
+        the placeholder element in the shadow dom of input elements.
+
+        Unlike pseudo classes, we did not have any support for prefixes and aliasing.
+        I want to keep the absurdly efficient matching we currently use for styling
+        because style updates are more common than stylesheet updates.
+        With that constraint in mind, the value of CSSSelector has to be the unprefixed
+        version for both forms of input.
+
+        This leaves us with the problem of displaying the CSSSelector for CSSOM.
+        To differentiate the legacy form from the standard form, I added
+        a new type of PseudoElement: PseudoElementWebKitCustomLegacyPrefixed.
+        When parsing, PseudoElementWebKitCustomLegacyPrefixed let us replace
+        the original value "-webkit-input-placeholder" by the standard value.
+        When creating the selectorText for CSSOM, PseudoElementWebKitCustomLegacyPrefixed
+        let us replace the standard for by the legacy form.
+
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::parsePseudoElementSelector):
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId):
+        (WebCore::CSSSelector::selectorText):
+        * css/CSSSelector.h:
+        (WebCore::CSSSelector::isCustomPseudoElement):
+        (WebCore::CSSSelector::isWebKitCustomPseudoElement):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively):
+        * css/SelectorPseudoElementTypeMap.in:
+        * css/html.css:
+        (::placeholder):
+        (input::placeholder, isindex::placeholder):
+        (textarea::placeholder):
+        (::-webkit-input-placeholder): Deleted.
+        (input::-webkit-input-placeholder, isindex::-webkit-input-placeholder): Deleted.
+        (textarea::-webkit-input-placeholder): Deleted.
+        * features.json:
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):
+
 2016-06-14  Doug Russell  <[email protected]>
 
         AX: Form label text should be exposed as static text if it contains only static text

Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (202065 => 202066)


--- trunk/Source/WebCore/css/CSSParserValues.cpp	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp	2016-06-14 22:09:33 UTC (rev 202066)
@@ -206,6 +206,11 @@
     auto selector = std::make_unique<CSSParserSelector>();
     selector->m_selector->setMatch(CSSSelector::PseudoElement);
     selector->m_selector->setPseudoElementType(pseudoType);
+    if (pseudoType == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed) {
+        ASSERT_WITH_MESSAGE(name == "-webkit-input-placeholder", "-webkit-input-placeholder is the only LegacyPrefix pseudo type.");
+        if (name == "-webkit-input-placeholder")
+            name = AtomicString("placeholder", AtomicString::ConstructFromLiteral);
+    }
     selector->m_selector->setValue(name);
     return selector.release();
 }

Modified: trunk/Source/WebCore/css/CSSSelector.cpp (202065 => 202066)


--- trunk/Source/WebCore/css/CSSSelector.cpp	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/CSSSelector.cpp	2016-06-14 22:09:33 UTC (rev 202066)
@@ -305,6 +305,7 @@
     case PseudoElementUnknown:
     case PseudoElementUserAgentCustom:
     case PseudoElementWebKitCustom:
+    case PseudoElementWebKitCustomLegacyPrefixed:
         return NOPSEUDO;
     }
 
@@ -660,6 +661,10 @@
                 str.append(')');
                 break;
 #endif
+            case CSSSelector::PseudoElementWebKitCustomLegacyPrefixed:
+                if (cs->value() == "placeholder")
+                    str.appendLiteral("::-webkit-input-placeholder");
+                break;
             default:
                 str.appendLiteral("::");
                 str.append(cs->value());

Modified: trunk/Source/WebCore/css/CSSSelector.h (202065 => 202066)


--- trunk/Source/WebCore/css/CSSSelector.h	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/CSSSelector.h	2016-06-14 22:09:33 UTC (rev 202066)
@@ -189,6 +189,10 @@
 #endif
             PseudoElementUserAgentCustom,
             PseudoElementWebKitCustom,
+
+            // WebKitCustom that appeared in an old prefixed form
+            // and need special handling.
+            PseudoElementWebKitCustomLegacyPrefixed,
         };
 
         enum PagePseudoClassType {
@@ -282,6 +286,7 @@
         bool matchesPseudoElement() const;
         bool isUnknownPseudoElement() const;
         bool isCustomPseudoElement() const;
+        bool isWebKitCustomPseudoElement() const;
         bool isSiblingSelector() const;
         bool isAttributeSelector() const;
 
@@ -407,9 +412,17 @@
 
 inline bool CSSSelector::isCustomPseudoElement() const
 {
-    return match() == PseudoElement && (pseudoElementType() == PseudoElementUserAgentCustom || pseudoElementType() == PseudoElementWebKitCustom);
+    return match() == PseudoElement
+        && (pseudoElementType() == PseudoElementUserAgentCustom
+            || pseudoElementType() == PseudoElementWebKitCustom
+            || pseudoElementType() == PseudoElementWebKitCustomLegacyPrefixed);
 }
 
+inline bool CSSSelector::isWebKitCustomPseudoElement() const
+{
+    return pseudoElementType() == PseudoElementWebKitCustom || pseudoElementType() == PseudoElementWebKitCustomLegacyPrefixed;
+}
+
 static inline bool pseudoClassIsRelativeToSiblings(CSSSelector::PseudoClassType type)
 {
     return type == CSSSelector::PseudoClassEmpty

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (202065 => 202066)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2016-06-14 22:09:33 UTC (rev 202066)
@@ -280,7 +280,7 @@
                 if (context.element->shadowPseudoId() != context.selector->value())
                     return MatchResult::fails(Match::SelectorFailsLocally);
 
-                if (context.selector->pseudoElementType() == CSSSelector::PseudoElementWebKitCustom && root->type() != ShadowRoot::Type::UserAgent)
+                if (context.selector->isWebKitCustomPseudoElement() && root->type() != ShadowRoot::Type::UserAgent)
                     return MatchResult::fails(Match::SelectorFailsLocally);
             } else
                 return MatchResult::fails(Match::SelectorFailsLocally);

Modified: trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in (202065 => 202066)


--- trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2016-06-14 22:09:33 UTC (rev 202066)
@@ -5,6 +5,8 @@
 #endif
 first-letter
 first-line
+placeholder, PseudoElementWebKitCustom
+-webkit-input-placeholder, PseudoElementWebKitCustomLegacyPrefixed
 -webkit-resizer
 -webkit-scrollbar
 -webkit-scrollbar-button

Modified: trunk/Source/WebCore/css/html.css (202065 => 202066)


--- trunk/Source/WebCore/css/html.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/css/html.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -619,13 +619,13 @@
     word-wrap: break-word;
 }
 
-::-webkit-input-placeholder {
+::placeholder {
     -webkit-text-security: none;
     color: darkGray;
     pointer-events: none !important;
 }
 
-input::-webkit-input-placeholder, isindex::-webkit-input-placeholder {
+input::placeholder, isindex::placeholder {
     white-space: pre;
     word-wrap: normal;
     overflow: hidden;
@@ -752,7 +752,7 @@
     border-color: rgb(188, 188, 188);
 }
 
-textarea::-webkit-input-placeholder {
+textarea::placeholder {
     text-indent: 2px;
 }
 #endif

Modified: trunk/Source/WebCore/features.json (202065 => 202066)


--- trunk/Source/WebCore/features.json	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/features.json	2016-06-14 22:09:33 UTC (rev 202066)
@@ -381,7 +381,7 @@
         "url": "http://dev.w3.org/csswg/selectors-4/#placeholder",
         "specification": "CSS Selectors Level 4",
         "description": "The selector :placeholder-shown matches any input element that has a visible placeholder.",
-        "comment": "Styling the placeholder can be done through the WebKit pseudo-element \"::-webkit-input-placeholder\".",
+        "comment": "Styling the placeholder can be done through the WebKit pseudo-element \"::placeholder\".",
         "contact": {
             "name": "Benjamin Poulain",
             "twitter": "@awfulben",
@@ -684,4 +684,4 @@
         "description": "Declares HTML fragments that can be cloned and inserted into the document by a script."
     }
     ]
-}
\ No newline at end of file
+}

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (202065 => 202066)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2016-06-14 22:09:33 UTC (rev 202066)
@@ -145,7 +145,7 @@
 TextControlPlaceholderElement::TextControlPlaceholderElement(Document& document)
     : HTMLDivElement(divTag, document)
 {
-    setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral));
+    setPseudo(AtomicString("placeholder", AtomicString::ConstructFromLiteral));
     setHasCustomStyleResolveCallbacks();
 }
 

Modified: trunk/Source/WebInspectorUI/ChangeLog (202065 => 202066)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-06-14 22:09:33 UTC (rev 202066)
@@ -1,3 +1,27 @@
+2016-06-14  Benjamin Poulain  <[email protected]>
+
+        Add the unprefixed version of the pseudo element ::placeholder
+        https://bugs.webkit.org/show_bug.cgi?id=158653
+
+        Reviewed by Dean Jackson.
+
+        * UserInterface/Views/FilterBar.css:
+        (.filter-bar > input[type="search"]::placeholder):
+        (.filter-bar > input[type="search"]::-webkit-input-placeholder): Deleted.
+        * UserInterface/Views/FindBanner.css:
+        (.find-banner.console-find-banner > input[type="search"]::placeholder):
+        (.find-banner.console-find-banner > input[type="search"]::-webkit-input-placeholder): Deleted.
+        * UserInterface/Views/GoToLineDialog.css:
+        (.go-to-line-dialog > div > input::placeholder):
+        (.go-to-line-dialog > div > input::-webkit-input-placeholder): Deleted.
+        * UserInterface/Views/OpenResourceDialog.css:
+        (.open-resource-dialog > .field > input::placeholder):
+        (.open-resource-dialog > .field > input::-webkit-input-placeholder): Deleted.
+        * UserInterface/Views/SearchBar.css:
+        (.search-bar > input[type="search"]::placeholder):
+        (.search-bar > input[type="search"]::-webkit-input-placeholder): Deleted.
+        * UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.css:
+
 2016-06-14  Nikita Vasilyev  <[email protected]>
 
         Web Inspector: Introduce --navigation-bar-height CSS variable

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -62,7 +62,7 @@
     height: 22px;
 }
 
-.filter-bar > input[type="search"]::-webkit-input-placeholder {
+.filter-bar > input[type="search"]::placeholder {
     color: hsla(0, 0%, 0%, 0.35);
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -209,7 +209,7 @@
     height: 22px;    
 }
 
-.find-banner.console-find-banner > input[type="search"]::-webkit-input-placeholder {
+.find-banner.console-find-banner > input[type="search"]::placeholder {
     color: hsla(0, 0%, 0%, 0.35);
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/GoToLineDialog.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/GoToLineDialog.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/GoToLineDialog.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -58,7 +58,7 @@
     outline: none;
 }
 
-.go-to-line-dialog > div > input::-webkit-input-placeholder {
+.go-to-line-dialog > div > input::placeholder {
     color: hsl(0, 0%, 52%);
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -61,7 +61,7 @@
     outline: none;
 }
 
-.open-resource-dialog > .field > input::-webkit-input-placeholder {
+.open-resource-dialog > .field > input::placeholder {
     color: hsl(0, 0%, 52%);
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -39,7 +39,7 @@
     height: 22px;
 }
 
-.search-bar > input[type="search"]::-webkit-input-placeholder {
+.search-bar > input[type="search"]::placeholder {
     color: hsla(0, 0%, 0%, 0.35);
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.css (202065 => 202066)


--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.css	2016-06-14 22:02:34 UTC (rev 202065)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.css	2016-06-14 22:09:33 UTC (rev 202066)
@@ -89,7 +89,7 @@
     line-height: 15px;
 }
 
-.visual-style-property-container .visual-style-comma-separated-keyword-item-editor::-webkit-input-placeholder,
+.visual-style-property-container .visual-style-comma-separated-keyword-item-editor::placeholder,
 .visual-style-property-container.comma-separated-keyword-editor > .visual-style-property-value-container > .visual-style-comma-separated-keyword-list > .visual-style-comma-separated-keyword-item > .titles > .subtitle {
     font-size: 10px;
     color: hsla(0, 0%, 100%, 0.7);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to