Bug 234054 - Use thread safe initialization for statics in ComplexTextController::collectComplexTextRunsForCharacters
Summary: Use thread safe initialization for statics in ComplexTextController::collectC...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Cameron McCormack (:heycam)
URL:
Keywords: InRadar
Depends on:
Blocks: 233488 273109
  Show dependency treegraph
 
Reported: 2021-12-08 18:27 PST by Cameron McCormack (:heycam)
Modified: 2024-04-22 20:24 PDT (History)
7 users (show)

See Also:


Attachments
Patch (5.14 KB, patch)
2021-12-08 18:29 PST, Cameron McCormack (:heycam)
darin: review+
Details | Formatted Diff | Diff
Patch (4.32 KB, patch)
2022-07-20 14:42 PDT, Matt Woodrow
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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].