Bug 118162 - CSS: Implement the :placeholder-shown pseudo-class from Selectors Level 4
Summary: CSS: Implement the :placeholder-shown pseudo-class from Selectors Level 4
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks: 118122
  Show dependency treegraph
 
Reported: 2013-06-27 18:17 PDT by James Craig
Modified: 2014-08-24 09:34 PDT (History)
9 users (show)

See Also:


Attachments
Patch (97.62 KB, patch)
2014-08-19 19:08 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (100.15 KB, patch)
2014-08-20 12:47 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (99.31 KB, patch)
2014-08-20 17:52 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Craig 2013-06-27 18:17:37 PDT
CSS: Implement the :placeholder-shown pseudo-class from Selectors Level 4

:placeholder-shown

http://dev.w3.org/csswg/selectors4/#rw-pseudos
Comment 1 Benjamin Poulain 2014-08-19 19:08:55 PDT
Created attachment 236847 [details]
Patch
Comment 2 WebKit Commit Bot 2014-08-19 19:10:13 PDT
Attachment 236847 [details] did not pass style-queue:


ERROR: Source/WebCore/cssjit/SelectorCompiler.cpp:2832:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 31 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Benjamin Poulain 2014-08-20 01:39:56 PDT
I'll fix Windows tomorrow.
Comment 4 Benjamin Poulain 2014-08-20 12:47:04 PDT
Created attachment 236889 [details]
Patch
Comment 5 WebKit Commit Bot 2014-08-20 12:49:16 PDT
Attachment 236889 [details] did not pass style-queue:


ERROR: Source/WebCore/cssjit/SelectorCompiler.cpp:2832:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 31 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Timothy Hatcher 2014-08-20 13:54:42 PDT
I assume this selector to style the magnifying glass would work with this patch:

.filter-bar > input[type="search"]:placeholder-shown::-webkit-search-decoration

That is how I plan to use it in the Web Inspector.
Comment 7 Antti Koivisto 2014-08-20 14:58:38 PDT
Comment on attachment 236889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=236889&action=review

> Source/WebCore/html/HTMLTextFormControlElement.cpp:169
> +    setNeedsStyleRecalc();

Why explicit setNeedsStyleRecalc? Shouldn't style change trigger recalc?

> Source/WebCore/html/HTMLTextFormControlElement.cpp:175
> +        if (m_isPlaceholderVisible)
> +            placeholder->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock, true);
> +        else
> +            placeholder->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);

I would use

placeholder->setInlineStyleProperty(CSSPropertyDisplay, m_isPlaceholderVisible ? CSSValueBlock : CSSValueNone, true);

> Source/WebCore/html/HTMLTextFormControlElement.cpp:643
> +        placeholder->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible : CSSValueHidden);

This doesn't look like it would compile.

> Source/WebCore/html/HTMLTextFormControlElement.cpp:650
> +            placeholder->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible : CSSValueHidden);

Nor does this.
Comment 8 Benjamin Poulain 2014-08-20 17:52:46 PDT
Created attachment 236904 [details]
Patch
Comment 9 WebKit Commit Bot 2014-08-20 17:56:33 PDT
Attachment 236904 [details] did not pass style-queue:


ERROR: Source/WebCore/cssjit/SelectorCompiler.cpp:2832:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 31 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Benjamin Poulain 2014-08-20 20:33:39 PDT
Committed r172826: <http://trac.webkit.org/changeset/172826>
Comment 11 Benjamin Poulain 2014-08-20 20:37:27 PDT
(In reply to comment #7)
> (From update of attachment 236889 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=236889&action=review
> 
> > Source/WebCore/html/HTMLTextFormControlElement.cpp:169
> > +    setNeedsStyleRecalc();
> 
> Why explicit setNeedsStyleRecalc? Shouldn't style change trigger recalc?

Unfortunately we also need that one.

The style change is done on the shadow DOM. We need that setNeedsStyleRecalc() to update the style of the current element based on :placeholder-shown.