Diff
Modified: trunk/LayoutTests/ChangeLog (138016 => 138017)
--- trunk/LayoutTests/ChangeLog 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/ChangeLog 2012-12-18 15:23:29 UTC (rev 138017)
@@ -1,3 +1,21 @@
+2012-12-18 Eric Carlson <[email protected]>
+
+ Add in-band text track cues only once
+ https://bugs.webkit.org/show_bug.cgi?id=104593
+
+ Reviewed by Dean Jackson.
+
+ Test to ensure that in-band text track cues are not added to the the cue list more than once.
+
+ * media/track/track-in-band-cues-added-once-expected.txt: Added.
+ * media/track/track-in-band-cues-added-once.html: Added.
+ * platform/chromium/TestExpectations:
+ * platform/efl/TestExpectations:
+ * platform/gtk/TestExpectations:
+ * platform/mac/TestExpectations:
+ * platform/qt/TestExpectations:
+ * platform/win/TestExpectations:
+
2012-12-18 Thiago Marcos P. Santos <[email protected]>
[WK2] Unreviewed gardening.
Added: trunk/LayoutTests/media/track/track-in-band-cues-added-once-expected.txt (0 => 138017)
--- trunk/LayoutTests/media/track/track-in-band-cues-added-once-expected.txt (rev 0)
+++ trunk/LayoutTests/media/track/track-in-band-cues-added-once-expected.txt 2012-12-18 15:23:29 UTC (rev 138017)
@@ -0,0 +1,27 @@
+In-band text tracks.
+
+EVENT(addtrack)
+EXPECTED (event.track == 'video.textTracks[0]') OK
+
+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
+
+RUN(inbandTrack1.mode = 'showing')
+RUN(video.play())
+EXPECTED (inbandTrack1.cues.length > '0') OK
+RUN(video.pause())
+RUN(video.currentTime = 0)
+RUN(video.play())
+
+EVENT(seeked)
+EXPECTED (inbandTrack1.cues.length > '0') OK
+RUN(video.pause())
+END OF TEST
+
Added: trunk/LayoutTests/media/track/track-in-band-cues-added-once.html (0 => 138017)
--- trunk/LayoutTests/media/track/track-in-band-cues-added-once.html (rev 0)
+++ trunk/LayoutTests/media/track/track-in-band-cues-added-once.html 2012-12-18 15:23:29 UTC (rev 138017)
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=""
+ <script src=""
+ <script>
+
+ var addtrackEventCount = 0;
+ var seekedCount = 0;
+ var cuesStarts = [];
+
+ function trackAdded(event)
+ {
+ consoleWrite("EVENT(" + event.type + ")");
+ compareTracks("event.track", "video.textTracks[" + addtrackEventCount + "]");
+ ++addtrackEventCount;
+ consoleWrite("");
+ }
+
+ function compareTracks(track1, track2)
+ {
+ var equal = (eval(track1) == eval(track2));
+ reportExpected(equal, track1, "==", track2, track1);
+ }
+
+ function pollProgress()
+ {
+ if (video.currentTime < 2)
+ return;
+
+ testExpected("inbandTrack1.cues.length", 0, ">");
+
+ if (!seekedCount) {
+ // Collect the start times of all cues, seek back to the beginning and play
+ // the same segment of the video file.
+ run("video.pause()");
+ for (var i = 0; i < inbandTrack1.cues.length; ++i)
+ cuesStarts.push(inbandTrack1.cues[i].startTime);
+ run("video.currentTime = 0");
+ run("video.play()");
+ consoleWrite("");
+ return;
+ }
+
+ run("video.pause()");
+ for (var i = 0; i < cuesStarts.length; ++i) {
+ if (cuesStarts[i] != inbandTrack1.cues[i].startTime)
+ logResult(false, "Found unexpected cue starting at " + inbandTrack1.cues[i].startTime);
+ }
+ endTest();
+ }
+
+ function canplaythrough()
+ {
+ video.textTracks.removeEventListener("addtrack", trackAdded, false);
+
+ 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("");
+
+ waitForEvent('seeked', function() { ++seekedCount; });
+ setInterval(pollProgress, 100);
+ run("inbandTrack1.mode = 'showing'");
+ run("video.play()");
+ }
+
+ function setup()
+ {
+ findMediaElement();
+ video.textTracks.addEventListener("addtrack", trackAdded);
+ video.src = '';
+ waitForEvent('canplaythrough', canplaythrough);
+ }
+
+ </script>
+ </head>
+ <body _onload_="setup()">
+ <video controls></video>
+ <p>In-band text tracks.</p>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/chromium/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/chromium/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/chromium/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -4231,6 +4231,7 @@
# No support for exposing in-band text tracks
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 ]
# Flaky on Win (perhaps due to lighttpd?)
webkit.org/b/104489 [ Win ] http/tests/w3c/webperf/submission/resource-timing/html/test_resource_attribute_order.html [ Failure Pass ]
Modified: trunk/LayoutTests/platform/efl/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/efl/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/efl/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -1653,6 +1653,7 @@
# No support for exposing in-band text tracks
Bug(EFL) media/track/track-in-band.html [ Skip ]
+Bug(EFL) media/track/track-in-band-cues-added-once.html [ Skip ]
# Newly added test in r136225 fails on GTK bot too.
webkit.org/b/103740 editing/selection/caret-alignment-for-vertical-text.html [ Failure ]
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -457,6 +457,7 @@
# No support for exposing in-band text tracks
webkit.org/b/103771 media/track/track-in-band.html [ Failure ]
+webkit.org/b/103771 media/track/track-in-band-cues-added-once.html [ Failure ]
#////////////////////////////////////////////////////////////////////////////////////////
# End of Expected failures
Modified: trunk/LayoutTests/platform/mac/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/mac/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -1241,6 +1241,7 @@
# Mountain Lion and prior do not allow access to in-band text tracks
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/104104 fast/overflow/scrollbar-click-retains-focus.html [ Failure ]
Modified: trunk/LayoutTests/platform/qt/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/qt/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/qt/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -2442,6 +2442,7 @@
# No support for exposing in-band text tracks
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/104150 fast/media/implicit-media-all.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (138016 => 138017)
--- trunk/LayoutTests/platform/win/TestExpectations 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/LayoutTests/platform/win/TestExpectations 2012-12-18 15:23:29 UTC (rev 138017)
@@ -2476,6 +2476,7 @@
# No support for exposing in-band text tracks
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 ]
# https://bugs.webkit.org/show_bug.cgi?id=97026
fast/events/keydown-leftright-keys.html
Modified: trunk/Source/WebCore/ChangeLog (138016 => 138017)
--- trunk/Source/WebCore/ChangeLog 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/ChangeLog 2012-12-18 15:23:29 UTC (rev 138017)
@@ -1,3 +1,35 @@
+2012-12-18 Eric Carlson <[email protected]>
+
+ Add in-band text track cues only once
+ https://bugs.webkit.org/show_bug.cgi?id=104593
+
+ Reviewed by Dean Jackson.
+
+ Test: media/track/track-in-band-cues-added-once.html
+
+ * html/track/InbandTextTrack.cpp:
+ (WebCore::InbandTextTrack::hasCue): New.
+ * html/track/InbandTextTrack.h:
+
+ * html/track/TextTrackCue.cpp:
+ (WebCore::TextTrackCue::setCueSettings): Remember the raw cue settings so they can be accessed later.
+ * html/track/TextTrackCue.h:
+
+ * platform/graphics/InbandTextTrackPrivateClient.h: Declare hasCue.
+
+ * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+ (WebCore::InbandTextTrackPrivateAVF::processCue): Early return if m_player has been cleared.
+ (WebCore::InbandTextTrackPrivateAVF::setMode): Ditto.
+
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+ (WebCore::MediaPlayerPrivateAVFoundation::seek): Clear the partially accumulated cue when the seek
+ starts, not when it completes.
+ (WebCore::MediaPlayerPrivateAVFoundation::seekCompleted): Ditto.
+ (WebCore::MediaPlayerPrivateAVFoundation::flushCurrentCue): Don't add a cue if it is already in the
+ text track cue list.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::clearTextTracks): Drive-by cleanup, clear the track list completely.
+
2012-12-18 Eugene Klyuchnikov <[email protected]>
Web Inspector: [Network] Ordering of cookies displayed is nondeterministic.
Modified: trunk/Source/WebCore/html/track/InbandTextTrack.cpp (138016 => 138017)
--- trunk/Source/WebCore/html/track/InbandTextTrack.cpp 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/html/track/InbandTextTrack.cpp 2012-12-18 15:23:29 UTC (rev 138017)
@@ -115,7 +115,59 @@
if (client())
client()->textTrackAddCues(this, m_cues.get());
}
+
+bool InbandTextTrack::hasCue(InbandTextTrackPrivate*, double startTime, double endTime, const String& id, const String& content, const String& settings)
+{
+
+ if (startTime < 0 || endTime < 0)
+ return false;
+
+ if (!cues()->length())
+ return false;
+
+ size_t searchStart = 0;
+ size_t searchEnd = cues()->length();
+
+ while (1) {
+ ASSERT(searchStart <= cues()->length());
+ ASSERT(searchEnd <= cues()->length());
+
+ TextTrackCue* cue;
+
+ // Cues in the TextTrackCueList are maintained in start time order.
+ if (searchStart == searchEnd) {
+ if (!searchStart)
+ return false;
+
+ cue = cues()->item(searchStart - 1);
+ if (!cue)
+ return false;
+ if (cue->startTime() != startTime)
+ return false;
+ if (cue->endTime() != endTime)
+ return false;
+ if (cue->text() != content)
+ return false;
+ if (cue->cueSettings() != settings)
+ return false;
+ if (cue->id() != id)
+ return false;
+
+ return true;
+ }
+
+ size_t index = (searchStart + searchEnd) / 2;
+ cue = cues()->item(index);
+ if (startTime < cue->startTime() || (startTime == cue->startTime() && endTime > cue->endTime()))
+ searchEnd = index;
+ else
+ searchStart = index + 1;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/track/InbandTextTrack.h (138016 => 138017)
--- trunk/Source/WebCore/html/track/InbandTextTrack.h 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/html/track/InbandTextTrack.h 2012-12-18 15:23:29 UTC (rev 138017)
@@ -52,6 +52,7 @@
InbandTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
virtual void addCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
+ virtual bool hasCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
RefPtr<InbandTextTrackPrivate> m_private;
};
Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (138016 => 138017)
--- trunk/Source/WebCore/html/track/TextTrackCue.cpp 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp 2012-12-18 15:23:29 UTC (rev 138017)
@@ -835,6 +835,7 @@
void TextTrackCue::setCueSettings(const String& input)
{
+ m_settings = input;
unsigned position = 0;
while (position < input.length()) {
Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (138016 => 138017)
--- trunk/Source/WebCore/html/track/TextTrackCue.h 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h 2012-12-18 15:23:29 UTC (rev 138017)
@@ -119,6 +119,7 @@
const String& text() const { return m_content; }
void setText(const String&);
+ const String& cueSettings() const { return m_settings; }
void setCueSettings(const String&);
int cueIndex();
@@ -185,6 +186,7 @@
double m_startTime;
double m_endTime;
String m_content;
+ String m_settings;
int m_linePosition;
int m_computedLinePosition;
int m_textPosition;
Modified: trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h (138016 => 138017)
--- trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h 2012-12-18 15:23:29 UTC (rev 138017)
@@ -39,6 +39,7 @@
virtual ~InbandTextTrackPrivateClient() { }
virtual void addCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
+ virtual bool hasCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (138016 => 138017)
--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2012-12-18 15:23:29 UTC (rev 138017)
@@ -222,6 +222,9 @@
void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
{
+ if (!m_player)
+ return;
+
if (m_havePartialCue) {
// Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
m_currentCueEndTime = time;
@@ -268,6 +271,9 @@
void InbandTextTrackPrivateAVF::setMode(InbandTextTrackPrivate::Mode newMode)
{
+ if (!m_player)
+ return;
+
InbandTextTrackPrivate::Mode oldMode = mode();
InbandTextTrackPrivate::setMode(newMode);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (138016 => 138017)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2012-12-18 15:23:29 UTC (rev 138017)
@@ -266,6 +266,14 @@
if (currentTime() == time)
return;
+#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
+ // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
+ // range, which will mean that the next cue delivered will result in the current cue getting the
+ // incorrect duration.
+ if (currentTrack())
+ currentTrack()->resetCueValues();
+#endif
+
LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
m_seekTo = time;
@@ -574,14 +582,6 @@
LOG(Media, "MediaPlayerPrivateAVFoundation::seekCompleted(%p) - finished = %d", this, finished);
UNUSED_PARAM(finished);
-#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
- // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
- // range, which will mean that the next cue delivered will result in the current cue getting the
- // incorrect duration.
- if (currentTrack())
- currentTrack()->resetCueValues();
-#endif
-
m_seekTo = MediaPlayer::invalidTime();
updateStates();
m_player->timeChanged();
@@ -816,6 +816,13 @@
if (!track->client())
return;
+ // AVFoundation returns a cue every time the data is buffered, only add it once.
+ if (track->client()->hasCue(track, track->start(), track->end(), track->id(), track->content(), track->settings())) {
+ LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - already have cue for time %.2f", this, track->start());
+ return;
+ }
+
+ LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - adding cue for time %.2f", this, track->start());
track->client()->addCue(track, track->start(), track->end(), track->id(), track->content(), track->settings());
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (138016 => 138017)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2012-12-18 15:01:02 UTC (rev 138016)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2012-12-18 15:23:29 UTC (rev 138017)
@@ -1197,8 +1197,12 @@
void MediaPlayerPrivateAVFoundationObjC::clearTextTracks()
{
- for (unsigned i = 0; i < m_textTracks.size(); ++i)
- player()->removeTextTrack(m_textTracks[i].get());
+ for (unsigned i = 0; i < m_textTracks.size(); ++i) {
+ RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
+ player()->removeTextTrack(track);
+ track->disconnect();
+ }
+ m_textTracks.clear();
}
void MediaPlayerPrivateAVFoundationObjC::processTextTracks()