Title: [118806] trunk
Revision
118806
Author
[email protected]
Date
2012-05-29 10:55:52 -0700 (Tue, 29 May 2012)

Log Message

Update cue event dispatching for zero and negative duration cues
https://bugs.webkit.org/show_bug.cgi?id=85143

Patch by Victor Carbune <[email protected]> on 2012-05-29
Reviewed by Eric Carlson.

Source/WebCore:

Updated existing test.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Explicitly
treated event dispatching for zero and negative duration cues.
(WebCore::HTMLMediaElement::textTrackAddCue): Interval tree doesn't
handle invalid cues with intervals - negative cues need to be treated
as zero-length cues as they are always missed cues anyway.
(WebCore::HTMLMediaElement::textTrackRemoveCue): Same.

LayoutTests:

* media/track/captions-webvtt/missed-cues.vtt: Added negative
duration cue and changed a missed cue to have zero-length.
* media/track/track-cues-missed-expected.txt: Updated.
* media/track/track-cues-missed.html: Updated.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (118805 => 118806)


--- trunk/LayoutTests/ChangeLog	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/LayoutTests/ChangeLog	2012-05-29 17:55:52 UTC (rev 118806)
@@ -1,3 +1,15 @@
+2012-05-29  Victor Carbune  <[email protected]>
+
+        Update cue event dispatching for zero and negative duration cues
+        https://bugs.webkit.org/show_bug.cgi?id=85143
+
+        Reviewed by Eric Carlson.
+
+        * media/track/captions-webvtt/missed-cues.vtt: Added negative
+        duration cue and changed a missed cue to have zero-length.
+        * media/track/track-cues-missed-expected.txt: Updated.
+        * media/track/track-cues-missed.html: Updated.
+
 2012-05-29  MORITA Hajime  <[email protected]>
 
         ShadowRoot.getElementById() returns removed node.

Modified: trunk/LayoutTests/media/track/captions-webvtt/missed-cues.vtt (118805 => 118806)


--- trunk/LayoutTests/media/track/captions-webvtt/missed-cues.vtt	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/LayoutTests/media/track/captions-webvtt/missed-cues.vtt	2012-05-29 17:55:52 UTC (rev 118806)
@@ -19,9 +19,13 @@
 This is the second missed cue in the test.
 
 5
-00:00:05.800 --> 00:00:05.801 align:start position:20%
-Maybe a third missed cue.
+00:00:05.800 --> 00:00:05.800 align:start position:20%
+Third missed cue - zero-length cue.
 
 6
-00:00:05.992 --> 00:00:05.993 align:start position:20%
+00:00:05.850 --> 00:00:05.851 align:start position:20%
 Fourth missed cue.
+
+7
+00:00:05.950 --> 00:00:01.100
+Negative length cue. Should be treated correctly.

Modified: trunk/LayoutTests/media/track/track-cues-missed-expected.txt (118805 => 118806)


--- trunk/LayoutTests/media/track/track-cues-missed-expected.txt	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/LayoutTests/media/track/track-cues-missed-expected.txt	2012-05-29 17:55:52 UTC (rev 118806)
@@ -1,32 +1,48 @@
 Tests that events are triggered for missed (skipped) cues during normal playback.
 
 EVENT(canplaythrough)
-EXPECTED (testTrack.track.cues.length == '6') OK
+EXPECTED (testTrack.track.cues.length == '7') OK
 RUN(video.play())
+
 EVENT(enter)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'I said Bear is coming now!!!!') OK
 EXPECTED (currentCue.id == '3') OK
+
 EVENT(exit)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'I said Bear is coming now!!!!') OK
 EXPECTED (currentCue.id == '3') OK
+
 EVENT(enter)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'This is the second missed cue in the test.') OK
 EXPECTED (currentCue.id == '4') OK
+
 EVENT(exit)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'This is the second missed cue in the test.') OK
 EXPECTED (currentCue.id == '4') OK
+
 EVENT(enter)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Third missed cue - zero-length cue.') OK
 EXPECTED (currentCue.id == '5') OK
+
 EVENT(exit)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Third missed cue - zero-length cue.') OK
 EXPECTED (currentCue.id == '5') OK
+
 EVENT(enter)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Fourth missed cue.') OK
 EXPECTED (currentCue.id == '6') OK
+
 EVENT(exit)
-EXPECTED (testTrack.track.cues.getCueById(cueCount) == '[object TextTrackCue]') OK
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Fourth missed cue.') OK
 EXPECTED (currentCue.id == '6') OK
+
+EVENT(enter)
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Negative length cue. Should be treated correctly.') OK
+EXPECTED (currentCue.id == '7') OK
+
+EVENT(exit)
+EXPECTED (testTrack.track.cues.getCueById(cueCount).text == 'Negative length cue. Should be treated correctly.') OK
+EXPECTED (currentCue.id == '7') OK
 EVENT(ended)
 END OF TEST
 

Modified: trunk/LayoutTests/media/track/track-cues-missed.html (118805 => 118806)


--- trunk/LayoutTests/media/track/track-cues-missed.html	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/LayoutTests/media/track/track-cues-missed.html	2012-05-29 17:55:52 UTC (rev 118806)
@@ -19,7 +19,7 @@
                     return;
 
                 testTrack = document.getElementById("testTrack");
-                testExpected("testTrack.track.cues.length", 6);
+                testExpected("testTrack.track.cues.length", 7);
 
                 for (cueCount = 2; cueCount < testTrack.track.cues.length; cueCount++) {
                     var cue = testTrack.track.cues[cueCount];
@@ -34,10 +34,11 @@
 
             function cueEnteredOrExited()
             {
+                consoleWrite("");
                 consoleWrite("EVENT(" + event.type + ")");
 
                 currentCue = event.target;
-                testExpected("testTrack.track.cues.getCueById(cueCount)", currentCue);
+                testExpected("testTrack.track.cues.getCueById(cueCount).text", currentCue.text, "==");
                 testExpected("currentCue.id", cueCount);
 
                 if (event.type == 'exit') {

Modified: trunk/Source/WebCore/ChangeLog (118805 => 118806)


--- trunk/Source/WebCore/ChangeLog	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/Source/WebCore/ChangeLog	2012-05-29 17:55:52 UTC (rev 118806)
@@ -1,3 +1,20 @@
+2012-05-29  Victor Carbune  <[email protected]>
+
+        Update cue event dispatching for zero and negative duration cues
+        https://bugs.webkit.org/show_bug.cgi?id=85143
+
+        Reviewed by Eric Carlson.
+
+        Updated existing test.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Explicitly
+        treated event dispatching for zero and negative duration cues.
+        (WebCore::HTMLMediaElement::textTrackAddCue): Interval tree doesn't
+        handle invalid cues with intervals - negative cues need to be treated
+        as zero-length cues as they are always missed cues anyway.
+        (WebCore::HTMLMediaElement::textTrackRemoveCue): Same.
+
 2012-05-29  MORITA Hajime  <[email protected]>
 
         ShadowRoot.getElementById() returns removed node.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (118805 => 118806)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-29 17:50:56 UTC (rev 118805)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-29 17:55:52 UTC (rev 118806)
@@ -1141,11 +1141,18 @@
         eventTasks.append(std::make_pair(missedCues[i].data()->startTime(),
                                          missedCues[i].data()));
 
-        // 10 - For each text track in missed cues, prepare an event
-        // named exit for the TextTrackCue object with the text track cue end
-        // time.
-        eventTasks.append(std::make_pair(missedCues[i].data()->endTime(),
-                                         missedCues[i].data()));
+        // 10 - For each text track [...] in missed cues, prepare an event
+        // named exit for the TextTrackCue object with the  with the later of
+        // the text track cue end time and the text track cue start time.
+
+        // Note: An explicit task is added only if the cue is NOT a zero or
+        // negative length cue. Otherwise, the need for an exit event is
+        // checked when these tasks are actually queued below. This doesn't
+        // affect sorting events before dispatch either, because the exit
+        // event has the same time as the enter event.
+        if (missedCues[i].data()->startTime() < missedCues[i].data()->endTime())
+            eventTasks.append(std::make_pair(missedCues[i].data()->endTime(),
+                                             missedCues[i].data()));
     }
 
     for (size_t i = 0; i < previousCuesSize; ++i) {
@@ -1179,15 +1186,25 @@
 
         // Each event in eventTasks may be either an enterEvent or an exitEvent,
         // depending on the time that is associated with the event. This
-        // correctly identifies the type of the event, since the startTime is
-        // always less than the endTime.
-        if (eventTasks[i].first == eventTasks[i].second->startTime())
+        // correctly identifies the type of the event, if the startTime is
+        // less than the endTime in the cue.
+        if (eventTasks[i].second->startTime() >= eventTasks[i].second->endTime()) {
             event = Event::create(eventNames().enterEvent, false, false);
-        else
+            event->setTarget(eventTasks[i].second);
+            m_asyncEventQueue->enqueueEvent(event.release());
+
             event = Event::create(eventNames().exitEvent, false, false);
+            event->setTarget(eventTasks[i].second);
+            m_asyncEventQueue->enqueueEvent(event.release());
+        } else {
+            if (eventTasks[i].first == eventTasks[i].second->startTime())
+                event = Event::create(eventNames().enterEvent, false, false);
+            else
+                event = Event::create(eventNames().exitEvent, false, false);
 
-        event->setTarget(eventTasks[i].second);
-        m_asyncEventQueue->enqueueEvent(event.release());
+            event->setTarget(eventTasks[i].second);
+            m_asyncEventQueue->enqueueEvent(event.release());
+        }
     }
 
     // 14 - Sort affected tracks in the same order as the text tracks appear in
@@ -1311,13 +1328,21 @@
 
 void HTMLMediaElement::textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue> cue)
 {
-    m_cueTree.add(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue.get()));
+    // Negative duration cues need be treated in the interval tree as
+    // zero-length cues.
+    double endTime = max(cue->startTime(), cue->endTime());
+
+    m_cueTree.add(m_cueTree.createInterval(cue->startTime(), endTime, cue.get()));
     updateActiveTextTrackCues(currentTime());
 }
 
 void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue> cue)
 {
-    m_cueTree.remove(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue.get()));
+    // Negative duration cues need to be treated in the interval tree as
+    // zero-length cues.
+    double endTime = max(cue->startTime(), cue->endTime());
+
+    m_cueTree.remove(m_cueTree.createInterval(cue->startTime(), endTime, cue.get()));
     updateActiveTextTrackCues(currentTime());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to