Title: [154527] trunk
Revision
154527
Author
[email protected]
Date
2013-08-23 15:44:15 -0700 (Fri, 23 Aug 2013)

Log Message

[Mac] some track language tags are not recognized
https://bugs.webkit.org/show_bug.cgi?id=119643

Source/WebCore: 

Reviewed by Jere Noble.

No new tests, existing tests updated.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_captionDisplayMode from settings
    if possible.
(WebCore::HTMLMediaElement::configureTextTrackGroup): Don't enable a default track when preferences
    say captions should be disabled. Don't disable an already visible track if we don't find
    a match unless preferences say captions should be disabled. m_forcedOrAutomaticSubtitleTrackLanguage ->
    m_subtitleTrackLanguage.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): If the language of the primary
    audio track changes, only kick off a text track recalc if caption preference are set to "automatic".
* html/HTMLMediaElement.h:

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation): Initialize m_characteristicsChanged
    and m_delayCharacteristicsChangedNotification.
(WebCore::MediaPlayerPrivateAVFoundation::setHasVideo): Call characteristicsChanged.
(WebCore::MediaPlayerPrivateAVFoundation::setHasAudio): Ditto.
(WebCore::MediaPlayerPrivateAVFoundation::setHasClosedCaptions): Ditto.
(WebCore::MediaPlayerPrivateAVFoundation::characteristicsChanged): New, allows us to coalesce 
    calls to the media player when we know several characteristics may change.
(WebCore::MediaPlayerPrivateAVFoundation::setDelayCharacteristicsChangedNotification): Enable or
    disable notification delay.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Always call languageOfPrimaryAudioTrack(),
    a track may have changed so we may have a new language.
(WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack): Call [AVAssetTrack languageCode]
    if [AVAssetTrack extendedLanguageTag] returns NULL in case the media file has an old
    QuickTime language code.

LayoutTests: 

Reviewed by Jer Noble.

Explicitly set caption mode to "Automatic" so the track 'default' attribute works.

* media/track/text-track-cue-is-reachable.html: 
* media/track/text-track-is-reachable.html: 
* media/track/track-active-cues.html:
* media/track/track-cue-overlap-snap-to-lines-not-set.html:
* media/track/track-cue-rendering-horizontal.html:
* media/track/track-cue-rendering-vertical.html:
* media/track/track-kind.html:
* media/track/track-large-timestamp.html:
* media/track/track-mode.html:
* media/track/track-text-track-cue-list.html:
* media/track/track-webvtt-tc000-empty.html:
* media/track/track-webvtt-tc002-bom.html:
* media/track/track-webvtt-tc010-no-timings.html:
* media/track/track-webvtt-tc027-empty-cue.html:
* media/track/track-webvtt-tc028-unsupported-markup.html:
* media/track/track-word-breaking.html:
* media/video-test.js:
(setCaptionDisplayMode):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154526 => 154527)


--- trunk/LayoutTests/ChangeLog	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/ChangeLog	2013-08-23 22:44:15 UTC (rev 154527)
@@ -1,3 +1,31 @@
+2013-08-23  Eric Carlson  <[email protected]>
+
+        [Mac] some track language tags are not recognized
+        https://bugs.webkit.org/show_bug.cgi?id=119643
+
+        Reviewed by Jer Noble.
+
+        Explicitly set caption mode to "Automatic" so the track 'default' attribute works.
+
+        * media/track/text-track-cue-is-reachable.html: 
+        * media/track/text-track-is-reachable.html: 
+        * media/track/track-active-cues.html:
+        * media/track/track-cue-overlap-snap-to-lines-not-set.html:
+        * media/track/track-cue-rendering-horizontal.html:
+        * media/track/track-cue-rendering-vertical.html:
+        * media/track/track-kind.html:
+        * media/track/track-large-timestamp.html:
+        * media/track/track-mode.html:
+        * media/track/track-text-track-cue-list.html:
+        * media/track/track-webvtt-tc000-empty.html:
+        * media/track/track-webvtt-tc002-bom.html:
+        * media/track/track-webvtt-tc010-no-timings.html:
+        * media/track/track-webvtt-tc027-empty-cue.html:
+        * media/track/track-webvtt-tc028-unsupported-markup.html:
+        * media/track/track-word-breaking.html:
+        * media/video-test.js:
+        (setCaptionDisplayMode):
+
 2013-08-23  Filip Pizlo  <[email protected]>
 
         Incorrect TypedArray#set behavior

Modified: trunk/LayoutTests/media/track/text-track-cue-is-reachable.html (154526 => 154527)


--- trunk/LayoutTests/media/track/text-track-cue-is-reachable.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/text-track-cue-is-reachable.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -37,6 +37,8 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
+
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/text-track-is-reachable.html (154526 => 154527)


--- trunk/LayoutTests/media/track/text-track-is-reachable.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/text-track-is-reachable.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -38,6 +38,8 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
+
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-active-cues.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-active-cues.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-active-cues.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -39,6 +39,8 @@
 
                 video.src = "" "../content/test");
             }
+
+            setCaptionDisplayMode('Automatic');
             
         </script>
     </head>

Modified: trunk/LayoutTests/media/track/track-cue-overlap-snap-to-lines-not-set.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-cue-overlap-snap-to-lines-not-set.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-cue-overlap-snap-to-lines-not-set.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -65,6 +65,7 @@
             });
         }
 
+        setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body _onload_="loaded()">

Modified: trunk/LayoutTests/media/track/track-cue-rendering-horizontal.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-cue-rendering-horizontal.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-cue-rendering-horizontal.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -26,6 +26,9 @@
         </script>
 
         <script src=""
+        <script>
+            setCaptionDisplayMode('Automatic');
+        </script>
     </head>
     <body _onload_="loaded()">
         <video>

Modified: trunk/LayoutTests/media/track/track-cue-rendering-vertical.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-cue-rendering-vertical.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-cue-rendering-vertical.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -27,6 +27,9 @@
         </script>
 
         <script src=""
+        <script>
+            setCaptionDisplayMode('Automatic');
+        </script>
     </head>
     <body _onload_="loaded()">
         <video>

Modified: trunk/LayoutTests/media/track/track-kind.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-kind.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-kind.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -76,6 +76,8 @@
                 video.src = "" '../content/counting');
             }
 
+            setCaptionDisplayMode('Automatic');
+
         </script>
     </head>
     <body _onload_="loaded()">

Modified: trunk/LayoutTests/media/track/track-large-timestamp.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-large-timestamp.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-large-timestamp.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -20,6 +20,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-mode.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-mode.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-mode.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -45,6 +45,8 @@
                 consoleWrite("<b>++ 'disabled'</b>");
                 setMode("disabled");
 
+                setCaptionDisplayMode('ForcedOnly');
+
                 waitForEvent('cuechange', cuechange);
                 video.addEventListener('playing', playing);
                 video.src = "" "../content/test");
@@ -86,6 +88,7 @@
                 }
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-text-track-cue-list.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-text-track-cue-list.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-text-track-cue-list.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -31,6 +31,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-webvtt-tc000-empty.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-webvtt-tc000-empty.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-webvtt-tc000-empty.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -15,6 +15,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-webvtt-tc002-bom.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-webvtt-tc002-bom.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-webvtt-tc002-bom.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -37,6 +37,8 @@
 
                 endTest();
             }
+
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-webvtt-tc010-no-timings.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-webvtt-tc010-no-timings.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-webvtt-tc010-no-timings.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -21,6 +21,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-webvtt-tc027-empty-cue.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-webvtt-tc027-empty-cue.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-webvtt-tc027-empty-cue.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -15,6 +15,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -34,6 +34,7 @@
                 endTest();
             }
 
+            setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body>

Modified: trunk/LayoutTests/media/track/track-word-breaking.html (154526 => 154527)


--- trunk/LayoutTests/media/track/track-word-breaking.html	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/track/track-word-breaking.html	2013-08-23 22:44:15 UTC (rev 154527)
@@ -31,6 +31,7 @@
             video.src = "" '../content/test');
         }
 
+        setCaptionDisplayMode('Automatic');
         </script>
     </head>
     <body _onload_="loaded()">

Modified: trunk/LayoutTests/media/video-test.js (154526 => 154527)


--- trunk/LayoutTests/media/video-test.js	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/LayoutTests/media/video-test.js	2013-08-23 22:44:15 UTC (rev 154527)
@@ -357,3 +357,12 @@
         eventList[i][0].addEventListener(requiredEvents[i], _eventCallback, true);
     }
 }
+
+function setCaptionDisplayMode(mode)
+{
+    if (window.internals)
+        internals.setCaptionDisplayMode(mode);
+    else
+        consoleWrite("<br><b>** This test only works in DRT! **<" + "/b><br>");
+
+}
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (154526 => 154527)


--- trunk/Source/WebCore/ChangeLog	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/ChangeLog	2013-08-23 22:44:15 UTC (rev 154527)
@@ -1,113 +1,42 @@
-2013-08-23  Brent Fulgham  <[email protected]>
+2013-08-23  Eric Carlson  <[email protected]>
 
-        [Windows] Unreviewed build correction. Need to force environment variable
-        to be escaped when running nmake command.
+        [Mac] some track language tags are not recognized
+        https://bugs.webkit.org/show_bug.cgi?id=119643
 
-        * WebCore.vcxproj/WebCoreGenerated.make:
+        Reviewed by Jere Noble.
 
-2013-08-23  Antti Koivisto  <[email protected]>
+        No new tests, existing tests updated.
 
-        Use ElementTraversal some more
-        https://bugs.webkit.org/show_bug.cgi?id=120226
-
-        Reviewed by Darin Adler.
-
-        More traversal with tighter typing.
-
-        * accessibility/AccessibilityNodeObject.cpp:
-        (WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
-        (WebCore::siblingWithAriaRole):
-        * accessibility/AccessibilityTable.cpp:
-        (WebCore::AccessibilityTable::isDataTable):
-        * css/CSSFontFaceSource.cpp:
-        (WebCore::CSSFontFaceSource::getFontData):
-        * dom/ContainerNode.cpp:
-        (WebCore::willRemoveChild):
-        * dom/ContainerNodeAlgorithms.h:
-        (WebCore::ChildFrameDisconnector::ChildFrameDisconnector):
-        (WebCore::ChildFrameDisconnector::collectFrameOwners):
-        (WebCore::ChildFrameDisconnector::disconnect):
         * html/HTMLMediaElement.cpp:
-        (WebCore::HTMLMediaElement::selectMediaResource):
-        (WebCore::HTMLMediaElement::textTrackModeChanged):
-        (WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
-        * html/HTMLObjectElement.cpp:
-        (WebCore::HTMLObjectElement::parametersForPlugin):
-        (WebCore::HTMLObjectElement::containsJavaApplet):
-        * html/HTMLParamElement.h:
-        (WebCore::isHTMLParamElement):
-        (WebCore::HTMLParamElement):
-        * html/HTMLSourceElement.h:
-        (WebCore::isHTMLSourceElement):
-        (WebCore::HTMLSourceElement):
-        * svg/SVGFontFaceElement.h:
-        (WebCore::isSVGFontFaceElement):
-        (WebCore::SVGFontFaceElement):
-        (WebCore::toSVGFontFaceElement):
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_captionDisplayMode from settings
+            if possible.
+        (WebCore::HTMLMediaElement::configureTextTrackGroup): Don't enable a default track when preferences
+            say captions should be disabled. Don't disable an already visible track if we don't find
+            a match unless preferences say captions should be disabled. m_forcedOrAutomaticSubtitleTrackLanguage ->
+            m_subtitleTrackLanguage.
+        (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): If the language of the primary
+            audio track changes, only kick off a text track recalc if caption preference are set to "automatic".
+        * html/HTMLMediaElement.h:
 
-2013-08-23  Andreas Kling  <[email protected]>
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation): Initialize m_characteristicsChanged
+            and m_delayCharacteristicsChangedNotification.
+        (WebCore::MediaPlayerPrivateAVFoundation::setHasVideo): Call characteristicsChanged.
+        (WebCore::MediaPlayerPrivateAVFoundation::setHasAudio): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundation::setHasClosedCaptions): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundation::characteristicsChanged): New, allows us to coalesce 
+            calls to the media player when we know several characteristics may change.
+        (WebCore::MediaPlayerPrivateAVFoundation::setDelayCharacteristicsChangedNotification): Enable or
+            disable notification delay.
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
 
-        Let Document keep its RenderView during render tree attach.
-        <https://webkit.org/b/120224>
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Always call languageOfPrimaryAudioTrack(),
+            a track may have changed so we may have a new language.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack): Call [AVAssetTrack languageCode]
+            if [AVAssetTrack extendedLanguageTag] returns NULL in case the media file has an old
+            QuickTime language code.
 
-        Reviewed by Antti Koivisto.
-
-        Remove prehistoric code that cleared Document's renderer pointer during tree attach.
-
-        * dom/Document.cpp:
-        (WebCore::Document::attach):
-
-2013-08-23  Darin Adler  <[email protected]>
-
-        Reduce use of Node in HTMLTableRowsCollection, and use modern traversal idiom
-        https://bugs.webkit.org/show_bug.cgi?id=120222
-
-        Reviewed by Antti Koivisto.
-
-        * html/HTMLTableRowElement.h:
-        (WebCore::isHTMLTableRowElement): Added.
-        (WebCore::isElementOfType<HTMLTableRowElement>): Added.
-        (WebCore::toHTMLTableRowElement): Added.
-
-        * html/HTMLTableRowsCollection.cpp:
-        (WebCore::assertRowIsInTable): Refactored a bit. Changed #if as Andy Estes
-        requested during rewview and got rid of local variables.
-        (WebCore::HTMLTableRowsCollection::rowAfter): Moved a ocmment in here.
-        Changed code to traverse elements instead of nodes, and used the Traversal<>
-        template to eliminate some loops entirely.
-        (WebCore::HTMLTableRowsCollection::lastRow): Ditto.
-        (WebCore::HTMLTableRowsCollection::HTMLTableRowsCollection): Changed argument
-        type from Node to HTMLTableElement.
-        (WebCore::HTMLTableRowsCollection::create): Added an assertion for the value
-        of the collection type argument, and added the typecast here needed for the
-        change above.
-        (WebCore::HTMLTableRowsCollection::virtualItemAfter): Removed the assertion
-        here that was a subset of the assertion we now have inside the rowAfter function.
-
-        * html/HTMLTableRowsCollection.h: Added FINAL. Made single-argument constructor
-        explicit.
-
-2013-08-23  Alex Christensen  <[email protected]>
-
-        Re-separating Win32 and Win64 builds.
-        https://bugs.webkit.org/show_bug.cgi?id=120178
-
-        Reviewed by Brent Fulgham.
-
-        * WebCore.vcxproj/WebCoreGenerated.make:
-        * WebCore.vcxproj/WebCoreGeneratedWinCairo.make:
-        Pass PlatformArchitecture as a command line parameter to bash scripts
-        and use PlatformArchitecture to determine which directory to delete
-        while cleaning (obj32 or obj64).
-        * WebCore.vcxproj/WebCoreGeneratedWinCairoCommon.props:
-        Export PlatformArchitecture to be used by make and cmd scripts.
-        * WebCore.vcxproj/build-generated-files.sh:
-        Use PlatformArchitecture from command line to determine which object directory to use (obj32 or obj64).
-        * WebCore.vcxproj/copyForwardingHeaders.cmd:
-        * WebCore.vcxproj/copyWebCoreResourceFiles.cmd:
-        Use PlatformArchitecture to determine which directory to copy to (obj32 or obj64).
-
-
 2013-08-23  Andreas Kling  <[email protected]>
 
         RenderView::compositor() should return a reference.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (154526 => 154527)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-08-23 22:44:15 UTC (rev 154527)
@@ -340,6 +340,8 @@
 
 #if ENABLE(VIDEO_TRACK)
     document->registerForCaptionPreferencesChangedCallbacks(this);
+    if (document->page())
+        m_captionDisplayMode = document->page()->group().captionPreferences()->captionDisplayMode();
 #endif
 }
 
@@ -3213,6 +3215,7 @@
 
     Page* page = document()->page();
     CaptionUserPreferences* captionPreferences = page? page->group().captionPreferences() : 0;
+    CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences ? captionPreferences->captionDisplayMode() : CaptionUserPreferences::Automatic;
 
     // First, find the track in the group that should be enabled (if any).
     Vector<RefPtr<TextTrack> > currentlyEnabledTracks;
@@ -3259,27 +3262,34 @@
             // * If the track element has a default attribute specified, and there is no other text track in the media
             // element's list of text tracks whose text track mode is showing or showing by default
             //    Let the text track mode be showing by default.
-            defaultTrack = textTrack;
+            if (group.kind != TrackGroup::CaptionsAndSubtitles || displayMode != CaptionUserPreferences::ForcedOnly)
+                defaultTrack = textTrack;
         }
     }
 
     if (!trackToEnable && defaultTrack)
         trackToEnable = defaultTrack;
-
+    
     // If no track matches the user's preferred language, none was marked as 'default', and there is a forced subtitle track
     // in the same language as the language of the primary audio track, enable it.
     if (!trackToEnable && forcedSubitleTrack)
         trackToEnable = forcedSubitleTrack;
 
+    // If no track matches, don't disable an already visible track unless preferences say they all should be off.
+    if (group.kind != TrackGroup::CaptionsAndSubtitles || displayMode != CaptionUserPreferences::ForcedOnly) {
+        if (!trackToEnable && !defaultTrack && group.visibleTrack)
+            trackToEnable = group.visibleTrack;
+    }
+    
     // If no track matches the user's preferred language and non was marked 'default', enable the first track
     // because the user has explicitly stated a preference for this kind of track.
     if (!trackToEnable && fallbackTrack)
         trackToEnable = fallbackTrack;
 
-    if (!defaultTrack && trackToEnable && trackToEnable != fallbackTrack && m_captionDisplayMode != CaptionUserPreferences::AlwaysOn)
-        m_forcedOrAutomaticSubtitleTrackLanguage = trackToEnable->language();
+    if (trackToEnable)
+        m_subtitleTrackLanguage = trackToEnable->language();
     else
-        m_forcedOrAutomaticSubtitleTrackLanguage = emptyString();
+        m_subtitleTrackLanguage = emptyString();
     
     if (currentlyEnabledTracks.size()) {
         for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
@@ -3840,7 +3850,7 @@
     beginProcessingMediaPlayerCallback();
 
 #if ENABLE(VIDEO_TRACK)
-    if (m_forcedOrAutomaticSubtitleTrackLanguage != m_player->languageOfPrimaryAudioTrack())
+    if (m_captionDisplayMode == CaptionUserPreferences::Automatic && m_subtitleTrackLanguage != m_player->languageOfPrimaryAudioTrack())
         markCaptionAndSubtitleTracksAsUnconfigured(AfterDelay);
 #endif
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (154526 => 154527)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2013-08-23 22:44:15 UTC (rev 154527)
@@ -724,7 +724,7 @@
     bool m_haveVisibleTextTrack : 1;
     bool m_processingPreferenceChange : 1;
 
-    String m_forcedOrAutomaticSubtitleTrackLanguage;
+    String m_subtitleTrackLanguage;
     float m_lastTextTrackUpdateTime;
 
     CaptionUserPreferences::CaptionDisplayMode m_captionDisplayMode;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (154526 => 154527)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2013-08-23 22:44:15 UTC (rev 154527)
@@ -63,6 +63,7 @@
     , m_seekTo(MediaPlayer::invalidTime())
     , m_requestedRate(1)
     , m_delayCallbacks(0)
+    , m_delayCharacteristicsChangedNotification(0)
     , m_mainThreadCallPending(false)
     , m_assetIsPlayable(false)
     , m_visible(false)
@@ -75,6 +76,7 @@
     , m_haveReportedFirstVideoFrame(false)
     , m_playWhenFramesAvailable(false)
     , m_inbandTrackConfigurationPending(false)
+    , m_characteristicsChanged(false)
     , m_seekCount(0)
 {
     LOG(Media, "MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(%p)", this);
@@ -328,7 +330,7 @@
 {
     if (m_cachedHasVideo != b) {
         m_cachedHasVideo = b;
-        m_player->characteristicChanged();
+        characteristicsChanged();
     }
 }
 
@@ -336,7 +338,7 @@
 {
     if (m_cachedHasAudio != b) {
         m_cachedHasAudio = b;
-        m_player->characteristicChanged();
+        characteristicsChanged();
     }
 }
 
@@ -344,10 +346,34 @@
 {
     if (m_cachedHasCaptions != b) {
         m_cachedHasCaptions = b;
-        m_player->characteristicChanged();
+        characteristicsChanged();
     }
 }
 
+void MediaPlayerPrivateAVFoundation::characteristicsChanged()
+{
+    if (m_delayCharacteristicsChangedNotification) {
+        m_characteristicsChanged = true;
+        return;
+    }
+
+    m_characteristicsChanged = false;
+    m_player->characteristicChanged();
+}
+
+void MediaPlayerPrivateAVFoundation::setDelayCharacteristicsChangedNotification(bool delay)
+{
+    if (delay) {
+        m_delayCharacteristicsChangedNotification++;
+        return;
+    }
+    
+    ASSERT(m_delayCharacteristicsChangedNotification);
+    m_delayCharacteristicsChangedNotification--;
+    if (!m_delayCharacteristicsChangedNotification && m_characteristicsChanged)
+        characteristicsChanged();
+}
+
 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundation::buffered() const
 {
     if (!m_cachedLoadedTimeRanges)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (154526 => 154527)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2013-08-23 22:44:15 UTC (rev 154527)
@@ -234,6 +234,8 @@
     void setHasVideo(bool);
     void setHasAudio(bool);
     void setHasClosedCaptions(bool);
+    void characteristicsChanged();
+    void setDelayCharacteristicsChangedNotification(bool);
     void setDelayCallbacks(bool) const;
     void setIgnoreLoadStateChanges(bool delay) { m_ignoreLoadStateChanges = delay; }
     void setNaturalSize(IntSize);
@@ -292,6 +294,7 @@
     double m_seekTo;
     float m_requestedRate;
     mutable int m_delayCallbacks;
+    int m_delayCharacteristicsChangedNotification;
     bool m_mainThreadCallPending;
     bool m_assetIsPlayable;
     bool m_visible;
@@ -304,6 +307,7 @@
     bool m_haveReportedFirstVideoFrame;
     bool m_playWhenFramesAvailable;
     bool m_inbandTrackConfigurationPending;
+    bool m_characteristicsChanged;
     size_t m_seekCount;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (154526 => 154527)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-08-23 22:35:35 UTC (rev 154526)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-08-23 22:44:15 UTC (rev 154527)
@@ -988,6 +988,8 @@
     if (!m_avAsset)
         return;
 
+    setDelayCharacteristicsChangedNotification(true);
+
     bool haveCCTrack = false;
     bool hasCaptions = false;
 
@@ -1047,8 +1049,10 @@
 
     sizeChanged();
 
-    if (!primaryAudioTrackLanguage.isNull() && primaryAudioTrackLanguage != languageOfPrimaryAudioTrack())
-        player()->characteristicChanged();
+    if (primaryAudioTrackLanguage != languageOfPrimaryAudioTrack())
+        characteristicsChanged();
+
+    setDelayCharacteristicsChangedNotification(false);
 }
 
 void MediaPlayerPrivateAVFoundationObjC::sizeChanged()
@@ -1499,6 +1503,12 @@
     AVAssetTrack *track = [tracks objectAtIndex:0];
     NSString *language = [track extendedLanguageTag];
 
+    // If the language code is stored as a QuickTime 5-bit packed code there aren't enough bits for a full
+    // RFC 4646 language tag so extendedLanguageTag returns NULL. In this case languageCode will return the
+    // ISO 639-2/T language code so check it.
+    if (!language)
+        language = [track languageCode];
+
     // Some legacy tracks have "und" as a language, treat that the same as no language at all.
     if (language && ![language isEqualToString:@"und"]) {
         m_languageOfPrimaryAudioTrack = language;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to