From 92907e15cdf4436c32de035e81fd3456288d2260 Mon Sep 17 00:00:00 2001 From: "eric.carlson@apple.com" Date: Wed, 27 Mar 2013 18:45:29 +0000 Subject: [PATCH] [Mac] webkitClosedCaptionsVisible doesn't work https://bugs.webkit.org/show_bug.cgi?id=113417 Reviewed by Jer Noble. Source/WebCore: Test: media/track/track-in-band-legacy-api.html * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): Delete m_disableCaptions, it is no longer used. (WebCore::HTMLMediaElement::configureTextTrackGroup): Pass this to textTrackSelectionScore. (WebCore::HTMLMediaElement::setClosedCaptionsVisible): Delete m_disableCaptions, it is no longer used. * html/HTMLMediaElement.h: Ditto. * page/CaptionUserPreferences.cpp: (WebCore::CaptionUserPreferences::textTrackSelectionScore): Add an HTMLMediaElement parameter. * page/CaptionUserPreferences.h: * page/CaptionUserPreferencesMac.h: * page/CaptionUserPreferencesMac.mm: (WebCore::CaptionUserPreferencesMac::textTrackSelectionScore): Return a score if the media element is showing captions, even if the preference says captions are disabled. LayoutTests: * media/track/track-in-band-legacy-api-expected.txt: Added. * media/track/track-in-band-legacy-api.html: Added. * platform/chromium/TestExpectations: Skip new test. * platform/efl/TestExpectations: Ditto. * platform/gtk/TestExpectations: Ditto. * platform/mac/TestExpectations: Ditto. * platform/qt/TestExpectations: Ditto. * platform/win/TestExpectations: Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147001 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 17 ++++++ .../track-in-band-legacy-api-expected.txt | 27 +++++++++ .../media/track/track-in-band-legacy-api.html | 56 +++++++++++++++++++ .../platform/chromium/TestExpectations | 1 + LayoutTests/platform/efl/TestExpectations | 1 + LayoutTests/platform/gtk/TestExpectations | 1 + LayoutTests/platform/mac/TestExpectations | 1 + LayoutTests/platform/qt/TestExpectations | 1 + LayoutTests/platform/win/TestExpectations | 1 + Source/WebCore/ChangeLog | 24 ++++++++ Source/WebCore/html/HTMLMediaElement.cpp | 11 +--- Source/WebCore/html/HTMLMediaElement.h | 1 - .../WebCore/page/CaptionUserPreferences.cpp | 2 +- Source/WebCore/page/CaptionUserPreferences.h | 3 +- .../WebCore/page/CaptionUserPreferencesMac.h | 2 +- .../WebCore/page/CaptionUserPreferencesMac.mm | 9 +-- 16 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 LayoutTests/media/track/track-in-band-legacy-api-expected.txt create mode 100644 LayoutTests/media/track/track-in-band-legacy-api.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 0032f9698b1..6f883bfd99b 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,20 @@ +2013-03-27 Eric Carlson + + [Mac] webkitClosedCaptionsVisible doesn't work + https://bugs.webkit.org/show_bug.cgi?id=113417 + + Reviewed by Jer Noble. + + * media/track/track-in-band-legacy-api-expected.txt: Added. + * media/track/track-in-band-legacy-api.html: Added. + + * platform/chromium/TestExpectations: Skip new test. + * platform/efl/TestExpectations: Ditto. + * platform/gtk/TestExpectations: Ditto. + * platform/mac/TestExpectations: Ditto. + * platform/qt/TestExpectations: Ditto. + * platform/win/TestExpectations: Ditto. + 2013-03-27 Eric Carlson [Mac] Text track menu items sometimes labeled incorrectly diff --git a/LayoutTests/media/track/track-in-band-legacy-api-expected.txt b/LayoutTests/media/track/track-in-band-legacy-api-expected.txt new file mode 100644 index 00000000000..6c761cf6946 --- /dev/null +++ b/LayoutTests/media/track/track-in-band-legacy-api-expected.txt @@ -0,0 +1,27 @@ +Test that in-band tracks work with .webkitClosedCaptionsVisible. + +EVENT(canplaythrough) + +** Check initial in-band track states +EXPECTED (video.textTracks.length == '1') OK +RUN(inbandTrack1 = video.textTracks[0]) +EXPECTED (inbandTrack1.mode == 'disabled') OK +EXPECTED (inbandTrack1.cues == 'null') OK +EXPECTED (inbandTrack1.language == 'en') OK +EXPECTED (inbandTrack1.kind == 'captions') OK + +** Enable cues and let them load +RUN(video.webkitClosedCaptionsVisible = true) +RUN(video.play()) +EVENT(seeked) + +** Test to make sure captions are displaying +EXPECTED (inbandTrack1.cues != 'null') OK +EXPECTED (textTrackDisplayElement(video, 'cue').textContent != 'null') OK + +** Disable captions, cues should be flushed +RUN(video.webkitClosedCaptionsVisible = false) +EXPECTED (inbandTrack1.cues == 'null') OK + +END OF TEST + diff --git a/LayoutTests/media/track/track-in-band-legacy-api.html b/LayoutTests/media/track/track-in-band-legacy-api.html new file mode 100644 index 00000000000..9d86a9e9225 --- /dev/null +++ b/LayoutTests/media/track/track-in-band-legacy-api.html @@ -0,0 +1,56 @@ + + + + In-band tracks enabled/disabled with legacy API + + + + + + + + +

Test that in-band tracks work with .webkitClosedCaptionsVisible.

+ + diff --git a/LayoutTests/platform/chromium/TestExpectations b/LayoutTests/platform/chromium/TestExpectations index 783ecac45ee..4bc1d67af42 100644 --- a/LayoutTests/platform/chromium/TestExpectations +++ b/LayoutTests/platform/chromium/TestExpectations @@ -3578,6 +3578,7 @@ webkit.org/b/94002 [ Mac Debug ] inspector/debugger/live-edit.html [ Crash Pass webkit.org/b/103767 [ Win Mac Linux ] media/track/track-in-band.html [ Skip ] webkit.org/b/103767 [ Win Mac Linux ] media/track/track-in-band-cues-added-once.html [ Skip ] webkit.org/b/103767 [ Win Mac Linux ] media/track/track-in-band-style.html [ Skip ] +webkit.org/b/103767 [ Win Mac Linux ] media/track/track-in-band-legacy-api.html [ Skip ] # Flaky on Win (perhaps due to lighttpd?) webkit.org/b/104489 [ Win ] http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_attribute_order.html [ Failure Pass ] diff --git a/LayoutTests/platform/efl/TestExpectations b/LayoutTests/platform/efl/TestExpectations index af404d1d50d..dda0f66a7ce 100644 --- a/LayoutTests/platform/efl/TestExpectations +++ b/LayoutTests/platform/efl/TestExpectations @@ -1622,6 +1622,7 @@ webkit.org/b/61138 http/tests/w3c/webperf/submission/Google/resource-timing [ Sk Bug(EFL) media/track/track-in-band.html [ Skip ] Bug(EFL) media/track/track-in-band-cues-added-once.html [ Skip ] Bug(EFL) media/track/track-in-band-style.html [ Skip ] +Bug(EFL) media/track/track-in-band-legacy-api.html [ Skip ] # All debug bots timeout (crash) on this one webkit.org/b/56496 [ Debug ] fast/js/array-sort-modifying-tostring.html [ Crash Pass ] diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations index cd7abe11b15..639d1f68937 100644 --- a/LayoutTests/platform/gtk/TestExpectations +++ b/LayoutTests/platform/gtk/TestExpectations @@ -406,6 +406,7 @@ webkit.org/b/103926 media/track/opera/track/webvtt/rendering/adhoc/voice_with_ev webkit.org/b/103771 media/track/track-in-band.html [ Failure ] webkit.org/b/103771 media/track/track-in-band-cues-added-once.html [ Timeout ] webkit.org/b/103771 media/track/track-in-band-style.html [ Timeout ] +webkit.org/b/103771 media/track/track-in-band-legacy-api.html [ Timeout ] #Incorrect rebaseline webkit.org/b/107818 media/controls-styling.html [ Failure ] diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations index 73f8acf1322..dd6144f054f 100644 --- a/LayoutTests/platform/mac/TestExpectations +++ b/LayoutTests/platform/mac/TestExpectations @@ -1355,6 +1355,7 @@ Bug(jernoble) [ MountainLion Lion SnowLeopard ] media/video-src-blob.html webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band.html webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-cues-added-once.html webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-style.html +webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-legacy-api.html # These two tests sometimes timeout webkit.org/b/112492 media/track/track-language-preference.html [ Failure Pass ] diff --git a/LayoutTests/platform/qt/TestExpectations b/LayoutTests/platform/qt/TestExpectations index 7c3b040e926..231dde12b22 100644 --- a/LayoutTests/platform/qt/TestExpectations +++ b/LayoutTests/platform/qt/TestExpectations @@ -2618,6 +2618,7 @@ webkit.org/b/112893 editing/spelling/spellcheck-paste-continuous-disabled.html [ webkit.org/b/103769 media/track/track-in-band.html [ Skip ] webkit.org/b/103769 media/track/track-in-band-cues-added-once.html [ Skip ] webkit.org/b/103769 media/track/track-in-band-style.html [ Skip ] +webkit.org/b/103769 media/track/track-in-band-legacy-api.html [ Skip ] webkit.org/b/104150 fast/media/implicit-media-all.html [ ImageOnlyFailure ] diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations index 414573e9cd1..a6d16505d17 100644 --- a/LayoutTests/platform/win/TestExpectations +++ b/LayoutTests/platform/win/TestExpectations @@ -2515,6 +2515,7 @@ fast/js/kde/Array.html webkit.org/b/103770 media/track/track-in-band.html [ Skip ] webkit.org/b/103770 media/track/track-in-band-cues-added-once.html [ Skip ] webkit.org/b/103770 media/track/track-in-band-style.html [ Skip ] +webkit.org/b/103770 media/track/track-in-band-legacy-api.html [ Skip ] # https://bugs.webkit.org/show_bug.cgi?id=97026 fast/events/keydown-leftright-keys.html diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index caceb51a99f..e7727c0819c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,27 @@ +2013-03-27 Eric Carlson + + [Mac] webkitClosedCaptionsVisible doesn't work + https://bugs.webkit.org/show_bug.cgi?id=113417 + + Reviewed by Jer Noble. + + Test: media/track/track-in-band-legacy-api.html + + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::HTMLMediaElement): Delete m_disableCaptions, it is no longer used. + (WebCore::HTMLMediaElement::configureTextTrackGroup): Pass this to textTrackSelectionScore. + (WebCore::HTMLMediaElement::setClosedCaptionsVisible): Delete m_disableCaptions, it is no longer used. + * html/HTMLMediaElement.h: Ditto. + + * page/CaptionUserPreferences.cpp: + (WebCore::CaptionUserPreferences::textTrackSelectionScore): Add an HTMLMediaElement parameter. + * page/CaptionUserPreferences.h: + + * page/CaptionUserPreferencesMac.h: + * page/CaptionUserPreferencesMac.mm: + (WebCore::CaptionUserPreferencesMac::textTrackSelectionScore): Return a score if the media element + is showing captions, even if the preference says captions are disabled. + 2013-03-27 Eric Carlson [Mac] Text track menu items sometimes labeled incorrectly diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index c044dc395e2..9f9006f7ef4 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -297,7 +297,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum , m_lastTextTrackUpdateTime(-1) , m_textTracks(0) , m_ignoreTrackDisplayUpdate(0) - , m_disableCaptions(false) #endif #if ENABLE(WEB_AUDIO) , m_audioSourceNode(0) @@ -317,11 +316,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum #if ENABLE(VIDEO_TRACK) document->registerForCaptionPreferencesChangedCallbacks(this); - if (document->page()) { - CaptionUserPreferences* captionPreferences = document->page()->group().captionPreferences(); - if (captionPreferences->userHasCaptionPreferences()) - m_disableCaptions = !captionPreferences->shouldShowCaptions(); - } #endif } @@ -3098,7 +3092,7 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group) if (m_processingPreferenceChange && textTrack->mode() == TextTrack::showingKeyword()) currentlyEnabledTracks.append(textTrack); - int trackScore = captionPreferences ? captionPreferences->textTrackSelectionScore(textTrack.get()) : 0; + int trackScore = captionPreferences ? captionPreferences->textTrackSelectionScore(textTrack.get(), this) : 0; if (trackScore) { // * If the text track kind is { [subtitles or captions] [descriptions] } and the user has indicated an interest in having a // track with this text track kind, text track language, and text track label enabled, and there is no @@ -4295,10 +4289,7 @@ void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) #if ENABLE(VIDEO_TRACK) if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) { m_processingPreferenceChange = true; - m_disableCaptions = !m_closedCaptionsVisible; - markCaptionAndSubtitleTracksAsUnconfigured(); - updateTextTrackDisplay(); } #else diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h index ecffb6ddeff..11de6c61f4e 100644 --- a/Source/WebCore/html/HTMLMediaElement.h +++ b/Source/WebCore/html/HTMLMediaElement.h @@ -705,7 +705,6 @@ private: CueList m_currentlyActiveCues; int m_ignoreTrackDisplayUpdate; - bool m_disableCaptions; #endif #if ENABLE(WEB_AUDIO) diff --git a/Source/WebCore/page/CaptionUserPreferences.cpp b/Source/WebCore/page/CaptionUserPreferences.cpp index 6c1512f497c..d231058a2b9 100644 --- a/Source/WebCore/page/CaptionUserPreferences.cpp +++ b/Source/WebCore/page/CaptionUserPreferences.cpp @@ -192,7 +192,7 @@ Vector > CaptionUserPreferences::sortedTrackListForMenu(TextTr return tracksForMenu; } -int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track) const +int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const { int trackScore = 0; diff --git a/Source/WebCore/page/CaptionUserPreferences.h b/Source/WebCore/page/CaptionUserPreferences.h index 0a277ca2d08..b7c1aeb24be 100644 --- a/Source/WebCore/page/CaptionUserPreferences.h +++ b/Source/WebCore/page/CaptionUserPreferences.h @@ -37,6 +37,7 @@ namespace WebCore { +class HTMLMediaElement; class PageGroup; class TextTrackList; @@ -49,7 +50,7 @@ public: virtual bool shouldShowCaptions() const; virtual void setShouldShowCaptions(bool); - virtual int textTrackSelectionScore(TextTrack*) const; + virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const; virtual int textTrackLanguageSelectionScore(TextTrack*) const; virtual bool userPrefersCaptions() const; diff --git a/Source/WebCore/page/CaptionUserPreferencesMac.h b/Source/WebCore/page/CaptionUserPreferencesMac.h index 7de618f342e..ad234cade5c 100644 --- a/Source/WebCore/page/CaptionUserPreferencesMac.h +++ b/Source/WebCore/page/CaptionUserPreferencesMac.h @@ -60,7 +60,7 @@ public: #endif - virtual int textTrackSelectionScore(TextTrack*) const OVERRIDE; + virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const OVERRIDE; virtual Vector > sortedTrackListForMenu(TextTrackList*) OVERRIDE; virtual String displayNameForTrack(TextTrack*) const OVERRIDE; diff --git a/Source/WebCore/page/CaptionUserPreferencesMac.mm b/Source/WebCore/page/CaptionUserPreferencesMac.mm index 106d0887312..4a6e5eac9e0 100644 --- a/Source/WebCore/page/CaptionUserPreferencesMac.mm +++ b/Source/WebCore/page/CaptionUserPreferencesMac.mm @@ -33,6 +33,7 @@ #import "CoreText/CoreText.h" #import "DOMWrapperWorld.h" #import "FloatConversion.h" +#import "HTMLMediaElement.h" #import "KURL.h" #import "Language.h" #import "LocalizedStrings.h" @@ -536,9 +537,9 @@ static String trackDisplayName(TextTrack* track) RetainPtr languageCF(AdoptCF, CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleLanguageCode, localeIdentifier.get())); String language = languageCF.get(); if (!label.isEmpty()) { - if (language.isEmpty() || label.contains(language)) { + if (language.isEmpty() || label.contains(language)) displayName.append(label); - } else { + else { RetainPtr localeDict(AdoptCF, CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorDefault, localeIdentifier.get())); if (localeDict) { CFStringRef countryCode = 0; @@ -600,9 +601,9 @@ static String languageIdentifier(const String& languageCode) return lowercaseLanguageCode; } -int CaptionUserPreferencesMac::textTrackSelectionScore(TextTrack* track) const +int CaptionUserPreferencesMac::textTrackSelectionScore(TextTrack* track, HTMLMediaElement* mediaElement) const { - if (!shouldShowCaptions()) + if (!shouldShowCaptions() && !mediaElement->webkitClosedCaptionsVisible()) return 0; if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword()) return 0; -- GitLab