Bug 138310 - Add parsing for :role()
Summary: Add parsing for :role()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 138196
  Show dependency treegraph
 
Reported: 2014-11-03 06:16 PST by Sukolsak Sakshuwong
Modified: 2014-11-17 18:21 PST (History)
6 users (show)

See Also:


Attachments
Patch (7.00 KB, patch)
2014-11-03 06:21 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Patch (16.91 KB, patch)
2014-11-15 16:05 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Test for case sensitivity (17.53 KB, patch)
2014-11-15 16:32 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Remove doubled changelog (17.08 KB, patch)
2014-11-17 17:06 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sukolsak Sakshuwong 2014-11-03 06:16:34 PST
See https://bugs.webkit.org/show_bug.cgi?id=138196
Comment 1 Sukolsak Sakshuwong 2014-11-03 06:21:36 PST
Created attachment 240847 [details]
Patch
Comment 2 Benjamin Poulain 2014-11-04 23:41:56 PST
Comment on attachment 240847 [details]
Patch

First round or review. Sorry for the delay, I have a huge backlog on my review queue :(

The patch looks good but:
-The new selector should be under ENABLE(CSS_SELECTORS_LEVEL4). Sorry I did not mention that by mail, :role() is part of the new selectors we are adding for Level 4 :(
-You should also include test for things that can go wrong, invalid input. For example, :role(), :role()), :role(25), :role(a, b), etc. We need to ensure we do not generate valid CSSSelector for invalid input.
-You should include tests covering uppercase and lowercase. We still need to define how case-sensitivity will work with :role(), in the meantime we should make sure the behavior is tested so that some tests would break when the behavior changes.
-I have recently added the test fast/selectors/invalid-functional-pseudo-class.html for functional pseudo class. Can you add :role() there too and extend the results?

I am a bit surprised you did not need to modify the parser.
Comment 3 Benjamin Poulain 2014-11-14 20:04:43 PST
Any update? I can help if you have questions.
Comment 4 Sukolsak Sakshuwong 2014-11-15 16:05:37 PST
Created attachment 241664 [details]
Patch
Comment 5 Sukolsak Sakshuwong 2014-11-15 16:32:59 PST
Created attachment 241666 [details]
Test for case sensitivity
Comment 6 Sukolsak Sakshuwong 2014-11-15 16:39:58 PST
Sorry for the delay. I was busy with school work. Thank you very much for the review.

(In reply to comment #2)
> -The new selector should be under ENABLE(CSS_SELECTORS_LEVEL4). Sorry I did
> not mention that by mail, :role() is part of the new selectors we are adding
> for Level 4 :(

Done.

> -You should also include test for things that can go wrong, invalid input.
> For example, :role(), :role()), :role(25), :role(a, b), etc. We need to
> ensure we do not generate valid CSSSelector for invalid input.

Done.

> -You should include tests covering uppercase and lowercase. We still need to
> define how case-sensitivity will work with :role(), in the meantime we
> should make sure the behavior is tested so that some tests would break when
> the behavior changes.

Done?

> -I have recently added the test
> fast/selectors/invalid-functional-pseudo-class.html for functional pseudo
> class. Can you add :role() there too and extend the results?

Done.

> I am a bit surprised you did not need to modify the parser.

That seemed to be wrong. The first patch generated valid CSSSelector for invalid input such as :role(42).
Comment 7 Darin Adler 2014-11-16 19:58:14 PST
Comment on attachment 241666 [details]
Test for case sensitivity

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

> LayoutTests/ChangeLog:18
> +        Add parsing for :role()
> +        https://bugs.webkit.org/show_bug.cgi?id=138310

Doubled change log here.
Comment 8 Benjamin Poulain 2014-11-17 16:20:19 PST
Comment on attachment 241666 [details]
Test for case sensitivity

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

Looks great. Some minor comments.

The tests look good, you'll just need to clean up the changelog.

> Source/WebCore/css/CSSGrammar.y.in:67
> +    case ROLEFUNCTION:

I don't think you need to define a new token type.  The type "FUNCTION should work.

> Source/WebCore/css/CSSParser.cpp:10703
> +            m_token = ROLEFUNCTION;

You still need this, but I think the token type could be simply FUNCTION.

> Source/WebCore/css/CSSSelector.h:162
> +            PseudoClassRole,

Uh, I should really sort this enum some day :)
Comment 9 Sukolsak Sakshuwong 2014-11-17 16:57:42 PST
Thank you for the review.

(In reply to comment #7)
> > LayoutTests/ChangeLog:18
> > +        Add parsing for :role()
> > +        https://bugs.webkit.org/show_bug.cgi?id=138310
> 
> Doubled change log here.

I will fix this.

(In reply to comment #8)
> > Source/WebCore/css/CSSGrammar.y.in:67
> > +    case ROLEFUNCTION:
> 
> I don't think you need to define a new token type.  The type "FUNCTION
> should work.
> 
> > Source/WebCore/css/CSSParser.cpp:10703
> > +            m_token = ROLEFUNCTION;
> 
> You still need this, but I think the token type could be simply FUNCTION.

If I use "FUNCTION", :role(42) will be valid because there is

"| ':' FUNCTION maybe_space maybe_unary_operator INTEGER maybe_space ')' {"

in the grammar.
Comment 10 Sukolsak Sakshuwong 2014-11-17 17:06:16 PST
Created attachment 241754 [details]
Remove doubled changelog
Comment 11 Benjamin Poulain 2014-11-17 17:41:56 PST
(In reply to comment #9)
> > I don't think you need to define a new token type.  The type "FUNCTION
> > should work.
> > 
> > > Source/WebCore/css/CSSParser.cpp:10703
> > > +            m_token = ROLEFUNCTION;
> > 
> > You still need this, but I think the token type could be simply FUNCTION.
> 
> If I use "FUNCTION", :role(42) will be valid because there is
> 
> "| ':' FUNCTION maybe_space maybe_unary_operator INTEGER maybe_space ')' {"
> 
> in the grammar.

Oh, of course. I was wondering how :lang() got away with it...but Dhi recently changed lang to have its own token type.
Comment 12 Benjamin Poulain 2014-11-17 17:42:28 PST
Comment on attachment 241754 [details]
Remove doubled changelog

Let's do it!
Comment 13 WebKit Commit Bot 2014-11-17 18:21:39 PST
Comment on attachment 241754 [details]
Remove doubled changelog

Clearing flags on attachment: 241754

Committed r176241: <http://trac.webkit.org/changeset/176241>
Comment 14 WebKit Commit Bot 2014-11-17 18:21:47 PST
All reviewed patches have been landed.  Closing bug.