Bug 106418 - Implement CSSGroupingRule for @host @-rules and @supports.
Summary: Implement CSSGroupingRule for @host @-rules and @supports.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Takashi Sakamoto
URL:
Keywords:
Depends on:
Blocks: 102344 104822
  Show dependency treegraph
 
Reported: 2013-01-08 22:08 PST by Takashi Sakamoto
Modified: 2013-01-10 23:09 PST (History)
15 users (show)

See Also:


Attachments
Patch (27.65 KB, patch)
2013-01-09 00:02 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
WIP (27.31 KB, patch)
2013-01-09 22:24 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (33.92 KB, patch)
2013-01-10 00:33 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
WIP for checking Windows BuildBot (35.46 KB, patch)
2013-01-10 21:51 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch for landing (35.40 KB, patch)
2013-01-10 22:50 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi Sakamoto 2013-01-08 22:08:04 PST
These implementations is almost the same and now CSSHostRule, which is also the same as the implementations, will be added.
So we need to refactor these implementations.
Comment 1 Takashi Sakamoto 2013-01-09 00:02:39 PST
Created attachment 181865 [details]
Patch
Comment 2 Pablo Flouret 2013-01-09 09:08:55 PST
Nice. You probably want to name the class CSSGroupingRule, as that's the name on the spec (http://dev.w3.org/csswg/css3-conditional/#cssgroupingrule)
Comment 3 Dimitri Glazkov (Google) 2013-01-09 09:37:38 PST
(In reply to comment #2)
> Nice. You probably want to name the class CSSGroupingRule, as that's the name on the spec (http://dev.w3.org/csswg/css3-conditional/#cssgroupingrule)

I like this suggestion.
Comment 4 Alexey Proskuryakov 2013-01-09 09:39:55 PST
> class CSSMediaRule and class WebKitCSSRegionRule can share most of their implementations

I have doubts whether these classes are semantically close enough to share a public base class. This refactoring looks like it makes code much more confusing.

Also, inlining bodies of these large functions just so that you could use templates is not good.
Comment 5 Dimitri Glazkov (Google) 2013-01-09 09:42:48 PST
Comment on attachment 181865 [details]
Patch

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

> Source/WebCore/ChangeLog:38
> +        is "const" method, needs static_cast and const_cast.

Does it need to be a const method?
Comment 6 Dimitri Glazkov (Google) 2013-01-09 09:44:15 PST
(In reply to comment #4)
> > class CSSMediaRule and class WebKitCSSRegionRule can share most of their implementations
> 
> I have doubts whether these classes are semantically close enough to share a public base class. This refactoring looks like it makes code much more confusing.

I think the idea of sharing the code for all grouping rules is a good one. Not sure about this specific refactoring yet.

> Also, inlining bodies of these large functions just so that you could use templates is not good.
Comment 7 Dimitri Glazkov (Google) 2013-01-09 10:06:23 PST
Comment on attachment 181865 [details]
Patch

I agree with Alexey, this patch looks sad because of gratuitous templating. The thing is, you almost don't need these templates and I am confident this refactoring can be done without them.
Comment 8 Antti Koivisto 2013-01-09 12:40:18 PST
Please don't try to use this for WebKitCSSRegionRule if it really doesn't share the interface. Also definitely no templates.

Please explain in ChangeLog the real reason for doing this (@supports rules).
Comment 9 Dimitri Glazkov (Google) 2013-01-09 12:41:02 PST
(In reply to comment #8)
> Please explain in ChangeLog the real reason for doing this (@supports rules).

and @host rules.
Comment 10 Takashi Sakamoto 2013-01-09 22:24:13 PST
Created attachment 182065 [details]
WIP
Comment 11 Takashi Sakamoto 2013-01-10 00:33:26 PST
Created attachment 182080 [details]
Patch
Comment 12 Takashi Sakamoto 2013-01-10 00:37:30 PST
Thank you for reviewing.

I uploaded a new patch. The differences between the previous one and this are:

- No template,
- Add @supports and @host @-rules to ChangeLog.
- Add the spec URLs to ChangeLog.

Talking about @region,

interface CSSRegionStyleRule : CSSRule {
  attribute DOMString selectorText;
  readonly attribute CSSRuleList cssRules;
  unsigned long insertRule(DOMString rule,  unsigned long index)
    raises(DOMException);
  void deleteRule(unsigned long index)
    raises(DOMException);
};

c.f. http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule

I think, this is the same as:

interface CSSGroupingRule : CSSRule {
    readonly attribute CSSRuleList cssRules;
    unsigned long insertRule (DOMString rule, unsigned long index);
    void deleteRule (unsigned long index);
}

http://www.w3.org/TR/2012/WD-css3-conditional-20121213/#the-cssgroupingrule-interface

Best regards,
Takashi Sakamoto
Comment 13 Build Bot 2013-01-10 01:00:26 PST
Comment on attachment 182080 [details]
Patch

Attachment 182080 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/15766738
Comment 14 Antti Koivisto 2013-01-10 02:19:16 PST
Comment on attachment 182080 [details]
Patch

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

Looks good.

> Source/WebCore/ChangeLog:14
> +        Since @supports and @host @-rules are dervied from CSSGroupingRule:
> +        http://www.w3.org/TR/2012/WD-css3-conditional/#the-cssgroupingrule-interface
> +        https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#css-host-rule-interface
> +        we need CSSGroupingRule (WK102344 and WK104822).
> +        Since @media is also derived from CSSGroupingRule and @region has the
> +        same interface as CSSGroupingRule, modify to use CSSGroupingRule:
> +        http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule

This is bit confusing. The reason you are adding CSSGroupingRule is to share code between CSSMediaRule, CSSSupportsRule and CSSHostRule. It would be good to spell it out.

> Source/WebCore/WebCore.vcproj/WebCore.vcproj:36179
> +				<FileConfiguration
> +					Name="Debug|Win32"
> +					ExcludedFromBuild="true"
> +					>
> +					<Tool

You don't need this stuff (probably why windows build is failing).

> Source/WebCore/css/CSSGroupingRule.cpp:46
> +CSSGroupingRule::CSSGroupingRule(StyleRuleBlock* groupRule, CSSStyleSheet* parent)

For consistency we should probably rename StyleRuleBlock -> StyleRuleGroup in another patch.

> Source/WebCore/css/CSSMediaRule.cpp:50
> +    return static_cast<const StyleRuleMedia*>(m_groupRule.get())->mediaQueries();

You might want to add inlined accessors that do the casting.

> Source/WebCore/css/WebKitCSSRegionRule.cpp:55
> +    result.append(static_cast<const StyleRuleRegion*>(m_groupRule.get())->selectorList().selectorsText());

For this too.
Comment 15 Takashi Sakamoto 2013-01-10 21:51:47 PST
Created attachment 182265 [details]
WIP for checking Windows BuildBot
Comment 16 Takashi Sakamoto 2013-01-10 22:02:53 PST
Comment on attachment 182080 [details]
Patch

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

Thank you for reviewing.

>> Source/WebCore/ChangeLog:14
>> +        http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule
> 
> This is bit confusing. The reason you are adding CSSGroupingRule is to share code between CSSMediaRule, CSSSupportsRule and CSSHostRule. It would be good to spell it out.

I see. I added the reason to the top of the description.

>> Source/WebCore/WebCore.vcproj/WebCore.vcproj:36179
>> +					<Tool
> 
> You don't need this stuff (probably why windows build is failing).

I found I missed CSSAllInOne.cpp. I'm now checking whether only the mistake (CSSAllInOne) causes windows build failure or not.

>> Source/WebCore/css/CSSGroupingRule.cpp:46
>> +CSSGroupingRule::CSSGroupingRule(StyleRuleBlock* groupRule, CSSStyleSheet* parent)
> 
> For consistency we should probably rename StyleRuleBlock -> StyleRuleGroup in another patch.

I see. If no bug for the renaming, I will file a new bug.

>> Source/WebCore/css/CSSMediaRule.cpp:50
>> +    return static_cast<const StyleRuleMedia*>(m_groupRule.get())->mediaQueries();
> 
> You might want to add inlined accessors that do the casting.

I see. Thanks. Done.

>> Source/WebCore/css/WebKitCSSRegionRule.cpp:55
>> +    result.append(static_cast<const StyleRuleRegion*>(m_groupRule.get())->selectorList().selectorsText());
> 
> For this too.

Done.
Comment 17 Takashi Sakamoto 2013-01-10 22:50:40 PST
Created attachment 182268 [details]
Patch for landing
Comment 18 WebKit Review Bot 2013-01-10 23:09:52 PST
Comment on attachment 182268 [details]
Patch for landing

Clearing flags on attachment: 182268

Committed r139409: <http://trac.webkit.org/changeset/139409>
Comment 19 WebKit Review Bot 2013-01-10 23:09:59 PST
All reviewed patches have been landed.  Closing bug.