Title: [258578] branches/safari-609.2.1.2-branch/Source/WebCore
Revision
258578
Author
[email protected]
Date
2020-03-17 13:28:13 -0700 (Tue, 17 Mar 2020)

Log Message

Cherry-pick r255997. rdar://problem/60507340

    Incorrect TextTrack sorting with invalid BCP47 language
    https://bugs.webkit.org/show_bug.cgi?id=207315

    Patch by Doug Kelly <[email protected]> on 2020-02-06
    Reviewed by Jer Noble.

    When comparing TextTracks, this ensures all tracks are compared based on consistent parameters, including tracks with an invalid BCP47
    language attribute.

    * page/CaptionUserPreferencesMediaAF.cpp:
    (WebCore::textTrackCompare):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255997 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-609.2.1.2-branch/Source/WebCore/ChangeLog (258577 => 258578)


--- branches/safari-609.2.1.2-branch/Source/WebCore/ChangeLog	2020-03-17 20:24:24 UTC (rev 258577)
+++ branches/safari-609.2.1.2-branch/Source/WebCore/ChangeLog	2020-03-17 20:28:13 UTC (rev 258578)
@@ -1,3 +1,35 @@
+2020-03-17  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r255997. rdar://problem/60507340
+
+    Incorrect TextTrack sorting with invalid BCP47 language
+    https://bugs.webkit.org/show_bug.cgi?id=207315
+    
+    Patch by Doug Kelly <[email protected]> on 2020-02-06
+    Reviewed by Jer Noble.
+    
+    When comparing TextTracks, this ensures all tracks are compared based on consistent parameters, including tracks with an invalid BCP47
+    language attribute.
+    
+    * page/CaptionUserPreferencesMediaAF.cpp:
+    (WebCore::textTrackCompare):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-02-06  Doug Kelly  <[email protected]>
+
+            Incorrect TextTrack sorting with invalid BCP47 language
+            https://bugs.webkit.org/show_bug.cgi?id=207315
+
+            Reviewed by Jer Noble.
+
+            When comparing TextTracks, this ensures all tracks are compared based on consistent parameters, including tracks with an invalid BCP47
+            language attribute.
+
+            * page/CaptionUserPreferencesMediaAF.cpp:
+            (WebCore::textTrackCompare):
+
 2020-03-13  Alan Coon  <[email protected]>
 
         Cherry-pick r257640. rdar://problem/60260332

Modified: branches/safari-609.2.1.2-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (258577 => 258578)


--- branches/safari-609.2.1.2-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2020-03-17 20:24:24 UTC (rev 258577)
+++ branches/safari-609.2.1.2-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2020-03-17 20:28:13 UTC (rev 258578)
@@ -813,36 +813,32 @@
 {
     String preferredLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(defaultLanguage()));
     String aLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(a->validBCP47Language()));
-    String bLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(b->language()));
+    String bLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(b->validBCP47Language()));
 
     // Tracks in the user's preferred language are always at the top of the menu.
     bool aIsPreferredLanguage = !codePointCompare(aLanguageDisplayName, preferredLanguageDisplayName);
     bool bIsPreferredLanguage = !codePointCompare(bLanguageDisplayName, preferredLanguageDisplayName);
-    if ((aIsPreferredLanguage || bIsPreferredLanguage) && (aIsPreferredLanguage != bIsPreferredLanguage))
+    if (aIsPreferredLanguage != bIsPreferredLanguage)
         return aIsPreferredLanguage;
 
     // Tracks not in the user's preferred language sort first by language ...
-    if (codePointCompare(aLanguageDisplayName, bLanguageDisplayName))
-        return codePointCompare(aLanguageDisplayName, bLanguageDisplayName) < 0;
+    if (auto languageDisplayNameComparison = codePointCompare(aLanguageDisplayName, bLanguageDisplayName))
+        return languageDisplayNameComparison < 0;
 
     // ... but when tracks have the same language, main program content sorts next highest ...
     bool aIsMainContent = a->isMainProgramContent();
     bool bIsMainContent = b->isMainProgramContent();
-    if ((aIsMainContent || bIsMainContent) && (aIsMainContent != bIsMainContent))
+    if (aIsMainContent != bIsMainContent)
         return aIsMainContent;
 
-    // ... and main program trakcs sort higher than CC tracks ...
+    // ... and main program tracks sort higher than CC tracks ...
     bool aIsCC = a->isClosedCaptions();
     bool bIsCC = b->isClosedCaptions();
-    if ((aIsCC || bIsCC) && (aIsCC != bIsCC)) {
-        if (aIsCC)
-            return aIsMainContent;
-        return bIsMainContent;
-    }
+    if (aIsCC != bIsCC)
+        return aIsCC;
 
     // ... and tracks of the same type and language sort by the menu item text.
-    auto trackDisplayComparison = codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get()));
-    if (trackDisplayComparison)
+    if (auto trackDisplayComparison = codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())))
         return trackDisplayComparison < 0;
 
     // ... and if the menu item text is the same, compare the unique IDs
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to