Bug 137824 - Use is<>() / downcast<>() for StyleImage
Summary: Use is<>() / downcast<>() for StyleImage
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Chris Dumez
URL:
Keywords:
Depends on: 137424
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-17 10:19 PDT by Chris Dumez
Modified: 2014-10-17 14:12 PDT (History)
1 user (show)

See Also:


Attachments
Patch (21.59 KB, patch)
2014-10-17 10:42 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (21.59 KB, patch)
2014-10-17 11:45 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (21.59 KB, patch)
2014-10-17 13:28 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-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.