[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
parent d0daea36
2013-03-27 Eric Carlson <eric.carlson@apple.com>
[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 <eric.carlson@apple.com>
[Mac] Text track menu items sometimes labeled incorrectly
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
<!DOCTYPE html>
<html>
<head>
<title>In-band tracks enabled/disabled with legacy API</title>
<script src=../media-file.js></script>
<script src=../video-test.js></script>
<script src=../media-controls.js></script>
<script>
function seeked()
{
consoleWrite("<br><i>** Test to make sure captions are displaying<" + "/i>");
testExpected("inbandTrack1.cues", null, '!=');
testExpected("textTrackDisplayElement(video, 'cue').textContent", null, '!=');
consoleWrite("<br><i>** Disable captions, cues should be flushed<" + "/i>");
run("video.webkitClosedCaptionsVisible = false");
testExpected("inbandTrack1.cues", null);
consoleWrite("");
endTest();
}
function canplaythrough()
{
consoleWrite("<br><i>** Check initial in-band track states<" + "/i>");
testExpected("video.textTracks.length", 1);
run("inbandTrack1 = video.textTracks[0]");
testExpected("inbandTrack1.mode", "disabled");
testExpected("inbandTrack1.cues", null);
testExpected("inbandTrack1.language", "en");
testExpected("inbandTrack1.kind", "captions");
consoleWrite("<br><i>** Enable cues and let them load<" + "/i>");
run("video.webkitClosedCaptionsVisible = true");
run("video.play()");
setTimeout(function() { video.pause(); video.currentTime = 0.3; }, 1000);
}
function setup()
{
findMediaElement();
video.src = '../content/counting-captioned.mov';
waitForEvent('seeked', seeked);
waitForEvent('canplaythrough', canplaythrough);
}
</script>
</head>
<body onload="setup()">
<video controls></video>
<p>Test that in-band tracks work with .webkitClosedCaptionsVisible.</p>
</body>
</html>
......@@ -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 ]
......
......@@ -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 ]
......
......@@ -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 ]
......
......@@ -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 ]
......
......@@ -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 ]
......
......@@ -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
......
2013-03-27 Eric Carlson <eric.carlson@apple.com>
[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 <eric.carlson@apple.com>
[Mac] Text track menu items sometimes labeled incorrectly
......@@ -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
......
......@@ -705,7 +705,6 @@ private:
CueList m_currentlyActiveCues;
int m_ignoreTrackDisplayUpdate;
bool m_disableCaptions;
#endif
#if ENABLE(WEB_AUDIO)
......
......@@ -192,7 +192,7 @@ Vector<RefPtr<TextTrack> > CaptionUserPreferences::sortedTrackListForMenu(TextTr
return tracksForMenu;
}
int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track) const
int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const
{
int trackScore = 0;
......
......@@ -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;
......
......@@ -60,7 +60,7 @@ public:
#endif
virtual int textTrackSelectionScore(TextTrack*) const OVERRIDE;
virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const OVERRIDE;
virtual Vector<RefPtr<TextTrack> > sortedTrackListForMenu(TextTrackList*) OVERRIDE;
virtual String displayNameForTrack(TextTrack*) const OVERRIDE;
......
......@@ -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<CFStringRef> 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<CFDictionaryRef> 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment