Bug 137824

Summary: Use is<>() / downcast<>() for StyleImage
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Layout and RenderingAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Enhancement CC: commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 137424    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Chris Dumez 2014-10-17 10:19:13 PDT
Use is<>() / downcast<>() for StyleImage.
Comment 1 Chris Dumez 2014-10-17 10:42:33 PDT
Created attachment 240021 [details]
Patch
Comment 2 Chris Dumez 2014-10-17 11:45:22 PDT
Created attachment 240027 [details]
Patch
Comment 3 Andreas Kling 2014-10-17 12:00:05 PDT
Comment on attachment 240027 [details]
Patch

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

r=me

> Source/WebCore/css/CSSCursorImageValue.cpp:67
> +    if (is<StylePendingImage>(m_image.get()))

Can we avoid the .get() here? An overload for RefPtr? Maybe that's overkill.

> Source/WebCore/css/CSSImageSetValue.cpp:193
> +    CachedResource* cachedResource = downcast<StyleCachedImageSet>(*m_imageSet).cachedImage();

cachedImage() returns a CachedImage*, and we store it in a CachedResource*, losing some type knowledge.
It doesn't actually matter in this case, but I'm commenting on it anyway because this is one reason I like auto.
Comment 4 Chris Dumez 2014-10-17 13:23:21 PDT
Comment on attachment 240027 [details]
Patch

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

>> Source/WebCore/css/CSSCursorImageValue.cpp:67
>> +    if (is<StylePendingImage>(m_image.get()))
> 
> Can we avoid the .get() here? An overload for RefPtr? Maybe that's overkill.

It is actually on my TODO list. There are actually not that many call sites that would benefit from it so it is not very high priority. Would still be nice to have though.

>> Source/WebCore/css/CSSImageSetValue.cpp:193
>> +    CachedResource* cachedResource = downcast<StyleCachedImageSet>(*m_imageSet).cachedImage();
> 
> cachedImage() returns a CachedImage*, and we store it in a CachedResource*, losing some type knowledge.
> It doesn't actually matter in this case, but I'm commenting on it anyway because this is one reason I like auto.

Ok, I will use tighter typing. (not a big fan of auto here because the type is not obvious but I understand it would help avoid this kind of loose typing mistakes).
Comment 5 Chris Dumez 2014-10-17 13:28:31 PDT
Created attachment 240033 [details]
Patch
Comment 6 WebKit Commit Bot 2014-10-17 14:12:47 PDT
Comment on attachment 240033 [details]
Patch

Clearing flags on attachment: 240033

Committed r174836: <http://trac.webkit.org/changeset/174836>
Comment 7 WebKit Commit Bot 2014-10-17 14:12:51 PDT
All reviewed patches have been landed.  Closing bug.