Bug 136766 - Introduce FONT_DATA_TYPE_CASTS, and use it
Summary: Introduce FONT_DATA_TYPE_CASTS, and use it
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gyuyoung Kim
URL:
Keywords:
Depends on:
Blocks: 136773
  Show dependency treegraph
 
Reported: 2014-09-11 16:45 PDT by Gyuyoung Kim
Modified: 2014-09-14 22:10 PDT (History)
2 users (show)

See Also:


Attachments
Patch (7.99 KB, patch)
2014-09-11 17:04 PDT, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (6.90 KB, patch)
2014-09-11 18:51 PDT, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch for landing (7.09 KB, patch)
2014-09-14 19:59 PDT, Gyuyoung Kim
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gyuyoung Kim 2014-09-11 16:45:32 PDT
SSIA
Comment 1 Gyuyoung Kim 2014-09-11 17:04:03 PDT
Created attachment 237998 [details]
Patch
Comment 2 Myles C. Maxfield 2014-09-11 17:20:46 PDT
unofficial r=me
Comment 3 Gyuyoung Kim 2014-09-11 18:51:29 PDT
Created attachment 238004 [details]
Patch
Comment 4 Darin Adler 2014-09-14 13:02:54 PDT
Comment on attachment 238004 [details]
Patch

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

> Source/WebCore/platform/graphics/FontGlyphs.cpp:74
> +        fontCache().releaseFontData(toSimpleFontData(m_realizedFontData[i]));

I don’t understand why the .get() isn’t needed any more.

> Source/WebCore/platform/graphics/FontGlyphs.cpp:82
> -        m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
> +        m_pitch = toSimpleFontData(fontData)->pitch();

Should be toSimpleFontData(*fontData).pitch()

> Source/WebCore/platform/graphics/FontGlyphs.cpp:84
> -        const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
> +        const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontData);

Should be a reference, not a pointer, since it can’t be null.
Comment 5 Gyuyoung Kim 2014-09-14 19:47:14 PDT
Comment on attachment 238004 [details]
Patch

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

>> Source/WebCore/platform/graphics/FontGlyphs.cpp:74
>> +        fontCache().releaseFontData(toSimpleFontData(m_realizedFontData[i]));
> 
> I don’t understand why the .get() isn’t needed any more.

By adding a below line, FONT_DATA_TYPE_CASTS generates "toSimpleFontData(const RefPtr<FontData>& fontData)" as well. Thanks to the function, FONT_DATA_TYPE_CASTS can handle .get(). It seems to me it would be nicer to delegate .get() handling to toFoo(). This idea comes from blink.

template<typename T> inline ToValueTypeName* to##ToValueTypeName(const RefPtr<T>& fontData) { return to##ToValueTypeName(fontData.get()); } \
Comment 6 Gyuyoung Kim 2014-09-14 19:59:11 PDT
Created attachment 238102 [details]
Patch for landing
Comment 7 WebKit Commit Bot 2014-09-14 21:29:33 PDT
Comment on attachment 238102 [details]
Patch for landing

Clearing flags on attachment: 238102

Committed r173612: <http://trac.webkit.org/changeset/173612>
Comment 8 WebKit Commit Bot 2014-09-14 21:29:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Darin Adler 2014-09-14 22:06:41 PDT
Comment on attachment 238004 [details]
Patch

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

>>> Source/WebCore/platform/graphics/FontGlyphs.cpp:74
>>> +        fontCache().releaseFontData(toSimpleFontData(m_realizedFontData[i]));
>> 
>> I don’t understand why the .get() isn’t needed any more.
> 
> By adding a below line, FONT_DATA_TYPE_CASTS generates "toSimpleFontData(const RefPtr<FontData>& fontData)" as well. Thanks to the function, FONT_DATA_TYPE_CASTS can handle .get(). It seems to me it would be nicer to delegate .get() handling to toFoo(). This idea comes from blink.
> 
> template<typename T> inline ToValueTypeName* to##ToValueTypeName(const RefPtr<T>& fontData) { return to##ToValueTypeName(fontData.get()); } \

I’m not sure this is a good idea. It’s random that some toXXX are overloaded to take RefPtr and others are not, and that this works on RefPtr but not PassRefPtr, and that the result is a raw pointer rather than another RefPtr. In some cases all of those things could be drawbacks. And in this case, the thing can never be nil so it would be nicer to use a reference rather than a pointer.
Comment 10 Gyuyoung Kim 2014-09-14 22:10:22 PDT
(In reply to comment #9)
> (From update of attachment 238004 [details])

so it would be nicer to use a reference rather than a pointer.

Darin, ok, I see. Let me adjust your suggestion into new patch on Bug 136809.