Changeset 141864 in webkit
- Timestamp:
- Feb 5, 2013 12:03:22 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141861 r141864 1 2013-02-04 Dean Jackson <dino@apple.com> 2 3 [Mac] Captions menu should indicate language and type of track 4 https://bugs.webkit.org/show_bug.cgi?id=108882 5 6 Reviewed by Eric Carlson. 7 8 Now that the captions menu can be labelled in a platform-specific way, move 9 the results into the platform directory. At the moment, they are skipped 10 everywhere but Mac. Also update the tests to the new menu structure, which 11 only has a single list of entries. 12 13 * media/video-controls-captions-trackmenu-localized.html: Updated for new menu structure. 14 * media/video-controls-captions-trackmenu-expected.txt: Removed. 15 * media/video-controls-captions-trackmenu-localized-expected.txt: Removed. 16 * media/video-controls-captions-trackmenu-sorted-expected.txt: Removed. 17 * media/video-controls-captions-trackmenu-sorted.html: Updated for new menu structure. 18 * media/video-controls-captions-trackmenu.html: Updated for new menu structure. 19 * platform/mac/media/video-controls-captions-trackmenu-expected.txt: New platform specific results. 20 * platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt: Ditto. 21 * platform/mac/media/video-controls-captions-trackmenu-sorted-expected.txt: Ditto. 22 1 23 2013-02-04 Hajime Morrita <morrita@google.com> 2 24 -
trunk/LayoutTests/media/video-controls-captions-trackmenu-localized.html
r138283 r141864 9 9 <script> 10 10 11 var captionsSection;11 var trackListSection; 12 12 var item; 13 13 … … 21 21 return; 22 22 23 // Track list should have two <section> elements. 24 var trackListSections = trackListElement.querySelectorAll("h3"); 25 if (!trackListSections || trackListSections.length != 2) { 26 failTest("There should be two section elements in track list menu"); 23 trackListSection = trackListElement.querySelector("h3"); 24 if (!trackListSection) { 25 failTest("There should be a single section element in track list menu"); 27 26 return; 28 27 } 29 28 30 captionsSection = trackListSections[0]; 31 logConsole("First section should be labelled 'Closed Captions'"); 32 testExpected("captionsSection.textContent", "Closed Captions"); 33 captionsSection = trackListSections[1]; 34 logConsole("Second section should be labelled 'Subtitles'"); 35 testExpected("captionsSection.textContent", "Subtitles"); 29 logConsole("Heading should be labelled 'Subtitles'"); 30 testExpected("trackListSection.textContent", "Subtitles"); 36 31 37 32 var captionsEntries = trackListElement.querySelectorAll("li"); -
trunk/LayoutTests/media/video-controls-captions-trackmenu-sorted.html
r138283 r141864 16 16 if (!trackListElement) 17 17 return; 18 // Track list should have two <ul> elements. 19 var trackListSections = trackListElement.querySelectorAll("ul"); 20 if (!trackListSections || trackListSections.length != 2) { 21 failTest("There should be two ul elements in track list menu"); 18 var trackListSection = trackListElement.querySelector("ul"); 19 if (!trackListSection) { 20 failTest("There should be a ul element in track list menu"); 22 21 return; 23 22 } 24 for (var i = 0; i < trackListSections.length; i++) { 25 consoleWrite("<br>*** Test menu section " + i + "."); 26 var lastTrackLabel = null; 27 var trackListItems = trackListSections[i].querySelectorAll("li"); 28 if (!trackListItems || trackListItems.length != 5) { 29 failTest("There should be five li elements in this section"); 30 return; 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 } 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; 31 39 } 32 for (var j = 0; j < trackListItems.length; j++) {33 var item = trackListItems[j];34 if (j == 0)35 logResult(item.textContent == "Off", "First item should be labelled off");36 else {37 if (lastTrackLabel)38 logResult(item.textContent > lastTrackLabel, lastTrackLabel + " comes before " + item.textContent);39 else40 logResult(true, item.textContent + " is the first real item in the list");41 lastTrackLabel = item.textContent;42 }43 }44 consoleWrite("Menu section " + i + " was ok.<br>");45 40 } 46 41 endTest(); … … 62 57 <track label="b" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au"> 63 58 <track label="a" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en"> 64 <track label="d" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">65 59 <track label="b" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja"> 66 60 <track label="a" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au"> 67 61 <track label="c" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en"> 68 <track label="d" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">69 62 </video> 70 63 </body> -
trunk/LayoutTests/media/video-controls-captions-trackmenu.html
r138322 r141864 23 23 if (!trackListElement) 24 24 return; 25 // Track list should have a <ul> with five<li> children (One of them is "Off").25 // Track list should have a <ul> with <li> children (One of them is "Off"). 26 26 var trackList = trackListElement.querySelector("ul"); 27 27 if (!trackList) { … … 71 71 testExpected("video.textTracks.length", 4); 72 72 consoleWrite("Track 0 should be showing"); 73 testExpected("video.textTracks[0].mode", " disabled");73 testExpected("video.textTracks[0].mode", "showing"); 74 74 consoleWrite("Track 1 should be disabled"); 75 testExpected("video.textTracks[1].mode", " showing");75 testExpected("video.textTracks[1].mode", "disabled"); 76 76 consoleWrite("Track 2 should be disabled"); 77 77 testExpected("video.textTracks[2].mode", "disabled"); -
trunk/LayoutTests/platform/mac/media/video-controls-captions-trackmenu-expected.txt
r141862 r141864 13 13 EXPECTED (video.textTracks.length == '4') OK 14 14 Track 0 should be showing 15 EXPECTED (video.textTracks[0].mode == ' disabled') OK15 EXPECTED (video.textTracks[0].mode == 'showing') OK 16 16 Track 1 should be disabled 17 EXPECTED (video.textTracks[1].mode == ' showing') OK17 EXPECTED (video.textTracks[1].mode == 'disabled') OK 18 18 Track 2 should be disabled 19 19 EXPECTED (video.textTracks[2].mode == 'disabled') OK -
trunk/LayoutTests/platform/mac/media/video-controls-captions-trackmenu-localized-expected.txt
r141862 r141864 5 5 *** Set the user language preference. 6 6 RUN(internals.setUserPreferredLanguages(['en'])) 7 EXPECTED (captionsSection.textContent == 'Closed Captions') OK 8 EXPECTED (captionsSection.textContent == 'Subtitles') OK 7 EXPECTED (trackListSection.textContent == 'Subtitles') OK 9 8 EXPECTED (item.textContent == 'Off') OK 10 9 EXPECTED (item.textContent == 'No label') OK -
trunk/Source/WebCore/ChangeLog
r141862 r141864 1 2013-02-04 Dean Jackson <dino@apple.com> 2 3 [Mac] Captions menu should indicate language and type of track 4 https://bugs.webkit.org/show_bug.cgi?id=108882 5 6 Reviewed by Eric Carlson. 7 8 On Mac, we want a specific format for menu items in a caption list. Since 9 other ports might want different formats, move the generation of the label 10 into CaptionsUserPreferences where it can be overridden. 11 12 This required CaptionsUserPreferences to become public on the PageGroup, so 13 it could be used when creating the menu. Also, since CaptionsUserPreferences 14 was hidden on Mountain Lion and below, be a little more specific about 15 which pieces can be seen on which builds. 16 17 Covered by exisiting media/video-controls-captions-trackmenu tests. 18 19 * English.lproj/Localizable.strings: Remove textTrackClosedCaptionsText. 20 * html/shadow/MediaControlElements.cpp: 21 (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu): Build only 22 one section and get the track's display name from the user preferences. 23 * page/CaptionUserPreferences.h: 24 (WebCore::CaptionUserPreferences::displayNameForTrack): Default implementation of 25 virtual function that provides a label for a captions menu item. 26 * page/CaptionUserPreferencesMac.h: Add the new virtual function, and expose just 27 a bit of this class outside 10.9 builds. 28 * page/CaptionUserPreferencesMac.mm: 29 (WebCore::CaptionUserPreferencesMac::CaptionUserPreferencesMac): Guard features for system version. 30 (WebCore::CaptionUserPreferencesMac::~CaptionUserPreferencesMac): Ditto. 31 (WebCore::CaptionUserPreferencesMac::displayNameForTrack): New OS X-specific method that 32 returns a string for the menu label. 33 * page/PageGroup.cpp: 34 (WebCore::PageGroup::captionPreferences): Unguard for system version. 35 * page/PageGroup.h: Make captionPreferences public. 36 * platform/LocalizedStrings.cpp: Remove textTrackClosedCaptionsText - not needed any more. 37 * platform/LocalizedStrings.h: Remove textTrackClosedCaptionsText. 38 1 39 2013-02-04 Kentaro Hara <haraken@chromium.org> 2 40 -
trunk/Source/WebCore/English.lproj/Localizable.strings
r140974 r141864 98 98 "Click to exit full screen mode" = "Click to exit full screen mode"; 99 99 100 /* Menu section heading for closed captions */101 "Closed Captions" = "Closed Captions";102 103 100 /* WebKitErrorCannotShowMIMEType description */ 104 101 "Content with specified MIME type can’t be shown" = "Content with specified MIME type can’t be shown"; … … 611 608 "current movie time in seconds" = "current movie time in seconds"; 612 609 613 /* definition detail*/610 /* role description of ARIA definition role */ 614 611 "definition" = "definition"; 615 612 … … 872 869 "temporarily redirected" = "temporarily redirected"; 873 870 874 /* term word of a de finition*/871 /* term word of a description list */ 875 872 "term" = "term"; 876 873 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r141790 r141864 33 33 #include "MediaControlElements.h" 34 34 35 #include "CaptionUserPreferences.h" 35 36 #include "DOMTokenList.h" 36 37 #include "EventNames.h" … … 872 873 873 874 Document* doc = document(); 875 CaptionUserPreferences* captionsUserPreferences = doc->page()->group().captionPreferences(); 874 876 875 877 RefPtr<Element> captionsSection = doc->createElement(sectionTag, ASSERT_NO_EXCEPTION); 876 878 RefPtr<Element> captionsHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION); 877 captionsHeader->appendChild(doc->createTextNode(textTrack ClosedCaptionsText()));879 captionsHeader->appendChild(doc->createTextNode(textTrackSubtitlesText())); 878 880 captionsSection->appendChild(captionsHeader); 879 881 RefPtr<Element> captionsMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION); 880 881 RefPtr<Element> subtitlesSection = doc->createElement(sectionTag, ASSERT_NO_EXCEPTION);882 RefPtr<Element> subtitlesHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);883 subtitlesHeader->appendChild(doc->createTextNode(textTrackSubtitlesText()));884 subtitlesSection->appendChild(subtitlesHeader);885 RefPtr<Element> subtitlesMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);886 882 887 883 RefPtr<Element> trackItem; … … 893 889 m_menuItems.append(trackItem); 894 890 895 trackItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);896 trackItem->appendChild(doc->createTextNode(textTrackOffText()));897 trackItem->setAttribute(trackIndexAttributeName(), textTracksOffAttrValue, ASSERT_NO_EXCEPTION);898 subtitlesMenuList->appendChild(trackItem);899 m_menuItems.append(trackItem);900 901 bool hasCaptions = false;902 bool hasSubtitles = false;903 904 891 for (unsigned i = 0, length = trackList->length(); i < length; ++i) { 905 892 TextTrack* track = trackList->item(i); … … 912 899 trackItem->setAttribute(trackIndexAttributeName(), String::number(i), ASSERT_NO_EXCEPTION); 913 900 914 AtomicString labelText = track->label(); 915 if (labelText.isNull() || labelText.isEmpty()) 916 labelText = displayNameForLanguageLocale(track->language()); 917 if (labelText.isNull() || labelText.isEmpty()) 918 labelText = textTrackNoLabelText(); 919 trackItem->appendChild(doc->createTextNode(labelText)); 920 921 if (track->kind() == track->captionsKeyword()) { 922 hasCaptions = true; 923 insertTextTrackMenuItemIntoSortedContainer(trackItem, captionsMenuList); 924 } 925 if (track->kind() == track->subtitlesKeyword()) { 926 hasSubtitles = true; 927 insertTextTrackMenuItemIntoSortedContainer(trackItem, subtitlesMenuList); 928 } 901 if (captionsUserPreferences) 902 trackItem->appendChild(doc->createTextNode(captionsUserPreferences->displayNameForTrack(track))); 903 else 904 trackItem->appendChild(doc->createTextNode(track->label())); 905 906 insertTextTrackMenuItemIntoSortedContainer(trackItem, captionsMenuList); 929 907 m_menuItems.append(trackItem); 930 908 } 931 909 932 910 captionsSection->appendChild(captionsMenuList); 933 subtitlesSection->appendChild(subtitlesMenuList); 934 935 if (hasCaptions) 936 appendChild(captionsSection); 937 if (hasSubtitles) 938 appendChild(subtitlesSection); 911 appendChild(captionsSection); 939 912 940 913 updateDisplay(); -
trunk/Source/WebCore/page/CaptionUserPreferences.h
r141790 r141864 30 30 31 31 #include "Language.h" 32 #include "LocalizedStrings.h" 33 #include "TextTrack.h" 32 34 #include <wtf/PassOwnPtr.h> 33 35 #include <wtf/text/AtomicString.h> … … 60 62 virtual Vector<String> preferredLanguages() const { return platformUserPreferredLanguages(); } 61 63 64 virtual String displayNameForTrack(TextTrack* track) const 65 { 66 if (track->label().isEmpty() && track->language().isEmpty()) 67 return textTrackNoLabelText(); 68 if (!track->label().isEmpty()) 69 return track->label(); 70 return track->language(); 71 } 72 62 73 PageGroup* pageGroup() { return m_pageGroup; } 63 74 -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.h
r141790 r141864 27 27 #define CaptionUserPreferencesMac_h 28 28 29 #if ENABLE(VIDEO_TRACK) && MAC_OS_X_VERSION_MIN_REQUIRED >= 109029 #if ENABLE(VIDEO_TRACK) 30 30 31 31 #include "CSSPropertyNames.h" … … 41 41 virtual ~CaptionUserPreferencesMac(); 42 42 43 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 43 44 virtual bool userPrefersCaptions() const OVERRIDE; 44 45 virtual void setUserPrefersCaptions(bool) OVERRIDE; … … 53 54 54 55 void captionPreferencesChanged(); 56 #endif 57 58 virtual String displayNameForTrack(TextTrack*) const OVERRIDE; 55 59 56 60 private: 57 61 CaptionUserPreferencesMac(PageGroup*); 58 62 63 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 59 64 String captionsWindowCSS() const; 60 65 String captionsBackgroundCSS() const; … … 72 77 HashSet<CaptionPreferencesChangedListener*> m_captionPreferenceChangeListeners; 73 78 bool m_listeningForPreferenceChanges; 79 #endif 74 80 }; 75 81 -
trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm
r141790 r141864 26 26 #import "config.h" 27 27 28 #if ENABLE(VIDEO_TRACK) && MAC_OS_X_VERSION_MIN_REQUIRED >= 109028 #if ENABLE(VIDEO_TRACK) 29 29 30 30 #import "CaptionUserPreferencesMac.h" … … 35 35 #import "FloatConversion.h" 36 36 #import "KURL.h" 37 #import "Language.h" 38 #import "LocalizedStrings.h" 39 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 37 40 #import "MediaAccessibility/MediaAccessibility.h" 41 #endif 38 42 #import "PageGroup.h" 39 43 #import "SoftLinking.h" … … 42 46 #import <wtf/RetainPtr.h> 43 47 #import <wtf/text/StringBuilder.h> 48 49 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 44 50 45 51 SOFT_LINK_FRAMEWORK_OPTIONAL(MediaAccessibility) … … 63 69 #define kMAXCaptionAppearanceSettingsChangedNotification getkMAXCaptionAppearanceSettingsChangedNotification() 64 70 71 #endif 72 65 73 using namespace std; 66 74 67 75 namespace WebCore { 68 76 77 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 69 78 static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef) 70 79 { 71 80 static_cast<CaptionUserPreferencesMac*>(observer)->captionPreferencesChanged(); 72 81 } 82 #endif 73 83 74 84 CaptionUserPreferencesMac::CaptionUserPreferencesMac(PageGroup* group) 75 85 : CaptionUserPreferences(group) 86 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 76 87 , m_listeningForPreferenceChanges(false) 88 #endif 77 89 { 78 90 } … … 80 92 CaptionUserPreferencesMac::~CaptionUserPreferencesMac() 81 93 { 94 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 82 95 if (kMAXCaptionAppearanceSettingsChangedNotification) 83 96 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, kMAXCaptionAppearanceSettingsChangedNotification, NULL); 84 } 85 97 #endif 98 } 99 100 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 86 101 bool CaptionUserPreferencesMac::userPrefersCaptions() const 87 102 { … … 398 413 return userPreferredLanguages; 399 414 } 415 #endif 416 417 String CaptionUserPreferencesMac::displayNameForTrack(TextTrack* track) const 418 { 419 String label = track->label(); 420 String language = track->language(); 421 String preferredLanguage = defaultLanguage(); 422 StringBuilder displayName; 423 424 if (label.isEmpty() && language.isEmpty()) { 425 displayName.append(textTrackNoLabelText()); 426 return displayName.toString(); 427 } 428 429 if (!label.isEmpty()) 430 displayName.append(label); 431 432 AtomicString localeDisplayName = displayNameForLanguageLocale(language); 433 if (!label.contains(localeDisplayName)) { 434 if (displayName.length() > 0) 435 displayName.append(" "); 436 displayName.append(localeDisplayName); 437 } 438 439 if (track->kind() == track->captionsKeyword()) { 440 if (track->isClosedCaptions()) 441 displayName.append(" CC"); 442 else 443 displayName.append(" SDH"); 444 } 445 446 return displayName.toString(); 447 } 400 448 401 449 } -
trunk/Source/WebCore/page/PageGroup.cpp
r141790 r141864 40 40 41 41 #if ENABLE(VIDEO_TRACK) 42 #if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 109042 #if PLATFORM(MAC) 43 43 #include "CaptionUserPreferencesMac.h" 44 44 #else … … 421 421 { 422 422 if (!m_captionPreferences) 423 #if PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090423 #if PLATFORM(MAC) 424 424 m_captionPreferences = CaptionUserPreferencesMac::create(this); 425 425 #else -
trunk/Source/WebCore/page/PageGroup.h
r141790 r141864 115 115 void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*); 116 116 void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*); 117 CaptionUserPreferences* captionPreferences(); 117 118 #endif 118 119 … … 123 124 void invalidatedInjectedStyleSheetCacheInAllFrames(); 124 125 125 #if ENABLE(VIDEO_TRACK)126 CaptionUserPreferences* captionPreferences();127 #endif128 126 String m_name; 129 127 -
trunk/Source/WebCore/platform/LocalizedStrings.cpp
r140974 r141864 1016 1016 1017 1017 #if ENABLE(VIDEO_TRACK) 1018 String textTrackClosedCaptionsText()1019 {1020 return WEB_UI_STRING("Closed Captions", "Menu section heading for closed captions");1021 }1022 1023 1018 String textTrackSubtitlesText() 1024 1019 { -
trunk/Source/WebCore/platform/LocalizedStrings.h
r140974 r141864 266 266 267 267 #if ENABLE(VIDEO_TRACK) 268 String textTrackClosedCaptionsText();269 268 String textTrackSubtitlesText(); 270 269 String textTrackOffText();
Note: See TracChangeset
for help on using the changeset viewer.