Title: [255997] trunk/Source/WebCore
Revision
255997
Author
[email protected]
Date
2020-02-06 18:09:56 -0800 (Thu, 06 Feb 2020)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255996 => 255997)


--- trunk/Source/WebCore/ChangeLog	2020-02-07 02:07:25 UTC (rev 255996)
+++ trunk/Source/WebCore/ChangeLog	2020-02-07 02:09:56 UTC (rev 255997)
@@ -1,3 +1,16 @@
+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-02-06  James Darpinian  <[email protected]>
 
         webgl/1.0.3/conformance/glsl/misc/shader-with-reserved-words.html is timing out on some hardware configurations

Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (255996 => 255997)


--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2020-02-07 02:07:25 UTC (rev 255996)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2020-02-07 02:09:56 UTC (rev 255997)
@@ -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