Bug 134122 - [iOS] getsectdata() is deprecated and we use it in DRT
Summary: [iOS] getsectdata() is deprecated and we use it in DRT
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-20 14:11 PDT by Myles C. Maxfield
Modified: 2014-06-24 09:06 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.71 KB, patch)
2014-06-20 14:12 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (4.07 KB, patch)
2014-06-22 10:09 PDT, Myles C. Maxfield
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2014-06-20 14:11:42 PDT
[iOS] getsectdata() is deprecated and we use it in DRT
Comment 1 Myles C. Maxfield 2014-06-20 14:12:37 PDT
Created attachment 233453 [details]
Patch
Comment 2 Alexey Proskuryakov 2014-06-20 20:48:24 PDT
Comment on attachment 233453 [details]
Patch

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

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:536
> -        char* fontData = getsectdata("__DATA", fontSectionNames[i], &fontDataLength);
> +        const uint8_t* const fontData = getsectiondata(_NSGetMachExecuteHeader(), "__DATA", fontSectionNames[i], &fontDataLength);

The recommended replacement for getsectdata is magic linker symbols, see <rdar://problem/14122320>.

As previously mentioned in bug 127730, it's unfortunate that we use different mechanisms for built-in fonts on Mac and on iOS.
Comment 3 Myles C. Maxfield 2014-06-21 11:17:56 PDT
Comment on attachment 233453 [details]
Patch

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

>> Tools/DumpRenderTree/mac/DumpRenderTree.mm:536
>> +        const uint8_t* const fontData = getsectiondata(_NSGetMachExecuteHeader(), "__DATA", fontSectionNames[i], &fontDataLength);
> 
> The recommended replacement for getsectdata is magic linker symbols, see <rdar://problem/14122320>.
> 
> As previously mentioned in bug 127730, it's unfortunate that we use different mechanisms for built-in fonts on Mac and on iOS.

It looks like the magic linker symbols rely on strings of the form "section$start$__DATA$__my" which means it will be tricky to iterate over an array of sections. I'll see what I can do.
Comment 4 Myles C. Maxfield 2014-06-21 11:35:47 PDT
Comment on attachment 233453 [details]
Patch

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

>>> Tools/DumpRenderTree/mac/DumpRenderTree.mm:536
>>> +        const uint8_t* const fontData = getsectiondata(_NSGetMachExecuteHeader(), "__DATA", fontSectionNames[i], &fontDataLength);
>> 
>> The recommended replacement for getsectdata is magic linker symbols, see <rdar://problem/14122320>.
>> 
>> As previously mentioned in bug 127730, it's unfortunate that we use different mechanisms for built-in fonts on Mac and on iOS.
> 
> It looks like the magic linker symbols rely on strings of the form "section$start$__DATA$__my" which means it will be tricky to iterate over an array of sections. I'll see what I can do.

Yeah, __asm() requires a string literal, which means I can't even do this iteration using template parameters. We may be stuck with getsectiondata :(
Comment 5 Myles C. Maxfield 2014-06-21 11:36:36 PDT
Comment on attachment 233453 [details]
Patch

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

>>>> Tools/DumpRenderTree/mac/DumpRenderTree.mm:536
>>>> +        const uint8_t* const fontData = getsectiondata(_NSGetMachExecuteHeader(), "__DATA", fontSectionNames[i], &fontDataLength);
>>> 
>>> The recommended replacement for getsectdata is magic linker symbols, see <rdar://problem/14122320>.
>>> 
>>> As previously mentioned in bug 127730, it's unfortunate that we use different mechanisms for built-in fonts on Mac and on iOS.
>> 
>> It looks like the magic linker symbols rely on strings of the form "section$start$__DATA$__my" which means it will be tricky to iterate over an array of sections. I'll see what I can do.
> 
> Yeah, __asm() requires a string literal, which means I can't even do this iteration using template parameters. We may be stuck with getsectiondata :(

Actually, I could likely do it with a preprocessor macro
Comment 6 Alexey Proskuryakov 2014-06-21 21:36:45 PDT
I don't have a strong opinion, just pointing out what I was previously told. If using magic symbols is hard, then we shouldn't do that.
Comment 7 Myles C. Maxfield 2014-06-22 10:09:44 PDT
Created attachment 233567 [details]
Patch
Comment 8 Myles C. Maxfield 2014-06-22 11:30:32 PDT
Comment on attachment 233567 [details]
Patch

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

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:532
> +    if (!GSFontAddCGFont(cgFont)) {

We can probably use CTFontManagerEnableFontDescriptors() instead, relieving the dependency on GraphicsServices
Comment 9 Myles C. Maxfield 2014-06-22 11:34:19 PDT
(In reply to comment #8)
> (From update of attachment 233567 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=233567&action=review
> 
> > Tools/DumpRenderTree/mac/DumpRenderTree.mm:532
> > +    if (!GSFontAddCGFont(cgFont)) {
> 
> We can probably use CTFontManagerEnableFontDescriptors() instead, relieving the dependency on GraphicsServices

https://bugs.webkit.org/show_bug.cgi?id=134133
Comment 10 Alexey Proskuryakov 2014-06-24 00:41:27 PDT
Comment on attachment 233567 [details]
Patch

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

Nice!

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:517
> +static void activateFontIOS(const uint8_t* ptr, unsigned long length, std::string sectionName)

I suggest using a more descriptive name for "ptr" (maybe fontData?)

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:519
> +    CGDataProviderRef data = CGDataProviderCreateWithData(NULL, ptr, length, NULL);

s/NULL/nullptr/g

> Tools/DumpRenderTree/mac/DumpRenderTree.mm:538
> +}
> +static void activateFontsIOS()

Missing empty line.
Comment 11 Myles C. Maxfield 2014-06-24 09:06:13 PDT
http://trac.webkit.org/changeset/170362