| Summary: | Update Media Accessibility preferences in the WebContent process from the UI process | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Per Arne Vollan <pvollan> | ||||||
| Component: | WebKit Misc. | Assignee: | Per Arne Vollan <pvollan> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | bfulgham, eric.carlson, ews-watchlist, glenn, jer.noble, philipj, sergio, webkit-bug-importer | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Attachments: |
|
||||||||
|
Description
Per Arne Vollan
2021-06-15 09:24:08 PDT
Created attachment 431447 [details]
Patch
Comment on attachment 431447 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431447&action=review > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:222 > + case kMACaptionAppearanceDisplayTypeForcedOnly: > + return ForcedOnly; > + > + case kMACaptionAppearanceDisplayTypeAutomatic: > + return Automatic; > + > + case kMACaptionAppearanceDisplayTypeAlwaysOn: > + return AlwaysOn; > + } I think it is a mistake to have the one method sometimes return the cached value and sometimes call the system because the caller always knows if it to do one thing or the other, so I would split this into two methods. > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:527 > + if (cachedPreferredLanguages().has_value()) > + return cachedPreferredLanguages().value(); > + > + auto captionLanguages = adoptCF(MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser)); > + CFIndex captionLanguagesCount = captionLanguages ? CFArrayGetCount(captionLanguages.get()) : 0; > + > + Vector<String> preferredLanguages; > + preferredLanguages.reserveInitialCapacity(captionLanguagesCount); > + for (CFIndex i = 0; i < captionLanguagesCount; i++) > + preferredLanguages.uncheckedAppend(static_cast<CFStringRef>(CFArrayGetValueAtIndex(captionLanguages.get(), i))); > + > + return preferredLanguages; Ditto. Created attachment 431524 [details]
Patch
Committed r278927 (238858@main): <https://commits.webkit.org/238858@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431524 [details]. (In reply to Eric Carlson from comment #3) > Comment on attachment 431447 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=431447&action=review > > > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:222 > > + case kMACaptionAppearanceDisplayTypeForcedOnly: > > + return ForcedOnly; > > + > > + case kMACaptionAppearanceDisplayTypeAutomatic: > > + return Automatic; > > + > > + case kMACaptionAppearanceDisplayTypeAlwaysOn: > > + return AlwaysOn; > > + } > > I think it is a mistake to have the one method sometimes return the cached > value and sometimes call the system because the caller always knows if it to > do one thing or the other, so I would split this into two methods. > > > Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:527 > > + if (cachedPreferredLanguages().has_value()) > > + return cachedPreferredLanguages().value(); > > + > > + auto captionLanguages = adoptCF(MACaptionAppearanceCopySelectedLanguages(kMACaptionAppearanceDomainUser)); > > + CFIndex captionLanguagesCount = captionLanguages ? CFArrayGetCount(captionLanguages.get()) : 0; > > + > > + Vector<String> preferredLanguages; > > + preferredLanguages.reserveInitialCapacity(captionLanguagesCount); > > + for (CFIndex i = 0; i < captionLanguagesCount; i++) > > + preferredLanguages.uncheckedAppend(static_cast<CFStringRef>(CFArrayGetValueAtIndex(captionLanguages.get(), i))); > > + > > + return preferredLanguages; > > Ditto. Fixed by moving the check outside the method. Thanks for reviewing! |