Bug 128915 - Add type-checked casts for StyleImage and subclasses
Summary: Add type-checked casts for StyleImage and 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: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on: 128671
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-17 09:38 PST by David Kilzer (:ddkilzer)
Modified: 2014-02-18 13:22 PST (History)
16 users (show)

See Also:


Attachments
Patch v1 (17.70 KB, patch)
2014-02-17 09:49 PST, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2014-02-17 09:38:40 PST
Add type-checked casts for StyleImage and its subclasses.
Comment 1 David Kilzer (:ddkilzer) 2014-02-17 09:49:50 PST
Created attachment 224390 [details]
Patch v1
Comment 2 Andreas Kling 2014-02-18 10:47:58 PST
Comment on attachment 224390 [details]
Patch v1

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

Sweet patch, just some stylistic comments.

> Source/WebCore/css/CSSCursorImageValue.cpp:198
> +    return toStyleCachedImage(m_image.get())->cachedImage()->url();

Since we're sure that m_image can't be null, I'd write this like so:
return toStyleCachedImage(*m_image).cachedImage()->url();

> Source/WebCore/css/CSSImageSetValue.cpp:64
> +        toStyleCachedImageSet(m_imageSet.get())->clearImageSetValue();

Same here.

> Source/WebCore/css/CSSImageSetValue.cpp:194
> +    CachedResource* cachedResource = toStyleCachedImageSet(m_imageSet.get())->cachedImage();

And here.

> Source/WebCore/css/CSSImageValue.cpp:108
> +    CachedResource* cachedResource = toStyleCachedImage(m_image.get())->cachedImage();

And here.

> Source/WebCore/rendering/style/StyleImage.h:97
> +    TYPE_CASTS_BASE(ToClassName, FromClassName, resource, resource->predicate(), resource.predicate())

Not that it matters much, but "resource" seems like a strange name for what's being passed around here.
Comment 3 Andreas Kling 2014-02-18 10:47:59 PST
Comment on attachment 224390 [details]
Patch v1

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

Sweet patch, just some stylistic comments.

> Source/WebCore/css/CSSCursorImageValue.cpp:198
> +    return toStyleCachedImage(m_image.get())->cachedImage()->url();

Since we're sure that m_image can't be null, I'd write this like so:
return toStyleCachedImage(*m_image).cachedImage()->url();

> Source/WebCore/css/CSSImageSetValue.cpp:64
> +        toStyleCachedImageSet(m_imageSet.get())->clearImageSetValue();

Same here.

> Source/WebCore/css/CSSImageSetValue.cpp:194
> +    CachedResource* cachedResource = toStyleCachedImageSet(m_imageSet.get())->cachedImage();

And here.

> Source/WebCore/css/CSSImageValue.cpp:108
> +    CachedResource* cachedResource = toStyleCachedImage(m_image.get())->cachedImage();

And here.

> Source/WebCore/rendering/style/StyleImage.h:97
> +    TYPE_CASTS_BASE(ToClassName, FromClassName, resource, resource->predicate(), resource.predicate())

Not that it matters much, but "resource" seems like a strange name for what's being passed around here.
Comment 4 WebKit Commit Bot 2014-02-18 11:05:25 PST
Comment on attachment 224390 [details]
Patch v1

Clearing flags on attachment: 224390

Committed r164298: <http://trac.webkit.org/changeset/164298>
Comment 5 WebKit Commit Bot 2014-02-18 11:05:30 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 David Kilzer (:ddkilzer) 2014-02-18 13:22:12 PST
Addressed style issues in Comment #3 in:

Committed r164310: <http://trac.webkit.org/changeset/164310>