Bug 234054

Summary: Use thread safe initialization for statics in ComplexTextController::collectComplexTextRunsForCharacters
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: Layout and RenderingAssignee: Cameron McCormack (:heycam) <heycam>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, darin, mattwoodrow, mmaxfield, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=234102
Bug Depends on:    
Bug Blocks: 233488, 273109    
Attachments:
Description Flags
Patch
darin: review+
Patch none

Description Cameron McCormack (:heycam) 2021-12-08 18:27:41 PST
Use thread safe initialization for statics in ComplexTextController::collectComplexTextRunsForCharacters
Comment 1 Cameron McCormack (:heycam) 2021-12-08 18:29:09 PST
Created attachment 446474 [details]
Patch
Comment 2 Darin Adler 2021-12-08 19:03:50 PST
Comment on attachment 446474 [details]
Patch

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

> Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm:163
> +static CFDictionaryRef ltrTypesetterOptions()
> +{
> +    static LazyNeverDestroyed<RetainPtr<CFDictionaryRef>> options;
> +    static std::once_flag onceFlag;
> +    std::call_once(onceFlag, [&] {
> +        options.construct(makeTypesetterOptions(true));
> +    });
> +    return options.get().get();
> +}
> +
> +static CFDictionaryRef rtlTypesetterOptions()
> +{
> +    static LazyNeverDestroyed<RetainPtr<CFDictionaryRef>> options;
> +    static std::once_flag onceFlag;
> +    std::call_once(onceFlag, [&] {
> +        options.construct(makeTypesetterOptions(false));
> +    });
> +    return options.get().get();
> +}

Use a template function with an int or bool argument so we don’t have to repeat the code twice?

> Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm:205
> +        RetainPtr<CTTypesetterRef> typesetter = adoptCF(CTTypesetterCreateWithUniCharProviderAndOptions(&provideStringAndAttributes, 0, &info, m_run.ltr() ? ltrTypesetterOptions() : rtlTypesetterOptions()));

auto is better here
Comment 3 Cameron McCormack (:heycam) 2021-12-09 23:18:23 PST
This patch too won't be needed if bug 234102 succeeds.
Comment 4 Radar WebKit Bug Importer 2021-12-15 18:28:14 PST
<rdar://problem/86553179>
Comment 5 Matt Woodrow 2022-07-20 14:42:02 PDT
Created attachment 461057 [details]
Patch
Comment 6 EWS 2022-07-20 17:38:31 PDT
Committed 252669@main (01711aa5bc47): <https://commits.webkit.org/252669@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 461057 [details].