Changeset 196010 in webkit
- Timestamp:
- Feb 2, 2016, 8:38:02 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196008 r196010 1 2016-02-02 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to disable automatic text track selection 4 https://bugs.webkit.org/show_bug.cgi?id=153761 5 <rdar://problem/24416768> 6 7 Reviewed by Darin Adler. 8 9 * media/track/track-manual-mode-expected.txt: Added. 10 * media/track/track-manual-mode.html: Added. 11 1 12 2016-02-02 Zalan Bujtas <zalan@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r196009 r196010 1 2016-02-02 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to disable automatic text track selection 4 https://bugs.webkit.org/show_bug.cgi?id=153761 5 <rdar://problem/24416768> 6 7 Reviewed by Darin Adler. 8 9 Test: media/track/track-manual-mode.html 10 11 * Modules/mediacontrols/MediaControlsHost.cpp: 12 (WebCore::MediaControlsHost::manualKeyword): New. 13 (WebCore::MediaControlsHost::captionDisplayMode): Support 'manual' mode. 14 * Modules/mediacontrols/MediaControlsHost.h: 15 16 * Modules/mediacontrols/mediaControlsApple.js: 17 (Controller.prototype.buildCaptionMenu): Check the 'off' item when in manual mode. 18 19 * html/HTMLMediaElement.cpp: 20 (WebCore::HTMLMediaElement::addTextTrack): Update m_captionDisplayMode when called for the first 21 time so it is always correct. Set the track's manual selection mode as appropriate. 22 (WebCore::HTMLMediaElement::captionPreferencesChanged): Set each track's manual selection 23 mode as appropriate. 24 25 * html/track/TextTrack.cpp: 26 (WebCore::TextTrack::kind): Return 'subtitles' for forced tracks when in manual mode. 27 * html/track/TextTrack.h: 28 29 * html/track/TrackBase.h: 30 (WebCore::TrackBase::kind): Make virtual. 31 32 * page/CaptionUserPreferences.cpp: 33 (WebCore::CaptionUserPreferences::beginBlockingNotifications): New. 34 (WebCore::CaptionUserPreferences::endBlockingNotifications): Ditto. 35 (WebCore::CaptionUserPreferences::notify): Don't notify when blocked. 36 * page/CaptionUserPreferences.h: 37 38 * page/CaptionUserPreferencesMediaAF.cpp: 39 (WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF): Set manual mode 40 when appropriate. 41 (WebCore::CaptionUserPreferencesMediaAF::captionDisplayMode): Check manual mode. 42 (WebCore::CaptionUserPreferencesMediaAF::setCaptionDisplayMode): Ditto. 43 (WebCore::CaptionUserPreferencesMediaAF::setPreferredLanguage): Ditto. 44 (WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore): Return zero when in manual mode. 45 (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): Consider manual mode. Fix 46 typos in logging. 47 48 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 49 (WebCore::mediaDescriptionForKind): Return 'auxiliary' when in manual mode. 50 51 * testing/Internals.cpp: 52 (WebCore::Internals::setCaptionDisplayMode): Support manual mode. 53 1 54 2016-02-02 Adrien Plazas <aplazas@igalia.com> 2 55 -
trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
r195487 r196010 62 62 } 63 63 64 const AtomicString& MediaControlsHost::manualKeyword() 65 { 66 static NeverDestroyed<const AtomicString> alwaysOn("manual", AtomicString::ConstructFromLiteral); 67 return alwaysOn; 68 } 69 70 64 71 Ref<MediaControlsHost> MediaControlsHost::create(HTMLMediaElement* mediaElement) 65 72 { … … 152 159 case CaptionUserPreferences::AlwaysOn: 153 160 return alwaysOnKeyword(); 161 case CaptionUserPreferences::Manual: 162 return manualKeyword(); 154 163 default: 155 164 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
r185472 r196010 53 53 static const AtomicString& forcedOnlyKeyword(); 54 54 static const AtomicString& alwaysOnKeyword(); 55 static const AtomicString& manualKeyword(); 55 56 56 57 Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*); -
trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
r195912 r196010 1837 1837 } 1838 1838 1839 if (offMenu && displayMode === 'forced-only'&& !trackMenuItemSelected) {1839 if (offMenu && (displayMode === 'forced-only' || displayMode === 'manual') && !trackMenuItemSelected) { 1840 1840 offMenu.classList.add(this.ClassNames.selected); 1841 1841 offMenu.setAttribute('tabindex', '0'); -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r195953 r196010 3577 3577 if (!m_requireCaptionPreferencesChangedCallbacks) { 3578 3578 m_requireCaptionPreferencesChangedCallbacks = true; 3579 document().registerForCaptionPreferencesChangedCallbacks(this); 3580 } 3581 3579 Document& document = this->document(); 3580 document.registerForCaptionPreferencesChangedCallbacks(this); 3581 if (Page* page = document.page()) 3582 m_captionDisplayMode = page->group().captionPreferences()->captionDisplayMode(); 3583 } 3584 3585 track->setManualSelectionMode(m_captionDisplayMode == CaptionUserPreferences::Manual); 3582 3586 textTracks()->append(track); 3583 3587 … … 5724 5728 return; 5725 5729 5730 if (m_captionDisplayMode == CaptionUserPreferences::Manual || displayMode == CaptionUserPreferences::Manual) { 5731 for (unsigned i = 0; i < m_textTracks->length(); ++i) 5732 m_textTracks->item(i)->setManualSelectionMode(displayMode == CaptionUserPreferences::Manual); 5733 } 5734 5726 5735 m_captionDisplayMode = displayMode; 5727 5736 setWebkitClosedCaptionsVisible(m_captionDisplayMode == CaptionUserPreferences::AlwaysOn); -
trunk/Source/WebCore/html/track/TextTrack.cpp
r194819 r196010 174 174 } 175 175 176 AtomicString TextTrack::kind() const 177 { 178 AtomicString kind = TrackBase::kind(); 179 if (!m_manualSelectionMode || kind != forcedKeyword()) 180 return kind; 181 182 return subtitlesKeyword(); 183 } 184 176 185 void TextTrack::setKind(const AtomicString& newKind) 177 186 { -
trunk/Source/WebCore/html/track/TextTrack.h
r188660 r196010 83 83 static const AtomicString& showingKeyword(); 84 84 85 virtual void setKind(const AtomicString&) override; 85 void setKind(const AtomicString&) override; 86 AtomicString kind() const override; 86 87 87 88 virtual AtomicString inBandMetadataTrackDispatchType() const { return emptyString(); } … … 143 144 virtual MediaTime startTimeVariance() const { return MediaTime::zeroTime(); } 144 145 146 void setManualSelectionMode(bool mode) { m_manualSelectionMode = mode; } 147 145 148 using RefCounted<TrackBase>::ref; 146 149 using RefCounted<TrackBase>::deref; … … 172 175 int m_renderedTrackIndex; 173 176 bool m_hasBeenConfigured; 177 bool m_manualSelectionMode { false }; 174 178 }; 175 179 -
trunk/Source/WebCore/html/track/TrackBase.h
r165676 r196010 52 52 virtual void setId(const AtomicString& id) { m_id = id; } 53 53 54 AtomicString kind() const { return m_kind; }54 virtual AtomicString kind() const { return m_kind; } 55 55 virtual void setKind(const AtomicString&); 56 56 -
trunk/Source/WebCore/page/CaptionUserPreferences.cpp
r194819 r196010 63 63 } 64 64 65 void CaptionUserPreferences::beginBlockingNotifications() 66 { 67 ++m_blockNotificationsCounter; 68 } 69 70 void CaptionUserPreferences::endBlockingNotifications() 71 { 72 ASSERT(m_blockNotificationsCounter); 73 --m_blockNotificationsCounter; 74 } 75 65 76 void CaptionUserPreferences::notify() 66 77 { 78 if (m_blockNotificationsCounter) 79 return; 80 67 81 m_havePreferences = true; 68 82 if (!m_timer.isActive()) -
trunk/Source/WebCore/page/CaptionUserPreferences.h
r184799 r196010 51 51 Automatic, 52 52 ForcedOnly, 53 AlwaysOn 53 AlwaysOn, 54 Manual, 54 55 }; 55 56 virtual CaptionDisplayMode captionDisplayMode() const; … … 99 100 protected: 100 101 void updateCaptionStyleSheetOveride(); 102 void beginBlockingNotifications(); 103 void endBlockingNotifications(); 101 104 102 105 private: … … 105 108 106 109 PageGroup& m_pageGroup; 107 CaptionDisplayMode m_displayMode;110 mutable CaptionDisplayMode m_displayMode; 108 111 Timer m_timer; 109 112 String m_userPreferredLanguage; … … 111 114 String m_captionsStyleSheetOverride; 112 115 String m_primaryAudioTrackLanguageOverride; 116 unsigned m_blockNotificationsCounter { 0 }; 113 117 bool m_testingMode; 114 118 bool m_havePreferences; -
trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
r194819 r196010 76 76 77 77 #define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute 78 #endif 79 #endif 78 79 typedef Boolean (*MTEnableCaption2015BehaviorPtrType) (); 80 static MTEnableCaption2015BehaviorPtrType MTEnableCaption2015BehaviorPtr() { return nullptr; } 81 82 #else 83 84 SOFT_LINK_FRAMEWORK(MediaToolbox) 85 SOFT_LINK_OPTIONAL(MediaToolbox, MTEnableCaption2015Behavior, Boolean, (), ()) 86 87 #endif // PLATFORM(WIN) 88 89 #endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) 80 90 81 91 namespace WebCore { … … 101 111 #endif 102 112 { 113 static bool initialized; 114 if (!initialized) { 115 initialized = true; 116 117 MTEnableCaption2015BehaviorPtrType function = MTEnableCaption2015BehaviorPtr(); 118 if (!function || !function()) 119 return; 120 121 beginBlockingNotifications(); 122 CaptionUserPreferences::setCaptionDisplayMode(Manual); 123 setUserPrefersCaptions(false); 124 setUserPrefersSubtitles(false); 125 setUserPrefersTextDescriptions(false); 126 endBlockingNotifications(); 127 } 103 128 } 104 129 … … 117 142 CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferencesMediaAF::captionDisplayMode() const 118 143 { 119 if (testingMode() || !MediaAccessibilityLibrary()) 120 return CaptionUserPreferences::captionDisplayMode(); 144 CaptionDisplayMode internalMode = CaptionUserPreferences::captionDisplayMode(); 145 if (internalMode == Manual || testingMode() || !MediaAccessibilityLibrary()) 146 return internalMode; 121 147 122 148 MACaptionAppearanceDisplayType displayType = MACaptionAppearanceGetDisplayType(kMACaptionAppearanceDomainUser); … … 142 168 return; 143 169 } 170 171 if (captionDisplayMode() == Manual) 172 return; 144 173 145 174 MACaptionAppearanceDisplayType displayType = kMACaptionAppearanceDisplayTypeForcedOnly; … … 433 462 void CaptionUserPreferencesMediaAF::setPreferredLanguage(const String& language) 434 463 { 464 if (CaptionUserPreferences::captionDisplayMode() == Manual) 465 return; 466 435 467 if (testingMode() || !MediaAccessibilityLibrary()) { 436 468 CaptionUserPreferences::setPreferredLanguage(language); … … 662 694 { 663 695 CaptionDisplayMode displayMode = captionDisplayMode(); 696 if (displayMode == Manual) 697 return 0; 698 664 699 bool legacyOverride = mediaElement->webkitClosedCaptionsVisible(); 665 700 if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride)) … … 805 840 Vector<RefPtr<TextTrack>> tracksForMenu; 806 841 HashSet<String> languagesIncluded; 842 CaptionDisplayMode displayMode = captionDisplayMode(); 807 843 bool prefersAccessibilityTracks = userPrefersCaptions(); 808 844 bool filterTrackList = shouldFilterTrackMenu(); … … 812 848 String language = displayNameForLanguageLocale(track->language()); 813 849 850 if (displayMode == Manual) { 851 LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because selection mode is 'manual'", track->kind().string().utf8().data(), language.utf8().data()); 852 tracksForMenu.append(track); 853 continue; 854 } 855 814 856 const AtomicString& kind = track->kind(); 815 857 if (kind != TextTrack::captionsKeyword() && kind != TextTrack::descriptionsKeyword() && kind != TextTrack::subtitlesKeyword()) … … 817 859 818 860 if (track->containsOnlyForcedSubtitles()) { 819 LOG(Media, "CaptionUserPreferencesM ac::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kind().string().utf8().data(), language.utf8().data());861 LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - skipping '%s' track with language '%s' because it contains only forced subtitles", track->kind().string().utf8().data(), language.utf8().data()); 820 862 continue; 821 863 } 822 864 823 865 if (track->isEasyToRead()) { 824 LOG(Media, "CaptionUserPreferencesM ac::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kind().string().utf8().data(), language.utf8().data());866 LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is 'easy to read'", track->kind().string().utf8().data(), language.utf8().data()); 825 867 if (!language.isEmpty()) 826 868 languagesIncluded.add(language); … … 830 872 831 873 if (track->mode() == TextTrack::showingKeyword()) { 832 LOG(Media, "CaptionUserPreferencesM ac::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kind().string().utf8().data(), language.utf8().data());874 LOG(Media, "CaptionUserPreferencesMediaAF::sortedTrackListForMenu - adding '%s' track with language '%s' because it is already visible", track->kind().string().utf8().data(), language.utf8().data()); 833 875 if (!language.isEmpty()) 834 876 languagesIncluded.add(language); … … 862 904 tracksForMenu.append(track); 863 905 864 LOG(Media, "CaptionUserPreferencesM ac::sortedTrackListForMenu - adding '%s' track with language '%s', is%s main program content", track->kind().string().utf8().data(), language.utf8().data(), track->isMainProgramContent() ? "" : " NOT");906 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"); 865 907 } 866 908 … … 869 911 TextTrack* track = trackList->item(i); 870 912 String language = displayNameForLanguageLocale(track->language()); 913 914 if (tracksForMenu.contains(track)) 915 continue; 871 916 872 917 const AtomicString& kind = track->kind(); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r195951 r196010 256 256 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString*) 257 257 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString*) 258 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString*) 258 259 259 260 #define AVURLAssetHTTPCookiesKey getAVURLAssetHTTPCookiesKey() … … 267 268 #define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility() 268 269 #define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility() 270 #define AVMediaCharacteristicIsAuxiliaryContent getAVMediaCharacteristicIsAuxiliaryContent() 269 271 #endif 270 272 … … 306 308 #endif 307 309 310 SOFT_LINK_FRAMEWORK(MediaToolbox) 311 SOFT_LINK_OPTIONAL(MediaToolbox, MTEnableCaption2015Behavior, Boolean, (), ()) 312 308 313 using namespace WebCore; 309 314 … … 733 738 static const NSArray* mediaDescriptionForKind(PlatformTextTrack::TrackKind kind) 734 739 { 740 static bool manualSelectionMode = MTEnableCaption2015BehaviorPtr() && MTEnableCaption2015BehaviorPtr()(); 741 if (manualSelectionMode) 742 return @[ AVMediaCharacteristicIsAuxiliaryContent ]; 743 735 744 // FIXME: Match these to correct types: 736 745 if (kind == PlatformTextTrack::Caption) -
trunk/Source/WebCore/testing/Internals.cpp
r195916 r196010 2785 2785 else if (equalLettersIgnoringASCIICase(mode, "alwayson")) 2786 2786 captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn); 2787 else if (equalLettersIgnoringASCIICase(mode, "manual")) 2788 captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::Manual); 2787 2789 else 2788 2790 ec = SYNTAX_ERR;
Note:
See TracChangeset
for help on using the changeset viewer.