Changeset 277793 in webkit


Ignore:
Timestamp:
May 20, 2021, 10:28:39 AM (4 years ago)
Author:
Devin Rousso
Message:

[Modern Media Controls] should not use codePointCompare as it doesn't take into account language specific sorting rules
https://bugs.webkit.org/show_bug.cgi?id=225993

Reviewed by Eric Carlson.

  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::sortedTrackListForMenu):

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::textTrackCompare):
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r277792 r277793  
     12021-05-20  Devin Rousso  <drousso@apple.com>
     2
     3        [Modern Media Controls] should not use `codePointCompare` as it doesn't take into account language specific sorting rules
     4        https://bugs.webkit.org/show_bug.cgi?id=225993
     5
     6        Reviewed by Eric Carlson.
     7
     8        * page/CaptionUserPreferences.cpp:
     9        (WebCore::CaptionUserPreferences::sortedTrackListForMenu):
     10        * page/CaptionUserPreferencesMediaAF.cpp:
     11        (WebCore::textTrackCompare):
     12        (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
     13
    1142021-05-20  Geoffrey Garen  <ggaren@apple.com>
    215
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r273191 r277793  
    4646#include <JavaScriptCore/StructureInlines.h>
    4747#include <wtf/Language.h>
     48#include <wtf/unicode/Collator.h>
    4849
    4950namespace WebCore {
     
    238239    }
    239240
    240     std::sort(tracksForMenu.begin(), tracksForMenu.end(), [](auto& a, auto& b) {
    241         return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
     241    Collator collator;
     242
     243    std::sort(tracksForMenu.begin(), tracksForMenu.end(), [&] (auto& a, auto& b) {
     244        return collator.collate(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
    242245    });
    243246
     
    280283    }
    281284
    282     std::sort(tracksForMenu.begin(), tracksForMenu.end(), [](auto& a, auto& b) {
    283         return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
     285    Collator collator;
     286
     287    std::sort(tracksForMenu.begin(), tracksForMenu.end(), [&] (auto& a, auto& b) {
     288        return collator.collate(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
    284289    });
    285290
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r277790 r277793  
    5050#include <wtf/text/StringConcatenateNumbers.h>
    5151#include <wtf/text/cf/StringConcatenateCF.h>
     52#include <wtf/unicode/Collator.h>
    5253
    5354#if PLATFORM(IOS_FAMILY)
     
    682683
    683684    // Tracks in the user's preferred language are always at the top of the menu.
    684     bool aIsPreferredLanguage = !codePointCompare(aLanguageDisplayName, preferredLanguageDisplayName);
    685     bool bIsPreferredLanguage = !codePointCompare(bLanguageDisplayName, preferredLanguageDisplayName);
     685    bool aIsPreferredLanguage = aLanguageDisplayName == preferredLanguageDisplayName;
     686    bool bIsPreferredLanguage = bLanguageDisplayName == preferredLanguageDisplayName;
    686687    if (aIsPreferredLanguage != bIsPreferredLanguage)
    687688        return aIsPreferredLanguage;
    688689
     690    Collator collator;
     691
    689692    // Tracks not in the user's preferred language sort first by language ...
    690     if (auto languageDisplayNameComparison = codePointCompare(aLanguageDisplayName, bLanguageDisplayName))
     693    if (auto languageDisplayNameComparison = collator.collate(aLanguageDisplayName, bLanguageDisplayName))
    691694        return languageDisplayNameComparison < 0;
    692695
     
    704707
    705708    // ... and tracks of the same type and language sort by the menu item text.
    706     if (auto trackDisplayComparison = codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())))
     709    if (auto trackDisplayComparison = collator.collate(trackDisplayName(a.get()), trackDisplayName(b.get())))
    707710        return trackDisplayComparison < 0;
    708711
     
    722725        tracksForMenu.append(track);
    723726    }
    724    
    725     std::sort(tracksForMenu.begin(), tracksForMenu.end(), [](auto& a, auto& b) {
    726         auto trackDisplayComparison = codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get()));
    727         if (trackDisplayComparison)
     727
     728    Collator collator;
     729
     730    std::sort(tracksForMenu.begin(), tracksForMenu.end(), [&] (auto& a, auto& b) {
     731        if (auto trackDisplayComparison = collator.collate(trackDisplayName(a.get()), trackDisplayName(b.get())))
    728732            return trackDisplayComparison < 0;
    729733
Note: See TracChangeset for help on using the changeset viewer.