Bug 137364 - Use is<>() / downcast<>() for CSSRule subclasses
Summary: Use is<>() / downcast<>() for CSSRule subclasses
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on: 137056
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-02 15:37 PDT by Chris Dumez
Modified: 2014-10-06 15:20 PDT (History)
6 users (show)

See Also:


Attachments
Patch (13.06 KB, patch)
2014-10-02 16:23 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.79 KB, patch)
2014-10-02 17:33 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.50 KB, patch)
2014-10-02 18:03 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-10-02 15:37:06 PDT
Use is<>() / downcast<>() for CSSRule subclasses
Comment 1 Chris Dumez 2014-10-02 16:23:03 PDT
Created attachment 239152 [details]
Patch
Comment 2 Benjamin Poulain 2014-10-02 17:20:22 PDT
Comment on attachment 239152 [details]
Patch

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

> Source/WebCore/css/CSSFontFaceRule.h:54
> +SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSFontFaceRule, FONT_FACE_RULE)

I would prefere CSSRule::FONT_FACE_RULE over FONT_FACE_RULE. A little more typing but I like that we follow the scope.

> Source/WebCore/css/InspectorCSSOMWrappers.cpp:64
> +            collect(downcast<CSSMediaRule>(cssRule));

cssRule is not null, shouldn't you use &downcast<CSSMediaRule>(*cssRule)) by you own rules?

> Source/WebCore/css/InspectorCSSOMWrappers.cpp:68
> -            collect(toCSSSupportsRule(cssRule));
> +            collect(downcast<CSSSupportsRule>(cssRule));

ditto

> Source/WebCore/css/InspectorCSSOMWrappers.cpp:73
> -            collect(toWebKitCSSRegionRule(cssRule));
> +            collect(downcast<WebKitCSSRegionRule>(cssRule));

ditto

> Source/WebCore/inspector/InspectorCSSAgent.cpp:432
>  CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule)
>  {
> -    if (rule->type() != CSSRule::STYLE_RULE)
> +    ASSERT(rule);

It would be nice to fix the call site to pass a CSSRule&, then remove the assertion.
Comment 3 Chris Dumez 2014-10-02 17:24:19 PDT
Comment on attachment 239152 [details]
Patch

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

>> Source/WebCore/css/CSSFontFaceRule.h:54
>> +SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSFontFaceRule, FONT_FACE_RULE)
> 
> I would prefere CSSRule::FONT_FACE_RULE over FONT_FACE_RULE. A little more typing but I like that we follow the scope.

Hmm, I already went the other way for http://trac.webkit.org/changeset/174236/trunk/Source/WebCore/css/CSSBasicShapes.h
But why not.

>> Source/WebCore/css/InspectorCSSOMWrappers.cpp:64
>> +            collect(downcast<CSSMediaRule>(cssRule));
> 
> cssRule is not null, shouldn't you use &downcast<CSSMediaRule>(*cssRule)) by you own rules?

I think you are confusing with is<>(). There is no null check in the downcast<>().

>> Source/WebCore/inspector/InspectorCSSAgent.cpp:432
>> +    ASSERT(rule);
> 
> It would be nice to fix the call site to pass a CSSRule&, then remove the assertion.

I hesitated :) Ok, will do it.
Comment 4 Chris Dumez 2014-10-02 17:33:49 PDT
Created attachment 239163 [details]
Patch
Comment 5 Chris Dumez 2014-10-02 18:03:08 PDT
Created attachment 239167 [details]
Patch
Comment 6 WebKit Commit Bot 2014-10-02 18:40:21 PDT
Comment on attachment 239167 [details]
Patch

Clearing flags on attachment: 239167

Committed r174253: <http://trac.webkit.org/changeset/174253>
Comment 7 WebKit Commit Bot 2014-10-02 18:40:26 PDT
All reviewed patches have been landed.  Closing bug.