[webkit-reviews] review granted: [Bug 208969] REGRESSION(r254389): Cordova throws an exception because it expects a hyphen inside navigator.locale : [Attachment 393565] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Mar 15 17:31:24 PDT 2020


Darin Adler <darin at apple.com> has granted Myles C. Maxfield
<mmaxfield at apple.com>'s request for review:
Bug 208969: REGRESSION(r254389): Cordova throws an exception because it expects
a hyphen inside navigator.locale
https://bugs.webkit.org/show_bug.cgi?id=208969

Attachment 393565: Patch

https://bugs.webkit.org/attachment.cgi?id=393565&action=review




--- Comment #9 from Darin Adler <darin at apple.com> ---
Comment on attachment 393565
  --> https://bugs.webkit.org/attachment.cgi?id=393565
Patch

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

> Source/WTF/wtf/cocoa/LanguageCocoa.mm:44
> +#if PLATFORM(MAC)
> +    static bool applicationVersionCheck = applicationSDKVersion() >=
DYLD_MACOSX_VERSION_10_15_4;
> +#elif PLATFORM(IOS)
> +    static bool applicationVersionCheck = applicationSDKVersion() >=
DYLD_IOS_VERSION_13_4;
> +#elif
> +    static bool applicationVersionCheck = true;
> +#endif
> +    static bool result = applicationVersionCheck && [NSLocale
respondsToSelector:@selector(minimizedLanguagesFromLanguages:)];

I suggest static const bool or static constexpr for all of these.

But also, not elegant to have two globals since the first is only used to
compute the second. So write it like this:

    static const bool result = [] {
#if PLATFORM(MAC)
	if (applicationSDKVersion() < DYLD_MACOSX_VERSION_10_15_4)
	    return false;
#endif
#if PLATFORM(IOS)
	if (applicationSDKVersion() < DYLD_IOS_VERSION_13_4)
	    return false;
#elif
	return [NSLocale
respondsToSelector:@selector(minimizedLanguagesFromLanguages:)];
    }();


More information about the webkit-reviews mailing list