Bug 128510 - Add type-safe casts for ContentData subclasses
Summary: Add type-safe casts for ContentData 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:
Blocks:
 
Reported: 2014-02-09 18:18 PST by David Kilzer (:ddkilzer)
Modified: 2014-02-10 09:30 PST (History)
10 users (show)

See Also:


Attachments
Patch v1 (10.35 KB, patch)
2014-02-09 18:25 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-09 18:18:50 PST
Add type-safe casts for all of the ContentData subclasses.
Comment 1 David Kilzer (:ddkilzer) 2014-02-09 18:25:29 PST
Created attachment 223660 [details]
Patch v1
Comment 2 Darin Adler 2014-02-09 23:48:36 PST
Comment on attachment 223660 [details]
Patch v1

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

> Source/WebCore/rendering/style/ContentData.h:105
> +inline bool ImageContentData::equals(const ContentData& data) const
> +{
> +    if (!data.isImage())
> +        return false;
> +    return *toImageContentData(data).image() == *image();
> +}

I think we could move this to the .cpp file, because I think everyone calls it polymorphically and so nobody really inlines it.

I also think this could read nicely with && rather than early return.

> Source/WebCore/rendering/style/ContentData.h:135
> +inline bool TextContentData::equals(const ContentData& data) const
> +{
> +    if (!data.isText())
> +        return false;
> +    return toTextContentData(data).text() == text();
> +}

Ditto.

> Source/WebCore/rendering/style/ContentData.h:169
> +inline bool CounterContentData::equals(const ContentData& data) const
> +{
> +    if (!data.isCounter())
> +        return false;
> +    return *toCounterContentData(data).counter() == *counter();
> +}

Again.

> Source/WebCore/rendering/style/ContentData.h:199
> +inline bool QuoteContentData::equals(const ContentData& data) const
> +{
> +    if (!data.isQuote())
> +        return false;
> +    return toQuoteContentData(data).quote() == quote();
> +}

Ditto.
Comment 3 WebKit Commit Bot 2014-02-10 00:18:54 PST
Comment on attachment 223660 [details]
Patch v1

Clearing flags on attachment: 223660

Committed r163770: <http://trac.webkit.org/changeset/163770>
Comment 4 WebKit Commit Bot 2014-02-10 00:18:57 PST
All reviewed patches have been landed.  Closing bug.
Comment 5 David Kilzer (:ddkilzer) 2014-02-10 09:30:40 PST
(In reply to comment #2)
> (From update of attachment 223660 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=223660&action=review
> 
> > Source/WebCore/rendering/style/ContentData.h:105
> > +inline bool ImageContentData::equals(const ContentData& data) const
> > +{
> > +    if (!data.isImage())
> > +        return false;
> > +    return *toImageContentData(data).image() == *image();
> > +}
> 
> I think we could move this to the .cpp file, because I think everyone calls it polymorphically and so nobody really inlines it.
> 
> I also think this could read nicely with && rather than early return.

Filed Bug 128538 to track this.