<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166238] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166238">166238</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-03-25 09:51:40 -0700 (Tue, 25 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Prevent 'removetrack' events from firing when all inband text tracks are removed.
https://bugs.webkit.org/show_bug.cgi?id=130704

Reviewed by Eric Carlson.

Source/WebCore: 

Test: media/track/track-remove-track.html

Based on the Blink change (patch by acolwell@chromium.org):
https://codereview.chromium.org/177243018/

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::prepareForLoad): Reorder steps to match W3C specification.
(WebCore::HTMLMediaElement::noneSupported): Forget tracks as required by specification.
(WebCore::HTMLMediaElement::mediaLoadingFailed): Forget tracks as required by specification.
(WebCore::HTMLMediaElement::removeTextTrack): Only request the 'removetracks' event if
requested by caller.
(WebCore::HTMLMediaElement::removeAllInbandTracks): Renamed to 'forgetResourceSpecificTracks'
(WebCore::HTMLMediaElement::noneSupported): Specify that we want the 'removetracks' event
fired for this use case.
(WebCore::HTMLMediaElement::prepareForLoad): Switch to new 'forgetResourceSpecificTracks' name.
* html/HTMLMediaElement.h:
* html/track/TextTrackList.cpp:
(TextTrackList::remove): Only fire the 'removetrack' event if the caller requests it.
* html/track/TextTrackList.h: Add default argument to fire the 'removetrack' event
when removing a track.
* html/track/TrackListBase.cpp:
(TrackListBase::remove): Only fire the 'removetrack' event if the caller requests it.
* html/track/TrackListBase.h: Add default argument to fire the 'removetrack' event.

LayoutTests: 

Based on the Blink change (patch by acolwell@chromium.org):
https://codereview.chromium.org/177243018/

* media/track/track-remove-track-expected.txt: Added.
* media/track/track-remove-track.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTextTrackListcpp">trunk/Source/WebCore/html/track/TextTrackList.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTextTrackListh">trunk/Source/WebCore/html/track/TextTrackList.h</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTrackListBasecpp">trunk/Source/WebCore/html/track/TrackListBase.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackTrackListBaseh">trunk/Source/WebCore/html/track/TrackListBase.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediatracktrackremovetrackexpectedtxt">trunk/LayoutTests/media/track/track-remove-track-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediatracktrackremovetrackhtml">trunk/LayoutTests/media/track/track-remove-track.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/LayoutTests/ChangeLog        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-03-24  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Prevent 'removetrack' events from firing when all inband text tracks are removed.
+        https://bugs.webkit.org/show_bug.cgi?id=130704
+
+        Reviewed by Eric Carlson.
+
+        Based on the Blink change (patch by acolwell@chromium.org):
+        https://codereview.chromium.org/177243018/
+
+        * media/track/track-remove-track-expected.txt: Added.
+        * media/track/track-remove-track.html: Added.
+
</ins><span class="cx"> 2014-03-25  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         media/W3C/audio/canPlayType/canPlayType_application_octet_stream.html frequently fails on EWS
</span></span></pre></div>
<a id="trunkLayoutTestsmediatracktrackremovetrackexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/track/track-remove-track-expected.txt (0 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/track/track-remove-track-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/track/track-remove-track-expected.txt        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS Tests that the 'removetrack' event is fired when an out-of-band TextTrack is removed. 
+PASS Tests that the 'removetrack' event is NOT fired for inband TextTrack on a failed load. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediatracktrackremovetrackhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/track/track-remove-track.html (0 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/track/track-remove-track.html                                (rev 0)
+++ trunk/LayoutTests/media/track/track-remove-track.html        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -0,0 +1,107 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
+
+        &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;script&gt;
+            async_test(function(test)
+            {
+                var video = document.createElement(&quot;video&quot;);
+                var track;
+
+                function trackRemoved()
+                {
+                    assert_equals(event.target, video.textTracks);
+                    assert_equals(event instanceof window.TrackEvent, true);
+                    assert_equals(event.track, track);
+                    test.done();
+                }
+
+                var trackElement = document.createElement('track');
+                video.appendChild(trackElement);
+
+                trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt';
+                trackElement.track.mode = 'hidden';
+
+                assert_equals(video.textTracks.length, 1);
+
+                track = video.textTracks[0];
+                video.removeChild(trackElement);
+                video.textTracks.addEventListener(&quot;removetrack&quot;, test.step_func(trackRemoved));
+            }, &quot;Tests that the 'removetrack' event is fired when an out-of-band TextTrack is removed.&quot;);
+
+            async_test(function(test)
+            {
+                var video = document.createElement(&quot;video&quot;);
+
+                // Create an out-of-band text track by adding a track element.
+                var trackElement = document.createElement('track');
+
+                trackElement.addEventListener(&quot;error&quot;, test.step_func(function()
+                {
+                    assert_unreached(&quot;'error' event on track element should not fire.&quot;)
+                }));
+
+                video.appendChild(trackElement);
+                trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt';
+                trackElement.track.mode = 'hidden';
+
+                assert_equals(video.textTracks.length, 1);
+                var outOfBandTrack = video.textTracks[0];
+
+                // Load a media file with an inband text track.
+                var inbandTrack = null;
+                var url = &quot;../content/counting-captioned.mov&quot;
+
+                var firstAddTrackHandler = test.step_func(function()
+                {
+                    assert_equals(event.target, video.textTracks);
+                    assert_equals(event instanceof window.TrackEvent, true);
+                    if (event.track == outOfBandTrack) {
+                        return;
+                    }
+
+                    assert_equals(inbandTrack, null);
+                    assert_equals(video.textTracks.length, 2);
+                    assert_equals(event.track, video.textTracks[1]);
+                    inbandTrack = event.track;
+
+                    video.textTracks.removeEventListener(&quot;addtrack&quot;, firstAddTrackHandler);
+
+                    // Clear .src to force the inband track to get destroyed.
+                    video.src = &quot;&quot;;
+
+                    // Verify that the inband track was removed.
+                    assert_not_equals(inbandTrack, null);
+                    assert_equals(video.textTracks.length, 1);
+                    assert_equals(video.textTracks[0], outOfBandTrack);
+
+                    // Load the URL again to trigger another 'addtrack' event to make sure
+                    // no 'removetrack' event was queued.
+                    video.src = url;
+                    video.textTracks.addEventListener(&quot;addtrack&quot;, test.step_func(function()
+                    {
+                        assert_equals(video.textTracks.length, 2);
+                        test.done();
+                    }));
+                });
+                video.textTracks.addEventListener(&quot;addtrack&quot;, firstAddTrackHandler);
+
+                video.textTracks.addEventListener(&quot;removetrack&quot;, test.step_func(function()
+                {
+                    assert_unreached(&quot;'removetrack' event should not fire.&quot;)
+                }));
+
+                video.src = url;
+            }, &quot;Tests that the 'removetrack' event is NOT fired for inband TextTrack on a failed load.&quot;);
+
+        &lt;/script&gt;
+        &lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/ChangeLog        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2014-03-24  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Prevent 'removetrack' events from firing when all inband text tracks are removed.
+        https://bugs.webkit.org/show_bug.cgi?id=130704
+
+        Reviewed by Eric Carlson.
+
+        Test: media/track/track-remove-track.html
+
+        Based on the Blink change (patch by acolwell@chromium.org):
+        https://codereview.chromium.org/177243018/
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::prepareForLoad): Reorder steps to match W3C specification.
+        (WebCore::HTMLMediaElement::noneSupported): Forget tracks as required by specification.
+        (WebCore::HTMLMediaElement::mediaLoadingFailed): Forget tracks as required by specification.
+        (WebCore::HTMLMediaElement::removeTextTrack): Only request the 'removetracks' event if
+        requested by caller.
+        (WebCore::HTMLMediaElement::removeAllInbandTracks): Renamed to 'forgetResourceSpecificTracks'
+        (WebCore::HTMLMediaElement::noneSupported): Specify that we want the 'removetracks' event
+        fired for this use case.
+        (WebCore::HTMLMediaElement::prepareForLoad): Switch to new 'forgetResourceSpecificTracks' name.
+        * html/HTMLMediaElement.h:
+        * html/track/TextTrackList.cpp:
+        (TextTrackList::remove): Only fire the 'removetrack' event if the caller requests it.
+        * html/track/TextTrackList.h: Add default argument to fire the 'removetrack' event
+        when removing a track.
+        * html/track/TrackListBase.cpp:
+        (TrackListBase::remove): Only fire the 'removetrack' event if the caller requests it.
+        * html/track/TrackListBase.h: Add default argument to fire the 'removetrack' event.
+
</ins><span class="cx"> 2014-03-25  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Hold a reference to firstSuccessfulSubmitButton in HTMLFormElement::submit
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -978,14 +978,40 @@
</span><span class="cx"> 
</span><span class="cx">     // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
</span><span class="cx">     if (m_networkState != NETWORK_EMPTY) {
</span><ins>+        // 4.1 - Queue a task to fire a simple event named emptied at the media element.
+        scheduleEvent(eventNames().emptiedEvent);
+
+        // 4.2 - If a fetching process is in progress for the media element, the user agent should stop it.
</ins><span class="cx">         m_networkState = NETWORK_EMPTY;
</span><ins>+
+        // 4.3 - Forget the media element's media-resource-specific tracks.
+        forgetResourceSpecificTracks();
+
+        // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that state.
</ins><span class="cx">         m_readyState = HAVE_NOTHING;
</span><span class="cx">         m_readyStateMaximum = HAVE_NOTHING;
</span><del>-        refreshCachedTime();
</del><ins>+
+        // 4.5 - If the paused attribute is false, then set it to true.
</ins><span class="cx">         m_paused = true;
</span><ins>+
+        // 4.6 - If seeking is true, set it to false.
</ins><span class="cx">         m_seeking = false;
</span><ins>+
+        // 4.7 - Set the current playback position to 0.
+        //       Set the official playback position to 0.
+        //       If this changed the official playback position, then queue a task to fire a simple event named timeupdate at the media element.
+        // FIXME: Add support for firing this event. e.g., scheduleEvent(eventNames().timeUpdateEvent);
+
+        // 4.8 - Set the initial playback position to 0.
+        // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call
+        // above.
+        refreshCachedTime();
+
</ins><span class="cx">         invalidateCachedTime();
</span><del>-        scheduleEvent(eventNames().emptiedEvent);
</del><ins>+
+        // 4.9 - Set the timeline offset to Not-a-Number (NaN).
+        // 4.10 - Update the duration attribute to Not-a-Number (NaN).
+
</ins><span class="cx">         updateMediaController();
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">         if (RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="lines">@@ -1011,6 +1037,9 @@
</span><span class="cx">     // 2 - Asynchronously await a stable state.
</span><span class="cx"> 
</span><span class="cx">     m_playedTimeRanges = TimeRanges::create();
</span><ins>+
+    // FIXME: Investigate whether these can be moved into m_networkState != NETWORK_EMPTY block above
+    // so they are closer to the relevant spec steps.
</ins><span class="cx">     m_lastSeekTime = 0;
</span><span class="cx"> 
</span><span class="cx">     // The spec doesn't say to block the load event until we actually run the asynchronous section
</span><span class="lines">@@ -1792,6 +1821,7 @@
</span><span class="cx">     m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
</span><span class="cx"> 
</span><span class="cx">     // 6.2 - Forget the media element's media-resource-specific text tracks.
</span><ins>+    forgetResourceSpecificTracks();
</ins><span class="cx"> 
</span><span class="cx">     // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE value.
</span><span class="cx">     m_networkState = NETWORK_NO_SOURCE;
</span><span class="lines">@@ -1917,11 +1947,18 @@
</span><span class="cx">     // &lt;source&gt; children, schedule the next one
</span><span class="cx">     if (m_readyState &lt; HAVE_METADATA &amp;&amp; m_loadState == LoadingFromSourceElement) {
</span><span class="cx">         
</span><ins>+        // resource selection algorithm
+        // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DOM manipulation task source, to fire a simple event named error at the candidate element.
</ins><span class="cx">         if (m_currentSourceNode)
</span><span class="cx">             m_currentSourceNode-&gt;scheduleErrorEvent();
</span><span class="cx">         else
</span><span class="cx">             LOG(Media, &quot;HTMLMediaElement::setNetworkState - error event not sent, &lt;source&gt; was removed&quot;);
</span><span class="cx">         
</span><ins>+        // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorithm says the synchronous section has ended.
+        
+        // 9.Otherwise.11 - Forget the media element's media-resource-specific tracks.
+        forgetResourceSpecificTracks();
+
</ins><span class="cx">         if (havePotentialSourceChild()) {
</span><span class="cx">             LOG(Media, &quot;HTMLMediaElement::setNetworkState - scheduling next &lt;source&gt;&quot;);
</span><span class="cx">             scheduleNextSourceChild();
</span><span class="lines">@@ -3365,7 +3402,7 @@
</span><span class="cx">     m_audioTracks-&gt;remove(track);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLMediaElement::removeTextTrack(TextTrack* track)
</del><ins>+void HTMLMediaElement::removeTextTrack(TextTrack* track, bool scheduleEvent)
</ins><span class="cx"> {
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="cx">         return;
</span><span class="lines">@@ -3375,7 +3412,7 @@
</span><span class="cx">     if (cues)
</span><span class="cx">         textTrackRemoveCues(track, cues);
</span><span class="cx">     track-&gt;clearClient();
</span><del>-    m_textTracks-&gt;remove(track);
</del><ins>+    m_textTracks-&gt;remove(track, scheduleEvent);
</ins><span class="cx"> 
</span><span class="cx">     closeCaptionTracksChanged();
</span><span class="cx"> }
</span><span class="lines">@@ -3388,7 +3425,7 @@
</span><span class="cx">     m_videoTracks-&gt;remove(track);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLMediaElement::removeAllInbandTracks()
</del><ins>+void HTMLMediaElement::forgetResourceSpecificTracks()
</ins><span class="cx"> {
</span><span class="cx">     while (m_audioTracks &amp;&amp;  m_audioTracks-&gt;length())
</span><span class="cx">         removeAudioTrack(m_audioTracks-&gt;lastItem());
</span><span class="lines">@@ -3399,7 +3436,7 @@
</span><span class="cx">             TextTrack* track = m_textTracks-&gt;item(i);
</span><span class="cx"> 
</span><span class="cx">             if (track-&gt;trackType() == TextTrack::InBand)
</span><del>-                removeTextTrack(track);
</del><ins>+                removeTextTrack(track, false);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -4519,7 +4556,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>-    removeAllInbandTracks();
</del><ins>+    forgetResourceSpecificTracks();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span><span class="lines">@@ -5424,7 +5461,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>-    removeAllInbandTracks();
</del><ins>+    forgetResourceSpecificTracks();
</ins><span class="cx"> #endif
</span><span class="cx">     m_player = MediaPlayer::create(this);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -290,9 +290,9 @@
</span><span class="cx">     void addTextTrack(PassRefPtr&lt;TextTrack&gt;);
</span><span class="cx">     void addVideoTrack(PassRefPtr&lt;VideoTrack&gt;);
</span><span class="cx">     void removeAudioTrack(AudioTrack*);
</span><del>-    void removeTextTrack(TextTrack*);
</del><ins>+    void removeTextTrack(TextTrack*, bool scheduleEvent = true);
</ins><span class="cx">     void removeVideoTrack(VideoTrack*);
</span><del>-    void removeAllInbandTracks();
</del><ins>+    void forgetResourceSpecificTracks();
</ins><span class="cx">     void closeCaptionTracksChanged();
</span><span class="cx">     void notifyMediaPlayerOfTextTrackChanges();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTextTrackListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TextTrackList.cpp (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TextTrackList.cpp        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/track/TextTrackList.cpp        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx">     scheduleAddTrackEvent(track.release());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextTrackList::remove(TrackBase* track)
</del><ins>+void TextTrackList::remove(TrackBase* track, bool scheduleEvent)
</ins><span class="cx"> {
</span><span class="cx">     TextTrack* textTrack = toTextTrack(track);
</span><span class="cx">     Vector&lt;RefPtr&lt;TrackBase&gt;&gt;* tracks = 0;
</span><span class="lines">@@ -219,7 +219,9 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;TrackBase&gt; trackRef = (*tracks)[index];
</span><span class="cx">     tracks-&gt;remove(index);
</span><del>-    scheduleRemoveTrackEvent(trackRef.release());
</del><ins>+
+    if (scheduleEvent)
+        scheduleRemoveTrackEvent(trackRef.release());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool TextTrackList::contains(TrackBase* track) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTextTrackListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TextTrackList.h (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TextTrackList.h        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/track/TextTrackList.h        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     TextTrack* lastItem() const { return item(length() - 1); }
</span><span class="cx"> 
</span><span class="cx">     void append(PassRefPtr&lt;TextTrack&gt;);
</span><del>-    virtual void remove(TrackBase*) override;
</del><ins>+    virtual void remove(TrackBase*, bool scheduleEvent = true) override;
</ins><span class="cx"> 
</span><span class="cx">     // EventTarget
</span><span class="cx">     virtual EventTargetInterface eventTargetInterface() const override;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTrackListBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TrackListBase.cpp (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TrackListBase.cpp        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/track/TrackListBase.cpp        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">     return m_inbandTracks.size();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TrackListBase::remove(TrackBase* track)
</del><ins>+void TrackListBase::remove(TrackBase* track, bool scheduleEvent)
</ins><span class="cx"> {
</span><span class="cx">     size_t index = m_inbandTracks.find(track);
</span><span class="cx">     ASSERT(index != notFound);
</span><span class="lines">@@ -70,7 +70,8 @@
</span><span class="cx"> 
</span><span class="cx">     m_inbandTracks.remove(index);
</span><span class="cx"> 
</span><del>-    scheduleRemoveTrackEvent(trackRef.release());
</del><ins>+    if (scheduleEvent)
+        scheduleRemoveTrackEvent(trackRef.release());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool TrackListBase::contains(TrackBase* track) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackTrackListBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/TrackListBase.h (166237 => 166238)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/TrackListBase.h        2014-03-25 16:44:33 UTC (rev 166237)
+++ trunk/Source/WebCore/html/track/TrackListBase.h        2014-03-25 16:51:40 UTC (rev 166238)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual unsigned length() const;
</span><span class="cx">     virtual bool contains(TrackBase*) const;
</span><del>-    virtual void remove(TrackBase*);
</del><ins>+    virtual void remove(TrackBase*, bool scheduleEvent = true);
</ins><span class="cx"> 
</span><span class="cx">     // EventTarget
</span><span class="cx">     virtual EventTargetInterface eventTargetInterface() const = 0;
</span></span></pre>
</div>
</div>

</body>
</html>