Bug 100826

Summary: [Shadow] Using isUnknownPseudoElement() for shadow pseudo id seems confusing
Product: WebKit Reporter: Shinya Kawanaka <shinyak>
Component: CSSAssignee: Shinya Kawanaka <shinyak>
Status: RESOLVED FIXED    
Severity: Normal CC: allan.jensen, cmarcelo, dglazkov, macpherson, menard, tasak, webcomponents-bugzilla, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 100919, 101170    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Shinya Kawanaka 2012-10-31 01:06:35 PDT
We would like to have more descriptive name for it.
Comment 1 Dimitri Glazkov (Google) 2012-10-31 10:34:22 PDT
Not sure I agree. The name is pretty clear in that the pseudo element is unknown at the time of parsing the selector. It could be either a custom pseudo element (starts with "x-", a WebKit-specific custom pseudo element (starts with "-webkit-"), or some totally unknown thing.

Ohhh... I think I understand what you're saying. Since we have these three choices and they are knowable at the time of parsing, we might distinguish between them. Right?
Comment 2 Shinya Kawanaka 2012-10-31 18:45:56 PDT
Yeah.. Actually it is actually used for shadowPseudoId, etc.
We can distinguish some specific types, so we should use some good name instead of UNKNOWN.
It's sometimes known.
Comment 3 Takashi Sakamoto 2012-11-01 19:03:17 PDT
(In reply to comment #2)
> Yeah.. Actually it is actually used for shadowPseudoId, etc.
> We can distinguish some specific types, so we should use some good name instead of UNKNOWN.
> It's sometimes known.

I'm not sure what to do. However, I would like to ask one question. If we use some pseudo type for shadow pseudo ids or custom pseudo, i.e. -webkit or x-, we need unknown ids, e.g. -UNKNOWN-UNKNOWN?

I have to check CSS spec. However I'm just interested in your idea about such completely unknown ids.
Comment 4 Shinya Kawanaka 2012-11-01 19:35:09 PDT
For completely UNKNOWN ids, we can skip using that CSS rule, right? It's because it won't match anything.
When parsing succeeded, we should already know the type of id.
Comment 5 Dimitri Glazkov (Google) 2012-11-01 19:50:22 PDT
(In reply to comment #4)
> For completely UNKNOWN ids, we can skip using that CSS rule, right? It's because it won't match anything.
> When parsing succeeded, we should already know the type of id.

Yes, that's the win I see.

In terms of naming, I see three types of "unknown" pseudo-elements:

1) CustomPseudoElement --> CUSTOM
2) WebKitPseudoElement --> WEBKIT_CUSTOM
3) UnknownPseudoElement --> UNKNOWN

The interesting bit is that WebKitCustomElement should only match attributes that were set by the UA. We should _not_ allow any random Bob set "-webkit-slider-thumb" on their div and have it matched. That would be bad.
Comment 6 Shinya Kawanaka 2012-11-04 21:35:39 PST
Created attachment 172267 [details]
Patch
Comment 7 WebKit Review Bot 2012-11-05 01:01:41 PST
Comment on attachment 172267 [details]
Patch

Attachment 172267 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14719717

New failing tests:
css3/selectors3/html/css3-modsel-161.html
fast/box-sizing/percentage-height.html
css3/selectors3/xhtml/css3-modsel-177b.xml
css3/selectors3/html/css3-modsel-177b.html
fast/dom/shadow/shadow-pseudo-id.html
css3/selectors3/xml/css3-modsel-161.xml
css3/selectors3/xml/css3-modsel-177b.xml
fast/selectors/177b.html
css3/selectors3/xhtml/css3-modsel-161.xml
Comment 8 Build Bot 2012-11-05 07:59:53 PST
Comment on attachment 172267 [details]
Patch

Attachment 172267 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14745151

New failing tests:
css3/selectors3/html/css3-modsel-161.html
fast/box-sizing/percentage-height.html
css3/selectors3/xhtml/css3-modsel-177b.xml
css3/selectors3/html/css3-modsel-177b.html
css3/selectors3/xml/css3-modsel-161.xml
css3/selectors3/xml/css3-modsel-177b.xml
fast/selectors/177b.html
css3/selectors3/xhtml/css3-modsel-161.xml
Comment 9 Shinya Kawanaka 2012-11-05 17:47:42 PST
Created attachment 172454 [details]
Patch
Comment 10 Hajime Morrita 2012-11-05 17:55:49 PST
Comment on attachment 172267 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        We used isUnknownPseudoElement() for these 3 meanings: 1) an element is custom pseudo element (starting with 'x-'),

s/a element is/the element is an/
By the way, what is "custom pseudo element"? Is it a standard-mentioned name?

> Source/WebCore/css/CSSParser.cpp:10111
> +    if (specifiers->isCustomPseudoElement() || specifiers->isWebKitCustomPseudoElement()) {

Looks like this combination is frequently used and better to have a shortcut method.
Otherwise this change makes the code more complex instead of less-confusing.

> Source/WebCore/css/CSSSelectorList.cpp:204
> +        return selector->isUnknownPseudoElement() || selector->isWebKitCustomPseudoElement() || selector->isCustomPseudoElement();

Let's define a CSSSelector method instead of scattering this kind of named logic here and there.

> LayoutTests/fast/dom/shadow/shadow-pseudo-id.html:30
> +</script>

Can we make this test code more descriptive? It's unclear what this test is trying to exercise,
which will make it hard to diagnose future regression.
Comment 11 Dimitri Glazkov (Google) 2012-11-05 17:56:43 PST
Comment on attachment 172454 [details]
Patch

unknown -> invalid?
Comment 12 Shinya Kawanaka 2012-11-05 18:02:30 PST
(In reply to comment #10)
> By the way, what is "custom pseudo element"? Is it a standard-mentioned name?

I've taken it from ShadowDOM spec.
https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#custom-pseudo-elements
Comment 13 Shinya Kawanaka 2012-11-05 18:13:49 PST
I would like to use 'AuthorCustomPseudoElement' instead of 'CustomPseudoElement',
and use 'CustomPseudoElement' as (AuthorCustomPseudoElement or WebKitCustomPseudoElement)...

Someone can come up with a better name?
Comment 14 Dimitri Glazkov (Google) 2012-11-05 18:17:23 PST
(In reply to comment #13)
> I would like to use 'AuthorCustomPseudoElement' instead of 'CustomPseudoElement',
> and use 'CustomPseudoElement' as (AuthorCustomPseudoElement or WebKitCustomPseudoElement)...
> 
> Someone can come up with a better name?

I don't think prefixing the name with Author makes it less clear. The fact that there are WebKit-specific custom pseudo elements is where we need to dig, not the other way around.

UserAgentPseudoElement?

Also, I really like the "invalid" name. It makes a lot more sense than "unqueriable". It's un-queriable because it's invalid. Better statement of purpose.
Comment 15 Shinya Kawanaka 2012-11-05 18:24:25 PST
Hmm... But we have :invalid pseudo-class already :-(
Comment 16 Dimitri Glazkov (Google) 2012-11-05 18:33:59 PST
(In reply to comment #15)
> Hmm... But we have :invalid pseudo-class already :-(

That's ok. That's different. Look here: http://dev.w3.org/csswg/selectors4/#invalid
Comment 17 Shinya Kawanaka 2012-11-05 20:03:42 PST
Created attachment 172474 [details]
Patch
Comment 18 Shinya Kawanaka 2012-11-05 20:04:58 PST
Another try
Comment 19 Hajime Morrita 2012-11-05 22:18:50 PST
Comment on attachment 172474 [details]
Patch

Looks fine. wait test green being show up.
Comment 20 WebKit Review Bot 2012-11-06 02:44:14 PST
Comment on attachment 172474 [details]
Patch

Clearing flags on attachment: 172474

Committed r133577: <http://trac.webkit.org/changeset/133577>
Comment 21 WebKit Review Bot 2012-11-06 02:44:19 PST
All reviewed patches have been landed.  Closing bug.