and from TextTrack::DISABLED.
https://bugs.webkit.org/show_bug.cgi?id=83377
Reviewed by Eric Carlson.
Source/WebCore:
No new tests. Instead updated media/track/track-mode.html
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackModeChanged):
Add the track's cues to the index when the mode changes to HIDDEN or SHOWING.
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::textTrackRemoveCues):
Fix a copy pasta error.
* html/track/TextTrack.cpp:
(WebCore::TextTrack::setMode):
Remove the track's cues from the index when the mode changes to DISABLED.
LayoutTests:
* media/track/track-mode-expected.txt:
* media/track/track-mode.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114026
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-12 Anna Cavender <annacc@chromium.org>
+
+ Update HTMLMediaElement's index of cues when TextTrack.mode changes to
+ and from TextTrack::DISABLED.
+ https://bugs.webkit.org/show_bug.cgi?id=83377
+
+ Reviewed by Eric Carlson.
+
+ * media/track/track-mode-expected.txt:
+ * media/track/track-mode.html:
+
2012-04-12 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r114005.
--- /dev/null
+WEBVTT
+
+1
+00:00:00.000 --> 00:00:00.200
+Lorem
+
+2
+00:00:00.200 --> 00:00:00.500
+ipsum
+
+3
+00:00:00.500 --> 00:00:00.800
+dolor
+
+4
+00:00:00.800 --> 00:00:01.000
+sit
RUN(textTrack.mode = '0')
EXPECTED (textTrack.mode == '0') OK
EXPECTED (video.textTracks[0].mode == '0') OK
+EXPECTED (textTrack.cues == 'null') OK
+
+++ 0 events expected while mode = TextTrack.DISABLED
++ 'TextTrack.HIDDEN'
RUN(textTrack.mode = '1')
+EVENT(cuechange)
+EXPECTED (textTrack.activeCues.length == '1'), OBSERVED '0' FAIL
EXPECTED (textTrack.mode == '1') OK
EXPECTED (video.textTracks[0].mode == '1') OK
+EXPECTED (textTrack.cues.length == '4') OK
++ 'TextTrack.SHOWING'
RUN(textTrack.mode = '2')
EXPECTED (textTrack.mode == '2') OK
EXPECTED (video.textTracks[0].mode == '2') OK
-
+EXPECTED (textTrack.cues.length == '4') OK
+
+++ 3 events expected while mode = TextTrack.SHOWING
+EVENT(cuechange)
+EXPECTED (textTrack.activeCues.length == '1') OK
+EVENT(cuechange)
+EXPECTED (textTrack.activeCues.length == '1') OK
+EVENT(cuechange)
+EXPECTED (textTrack.activeCues.length == '1') OK
END OF TEST
<script>
var textTrack;
+ var cueCount;
+
function setMode(value)
{
run("textTrack.mode = '" + value + "'");
testExpected("textTrack.mode", value);
testExpected("video.textTracks[0].mode", value);
+ if (value == TextTrack.DISABLED)
+ testExpected("textTrack.cues", null);
+ else
+ testExpected("textTrack.cues.length", textTrack.cues.length);
consoleWrite("");
}
function start()
{
findMediaElement();
+ cueCount = 0;
consoleWrite("");
textTrack = document.getElementById('track_1').track;
consoleWrite("<b>++ 'TextTrack.DISABLED'</b>");
setMode(TextTrack.DISABLED);
+ video.src = findMediaFile("video", "../content/test");
+ video.play();
+ // Wait for end of first cue (no events should fire while track is disabled).
+ setTimeout(testHiddenAndShowing, 300);
+ consoleWrite("++ 0 events expected while mode = TextTrack.DISABLED");
+ consoleWrite("");
+ }
+
+ function testHiddenAndShowing()
+ {
consoleWrite("<b>++ 'TextTrack.HIDDEN'</b>");
setMode(TextTrack.HIDDEN);
consoleWrite("<b>++ 'TextTrack.SHOWING'</b>");
setMode(TextTrack.SHOWING);
- endTest();
+ consoleWrite("++ " + (textTrack.cues.length - 1) + " events expected while mode = TextTrack.SHOWING");
}
+
+ waitForEvent('cuechange',
+ function ()
+ {
+ testExpected("textTrack.activeCues.length", 1);
+ cueCount++;
+ if (cueCount == textTrack.cues.length)
+ endTest();
+ }
+ );
+
</script>
</head>
<body>
<p>Tests that the TextTrack mode attribute is appropriately set.</p>
<video>
- <track id=track_1 src="captions-webvtt/captions.vtt" onload="start()" default>
+ <track id=track_1 src="captions-webvtt/captions-fast.vtt" onload="start()" default>
</video>
</body>
</html>
+2012-04-12 Anna Cavender <annacc@chromium.org>
+
+ Update HTMLMediaElement's index of cues when TextTrack.mode changes to
+ and from TextTrack::DISABLED.
+ https://bugs.webkit.org/show_bug.cgi?id=83377
+
+ Reviewed by Eric Carlson.
+
+ No new tests. Instead updated media/track/track-mode.html
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::textTrackModeChanged):
+ Add the track's cues to the index when the mode changes to HIDDEN or SHOWING.
+
+ * html/HTMLTrackElement.cpp:
+ (WebCore::HTMLTrackElement::textTrackRemoveCues):
+ Fix a copy pasta error.
+
+ * html/track/TextTrack.cpp:
+ (WebCore::TextTrack::setMode):
+ Remove the track's cues from the index when the mode changes to DISABLED.
+
2012-04-12 Cem Kocagil <cem.kocagil@gmail.com>
Allow certain Char events in fullscreen
// Mark this track as "configured" so configureNewTextTracks won't change the mode again.
trackElement->setHasBeenConfigured(true);
- if (track->mode() != TextTrack::DISABLED && trackElement->readyState() == HTMLTrackElement::NONE)
- trackElement->scheduleLoad();
+ if (track->mode() != TextTrack::DISABLED) {
+ if (trackElement->readyState() == HTMLTrackElement::LOADED)
+ textTrackAddCues(track, track->cues());
+ else if (trackElement->readyState() == HTMLTrackElement::NONE)
+ trackElement->scheduleLoad();
+ }
break;
}
}
void HTMLTrackElement::textTrackRemoveCues(TextTrack* track, const TextTrackCueList* cues)
{
if (HTMLMediaElement* parent = mediaElement())
- return parent->textTrackAddCues(track, cues);
+ return parent->textTrackRemoveCues(track, cues);
}
void HTMLTrackElement::textTrackAddCue(TextTrack* track, PassRefPtr<TextTrackCue> cue)
if (m_mode == static_cast<Mode>(mode))
return;
+ // If mode changes to disabled, remove this track's cues from the client
+ // because they will no longer be accessible from the cues() function.
+ if (mode == TextTrack::DISABLED && m_client && m_cues)
+ m_client->textTrackRemoveCues(this, m_cues.get());
+
// ... Note: If the mode had been showing by default, this will change it to showing,
// even though the value of mode would appear not to change.
m_mode = static_cast<Mode>(mode);