Title: [141161] branches/chromium/1364
Revision
141161
Author
cev...@google.com
Date
2013-01-29 13:49:12 -0800 (Tue, 29 Jan 2013)

Log Message

Merge 140834
BUG=164581
Review URL: https://codereview.chromium.org/12087064

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt (from rev 140834, trunk/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt) (0 => 141161)


--- branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt	                        (rev 0)
+++ branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt	2013-01-29 21:49:12 UTC (rev 141161)
@@ -0,0 +1,15 @@
+Tests that removing an active cue does not crash the browser.
+
+** Add a text track to the video element **
+** Add a cue to the track with enter event listener. **
+
+** Play the video and remove cue when it becomes active. **
+RUN(video.play())
+EXPECTED (video.textTracks[0].activeCues.length == '1') OK
+
+** Remove the cue while it is active **
+
+No crash. PASS.
+
+END OF TEST
+

Copied: branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash.html (from rev 140834, trunk/LayoutTests/media/track/track-remove-active-cue-crash.html) (0 => 141161)


--- branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash.html	                        (rev 0)
+++ branches/chromium/1364/LayoutTests/media/track/track-remove-active-cue-crash.html	2013-01-29 21:49:12 UTC (rev 141161)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script>
+        function removeActiveCue()
+        {
+            testExpected("video.textTracks[0].activeCues.length", 1);
+
+            consoleWrite("");
+            consoleWrite("** Remove the cue while it is active **");
+            video.textTracks[0].removeCue(video.textTracks[0].activeCues[0]);
+
+            consoleWrite("");
+            consoleWrite("No crash. PASS.");
+            consoleWrite("");
+
+            endTest();
+        }
+
+        function startTest()
+        {
+            findMediaElement();
+            video.src = "" '../content/test');
+
+            consoleWrite("** Add a text track to the video element **");
+            video.addTextTrack("captions", "regular captions track", "en");
+
+            consoleWrite("** Add a cue to the track with enter event listener. **");
+            var cue = new TextTrackCue(0.00, 4.00, "Random");
+            cue.addEventListener("enter", removeActiveCue);
+            video.textTracks[0].addCue(cue);
+
+            consoleWrite("");
+            consoleWrite("** Play the video and remove cue when it becomes active.  **");
+            run("video.play()");
+
+            video.textTracks[0].mode = "showing";
+          }
+        </script>
+    </head>
+
+    <body _onload_="startTest()">
+        <p>Tests that removing an active cue does not crash the browser.</p>
+        <video controls />
+    </body>
+</html>

Modified: branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.cpp (141160 => 141161)


--- branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-29 21:32:07 UTC (rev 141160)
+++ branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-29 21:49:12 UTC (rev 141161)
@@ -1072,16 +1072,15 @@
     // media element (not the disabled ones) whose start times are less than or
     // equal to the current playback position and whose end times are greater
     // than the current playback position.
-    Vector<CueIntervalTree::IntervalType> currentCues;
+    CueList currentCues;
 
     // The user agent must synchronously unset [the text track cue active] flag
     // whenever ... the media element's readyState is changed back to HAVE_NOTHING.
     if (m_readyState != HAVE_NOTHING && m_player)
         currentCues = m_cueTree.allOverlaps(m_cueTree.createInterval(movieTime, movieTime));
 
-    Vector<CueIntervalTree::IntervalType> affectedCues;
-    Vector<CueIntervalTree::IntervalType> previousCues;
-    Vector<CueIntervalTree::IntervalType> missedCues;
+    CueList previousCues;
+    CueList missedCues;
 
     // 2 - Let other cues be a list of cues, initialized to contain all the cues
     // of hidden, showing, and showing by default text tracks of the media
@@ -1100,7 +1099,7 @@
     // end times are less than or equal to the current playback position.
     // Otherwise, let missed cues be an empty list.
     if (lastTime >= 0 && m_lastSeekTime < movieTime) {
-        Vector<CueIntervalTree::IntervalType> potentiallySkippedCues =
+        CueList potentiallySkippedCues =
             m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime));
 
         for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) {
@@ -1376,7 +1375,7 @@
     // zero-length cues.
     double endTime = max(cue->startTime(), cue->endTime());
 
-    CueIntervalTree::IntervalType interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
+    CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
     if (!m_cueTree.contains(interval))
         m_cueTree.add(interval);
     updateActiveTextTrackCues(currentTime());
@@ -1388,7 +1387,13 @@
     // zero-length cues.
     double endTime = max(cue->startTime(), cue->endTime());
 
-    m_cueTree.remove(m_cueTree.createInterval(cue->startTime(), endTime, cue.get()));
+    CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
+    m_cueTree.remove(interval);
+
+    size_t index = m_currentlyActiveCues.find(interval);
+    if (index != notFound)
+        m_currentlyActiveCues.remove(index);
+
     updateActiveTextTrackCues(currentTime());
 }
 

Modified: branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.h (141160 => 141161)


--- branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.h	2013-01-29 21:32:07 UTC (rev 141160)
+++ branches/chromium/1364/Source/WebCore/html/HTMLMediaElement.h	2013-01-29 21:49:12 UTC (rev 141161)
@@ -72,7 +72,8 @@
 class InbandTextTrackPrivate;
 
 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
-typedef Vector<CueIntervalTree::IntervalType> CueList;
+typedef CueIntervalTree::IntervalType CueInterval;
+typedef Vector<CueInterval> CueList;
 #endif
 
 // FIXME: The inheritance from MediaPlayerClient here should be private inheritance.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to