Changeset 146380 in webkit
- Timestamp:
- Mar 20, 2013, 1:13:36 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 36 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/media/track/track-user-preferences-expected.txt (modified) (2 diffs)
-
LayoutTests/media/track/track-user-preferences.html (modified) (5 diffs)
-
LayoutTests/media/video-controls-captions-trackmenu-localized.html (modified) (1 diff)
-
LayoutTests/media/video-controls-captions-trackmenu-sorted.html (modified) (3 diffs)
-
LayoutTests/media/video-controls-captions-trackmenu.html (modified) (4 diffs)
-
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/English.lproj/Localizable.strings (modified) (3 diffs)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (7 diffs)
-
Source/WebCore/html/HTMLMediaElement.h (modified) (1 diff)
-
Source/WebCore/html/shadow/MediaControlElements.cpp (modified) (8 diffs)
-
Source/WebCore/html/shadow/MediaControlElements.h (modified) (1 diff)
-
Source/WebCore/html/shadow/MediaControls.cpp (modified) (1 diff)
-
Source/WebCore/html/track/InbandTextTrack.cpp (modified) (1 diff)
-
Source/WebCore/html/track/InbandTextTrack.h (modified) (1 diff)
-
Source/WebCore/html/track/TextTrack.cpp (modified) (1 diff)
-
Source/WebCore/html/track/TextTrack.h (modified) (1 diff)
-
Source/WebCore/html/track/TextTrackList.cpp (modified) (1 diff)
-
Source/WebCore/html/track/TextTrackList.h (modified) (1 diff)
-
Source/WebCore/page/CaptionUserPreferences.cpp (modified) (3 diffs)
-
Source/WebCore/page/CaptionUserPreferences.h (modified) (4 diffs)
-
Source/WebCore/page/CaptionUserPreferencesMac.h (modified) (3 diffs)
-
Source/WebCore/page/CaptionUserPreferencesMac.mm (modified) (5 diffs)
-
Source/WebCore/platform/Language.cpp (modified) (1 diff)
-
Source/WebCore/platform/LocalizedStrings.cpp (modified) (1 diff)
-
Source/WebCore/platform/LocalizedStrings.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/InbandTextTrackPrivate.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm (modified) (3 diffs)
-
Source/WebCore/testing/InternalSettings.cpp (modified) (4 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in (modified) (1 diff)
-
Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r146371 r146380 1 2013-03-20 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports specific text track menu 4 https://bugs.webkit.org/show_bug.cgi?id=112800 5 6 Reviewed by Dean Jackson. 7 8 * media/track/track-user-preferences-expected.txt: 9 * media/track/track-user-preferences.html: 10 * media/video-controls-captions-trackmenu-localized.html: 11 * media/video-controls-captions-trackmenu-sorted.html: 12 * media/video-controls-captions-trackmenu.html: 13 * platform/mac/media/video-controls-captions-trackmenu-expected.txt: 14 * platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt: 15 * platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt: 16 1 17 2013-03-20 Julien Chaffraix <jchaffraix@webkit.org> 2 18 -
trunk/LayoutTests/media/track/track-user-preferences-expected.txt
r142809 r146380 19 19 Test 3: select 'fr' track from menu 20 20 - show captions menu. 21 EXPECTED (trackMenuItems[ 1].className == '') OK22 EXPECTED (trackMenuItems[ 2].className == '') OK23 EXPECTED (trackMenuItems[ 3].className == 'selected') OK24 - click on menu item 2.21 EXPECTED (trackMenuItems[menuIndexForLanguage('French')].className == '') OK 22 EXPECTED (trackMenuItems[menuIndexForLanguage('English')].className == '') OK 23 EXPECTED (trackMenuItems[menuIndexForLanguage('Norwegian')].className == 'selected') OK 24 - click on 'French' menu item. 25 25 EVENT(load) 26 26 EXPECTED (event.target.srclang == 'fr') OK … … 39 39 Test 5: turning captions off from menu disables caption selection 40 40 - show captions menu. 41 - click on menu item 0.41 - click on 'Off' menu item. 42 42 - creating tracks for: [ru,jp,en]. 43 43 EXPECTED (video.textTracks[0].mode == 'disabled') OK -
trunk/LayoutTests/media/track/track-user-preferences.html
r142809 r146380 45 45 } 46 46 47 function selectCaptionMenuItem(index)47 function menuIndexForLanguage(language) 48 48 { 49 consoleWrite("- click on menu item " + index + ".");50 49 var trackMenuItems = trackMenuList(); 50 for (i = 0; i < trackMenuItems.length; ++i) { 51 if (trackMenuItems[i].textContent.indexOf(language) >= 0) 52 break; 53 } 54 return (i < trackMenuItems.length) ? i : -1; 55 } 56 57 function selectCaptionMenuItem(language) 58 { 59 var trackMenuItems = trackMenuList(); 60 var index = menuIndexForLanguage(language); 61 if (index < 0) { 62 failTest("Menu item " + language + " not found in track list menu."); 63 return; 64 } 65 66 consoleWrite("- click on '" + language + "' menu item."); 51 67 var selectedTrackItem = trackMenuItems[index]; 52 68 var boundingRect = selectedTrackItem.getBoundingClientRect(); … … 71 87 var track = document.createElement('track'); 72 88 track.setAttribute('kind', "captions"); 73 track.src = 'data:text/vtt,' +encodeURIComponent("WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nCaption 1\n");89 track.src = 'data:text/vtt,' + encodeURIComponent("WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nCaption 1\n"); 74 90 track.setAttribute('srclang', language); 75 91 track.setAttribute('onload', 'trackLoaded()'); … … 109 125 110 126 case 3: 111 // Clear the debug setting so it isn't considered in the track selection logic112 internals.settings.setShouldDisplayTrackKind('Captions', false);113 114 127 consoleWrite("<br>Test 3: select 'fr' track from menu"); 115 128 showCaptionMenu(); … … 118 131 case 4: 119 132 trackMenuItems = trackMenuList(); 120 testExpected("trackMenuItems[ 1].className", "");121 testExpected("trackMenuItems[ 2].className", "");122 testExpected("trackMenuItems[ 3].className", "selected");133 testExpected("trackMenuItems[menuIndexForLanguage('French')].className", ""); 134 testExpected("trackMenuItems[menuIndexForLanguage('English')].className", ""); 135 testExpected("trackMenuItems[menuIndexForLanguage('Norwegian')].className", "selected"); 123 136 124 selectCaptionMenuItem( 2);137 selectCaptionMenuItem("French"); 125 138 expectedLanguage = 'fr'; 126 139 break; … … 144 157 145 158 case 7: 146 selectCaptionMenuItem( 0);159 selectCaptionMenuItem("Off"); 147 160 createTrackElements([ 'ru', 'jp', 'en']); 148 161 timer = setTimeout(nextStep, 100); -
trunk/LayoutTests/media/video-controls-captions-trackmenu-localized.html
r142003 r146380 45 45 46 46 item = captionsEntries[2]; 47 consoleWrite("<br>Third item in captions menu should be labelled 'Unknown '");48 testExpected("item.textContent", "Unknown ");47 consoleWrite("<br>Third item in captions menu should be labelled 'Unknown SDH'"); 48 testExpected("item.textContent", "Unknown SDH"); 49 49 50 50 item = captionsEntries[3]; -
trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html
r141864 r146380 8 8 <script src="trackmenu-test.js"></script> 9 9 <script> 10 var test = 0; 10 11 if (window.testRunner) 11 12 testRunner.dumpAsText(); 12 13 13 function te stSortedMenu()14 function textTrackMenuItems() 14 15 { 16 // Show and hide the menu to force a recalculation. 17 clickCCButton(); 18 clickCCButton(); 19 15 20 var trackListElement = getTrackListElement(); 16 21 if (!trackListElement) … … 21 26 return; 22 27 } 23 var lastTrackLabel = null; 24 var trackListItems = trackListSection.querySelectorAll("li"); 25 if (!trackListItems || trackListItems.length != 7) { 26 failTest("There should be seven li elements in the menu"); 27 return; 28 return trackListSection.querySelectorAll("li"); 29 } 30 31 function testSortedMenu() 32 { 33 switch (test) 34 { 35 case 0: 36 consoleWrite("<br><i>** Test with preferred language set to English, track type set to captions<" + "/i>"); 37 run("internals.settings.setShouldDisplayTrackKind('Captions', true)"); 38 window.setTimeout(testSortedMenu, 0); 39 break; 40 41 case 1: 42 trackMenuItems = textTrackMenuItems(); 43 testExpected("trackMenuItems[0].textContent", "Off"); 44 testExpected("trackMenuItems[1].textContent", "u (English) SDH"); 45 testExpected("trackMenuItems[2].textContent", "y (English-Australia) SDH"); 46 testExpected("trackMenuItems[3].textContent", "v (English)"); 47 testExpected("trackMenuItems[4].textContent", "x (English-Australia)"); 48 testExpected("trackMenuItems[5].textContent", "w (Japanese) SDH"); 49 testExpected("trackMenuItems[6].textContent", "z (Japanese)"); 50 testExpected("video.textTracks.length", 6); 51 testExpected("trackMenuItems.length", 7); 52 53 consoleWrite("<br><i>** Change preferred language to Japanese, change preference to subtitles<" + "/i>"); 54 run("internals.setUserPreferredLanguages(['ja'])"); 55 run("internals.settings.setShouldDisplayTrackKind('Captions', false)"); 56 run("internals.settings.setShouldDisplayTrackKind('Subtitles', true)"); 57 58 window.setTimeout(testSortedMenu, 0); 59 break; 60 61 case 2: 62 trackMenuItems = textTrackMenuItems(); 63 testExpected("trackMenuItems[0].textContent", "Off"); 64 testExpected("trackMenuItems[1].textContent", "z (Japanese)"); 65 testExpected("trackMenuItems[2].textContent", "v (English)"); 66 testExpected("trackMenuItems[3].textContent", "x (English-Australia)"); 67 testExpected("video.textTracks.length", 6); 68 testExpected("trackMenuItems.length", 4); 69 70 consoleWrite(""); 71 endTest(); 72 break; 28 73 } 29 for (var j = 0; j < trackListItems.length; j++) { 30 var item = trackListItems[j]; 31 if (j == 0) 32 logResult(item.textContent == "Off", "First item should be labelled off"); 33 else { 34 if (lastTrackLabel) 35 logResult(item.textContent > lastTrackLabel, lastTrackLabel + " comes before " + item.textContent); 36 else 37 logResult(true, item.textContent + " is the first real item in the list"); 38 lastTrackLabel = item.textContent; 39 } 40 } 41 endTest(); 74 75 ++test; 42 76 } 43 77 … … 52 86 53 87 <body onload="start()"> 54 <p>Test that captions and subtitles are sorted in the menu .</p>88 <p>Test that captions and subtitles are sorted in the menu according to user preferences.</p> 55 89 <video width="500" height="300" controls> 56 <track label=" c" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">57 <track label=" b" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">58 <track label=" a" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en">59 <track label=" b" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">60 <track label=" a" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">61 <track label=" c" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en">90 <track label="z" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja"> 91 <track label="y" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au"> 92 <track label="x" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au"> 93 <track label="w" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja"> 94 <track label="v" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en"> 95 <track label="u" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en"> 62 96 </video> 63 97 </body> -
trunk/LayoutTests/media/video-controls-captions-trackmenu.html
r141864 r146380 16 16 run('video.addTextTrack("captions", "Commentary", "ru")'); 17 17 window.setTimeout(turnCaptionsOn, 100); 18 consoleWrite(""); 18 19 } 19 20 … … 40 41 function testMenu() 41 42 { 42 vartrackListItems = trackMenuList();43 trackListItems = trackMenuList(); 43 44 var expectedItemCount = video.textTracks.length + 1; 44 45 consoleWrite("There should be " + expectedItemCount + " items in the menu."); 45 testExpected( trackListItems.length, expectedItemCount);46 testExpected("trackListItems.length", expectedItemCount); 46 47 } 47 48 … … 63 64 { 64 65 consoleWrite("*** Turning captions on"); 65 // Click on the third item, which is the second track (Off is the first item in the menu)66 // Click on the second item, which is the second track (Off is the first item in the menu) 66 67 selectCaptionMenuItem(2, testCaptionsVisible); 67 68 } … … 118 119 <p>Test that we are able to trigger the list of captions, and select from the list.</p> 119 120 <video width="500" height="300" controls> 121 <track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="fr"> 120 122 <track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en"> 121 <track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">122 123 <track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja"> 123 124 </video> -
trunk/LayoutTests/platform/mac/media/video-controls-captions-trackmenu-expected.txt
r141864 r146380 8 8 *** Add another text track. 9 9 RUN(video.addTextTrack("captions", "Commentary", "ru")) 10 10 11 *** Turning captions on 11 12 There should be 5 items in the menu. 12 EXPECTED ( 5== '5') OK13 EXPECTED (trackListItems.length == '5') OK 13 14 EXPECTED (video.textTracks.length == '4') OK 14 15 Track 0 should be showing … … 26 27 *** Turning captions off 27 28 There should be 4 items in the menu. 28 EXPECTED ( 4== '4') OK29 EXPECTED (trackListItems.length == '4') OK 29 30 EXPECTED (video.textTracks.length == '3') OK 30 31 Track 0 should be disabled -
trunk/LayoutTests/platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt
r142003 r146380 12 12 13 13 Second item in captions menu should be labelled 'English CC' 14 EXPECTED (item.textContent == 'English CC'), OBSERVED 'Unknown ' FAIL14 EXPECTED (item.textContent == 'English CC'), OBSERVED 'Unknown SDH' FAIL 15 15 16 Third item in captions menu should be labelled 'Unknown '17 EXPECTED (item.textContent == 'Unknown ') OK16 Third item in captions menu should be labelled 'Unknown SDH' 17 EXPECTED (item.textContent == 'Unknown SDH'), OBSERVED 'Unknown' FAIL 18 18 19 19 Fourth item in captions menu should be labelled 'Unknown' -
trunk/LayoutTests/platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt
r141864 r146380 1 Test that captions and subtitles are sorted in the menu .1 Test that captions and subtitles are sorted in the menu according to user preferences. 2 2 3 3 EVENT(canplaythrough) … … 5 5 *** Set the user language preference. 6 6 RUN(internals.setUserPreferredLanguages(['en'])) 7 First item should be labelled off OK 8 a English (Australia) is the first real item in the list OK 9 a English (Australia) comes before a English SDH OK 10 a English SDH comes before b English (Australia) SDH OK 11 b English (Australia) SDH comes before b Japanese OK 12 b Japanese comes before c English OK 13 c English comes before c Japanese SDH OK 7 8 ** Test with preferred language set to English, track type set to captions 9 RUN(internals.settings.setShouldDisplayTrackKind('Captions', true)) 10 EXPECTED (trackMenuItems[0].textContent == 'Off') OK 11 EXPECTED (trackMenuItems[1].textContent == 'u (English) SDH') OK 12 EXPECTED (trackMenuItems[2].textContent == 'y (English-Australia) SDH') OK 13 EXPECTED (trackMenuItems[3].textContent == 'v (English)') OK 14 EXPECTED (trackMenuItems[4].textContent == 'x (English-Australia)') OK 15 EXPECTED (trackMenuItems[5].textContent == 'w (Japanese) SDH') OK 16 EXPECTED (trackMenuItems[6].textContent == 'z (Japanese)') OK 17 EXPECTED (video.textTracks.length == '6') OK 18 EXPECTED (trackMenuItems.length == '7') OK 19 20 ** Change preferred language to Japanese, change preference to subtitles 21 RUN(internals.setUserPreferredLanguages(['ja'])) 22 RUN(internals.settings.setShouldDisplayTrackKind('Captions', false)) 23 RUN(internals.settings.setShouldDisplayTrackKind('Subtitles', true)) 24 EXPECTED (trackMenuItems[0].textContent == 'Off') OK 25 EXPECTED (trackMenuItems[1].textContent == 'z (Japanese)') OK 26 EXPECTED (trackMenuItems[2].textContent == 'v (English)') OK 27 EXPECTED (trackMenuItems[3].textContent == 'x (English-Australia)') OK 28 EXPECTED (video.textTracks.length == '6') OK 29 EXPECTED (trackMenuItems.length == '4') OK 30 14 31 END OF TEST 15 32 -
trunk/Source/WebCore/ChangeLog
r146379 r146380 1 2013-03-20 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports specific text track menu 4 https://bugs.webkit.org/show_bug.cgi?id=112800 5 6 Reviewed by Dean Jackson. 7 8 No new tests, existing tests updated for changes. 9 10 * English.lproj/Localizable.strings: Add localizable strings for text track names. 11 12 * html/HTMLMediaElement.cpp: 13 (WebCore::HTMLMediaElement::HTMLMediaElement): userPrefersCaptions -> shouldShowCaptions. 14 (WebCore::HTMLMediaElement::setSelectedTextTrack): toggleTrackAtIndex -> setSelectedTextTrack. 15 (WebCore::HTMLMediaElement::userPrefersCaptions): userPrefersCaptions -> shouldShowCaptions. 16 (WebCore::HTMLMediaElement::userIsInterestedInThisTrackKind): Get preferences from CaptionUserPreferences 17 instead of from Settings. 18 (WebCore::HTMLMediaElement::setSelectedTextTrack): Renamed from toggleTrackAtIndex. Now takes 19 a TextTrack* instead of an int. 20 (WebCore::HTMLMediaElement::captionPreferencesChanged): Don't force a recalculation unless 21 captions are enabled/disabled to avoid unnecessary thrash. 22 * html/HTMLMediaElement.h: 23 24 * html/shadow/MediaControlElements.cpp: 25 (WebCore::MediaControlClosedCaptionsTrackListElement::defaultEventHandler): Use the menu to track 26 map instead of just the track index. 27 (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay): Build and configure the 28 menu from the menu to track map. 29 (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu): Start with a list 30 of tracks already sorted according to platform specific rules. Build a menu to track map 31 so tracks are retained while the menu is visible. 32 * html/shadow/MediaControlElements.h: 33 34 * html/shadow/MediaControls.cpp: 35 (WebCore::MediaControls::textTrackPreferencesChanged): Call closedCaptionTracksChanged so the 36 track menu will be rebuilt before it is shown again. 37 38 * html/track/InbandTextTrack.cpp: 39 (WebCore::InbandTextTrack::containsOnlyForcedSubtitles): New, passthrough to the private track. 40 (WebCore::InbandTextTrack::isMainProgramContent): Ditto. 41 (WebCore::InbandTextTrack::isEasyToRead): Ditto. 42 * html/track/InbandTextTrack.h: 43 * html/track/TextTrack.h: 44 45 * html/track/TextTrackList.cpp: 46 (WebCore::TextTrackList::contains): New. 47 * html/track/TextTrackList.h: 48 49 * page/CaptionUserPreferences.cpp: 50 (WebCore::CaptionUserPreferences::CaptionUserPreferences): Pull in from .h ditto. 51 (WebCore::CaptionUserPreferences::~CaptionUserPreferences): Ditto. 52 (WebCore::CaptionUserPreferences::shouldShowCaptions): Renamed from userPrefersCaptions. 53 (WebCore::CaptionUserPreferences::setShouldShowCaptions): New. 54 (WebCore::CaptionUserPreferences::userPrefersCaptions): Ditto. 55 (WebCore::CaptionUserPreferences::setUserPrefersCaptions): Ditto. 56 (WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto. 57 (WebCore::CaptionUserPreferences::setUserPrefersSubtitles): Ditto. 58 (WebCore::CaptionUserPreferences::userPrefersTextDescriptions): Ditto. 59 (WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions): Ditto. 60 (WebCore::CaptionUserPreferences::displayNameForTrack): Ditto. 61 (WebCore::CaptionUserPreferences::sortedTrackListForMenu): Ditto. 62 * page/CaptionUserPreferences.h: 63 64 * page/CaptionUserPreferencesMac.h: 65 * page/CaptionUserPreferencesMac.mm: 66 (WebCore::CaptionUserPreferencesMac::shouldShowCaptions): Renamed from userPrefersCaptions. 67 (WebCore::CaptionUserPreferencesMac::userPrefersCaptions): New. 68 (WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto. 69 (WebCore::trackDisplayName): Update logic used to build track title. 70 (WebCore::CaptionUserPreferencesMac::displayNameForTrack): Call trackDisplayName. 71 (WebCore::textTrackCompare): Text track title sort comparison function. 72 (WebCore::CaptionUserPreferencesMac::sortedTrackListForMenu): New. Sort the list of tracks 73 according to title, language, and user preferences. 74 75 * platform/Language.cpp: 76 (WebCore::displayNameForLanguageLocale): Don't leak the CFLocale. 77 78 * platform/LocalizedStrings.cpp: 79 (WebCore::textTrackCountryAndLanguageMenuItemText): New. 80 (WebCore::textTrackLanguageMenuItemText): Ditto. 81 (WebCore::closedCaptionTrackMenuItemText): Ditto. 82 (WebCore::sdhTrackMenuItemText): Ditto. 83 (WebCore::easyReaderTrackMenuItemText): Ditto. 84 * platform/LocalizedStrings.h: 85 86 * platform/graphics/InbandTextTrackPrivate.h: 87 * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h: 88 * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm: 89 (WebCore::InbandTextTrackPrivateAVFObjC::containsOnlyForcedSubtitles): New, return AVFoundation property. 90 (WebCore::InbandTextTrackPrivateAVFObjC::isMainProgramContent): Ditto. 91 (WebCore::InbandTextTrackPrivateAVFObjC::isEasyToRead): Ditto. 92 93 * testing/InternalSettings.cpp: 94 (WebCore::InternalSettings::setShouldDisplayTrackKind): Set setting via CaptionUserPreferences 95 instead of from Settings. 96 (WebCore::InternalSettings::shouldDisplayTrackKind): Get setting from CaptionUserPreferences 97 instead of from Settings. 98 1 99 2013-03-20 Zan Dobersek <zdobersek@igalia.com> 2 100 -
trunk/Source/WebCore/English.lproj/Localizable.strings
r144769 r146380 20 20 "%@ (%@ Internet plug-in)" = "%@ (%@ Internet plug-in)"; 21 21 22 /* Text track display name format that includes the language of the subtitle, in the form of 'Title (Language)' */ 23 "%@ (%@)" = "%@ (%@)"; 24 25 /* Text track display name format that includes the country and language of the subtitle, in the form of 'Title (Language-Country)' */ 26 "%@ (%@-%@)" = "%@ (%@-%@)"; 27 28 /* Text track contains closed captions */ 29 "%@ CC" = "%@ CC"; 30 31 /* Text track contains simplified (3rd grade level) subtitles */ 32 "%@ Easy Reader" = "%@ Easy Reader"; 33 22 34 /* visible name of the network process. The argument is the application name. */ 23 35 "%@ Networking" = "%@ Networking"; … … 26 38 "%@ Offline Storage" = "%@ Offline Storage"; 27 39 40 /* Text track contains subtitles for the deaf and hard of hearing */ 41 "%@ SDH" = "%@ SDH"; 42 28 43 /* Visible name of the shared worker process. The argument is the application name. */ 29 44 "%@ Shared Worker" = "%@ Shared Worker"; … … 518 533 "Underline (Undo action name)" = "Underline"; 519 534 520 /* Menu item label for a closed captions track that has no other name */521 "Unknown (closed captions track)" = "Unknown";522 523 535 /* Unknown filesize FTP directory listing item */ 524 536 "Unknown (filesize)" = "Unknown"; 525 537 538 /* Menu item label for a text track that has no other name */ 539 "Unknown (text track)" = "Unknown"; 540 526 541 /* Undo action name */ 527 542 "Unlink (Undo action name)" = "Unlink"; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r145826 r146380 321 321 CaptionUserPreferences* captionPreferences = document->page()->group().captionPreferences(); 322 322 if (captionPreferences->userHasCaptionPreferences()) 323 m_disableCaptions = !captionPreferences-> userPrefersCaptions();323 m_disableCaptions = !captionPreferences->shouldShowCaptions(); 324 324 } 325 325 #endif … … 2863 2863 2864 2864 if (!platformTrack) { 2865 toggleTrackAtIndex(textTracksOffIndex(), true);2865 setSelectedTextTrack(0); 2866 2866 return; 2867 2867 } … … 2878 2878 if (i == m_textTracks->length()) 2879 2879 return; 2880 toggleTrackAtIndex(i, true);2880 setSelectedTextTrack(textTrack); 2881 2881 } 2882 2882 … … 3077 3077 3078 3078 CaptionUserPreferences* captionPreferences = page->group().captionPreferences(); 3079 return captionPreferences->userHasCaptionPreferences() && captionPreferences-> userPrefersCaptions();3079 return captionPreferences->userHasCaptionPreferences() && captionPreferences->shouldShowCaptions(); 3080 3080 } 3081 3081 … … 3085 3085 return false; 3086 3086 3087 Settings* settings = document()->settings(); 3087 Page* page = document()->page(); 3088 if (!page) 3089 return false; 3090 3091 CaptionUserPreferences* captionPreferences = page->group().captionPreferences(); 3088 3092 bool userPrefersCaptionsOrSubtitles = m_closedCaptionsVisible || userPrefersCaptions(); 3089 3093 3090 3094 if (kind == TextTrack::subtitlesKeyword()) 3091 return (settings && settings->shouldDisplaySubtitles()) || userPrefersCaptionsOrSubtitles;3095 return captionPreferences->userPrefersSubtitles() || userPrefersCaptionsOrSubtitles; 3092 3096 if (kind == TextTrack::captionsKeyword()) 3093 return (settings && settings->shouldDisplayCaptions()) || userPrefersCaptionsOrSubtitles;3097 return captionPreferences->userPrefersCaptions() || userPrefersCaptionsOrSubtitles; 3094 3098 if (kind == TextTrack::descriptionsKeyword()) 3095 return settings && settings->shouldDisplayTextDescriptions();3099 return captionPreferences->userPrefersTextDescriptions() || userPrefersCaptionsOrSubtitles; 3096 3100 3097 3101 return false; … … 3179 3183 } 3180 3184 3181 void HTMLMediaElement:: toggleTrackAtIndex(int index, bool exclusive)3185 void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect) 3182 3186 { 3183 3187 TextTrackList* trackList = textTracks(); 3184 3188 if (!trackList || !trackList->length()) 3185 3189 return; 3186 3187 CaptionUserPreferences* captionPreferences = document()->page() ? document()->page()->group().captionPreferences() : 0; 3188 if (captionPreferences) 3189 captionPreferences->setUserPrefersCaptions(index != textTracksOffIndex()); 3190 if (trackToSelect && !trackList->contains(trackToSelect)) 3191 return; 3190 3192 3191 3193 for (int i = 0, length = trackList->length(); i < length; ++i) { 3192 3194 TextTrack* track = trackList->item(i); 3193 if (i == index) { 3195 if (!trackToSelect || track != trackToSelect) 3196 track->setMode(TextTrack::disabledKeyword()); 3197 else 3194 3198 track->setMode(TextTrack::showingKeyword()); 3195 if (captionPreferences && track->language().length()) 3196 captionPreferences->setPreferredLanguage(track->language()); 3197 } 3198 else if (exclusive || index == HTMLMediaElement::textTracksOffIndex()) 3199 track->setMode(TextTrack::disabledKeyword()); 3199 } 3200 3201 CaptionUserPreferences* captionPreferences = document()->page() ? document()->page()->group().captionPreferences() : 0; 3202 if (captionPreferences) { 3203 captionPreferences->setShouldShowCaptions(trackToSelect); 3204 if (trackToSelect && trackToSelect->language().length()) 3205 captionPreferences->setPreferredLanguage(trackToSelect->language()); 3200 3206 } 3201 3207 } … … 4521 4527 return; 4522 4528 4523 m_processingPreferenceChange = true;4524 setClosedCaptionsVisible(userPrefersCaptions());4525 4526 4529 if (hasMediaControls()) 4527 4530 mediaControls()->textTrackPreferencesChanged(); 4531 4532 bool prefersCaptions = userPrefersCaptions(); 4533 if (m_disableCaptions == !prefersCaptions) 4534 return; 4535 4536 m_processingPreferenceChange = true; 4537 setClosedCaptionsVisible(prefersCaptions); 4528 4538 } 4529 4539 -
trunk/Source/WebCore/html/HTMLMediaElement.h
r145826 r146380 268 268 void configureTextTrackGroup(const TrackGroup&); 269 269 270 void toggleTrackAtIndex(int index, bool exclusive = true);270 void setSelectedTextTrack(TextTrack*); 271 271 static int textTracksOffIndex() { return -1; } 272 272 static int textTracksIndexNotFound() { return -2; } -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r146140 r146380 756 756 // tell the HTMLMediaElement to enable that track. 757 757 758 RefPtr<TextTrack> textTrack; 759 MenuItemToTrackMap::iterator iter = m_menuToTrackMap.find(toElement(target)); 760 if (iter != m_menuToTrackMap.end()) 761 textTrack = iter->value; 762 m_menuToTrackMap.clear(); 763 m_controls->toggleClosedCaptionTrackList(); 764 758 765 int trackIndex = trackListIndexForElement(toElement(target)); 759 766 if (trackIndex == HTMLMediaElement::textTracksIndexNotFound()) … … 764 771 return; 765 772 766 mediaElement->toggleTrackAtIndex(trackIndex); 767 768 // We've selected a track to display, so we can now close the menu. 769 m_controls->toggleClosedCaptionTrackList(); 773 if (textTrack) 774 mediaElement->setSelectedTextTrack(textTrack.get()); 775 else if (trackIndex == HTMLMediaElement::textTracksOffIndex()) 776 mediaElement->setSelectedTextTrack(0); 777 770 778 updateDisplay(); 771 779 } … … 800 808 if (m_trackListHasChanged) 801 809 rebuildTrackListMenu(); 802 810 803 811 bool captionsVisible = mediaElement->closedCaptionsVisible(); 804 812 for (unsigned i = 0, length = m_menuItems.size(); i < length; ++i) { 805 813 RefPtr<Element> trackItem = m_menuItems[i]; 814 806 815 int trackIndex = trackListIndexForElement(trackItem.get()); 807 if (trackIndex != HTMLMediaElement::textTracksIndexNotFound()) { 808 if (trackIndex == HTMLMediaElement::textTracksOffIndex()) { 809 if (captionsVisible) 810 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 811 else 812 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 813 } else { 814 TextTrack* track = trackList->item(trackIndex); 815 if (!track) 816 continue; 817 if (track->mode() == TextTrack::showingKeyword()) 818 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 819 else 820 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 821 } 816 if (trackIndex == HTMLMediaElement::textTracksIndexNotFound()) 817 continue; 818 819 if (trackIndex == HTMLMediaElement::textTracksOffIndex()) { 820 if (captionsVisible) 821 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 822 else 823 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 824 continue; 822 825 } 826 827 RefPtr<TextTrack> textTrack; 828 MenuItemToTrackMap::iterator iter = m_menuToTrackMap.find(trackItem.get()); 829 if (iter == m_menuToTrackMap.end()) 830 continue; 831 textTrack = iter->value; 832 if (!textTrack) 833 continue; 834 if (textTrack->mode() == TextTrack::showingKeyword()) 835 trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION); 836 else 837 trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION); 823 838 } 824 839 #endif 825 840 } 826 827 #if ENABLE(VIDEO_TRACK)828 static void insertTextTrackMenuItemIntoSortedContainer(RefPtr<Element>& item, RefPtr<Element>& container)829 {830 // The container will always have the "Off" entry already present and it831 // should remain at the start of the list.832 ASSERT(container->childNodeCount() > 0);833 ASSERT(item->childNodeCount() == 1); // Each item should have a single text node child for the label.834 String itemLabel = toText(item->firstChild())->wholeText();835 836 // This is an insertion sort :( However, there shouldn't be a horrible number of text track items.837 for (int i = 1, numChildNodes = container->childNodeCount(); i < numChildNodes; ++i) {838 Node* child = container->childNode(i);839 ASSERT(child->childNodeCount() == 1); // Each item should have a single text node child for the label.840 String childLabel = toText(child->firstChild())->wholeText();841 if (codePointCompareLessThan(itemLabel, childLabel)) {842 container->insertBefore(item, child);843 return;844 }845 }846 container->appendChild(item);847 }848 #endif849 841 850 842 void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu() … … 856 848 857 849 m_trackListHasChanged = false; 850 m_menuToTrackMap.clear(); 858 851 859 852 if (!mediaController()->hasClosedCaptions()) … … 865 858 866 859 TextTrackList* trackList = mediaElement->textTracks(); 867 868 860 if (!trackList || !trackList->length()) 869 861 return; … … 871 863 Document* doc = document(); 872 864 CaptionUserPreferences* captionsUserPreferences = doc->page()->group().captionPreferences(); 865 Vector<RefPtr<TextTrack> > tracksForMenu = captionsUserPreferences->sortedTrackListForMenu(trackList); 873 866 874 867 RefPtr<Element> captionsHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION); … … 877 870 RefPtr<Element> captionsMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION); 878 871 879 RefPtr<Element> trackItem; 880 881 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 882 trackItem->appendChild(doc->createTextNode(textTrackOffText())); 883 trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION); 884 captionsMenuList->appendChild(trackItem); 885 m_menuItems.append(trackItem); 886 887 for (unsigned i = 0, length = trackList->length(); i < length; ++i) { 888 TextTrack* track = trackList->item(i); 889 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 872 RefPtr<Element> menuItem; 873 menuItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 874 menuItem->appendChild(doc->createTextNode(textTrackOffText())); 875 menuItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION); 876 captionsMenuList->appendChild(menuItem); 877 m_menuItems.append(menuItem); 878 879 for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) { 880 RefPtr<TextTrack> textTrack = tracksForMenu[i]; 881 menuItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION); 890 882 891 883 // Add a custom attribute to the <li> element which will allow … … 893 885 // track. Since this list is rebuilt if the tracks change, we 894 886 // should always be in sync. 895 trackItem->setAttribute(trackIndexAttributeName(), String::number(i), ASSERT_NO_EXCEPTION); 896 897 if (captionsUserPreferences) 898 trackItem->appendChild(doc->createTextNode(captionsUserPreferences->displayNameForTrack(track))); 899 else 900 trackItem->appendChild(doc->createTextNode(track->label())); 901 902 insertTextTrackMenuItemIntoSortedContainer(trackItem, captionsMenuList); 903 m_menuItems.append(trackItem); 887 menuItem->setAttribute(trackIndexAttributeName(), String::number(i), ASSERT_NO_EXCEPTION); 888 889 menuItem->appendChild(doc->createTextNode(captionsUserPreferences->displayNameForTrack(textTrack.get()))); 890 891 captionsMenuList->appendChild(menuItem); 892 m_menuItems.append(menuItem); 893 m_menuToTrackMap.add(menuItem, textTrack); 904 894 } 905 895 -
trunk/Source/WebCore/html/shadow/MediaControlElements.h
r145397 r146380 316 316 typedef Vector<RefPtr<Element> > TrackMenuItems; 317 317 TrackMenuItems m_menuItems; 318 #if ENABLE(VIDEO_TRACK) 319 typedef HashMap<RefPtr<Element>, RefPtr<TextTrack> > MenuItemToTrackMap; 320 MenuItemToTrackMap m_menuToTrackMap; 321 #endif 318 322 MediaControls* m_controls; 319 323 bool m_trackListHasChanged; -
trunk/Source/WebCore/html/shadow/MediaControls.cpp
r145403 r146380 412 412 if (m_textDisplayContainer) 413 413 m_textDisplayContainer->updateSizes(true); 414 closedCaptionTracksChanged(); 414 415 } 415 416 #endif -
trunk/Source/WebCore/html/track/InbandTextTrack.cpp
r142349 r146380 104 104 } 105 105 106 bool InbandTextTrack::containsOnlyForcedSubtitles() const 107 { 108 if (!m_private) 109 return false; 110 111 return m_private->containsOnlyForcedSubtitles(); 112 } 113 114 bool InbandTextTrack::isMainProgramContent() const 115 { 116 if (!m_private) 117 return false; 118 119 return m_private->isMainProgramContent(); 120 } 121 122 bool InbandTextTrack::isEasyToRead() const 123 { 124 if (!m_private) 125 return false; 126 127 return m_private->isEasyToRead(); 128 } 129 106 130 size_t InbandTextTrack::inbandTrackIndex() 107 131 { -
trunk/Source/WebCore/html/track/InbandTextTrack.h
r145322 r146380 47 47 48 48 virtual bool isClosedCaptions() const OVERRIDE; 49 virtual bool containsOnlyForcedSubtitles() const OVERRIDE; 50 virtual bool isMainProgramContent() const OVERRIDE; 51 virtual bool isEasyToRead() const OVERRIDE; 49 52 virtual void setMode(const AtomicString&) OVERRIDE; 50 53 size_t inbandTrackIndex(); -
trunk/Source/WebCore/html/track/TextTrack.cpp
r145322 r146380 430 430 #endif 431 431 432 bool TextTrack::isMainProgramContent() const 433 { 434 // "Main program" content is intrinsic to the presentation of the media file, regardless of locale. Content such as 435 // directors commentary is not "main program" because it is not essential for the presentation. HTML5 doesn't have 436 // a way to express this in a machine-reable form, it is typically done with the track label, so we assume that caption 437 // tracks are main content and all other track types are not. 438 return m_kind == captionsKeyword(); 439 } 440 432 441 } // namespace WebCore 433 442 -
trunk/Source/WebCore/html/track/TextTrack.h
r145322 r146380 120 120 virtual bool isClosedCaptions() const { return false; } 121 121 122 virtual bool containsOnlyForcedSubtitles() const { return false; } 123 virtual bool isMainProgramContent() const; 124 virtual bool isEasyToRead() const { return false; } 125 122 126 int trackIndex(); 123 127 void invalidateTrackIndex(); -
trunk/Source/WebCore/html/track/TextTrackList.cpp
r142375 r146380 212 212 } 213 213 214 bool TextTrackList::contains(TextTrack* track) const 215 { 216 const Vector<RefPtr<TextTrack> >* tracks = 0; 217 218 if (track->trackType() == TextTrack::TrackElement) 219 tracks = &m_elementTracks; 220 else if (track->trackType() == TextTrack::AddTrack) 221 tracks = &m_addTrackTracks; 222 else if (track->trackType() == TextTrack::InBand) 223 tracks = &m_inbandTracks; 224 else 225 ASSERT_NOT_REACHED(); 226 227 return tracks->find(track) != notFound; 228 } 229 214 230 const AtomicString& TextTrackList::interfaceName() const 215 231 { -
trunk/Source/WebCore/html/track/TextTrackList.h
r135410 r146380 54 54 int getTrackIndex(TextTrack*); 55 55 int getTrackIndexRelativeToRenderedTracks(TextTrack*); 56 bool contains(TextTrack*) const; 56 57 57 58 TextTrack* item(unsigned index); -
trunk/Source/WebCore/page/CaptionUserPreferences.cpp
r145826 r146380 29 29 30 30 #include "CaptionUserPreferences.h" 31 #include "Page.h" 31 32 #include "PageGroup.h" 33 #include "Settings.h" 34 #include "TextTrackList.h" 35 #include <wtf/NonCopyingSort.h> 32 36 33 37 namespace WebCore { 34 38 39 CaptionUserPreferences::CaptionUserPreferences(PageGroup* group) 40 : m_pageGroup(group) 41 , m_timer(this, &CaptionUserPreferences::timerFired) 42 , m_testingMode(false) 43 , m_havePreferences(false) 44 , m_shouldShowCaptions(false) 45 { 46 } 47 48 CaptionUserPreferences::~CaptionUserPreferences() 49 { 50 } 51 52 bool CaptionUserPreferences::shouldShowCaptions() const 53 { 54 return m_testingMode ? m_shouldShowCaptions : false; 55 } 56 57 void CaptionUserPreferences::timerFired(Timer<CaptionUserPreferences>*) 58 { 59 captionPreferencesChanged(); 60 } 61 62 void CaptionUserPreferences::notify() 63 { 64 if (!m_testingMode) 65 return; 66 67 m_havePreferences = true; 68 if (!m_timer.isActive()) 69 m_timer.startOneShot(0); 70 } 71 72 void CaptionUserPreferences::setShouldShowCaptions(bool preference) 73 { 74 m_shouldShowCaptions = preference; 75 notify(); 76 } 77 78 bool CaptionUserPreferences::userPrefersCaptions() const 79 { 80 Page* page = *(pageGroup()->pages().begin()); 81 if (!page) 82 return false; 83 84 return page->settings()->shouldDisplayCaptions(); 85 } 86 35 87 void CaptionUserPreferences::setUserPrefersCaptions(bool preference) 36 88 { 37 m_userPrefersCaptions = preference; 38 if (m_testingMode) { 39 m_havePreferences = true; 40 captionPreferencesChanged(); 41 } 89 Page* page = *(pageGroup()->pages().begin()); 90 if (!page) 91 return; 92 93 page->settings()->setShouldDisplayCaptions(preference); 94 notify(); 95 } 96 97 bool CaptionUserPreferences::userPrefersSubtitles() const 98 { 99 Page* page = *(pageGroup()->pages().begin()); 100 if (!page) 101 return false; 102 103 return page->settings()->shouldDisplaySubtitles(); 104 } 105 106 void CaptionUserPreferences::setUserPrefersSubtitles(bool preference) 107 { 108 Page* page = *(pageGroup()->pages().begin()); 109 if (!page) 110 return; 111 112 page->settings()->setShouldDisplaySubtitles(preference); 113 notify(); 114 } 115 116 bool CaptionUserPreferences::userPrefersTextDescriptions() const 117 { 118 Page* page = *(pageGroup()->pages().begin()); 119 if (!page) 120 return false; 121 122 return page->settings()->shouldDisplayTextDescriptions(); 123 } 124 125 void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference) 126 { 127 Page* page = *(pageGroup()->pages().begin()); 128 if (!page) 129 return; 130 131 page->settings()->setShouldDisplayTextDescriptions(preference); 132 notify(); 42 133 } 43 134 … … 59 150 { 60 151 m_userPreferredLanguage = language; 61 if (m_testingMode) { 62 m_havePreferences = true; 63 captionPreferencesChanged(); 64 } 152 notify(); 65 153 } 66 154 67 String CaptionUserPreferences::displayNameForTrack(TextTrack* track) const 155 static String trackDisplayName(TextTrack* track) 68 156 { 69 157 if (track->label().isEmpty() && track->language().isEmpty()) … … 74 162 } 75 163 164 String CaptionUserPreferences::displayNameForTrack(TextTrack* track) const 165 { 166 return trackDisplayName(track); 167 } 168 169 static bool textTrackCompare(const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b) 170 { 171 return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0; 172 } 173 174 Vector<RefPtr<TextTrack> > CaptionUserPreferences::sortedTrackListForMenu(TextTrackList* trackList) 175 { 176 ASSERT(trackList); 177 178 Vector<RefPtr<TextTrack> > tracksForMenu; 179 180 for (unsigned i = 0, length = trackList->length(); i < length; ++i) 181 tracksForMenu.append(trackList->item(i)); 182 183 nonCopyingSort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare); 184 185 return tracksForMenu; 186 } 187 76 188 } 77 189 -
trunk/Source/WebCore/page/CaptionUserPreferences.h
r145826 r146380 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "LocalizedStrings.h" 33 33 #include "TextTrack.h" 34 #include "Timer.h" 34 35 #include <wtf/PassOwnPtr.h> 35 36 #include <wtf/text/AtomicString.h> … … 38 39 39 40 class PageGroup; 41 class TextTrackList; 40 42 41 43 class CaptionUserPreferences { 42 44 public: 43 45 static PassOwnPtr<CaptionUserPreferences> create(PageGroup* group) { return adoptPtr(new CaptionUserPreferences(group)); } 44 virtual ~CaptionUserPreferences() { }46 virtual ~CaptionUserPreferences(); 45 47 46 48 virtual bool userHasCaptionPreferences() const { return m_testingMode && m_havePreferences; } 47 virtual bool userPrefersCaptions() const { return m_testingMode ? m_userPrefersCaptions : false; } 48 virtual void setUserPrefersCaptions(bool preference); 49 virtual bool shouldShowCaptions() const; 50 virtual void setShouldShowCaptions(bool); 51 52 virtual bool userPrefersCaptions() const; 53 virtual void setUserPrefersCaptions(bool); 54 55 virtual bool userPrefersSubtitles() const; 56 virtual void setUserPrefersSubtitles(bool preference); 57 58 virtual bool userPrefersTextDescriptions() const; 59 virtual void setUserPrefersTextDescriptions(bool preference); 60 49 61 virtual float captionFontSizeScale(bool& important) const { important = false; return 0.05f; } 50 62 virtual String captionsStyleSheetOverride() const { return emptyString(); } … … 58 70 59 71 virtual String displayNameForTrack(TextTrack*) const; 72 virtual Vector<RefPtr<TextTrack> > sortedTrackListForMenu(TextTrackList*); 60 73 61 74 virtual bool testingMode() const { return m_testingMode; } 62 75 virtual void setTestingMode(bool override) { m_testingMode = override; } 63 76 64 PageGroup* pageGroup() { return m_pageGroup; }77 PageGroup* pageGroup() const { return m_pageGroup; } 65 78 66 79 protected: 67 CaptionUserPreferences(PageGroup* group) 68 : m_pageGroup(group) 69 , m_testingMode(false) 70 , m_havePreferences(false) 71 , m_userPrefersCaptions(false) 72 { 73 } 80 CaptionUserPreferences(PageGroup*); 74 81 75 82 private: 83 void timerFired(Timer<CaptionUserPreferences>*); 84 void notify(); 85 76 86 PageGroup* m_pageGroup; 87 Timer<CaptionUserPreferences> m_timer; 77 88 String m_userPreferredLanguage; 78 89 bool m_testingMode; 79 90 bool m_havePreferences; 80 bool m_ userPrefersCaptions;91 bool m_shouldShowCaptions; 81 92 }; 82 93 -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.h
r145826 r146380 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) 44 44 virtual bool userHasCaptionPreferences() const OVERRIDE; 45 virtual bool shouldShowCaptions() const OVERRIDE; 46 virtual void setShouldShowCaptions(bool) OVERRIDE; 47 45 48 virtual bool userPrefersCaptions() const OVERRIDE; 46 virtual void setUserPrefersCaptions(bool) OVERRIDE; 49 virtual bool userPrefersSubtitles() const OVERRIDE; 50 47 51 virtual float captionFontSizeScale(bool&) const OVERRIDE; 48 52 virtual String captionsStyleSheetOverride() const OVERRIDE; … … 54 58 55 59 virtual void captionPreferencesChanged() OVERRIDE; 60 56 61 #endif 57 62 63 virtual Vector<RefPtr<TextTrack> > sortedTrackListForMenu(TextTrackList*) OVERRIDE; 58 64 virtual String displayNameForTrack(TextTrack*) const OVERRIDE; 59 65 -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm
r145826 r146380 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 42 42 #import "SoftLinking.h" 43 43 #import "TextTrackCue.h" 44 #import "TextTrackList.h" 44 45 #import "UserStyleSheetTypes.h" 46 #import <wtf/NonCopyingSort.h> 45 47 #import <wtf/RetainPtr.h> 46 48 #import <wtf/text/StringBuilder.h> … … 72 74 SOFT_LINK(MediaAccessibility, MACaptionAppearanceAddSelectedLanguage, bool, (MACaptionAppearanceDomain domain, CFStringRef language), (domain, language)); 73 75 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopySelectedLanguages, CFArrayRef, (MACaptionAppearanceDomain domain), (domain)); 76 SOFT_LINK(MediaAccessibility, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics, CFArrayRef, (MACaptionAppearanceDomain domain), (domain)); 74 77 75 78 SOFT_LINK_POINTER(MediaAccessibility, kMAXCaptionAppearanceSettingsChangedNotification, CFStringRef) … … 112 115 113 116 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) 117 118 bool CaptionUserPreferencesMac::shouldShowCaptions() const 119 { 120 if (testingMode() || !MediaAccessibilityLibrary()) 121 return CaptionUserPreferences::shouldShowCaptions(); 122 123 return MACaptionAppearanceGetShowCaptions(kMACaptionAppearanceDomainUser); 124 } 125 126 void CaptionUserPreferencesMac::setShouldShowCaptions(bool preference) 127 { 128 if (testingMode() || !MediaAccessibilityLibrary()) { 129 CaptionUserPreferences::setShouldShowCaptions(preference); 130 return; 131 } 132 133 MACaptionAppearanceSetShowCaptions(kMACaptionAppearanceDomainUser, preference); 134 } 135 114 136 bool CaptionUserPreferencesMac::userPrefersCaptions() const 115 137 { 116 if (testingMode() || !MediaAccessibilityLibrary()) 117 return CaptionUserPreferences::userPrefersCaptions(); 118 119 return MACaptionAppearanceGetShowCaptions(kMACaptionAppearanceDomainUser); 120 } 121 122 void CaptionUserPreferencesMac::setUserPrefersCaptions(bool preference) 123 { 124 if (testingMode() || !MediaAccessibilityLibrary()) { 125 CaptionUserPreferences::setUserPrefersCaptions(preference); 126 return; 127 } 128 129 MACaptionAppearanceSetShowCaptions(kMACaptionAppearanceDomainUser, preference); 138 bool captionSetting = CaptionUserPreferences::userPrefersCaptions(); 139 if (captionSetting || testingMode() || !MediaAccessibilityLibrary()) 140 return captionSetting; 141 142 RetainPtr<CFArrayRef> captioningMediaCharacteristics(AdoptCF, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics(kMACaptionAppearanceDomainUser)); 143 return captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get()); 144 } 145 146 bool CaptionUserPreferencesMac::userPrefersSubtitles() const 147 { 148 bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles(); 149 if (subtitlesSetting || testingMode() || !MediaAccessibilityLibrary()) 150 return subtitlesSetting; 151 152 RetainPtr<CFArrayRef> captioningMediaCharacteristics(AdoptCF, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics(kMACaptionAppearanceDomainUser)); 153 return !(captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get())); 130 154 } 131 155 … … 500 524 return userPreferredLanguages; 501 525 } 502 #endif 526 #endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK) 527 528 static String trackDisplayName(TextTrack* track) 529 { 530 StringBuilder displayName; 531 String label = track->label(); 532 String trackLanguageIdentifier = track->language(); 533 534 RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent()); 535 RetainPtr<CFStringRef> localeIdentifier(AdoptCF, CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, trackLanguageIdentifier.createCFString().get())); 536 RetainPtr<CFStringRef> languageCF(AdoptCF, CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleLanguageCode, localeIdentifier.get())); 537 String language = languageCF.get(); 538 if (!label.isEmpty()) { 539 if (!language.isEmpty() && !label.contains(language)) { 540 RetainPtr<CFDictionaryRef> localeDict(AdoptCF, CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorDefault, localeIdentifier.get())); 541 if (localeDict) { 542 CFStringRef countryCode = 0; 543 String countryName; 544 545 CFDictionaryGetValueIfPresent(localeDict.get(), kCFLocaleCountryCode, (const void **)&countryCode); 546 if (countryCode) { 547 RetainPtr<CFStringRef> countryNameCF(AdoptCF, CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleCountryCode, countryCode)); 548 countryName = countryNameCF.get(); 549 } 550 551 if (!countryName.isEmpty()) 552 displayName.append(textTrackCountryAndLanguageMenuItemText(label, countryName, language)); 553 else 554 displayName.append(textTrackLanguageMenuItemText(label, language)); 555 } 556 } 557 } else { 558 String languageAndLocale = CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, trackLanguageIdentifier.createCFString().get()); 559 if (!languageAndLocale.isEmpty()) 560 displayName.append(languageAndLocale); 561 else if (!language.isEmpty()) 562 displayName.append(language); 563 else 564 displayName.append(localeIdentifier.get()); 565 } 566 567 if (displayName.isEmpty()) 568 displayName.append(textTrackNoLabelText()); 569 570 if (track->isEasyToRead()) 571 return easyReaderTrackMenuItemText(displayName.toString()); 572 573 if (track->kind() != track->captionsKeyword()) 574 return displayName.toString(); 575 576 if (track->isClosedCaptions()) 577 return closedCaptionTrackMenuItemText(displayName.toString()); 578 579 return sdhTrackMenuItemText(displayName.toString()); 580 } 503 581 504 582 String CaptionUserPreferencesMac::displayNameForTrack(TextTrack* track) const 505 583 { 506 String label = track->label(); 507 String language = track->language(); 508 String preferredLanguage = defaultLanguage(); 509 StringBuilder displayName; 510 511 if (label.isEmpty() && language.isEmpty()) { 512 displayName.append(textTrackNoLabelText()); 513 return displayName.toString(); 514 } 515 516 if (!label.isEmpty()) 517 displayName.append(label); 518 519 AtomicString localeDisplayName = displayNameForLanguageLocale(language); 520 if (!label.contains(localeDisplayName)) { 521 if (displayName.length() > 0) 522 displayName.append(" "); 523 displayName.append(localeDisplayName); 524 } 525 526 if (track->kind() == track->captionsKeyword()) { 527 if (track->isClosedCaptions()) 528 displayName.append(" CC"); 529 else 530 displayName.append(" SDH"); 531 } 532 533 return displayName.toString(); 534 } 535 584 return trackDisplayName(track); 585 } 586 587 static String languageIdentifier(const String& languageCode) 588 { 589 if (languageCode.isEmpty()) 590 return languageCode; 591 592 String lowercaseLanguageCode = languageCode.lower(); 593 594 if (lowercaseLanguageCode.length() >= 3 && (lowercaseLanguageCode[2] == '_' || lowercaseLanguageCode[2] == '-')) 595 lowercaseLanguageCode.truncate(2); 596 597 return lowercaseLanguageCode; 598 } 599 600 static bool textTrackCompare(const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b) 601 { 602 String preferredLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(defaultLanguage())); 603 String aLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(a->language())); 604 String bLanguageDisplayName = displayNameForLanguageLocale(languageIdentifier(b->language())); 605 606 // Tracks in the user's preferred language are always at the top of the menu. 607 bool aIsPreferredLanguage = !codePointCompare(aLanguageDisplayName, preferredLanguageDisplayName); 608 bool bIsPreferredLanguage = !codePointCompare(bLanguageDisplayName, preferredLanguageDisplayName); 609 if ((aIsPreferredLanguage || bIsPreferredLanguage) && (aIsPreferredLanguage != bIsPreferredLanguage)) 610 return aIsPreferredLanguage; 611 612 // Tracks not in the user's preferred language sort first by language ... 613 if (codePointCompare(aLanguageDisplayName, bLanguageDisplayName)) 614 return codePointCompare(aLanguageDisplayName, bLanguageDisplayName) < 0; 615 616 // ... but when tracks have the same language, main program content sorts next highest ... 617 bool aIsMainContent = a->isMainProgramContent(); 618 bool bIsMainContent = b->isMainProgramContent(); 619 if ((aIsMainContent || bIsMainContent) && (aIsMainContent != bIsMainContent)) 620 return aIsMainContent; 621 622 // ... and main program trakcs sort higher than CC tracks ... 623 bool aIsCC = a->isClosedCaptions(); 624 bool bIsCC = b->isClosedCaptions(); 625 if ((aIsCC || bIsCC) && (aIsCC != bIsCC)) { 626 if (aIsCC) 627 return aIsMainContent; 628 return bIsMainContent; 629 } 630 631 // ... and tracks of the same type and language sort by the menu item text. 632 return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0; 633 } 634 635 Vector<RefPtr<TextTrack> > CaptionUserPreferencesMac::sortedTrackListForMenu(TextTrackList* trackList) 636 { 637 ASSERT(trackList); 638 639 Vector<RefPtr<TextTrack> > tracksForMenu; 640 HashSet<String> languagesIncluded; 641 bool prefersAccessibilityTracks = userPrefersCaptions(); 642 643 for (unsigned i = 0, length = trackList->length(); i < length; ++i) { 644 TextTrack* track = trackList->item(i); 645 String language = displayNameForLanguageLocale(track->language()); 646 647 if (track->isEasyToRead()) { 648 if (!language.isEmpty()) 649 languagesIncluded.add(language); 650 tracksForMenu.append(track); 651 continue; 652 } 653 654 if (track->containsOnlyForcedSubtitles()) 655 continue; 656 657 if (!language.isEmpty() && track->isMainProgramContent()) { 658 bool isAccessibilityTrack = track->kind() == track->captionsKeyword(); 659 if (prefersAccessibilityTracks) { 660 // In the first pass, include only caption tracks if the user prefers accessibility tracks. 661 if (!isAccessibilityTrack) { 662 LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - skipping %s because it is NOT an accessibility track", language.utf8().data()); 663 continue; 664 } 665 } else { 666 // In the first pass, only include the first non-CC or SDH track with each language if the user prefers translation tracks. 667 if (isAccessibilityTrack) { 668 LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - skipping %s because it is an accessibility track", language.utf8().data()); 669 continue; 670 } 671 if (languagesIncluded.contains(language)) { 672 LOG(Media, "CaptionUserPreferencesMac::sortedTrackListForMenu - skipping %s because it is not the first with this language", language.utf8().data()); 673 continue; 674 } 675 } 676 } 677 678 if (!language.isEmpty()) 679 languagesIncluded.add(language); 680 tracksForMenu.append(track); 681 } 682 683 // Now that we have filtered for the user's accessibility/translation preference, add all tracks with a unique language without regard to track type. 684 for (unsigned i = 0, length = trackList->length(); i < length; ++i) { 685 TextTrack* track = trackList->item(i); 686 String language = displayNameForLanguageLocale(track->language()); 687 688 // All candidates with no languge were added the first time through. 689 if (language.isEmpty()) 690 continue; 691 692 if (track->containsOnlyForcedSubtitles()) 693 continue; 694 695 if (!languagesIncluded.contains(language) && track->isMainProgramContent()) { 696 languagesIncluded.add(language); 697 tracksForMenu.append(track); 698 } 699 } 700 701 nonCopyingSort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare); 702 703 return tracksForMenu; 704 } 705 536 706 } 537 707 -
trunk/Source/WebCore/platform/Language.cpp
r142580 r146380 155 155 { 156 156 #if PLATFORM(MAC) 157 if (!localeName.isNull() && !localeName.isEmpty()) 158 return CFLocaleCopyDisplayNameForPropertyValue(CFLocaleCopyCurrent(), kCFLocaleIdentifier, localeName.createCFString().get()); 157 if (!localeName.isNull() && !localeName.isEmpty()) { 158 RetainPtr<CFLocaleRef> currentLocale(AdoptCF, CFLocaleCopyCurrent()); 159 return CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, localeName.createCFString().get()); 160 } 159 161 #endif 160 162 return localeName; -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r143232 r146380 1028 1028 String textTrackNoLabelText() 1029 1029 { 1030 return WEB_UI_STRING_KEY("Unknown", "Unknown (closed captions track)", "Menu item label for a closed captions track that has no other name"); 1031 } 1030 return WEB_UI_STRING_KEY("Unknown", "Unknown (text track)", "Menu item label for a text track that has no other name"); 1031 } 1032 1033 #if PLATFORM(MAC) 1034 String textTrackCountryAndLanguageMenuItemText(const String& title, const String& country, const String& language) 1035 { 1036 return formatLocalizedString(WEB_UI_STRING("%@ (%@-%@)", "Text track display name format that includes the country and language of the subtitle, in the form of 'Title (Language-Country)'"), title.createCFString().get(), language.createCFString().get(), country.createCFString().get()); 1037 } 1038 1039 String textTrackLanguageMenuItemText(const String& title, const String& language) 1040 { 1041 return formatLocalizedString(WEB_UI_STRING("%@ (%@)", "Text track display name format that includes the language of the subtitle, in the form of 'Title (Language)'"), title.createCFString().get(), language.createCFString().get()); 1042 } 1043 1044 String closedCaptionTrackMenuItemText(const String& title) 1045 { 1046 return formatLocalizedString(WEB_UI_STRING("%@ CC", "Text track contains closed captions"), title.createCFString().get()); 1047 } 1048 1049 String sdhTrackMenuItemText(const String& title) 1050 { 1051 return formatLocalizedString(WEB_UI_STRING("%@ SDH", "Text track contains subtitles for the deaf and hard of hearing"), title.createCFString().get()); 1052 } 1053 1054 String easyReaderTrackMenuItemText(const String& title) 1055 { 1056 return formatLocalizedString(WEB_UI_STRING("%@ Easy Reader", "Text track contains simplified (3rd grade level) subtitles"), title.createCFString().get()); 1057 } 1058 #endif 1059 1032 1060 #endif 1033 1061 -
trunk/Source/WebCore/platform/LocalizedStrings.h
r142507 r146380 269 269 String textTrackOffText(); 270 270 String textTrackNoLabelText(); 271 #if PLATFORM(MAC) 272 String textTrackCountryAndLanguageMenuItemText(const String& title, const String& country, const String& language); 273 String textTrackLanguageMenuItemText(const String& title, const String& language); 274 String closedCaptionTrackMenuItemText(const String&); 275 String sdhTrackMenuItemText(const String&); 276 String easyReaderTrackMenuItemText(const String&); 277 #endif 271 278 #endif 272 279 -
trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
r141957 r146380 57 57 virtual Kind kind() const { return Subtitles; } 58 58 virtual bool isClosedCaptions() const { return false; } 59 virtual bool containsOnlyForcedSubtitles() const { return false; } 60 virtual bool isMainProgramContent() const { return true; } 61 virtual bool isEasyToRead() const { return false; } 59 62 60 63 virtual AtomicString label() const { return emptyAtom; } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
r141957 r146380 50 50 virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE; 51 51 virtual bool isClosedCaptions() const OVERRIDE; 52 virtual bool containsOnlyForcedSubtitles() const OVERRIDE; 53 virtual bool isMainProgramContent() const OVERRIDE; 54 virtual bool isEasyToRead() const OVERRIDE; 52 55 virtual AtomicString label() const OVERRIDE; 53 56 virtual AtomicString language() const OVERRIDE; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
r141957 r146380 53 53 #define AVMediaCharacteristicAudible getAVMediaCharacteristicAudible() 54 54 #define AVMediaTypeClosedCaption getAVMediaTypeClosedCaption() 55 #define AVMediaTypeVideo getAVMediaTypeVideo() 56 #define AVMediaTypeAudio getAVMediaTypeAudio() 55 #define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles() 56 #define AVMediaCharacteristicIsMainProgramContent getAVMediaCharacteristicIsMainProgramContent() 57 #define AVMediaCharacteristicEasyToRead getAVMediaCharacteristicEasyToRead() 57 58 58 59 SOFT_LINK_POINTER(AVFoundation, AVMediaTypeClosedCaption, NSString *) … … 63 64 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *) 64 65 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString *) 66 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *) 67 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *) 68 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicEasyToRead, NSString *) 69 65 70 #define AVMetadataItem getAVMetadataItemClass() 66 71 #define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass() … … 120 125 } 121 126 127 bool InbandTextTrackPrivateAVFObjC::containsOnlyForcedSubtitles() const 128 { 129 if (!m_mediaSelectionOption) 130 return false; 131 132 return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles]; 133 } 134 135 bool InbandTextTrackPrivateAVFObjC::isMainProgramContent() const 136 { 137 if (!m_mediaSelectionOption) 138 return false; 139 140 return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent]; 141 } 142 143 bool InbandTextTrackPrivateAVFObjC::isEasyToRead() const 144 { 145 if (!m_mediaSelectionOption) 146 return false; 147 148 return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicEasyToRead]; 149 } 150 122 151 AtomicString InbandTextTrackPrivateAVFObjC::label() const 123 152 { -
trunk/Source/WebCore/testing/InternalSettings.cpp
r145750 r146380 28 28 #include "InternalSettings.h" 29 29 30 #include "CaptionUserPreferences.h" 30 31 #include "Document.h" 31 32 #include "ExceptionCode.h" … … 35 36 #include "LocaleToScriptMapping.h" 36 37 #include "Page.h" 38 #include "PageGroup.h" 37 39 #include "RuntimeEnabledFeatures.h" 38 40 #include "Settings.h" … … 427 429 428 430 #if ENABLE(VIDEO_TRACK) 431 if (!page()) 432 return; 433 CaptionUserPreferences* captionPreferences = page()->group().captionPreferences(); 434 429 435 if (equalIgnoringCase(kind, "Subtitles")) 430 settings()->setShouldDisplaySubtitles(enabled);436 captionPreferences->setUserPrefersSubtitles(enabled); 431 437 else if (equalIgnoringCase(kind, "Captions")) 432 settings()->setShouldDisplayCaptions(enabled);438 captionPreferences->setUserPrefersCaptions(enabled); 433 439 else if (equalIgnoringCase(kind, "TextDescriptions")) 434 settings()->setShouldDisplayTextDescriptions(enabled);440 captionPreferences->setUserPrefersTextDescriptions(enabled); 435 441 else 436 442 ec = SYNTAX_ERR; … … 446 452 447 453 #if ENABLE(VIDEO_TRACK) 454 if (!page()) 455 return false; 456 CaptionUserPreferences* captionPreferences = page()->group().captionPreferences(); 457 448 458 if (equalIgnoringCase(kind, "Subtitles")) 449 return settings()->shouldDisplaySubtitles();459 return captionPreferences->userPrefersSubtitles(); 450 460 if (equalIgnoringCase(kind, "Captions")) 451 return settings()->shouldDisplayCaptions();461 return captionPreferences->userPrefersCaptions(); 452 462 if (equalIgnoringCase(kind, "TextDescriptions")) 453 return settings()->shouldDisplayTextDescriptions();463 return captionPreferences->userPrefersTextDescriptions(); 454 464 455 465 ec = SYNTAX_ERR; -
trunk/Source/WebKit/ChangeLog
r146367 r146380 1 2013-03-20 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports specific text track menu 4 https://bugs.webkit.org/show_bug.cgi?id=112800 5 6 Reviewed by Dean Jackson. 7 8 * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: Add new exports. 9 * win/WebKit.vcproj/WebKitExports.def.in: Ditto. 10 1 11 2013-03-20 Roger Fong <roger_fong@apple.com> 2 12 -
trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
r146367 r146380 417 417 ?setAcceleratedCompositingEnabled@Settings@WebCore@@QAEX_N@Z 418 418 ?setAutofilled@HTMLInputElement@WebCore@@QAEX_N@Z 419 ?captionPreferences@PageGroup@WebCore@@QAEPAVCaptionUserPreferences@2@XZ 420 ?initGroup@Page@WebCore@@AAEXXZ 419 421 420 422 #if ENABLE(WORKERS) -
trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in
r146361 r146380 417 417 ?setAcceleratedCompositingEnabled@Settings@WebCore@@QAEX_N@Z 418 418 ?setAutofilled@HTMLInputElement@WebCore@@QAEX_N@Z 419 ?captionPreferences@PageGroup@WebCore@@QAEPAVCaptionUserPreferences@2@XZ 420 ?initGroup@Page@WebCore@@AAEXXZ 419 421 420 422 #if ENABLE(WORKERS)
Note:
See TracChangeset
for help on using the changeset viewer.