haikuwebkit/Source/JavaScriptCore/shell/playstation
Devin Rousso 985831945d [Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks
https://bugs.webkit.org/show_bug.cgi?id=226038

Reviewed by Myles C. Maxfield and Eric Carlson.

Source/JavaScriptCore:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

* shell/playstation/TestShell.cpp:
(preTest):
Instead of propagating the override, just clear it out.

Source/WebCore:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

Test: media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html

* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::preferredLanguages const):
(WebCore::CaptionUserPreferences::textTrackSelectionScore const):
(WebCore::CaptionUserPreferences::primaryAudioTrackLanguageOverride const):
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::preferredLanguages const):
(WebCore::buildDisplayStringForTrackBase):
(WebCore::trackDisplayName):
(WebCore::textTrackCompare):
* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
(WebCore::MediaSelectionGroupAVFObjC::updateOptions):

* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
* bindings/js/JSWorkletGlobalScopeBase.cpp:
Wrap `defaultLanguage` in a lambda since it now has a parameter.

* platform/LocalizedStrings.h:
* platform/LocalizedStrings.cpp:
(WebCore::captionsTextTrackKindDisplayName): Added.
(WebCore::descriptionsTextTrackKindDisplayName): Added.
(WebCore::chaptersTextTrackKindDisplayName): Added.
(WebCore::metadataTextTrackKindDisplayName): Added.
(WebCore::closedCaptionKindTrackDisplayName): Added.
(WebCore::sdhTrackKindDisplayName): Added.
(WebCore::easyReaderKindDisplayName): Added.
(WebCore::forcedTrackKindDisplayName): Added.
Move the logic added in r277797 from `buildDisplayStringForTrackBase` to `trackDisplayName`
and only perform it if the text track display name doesn't already contain the display name
for the text track kind (e.g. if the `label` is "English Captions" don't add "Captions", but
do if the `label` is only "English").

Source/WTF:

Media controls need access to the full list of language preferences in order to properly
sort/order the list of tracks in the controls UI. For example, if a `<video>` has subtitles
for English, Spanish, and French, and the user has English (default) and French (alternate)
configured in the Language & Region view of System Preferences on macOS, WebKit should order
the subtitles list English, French, and then Spanish.

* wtf/Language.h:
* wtf/Language.cpp:
(WTF::cachedFullPlatformPreferredLanguages): Added.
(WTF::cachedMinimizedPlatformPreferredLanguages): Added.
(WTF::languageDidChange):
(WTF::defaultLanguage):
(WTF::userPreferredLanguages):
(WTF::platformLanguageDidChange): Deleted.
Move the caching in `wtf/cf/LanguageCF.cpp` to `wtf/Language.cpp` so that all platforms can
benefit from caching the result of `platformUserPreferredLanguages`.

* wtf/cf/LanguageCF.cpp:
(WTF::platformUserPreferredLanguages):
(WTF::platformLanguageDidChange): Deleted.
* wtf/playstation/LanguagePlayStation.cpp:
(WTF::platformUserPreferredLanguages):
* wtf/spi/cocoa/NSLocaleSPI.h:
* wtf/unix/LanguageUnix.cpp:
(WTF::platformUserPreferredLanguages):
* wtf/win/LanguageWin.cpp:
(WTF::platformUserPreferredLanguages):
Add `WTF::ShouldMinimizeLanguages` that controls whether `WTF::minimizedPreferredLanguages`
is called. Since the result is cached, create separate `Vector<String>` for each enum value.

LayoutTests:

* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages.html: Added.
* media/modern-media-controls/tracks-support/sorted-by-user-preferred-languages-expected.txt: Added.

* media/content/lorem-ipsum.vtt: Added.


Canonical link: https://commits.webkit.org/238145@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278064 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-26 00:15:02 +00:00
..
Initializer.cpp
TestShell.cpp [Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks 2021-05-26 00:15:02 +00:00