Title: [196121] branches/safari-601.1.46-branch

Diff

Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (196120 => 196121)


--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2016-02-04 16:22:19 UTC (rev 196121)
@@ -1,5 +1,24 @@
 2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r196096. rdar://problem/24416768
+
+    2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
+
+            Merge r196010. rdar://problem/24417428
+
+        2016-02-02  Eric Carlson  <eric.carl...@apple.com>
+
+                Allow ports to disable automatic text track selection
+                https://bugs.webkit.org/show_bug.cgi?id=153761
+                <rdar://problem/24416768>
+
+                Reviewed by Darin Adler.
+
+                * media/track/track-manual-mode-expected.txt: Added.
+                * media/track/track-manual-mode.html: Added.
+
+2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r196095. rdar://problem/24416768
 
     2016-02-03  Matthew Hanson  <matthew_han...@apple.com>

Added: branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode-expected.txt (0 => 196121)


--- branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode-expected.txt	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode-expected.txt	2016-02-04 16:22:19 UTC (rev 196121)
@@ -0,0 +1,53 @@
+Tests 'manual' caption mode.
+
+
+RUN(internals.setUserPreferredLanguages(['en']))
+RUN(internals.setPrimaryAudioTrackLanguageOverride('fr'))
+RUN(internals.setCaptionDisplayMode('manual'))
+EVENT(canplaythrough)
+
+** Forced tracks should be in .textTracks as well as in the menu,
+** but should be labeled as 'subtitles'
+
+EXPECTED (video.textTracks.length == '9') OK
+EXPECTED (trackMenuItems.length == '11') OK
+
+** No track should be enabled by default
+EXPECTED (video.textTracks[0].language == 'en') OK
+EXPECTED (video.textTracks[0].kind == 'subtitles') OK
+EXPECTED (video.textTracks[0].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[1].language == 'en') OK
+EXPECTED (video.textTracks[1].kind == 'subtitles') OK
+EXPECTED (video.textTracks[1].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[2].language == 'fr') OK
+EXPECTED (video.textTracks[2].kind == 'subtitles') OK
+EXPECTED (video.textTracks[2].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[3].language == 'fr') OK
+EXPECTED (video.textTracks[3].kind == 'subtitles') OK
+EXPECTED (video.textTracks[3].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[4].language == 'es') OK
+EXPECTED (video.textTracks[4].kind == 'subtitles') OK
+EXPECTED (video.textTracks[4].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[5].language == 'es') OK
+EXPECTED (video.textTracks[5].kind == 'subtitles') OK
+EXPECTED (video.textTracks[5].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[6].language == 'de') OK
+EXPECTED (video.textTracks[6].kind == 'subtitles') OK
+EXPECTED (video.textTracks[6].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[7].language == 'de') OK
+EXPECTED (video.textTracks[7].kind == 'subtitles') OK
+EXPECTED (video.textTracks[7].mode == 'disabled') OK
+
+EXPECTED (video.textTracks[8].language == 'en') OK
+EXPECTED (video.textTracks[8].kind == 'captions') OK
+EXPECTED (video.textTracks[8].mode == 'disabled') OK
+
+END OF TEST
+

Added: branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode.html (0 => 196121)


--- branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode.html	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/media/track/track-manual-mode.html	2016-02-04 16:22:19 UTC (rev 196121)
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script src=""
+        <script>
+
+            function testTracks()
+            {
+                consoleWrite(`<br><i>** Forced tracks should be in .textTracks as well as in the menu,`);
+                consoleWrite(`<i>** but should be labeled as 'subtitles'</i><br>`);
+                testExpected("video.textTracks.length", 9);
+
+                // Click the CC button to show the menu because it isn't created until it becomes visible.
+                clickCCButton();
+
+                trackMenuItems = captionTrackMenuList();
+                if (!trackMenuItems) {
+                    failTest("Failed to find track menu!");
+                    return;
+                }
+                testExpected("trackMenuItems.length", 11);
+
+                consoleWrite("<br><i>** No track should be enabled by default<" + "/i>");
+                testExpected("video.textTracks[0].language", "en");
+                testExpected("video.textTracks[0].kind", "subtitles");
+                testExpected("video.textTracks[0].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[1].language", "en");
+                testExpected("video.textTracks[1].kind", "subtitles");
+                testExpected("video.textTracks[1].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[2].language", "fr");
+                testExpected("video.textTracks[2].kind", "subtitles");
+                testExpected("video.textTracks[2].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[3].language", "fr");
+                testExpected("video.textTracks[3].kind", "subtitles");
+                testExpected("video.textTracks[3].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[4].language", "es");
+                testExpected("video.textTracks[4].kind", "subtitles");
+                testExpected("video.textTracks[4].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[5].language", "es");
+                testExpected("video.textTracks[5].kind", "subtitles");
+                testExpected("video.textTracks[5].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[6].language", "de");
+                testExpected("video.textTracks[6].kind", "subtitles");
+                testExpected("video.textTracks[6].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[7].language", "de");
+                testExpected("video.textTracks[7].kind", "subtitles");
+                testExpected("video.textTracks[7].mode", "disabled");
+                consoleWrite("");
+
+                testExpected("video.textTracks[8].language", "en");
+                testExpected("video.textTracks[8].kind", "captions");
+                testExpected("video.textTracks[8].mode", "disabled");
+                consoleWrite("");
+
+                endTest();
+            }
+
+            function setup()
+            {
+                findMediaElement();
+                run("internals.setUserPreferredLanguages(['en'])");
+                run("internals.setPrimaryAudioTrackLanguageOverride('fr')");
+                run("internals.setCaptionDisplayMode('manual')");
+                video.src = '';
+
+                waitForEvent('canplaythrough', testTracks);
+            }
+
+        </script>
+    </head>
+    <body _onload_="setup()">
+        <p>Tests 'manual' caption mode.</p>
+        <video width="640" height="360" controls>
+        </video>
+    </body>
+</html>

Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2016-02-04 16:22:19 UTC (rev 196121)
@@ -1,5 +1,66 @@
 2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r196096. rdar://problem/24416768
+
+    2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
+
+            Merge r196010. rdar://problem/24417428
+
+        2016-02-02  Eric Carlson  <eric.carl...@apple.com>
+
+                Allow ports to disable automatic text track selection
+                https://bugs.webkit.org/show_bug.cgi?id=153761
+                <rdar://problem/24416768>
+
+                Reviewed by Darin Adler.
+
+                Test: media/track/track-manual-mode.html
+
+                * Modules/mediacontrols/MediaControlsHost.cpp:
+                (WebCore::MediaControlsHost::manualKeyword): New.
+                (WebCore::MediaControlsHost::captionDisplayMode): Support 'manual' mode.
+                * Modules/mediacontrols/MediaControlsHost.h:
+
+                * Modules/mediacontrols/mediaControlsApple.js:
+                (Controller.prototype.buildCaptionMenu): Check the 'off' item when in manual mode.
+
+                * html/HTMLMediaElement.cpp:
+                (WebCore::HTMLMediaElement::addTextTrack): Update m_captionDisplayMode when called for the first
+                  time so it is always correct. Set the track's manual selection mode as appropriate.
+                (WebCore::HTMLMediaElement::captionPreferencesChanged): Set each track's manual selection
+                  mode as appropriate.
+
+                * html/track/TextTrack.cpp:
+                (WebCore::TextTrack::kind): Return 'subtitles' for forced tracks when in manual mode.
+                * html/track/TextTrack.h:
+
+                * html/track/TrackBase.h:
+                (WebCore::TrackBase::kind): Make virtual.
+
+                * page/CaptionUserPreferences.cpp:
+                (WebCore::CaptionUserPreferences::beginBlockingNotifications): New.
+                (WebCore::CaptionUserPreferences::endBlockingNotifications): Ditto.
+                (WebCore::CaptionUserPreferences::notify): Don't notify when blocked.
+                * page/CaptionUserPreferences.h:
+
+                * page/CaptionUserPreferencesMediaAF.cpp:
+                (WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF): Set manual mode
+                  when appropriate.
+                (WebCore::CaptionUserPreferencesMediaAF::captionDisplayMode): Check manual mode.
+                (WebCore::CaptionUserPreferencesMediaAF::setCaptionDisplayMode): Ditto.
+                (WebCore::CaptionUserPreferencesMediaAF::setPreferredLanguage): Ditto.
+                (WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore): Return zero when in manual mode.
+                (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): Consider manual mode. Fix
+                  typos in logging.
+
+                * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+                (WebCore::mediaDescriptionForKind): Return 'auxiliary' when in manual mode.
+
+                * testing/Internals.cpp:
+                (WebCore::Internals::setCaptionDisplayMode): Support manual mode.
+
+2016-02-03  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r196095. rdar://problem/24416768
 
     2016-02-03  Matthew Hanson  <matthew_han...@apple.com>

Modified: branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -61,6 +61,13 @@
     return alwaysOn;
 }
 
+const AtomicString& MediaControlsHost::manualKeyword()
+{
+    DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, alwaysOn, ("manual", AtomicString::ConstructFromLiteral));
+    return alwaysOn;
+}
+
+
 Ref<MediaControlsHost> MediaControlsHost::create(HTMLMediaElement* mediaElement)
 {
     return adoptRef(*new MediaControlsHost(mediaElement));
@@ -151,6 +158,8 @@
         return forcedOnlyKeyword();
     case CaptionUserPreferences::AlwaysOn:
         return alwaysOnKeyword();
+    case CaptionUserPreferences::Manual:
+        return manualKeyword();
     default:
         ASSERT_NOT_REACHED();
         return emptyAtom;

Modified: branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2016-02-04 16:22:19 UTC (rev 196121)
@@ -52,6 +52,7 @@
     static const AtomicString& automaticKeyword();
     static const AtomicString& forcedOnlyKeyword();
     static const AtomicString& alwaysOnKeyword();
+    static const AtomicString& manualKeyword();
 
     Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*);
     Vector<RefPtr<AudioTrack>> sortedTrackListForMenu(AudioTrackList*);

Modified: branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-02-04 16:22:19 UTC (rev 196121)
@@ -1745,7 +1745,7 @@
 
             }
 
-            if (offMenu && displayMode === 'forced-only' && !trackMenuItemSelected) {
+            if (offMenu && (displayMode === 'forced-only' || displayMode === 'manual') && !trackMenuItemSelected) {
                 offMenu.classList.add(this.ClassNames.selected);
                 offMenu.setAttribute('tabindex', '0');
                 offMenu.setAttribute('aria-checked', 'true');

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -3511,9 +3511,13 @@
 
     if (!m_requireCaptionPreferencesChangedCallbacks) {
         m_requireCaptionPreferencesChangedCallbacks = true;
-        document().registerForCaptionPreferencesChangedCallbacks(this);
+        Document& document = this->document();
+        document.registerForCaptionPreferencesChangedCallbacks(this);
+        if (Page* page = document.page())
+            m_captionDisplayMode = page->group().captionPreferences()->captionDisplayMode();
     }
 
+    track->setManualSelectionMode(m_captionDisplayMode == CaptionUserPreferences::Manual);
     textTracks()->append(track);
 
     closeCaptionTracksChanged();
@@ -5627,6 +5631,11 @@
     if (m_captionDisplayMode == displayMode)
         return;
 
+    if (m_captionDisplayMode == CaptionUserPreferences::Manual || displayMode == CaptionUserPreferences::Manual) {
+        for (unsigned i = 0; i < m_textTracks->length(); ++i)
+            m_textTracks->item(i)->setManualSelectionMode(displayMode == CaptionUserPreferences::Manual);
+    }
+
     m_captionDisplayMode = displayMode;
     setWebkitClosedCaptionsVisible(m_captionDisplayMode == CaptionUserPreferences::AlwaysOn);
 }

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -177,6 +177,15 @@
     return false;
 }
 
+AtomicString TextTrack::kind() const
+{
+    AtomicString kind = TrackBase::kind();
+    if (!m_manualSelectionMode || kind != forcedKeyword())
+        return kind;
+
+    return subtitlesKeyword();
+}
+
 void TextTrack::setKind(const AtomicString& newKind)
 {
     String oldKind = kind();

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.h (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.h	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/track/TextTrack.h	2016-02-04 16:22:19 UTC (rev 196121)
@@ -92,7 +92,8 @@
     static const AtomicString& hiddenKeyword();
     static const AtomicString& showingKeyword();
 
-    virtual void setKind(const AtomicString&) override;
+    void setKind(const AtomicString&) override;
+    AtomicString kind() const override;
 
     virtual AtomicString inBandMetadataTrackDispatchType() const { return emptyString(); }
 
@@ -158,6 +159,8 @@
 
     virtual MediaTime startTimeVariance() const { return MediaTime::zeroTime(); }
 
+    void setManualSelectionMode(bool mode) { m_manualSelectionMode = mode; }
+
     using RefCounted<TrackBase>::ref;
     using RefCounted<TrackBase>::deref;
 
@@ -195,6 +198,7 @@
     int m_trackIndex;
     int m_renderedTrackIndex;
     bool m_hasBeenConfigured;
+    bool m_manualSelectionMode { false };
 };
 
 inline TextTrack* toTextTrack(TrackBase* track)

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/track/TrackBase.h (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/html/track/TrackBase.h	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/track/TrackBase.h	2016-02-04 16:22:19 UTC (rev 196121)
@@ -51,7 +51,7 @@
     virtual AtomicString id() const { return m_id; }
     virtual void setId(const AtomicString& id) { m_id = id; }
 
-    AtomicString kind() const { return m_kind; }
+    virtual AtomicString kind() const { return m_kind; }
     virtual void setKind(const AtomicString&);
 
     AtomicString label() const { return m_label; }

Modified: branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -59,8 +59,22 @@
     captionPreferencesChanged();
 }
 
+void CaptionUserPreferences::beginBlockingNotifications()
+{
+    ++m_blockNotificationsCounter;
+}
+
+void CaptionUserPreferences::endBlockingNotifications()
+{
+    ASSERT(m_blockNotificationsCounter);
+    --m_blockNotificationsCounter;
+}
+
 void CaptionUserPreferences::notify()
 {
+    if (m_blockNotificationsCounter)
+        return;
+
     m_havePreferences = true;
     if (!m_timer.isActive())
         m_timer.startOneShot(0);

Modified: branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.h (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.h	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferences.h	2016-02-04 16:22:19 UTC (rev 196121)
@@ -50,7 +50,8 @@
     enum CaptionDisplayMode {
         Automatic,
         ForcedOnly,
-        AlwaysOn
+        AlwaysOn,
+        Manual,
     };
     virtual CaptionDisplayMode captionDisplayMode() const;
     virtual void setCaptionDisplayMode(CaptionDisplayMode);
@@ -98,18 +99,21 @@
 
 protected:
     void updateCaptionStyleSheetOveride();
+    void beginBlockingNotifications();
+    void endBlockingNotifications();
 
 private:
     void timerFired();
     void notify();
 
     PageGroup& m_pageGroup;
-    CaptionDisplayMode m_displayMode;
+    mutable CaptionDisplayMode m_displayMode;
     Timer m_timer;
     String m_userPreferredLanguage;
     String m_userPreferredAudioCharacteristic;
     String m_captionsStyleSheetOverride;
     String m_primaryAudioTrackLanguageOverride;
+    unsigned m_blockNotificationsCounter { 0 };
     bool m_testingMode;
     bool m_havePreferences;
 };

Modified: branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -74,9 +74,19 @@
 #define kCTFontNameAttribute getkCTFontNameAttribute()
 
 #define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
-#endif
-#endif
 
+typedef Boolean (*MTEnableCaption2015BehaviorPtrType) ();
+static MTEnableCaption2015BehaviorPtrType MTEnableCaption2015BehaviorPtr() { return nullptr; }
+
+#else
+
+SOFT_LINK_FRAMEWORK(MediaToolbox)
+SOFT_LINK_OPTIONAL(MediaToolbox, MTEnableCaption2015Behavior, Boolean, (), ())
+
+#endif // PLATFORM(WIN)
+
+#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+
 namespace WebCore {
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
@@ -99,6 +109,21 @@
     , m_listeningForPreferenceChanges(false)
 #endif
 {
+    static bool initialized;
+    if (!initialized) {
+        initialized = true;
+
+        MTEnableCaption2015BehaviorPtrType function = MTEnableCaption2015BehaviorPtr();
+        if (!function || !function())
+            return;
+
+        beginBlockingNotifications();
+        CaptionUserPreferences::setCaptionDisplayMode(Manual);
+        setUserPrefersCaptions(false);
+        setUserPrefersSubtitles(false);
+        setUserPrefersTextDescriptions(false);
+        endBlockingNotifications();
+    }
 }
 
 CaptionUserPreferencesMediaAF::~CaptionUserPreferencesMediaAF()
@@ -115,8 +140,9 @@
 
 CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferencesMediaAF::captionDisplayMode() const
 {
-    if (testingMode() || !MediaAccessibilityLibrary())
-        return CaptionUserPreferences::captionDisplayMode();
+    CaptionDisplayMode internalMode = CaptionUserPreferences::captionDisplayMode();
+    if (internalMode == Manual || testingMode() || !MediaAccessibilityLibrary())
+        return internalMode;
 
     MACaptionAppearanceDisplayType displayType = MACaptionAppearanceGetDisplayType(kMACaptionAppearanceDomainUser);
     switch (displayType) {
@@ -141,6 +167,9 @@
         return;
     }
 
+    if (captionDisplayMode() == Manual)
+        return;
+
     MACaptionAppearanceDisplayType displayType = kMACaptionAppearanceDisplayTypeForcedOnly;
     switch (mode) {
     case Automatic:
@@ -431,6 +460,9 @@
 
 void CaptionUserPreferencesMediaAF::setPreferredLanguage(const String& language)
 {
+    if (CaptionUserPreferences::captionDisplayMode() == Manual)
+        return;
+
     if (testingMode() || !MediaAccessibilityLibrary()) {
         CaptionUserPreferences::setPreferredLanguage(language);
         return;
@@ -660,6 +692,9 @@
 int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTMLMediaElement* mediaElement) const
 {
     CaptionDisplayMode displayMode = captionDisplayMode();
+    if (displayMode == Manual)
+        return 0;
+
     bool legacyOverride = mediaElement->webkitClosedCaptionsVisible();
     if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride))
         return 0;
@@ -803,6 +838,7 @@
 
     Vector<RefPtr<TextTrack>> tracksForMenu;
     HashSet<String> languagesIncluded;
+    CaptionDisplayMode displayMode = captionDisplayMode();
     bool prefersAccessibilityTracks = userPrefersCaptions();
     bool filterTrackList = shouldFilterTrackMenu();
 
@@ -810,17 +846,23 @@
         TextTrack* track = trackList->item(i);
         String language = displayNameForLanguageLocale(track->language());
 
+        if (displayMode == Manual) {
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because selection mode is 'manual'", track->kind().string().utf8().data(), language.utf8().data());
+            tracksForMenu.append(track);
+            continue;
+        }
+
         const AtomicString& kind = track->kind();
         if (kind != TextTrack::captionsKeyword() && kind != TextTrack::descriptionsKeyword() && kind != TextTrack::subtitlesKeyword())
             continue;
 
         if (track->containsOnlyForcedSubtitles()) {
-            LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kind().string().utf8().data(), language.utf8().data());
             continue;
         }
         
         if (track->isEasyToRead()) {
-            LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kind().string().utf8().data(), language.utf8().data());
             if (!language.isEmpty())
                 languagesIncluded.add(language);
             tracksForMenu.append(track);
@@ -828,7 +870,7 @@
         }
 
         if (track->mode() == TextTrack::showingKeyword()) {
-            LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kind().string().utf8().data(), language.utf8().data());
+            LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kind().string().utf8().data(), language.utf8().data());
             if (!language.isEmpty())
                 languagesIncluded.add(language);
             tracksForMenu.append(track);
@@ -860,7 +902,7 @@
             languagesIncluded.add(language);
         tracksForMenu.append(track);
 
-        LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - adding '%s' track with language '%s', is%s main program content", track->kind().string().utf8().data(), language.utf8().data(), track->isMainProgramContent() ? "" : " NOT");
+        LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s', is%s main program content", track->kind().string().utf8().data(), language.utf8().data(), track->isMainProgramContent() ? "" : " NOT");
     }
 
     // Now that we have filtered for the user's accessibility/translation preference, add  all tracks with a unique language without regard to track type.
@@ -868,6 +910,9 @@
         TextTrack* track = trackList->item(i);
         String language = displayNameForLanguageLocale(track->language());
 
+        if (tracksForMenu.contains(track))
+            continue;
+
         const AtomicString& kind = track->kind();
         if (kind != TextTrack::captionsKeyword() && kind != TextTrack::descriptionsKeyword() && kind != TextTrack::subtitlesKeyword())
             continue;

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-02-04 16:22:19 UTC (rev 196121)
@@ -262,6 +262,7 @@
 SOFT_LINK_POINTER(AVFoundation, AVOutOfBandAlternateTrackSourceKey, NSString*)
 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString*)
 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString*)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString*)
 
 #define AVURLAssetHTTPCookiesKey getAVURLAssetHTTPCookiesKey()
 #define AVURLAssetOutOfBandAlternateTracksKey getAVURLAssetOutOfBandAlternateTracksKey()
@@ -273,6 +274,7 @@
 #define AVOutOfBandAlternateTrackSourceKey getAVOutOfBandAlternateTrackSourceKey()
 #define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility()
 #define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
+#define AVMediaCharacteristicIsAuxiliaryContent getAVMediaCharacteristicIsAuxiliaryContent()
 #endif
 
 #if ENABLE(DATACUE_VALUE)
@@ -294,6 +296,9 @@
 #define AVURLAssetBoundNetworkInterfaceName getAVURLAssetBoundNetworkInterfaceName()
 #endif
 
+SOFT_LINK_FRAMEWORK(MediaToolbox)
+SOFT_LINK_OPTIONAL(MediaToolbox, MTEnableCaption2015Behavior, Boolean, (), ())
+
 using namespace WebCore;
 
 enum MediaPlayerAVFoundationObservationContext {
@@ -745,6 +750,10 @@
 #if ENABLE(AVF_CAPTIONS)
 static const NSArray* mediaDescriptionForKind(PlatformTextTrack::TrackKind kind)
 {
+    static bool manualSelectionMode = MTEnableCaption2015BehaviorPtr() && MTEnableCaption2015BehaviorPtr()();
+    if (manualSelectionMode)
+        return @[ AVMediaCharacteristicIsAuxiliaryContent ];
+
     // FIXME: Match these to correct types:
     if (kind == PlatformTextTrack::Caption)
         return [NSArray arrayWithObjects: AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, nil];

Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp (196120 => 196121)


--- branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp	2016-02-04 16:22:12 UTC (rev 196120)
+++ branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp	2016-02-04 16:22:19 UTC (rev 196121)
@@ -2521,6 +2521,8 @@
         captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::ForcedOnly);
     else if (equalIgnoringCase(mode, "AlwaysOn"))
         captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn);
+    else if (equalIgnoringCase(mode, "manual"))
+        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::Manual);
     else
         ec = SYNTAX_ERR;
 #else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to