Bug 136774

Summary: Generate toCSSStyleSheet using STYLE_SHEET_TYPE_CASTS
Product: WebKit Reporter: Gyuyoung Kim <gyuyoung.kim>
Component: WebKit Misc.Assignee: Gyuyoung Kim <gyuyoung.kim>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 136773    
Attachments:
Description Flags
Patch
none
Patch for landing
none
Patch for landing none

Description Gyuyoung Kim 2014-09-11 23:33:41 PDT
As a step to use toFoo, this patch introduces STYLE_SHEET_TYPE_CASTS for toCSSStyleSheet(). This will help to detect wrong type cast. Additonally this patch helps to remove argument type of RefPtr.
Comment 1 Gyuyoung Kim 2014-09-11 23:34:26 PDT
Created attachment 238017 [details]
Patch
Comment 2 Gyuyoung Kim 2014-09-13 21:03:07 PDT
CC'ing Darin.
Comment 3 Darin Adler 2014-09-14 12:37:37 PDT
Comment on attachment 238017 [details]
Patch

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

> Source/WebCore/dom/ProcessingInstruction.cpp:225
> -        static_cast<CSSStyleSheet*>(m_sheet.get())->contents().parseString(sheet);
> +        toCSSStyleSheet(m_sheet)->contents().parseString(sheet);

Since we are assuming m_sheet is non-null, it would be better style to write:

    toCSSStyleSheet(*m_sheet)->contents()

This ensures we don't compile in bogus null checks, although it’s possible the compiler is smart enough to not compile them anyway.

> Source/WebCore/dom/ProcessingInstruction.cpp:238
> -        static_cast<CSSStyleSheet*>(m_sheet.get())->contents().checkLoaded();
> +        toCSSStyleSheet(m_sheet)->contents().checkLoaded();

Ditto.

> Source/WebCore/inspector/InspectorCSSAgent.cpp:686
>              StyleSheet* styleSheet = list->item(i);

Should be StyleSheet& instead of StyleSheet*.
Comment 4 Gyuyoung Kim 2014-09-14 17:20:11 PDT
Created attachment 238096 [details]
Patch for landing
Comment 5 Gyuyoung Kim 2014-09-14 19:31:31 PDT
Created attachment 238101 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2014-09-14 21:07:42 PDT
Comment on attachment 238101 [details]
Patch for landing

Clearing flags on attachment: 238101

Committed r173611: <http://trac.webkit.org/changeset/173611>
Comment 7 WebKit Commit Bot 2014-09-14 21:07:45 PDT
All reviewed patches have been landed.  Closing bug.