Bug 137364

Summary: Use is<>() / downcast<>() for CSSRule subclasses
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: CSSAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, gyuyoung.kim, jake.nielsen.webkit, kling, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 137056    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

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.