Title: [220472] trunk
Revision
220472
Author
commit-qu...@webkit.org
Date
2017-08-09 12:13:51 -0700 (Wed, 09 Aug 2017)

Log Message

Old subtitle track is not deleted on 'src' attribute change event
https://bugs.webkit.org/show_bug.cgi?id=175031

Patch by Kirill Ovchinnikov <kirill.ovchinni...@lge.com> on 2017-08-09
Reviewed by Eric Carlson.

Source/WebCore:

Test: media/track/text-track-src-change.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackReadyStateChanged):
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::loadTimerFired):
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::clearTextDisplayContainer):
* html/shadow/MediaControls.h:

LayoutTests:

* media/track/text-track-src-change-expected.txt: Added.
* media/track/text-track-src-change.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220471 => 220472)


--- trunk/LayoutTests/ChangeLog	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/LayoutTests/ChangeLog	2017-08-09 19:13:51 UTC (rev 220472)
@@ -1,3 +1,13 @@
+2017-08-09  Kirill Ovchinnikov  <kirill.ovchinni...@lge.com>
+
+        Old subtitle track is not deleted on 'src' attribute change event
+        https://bugs.webkit.org/show_bug.cgi?id=175031
+
+        Reviewed by Eric Carlson.
+
+        * media/track/text-track-src-change-expected.txt: Added.
+        * media/track/text-track-src-change.html: Added.
+
 2017-08-09  Nan Wang  <n_w...@apple.com>
 
         AX: crash at WebCore::AccessibilityObject::supportsARIALiveRegion() const + 24

Added: trunk/LayoutTests/media/track/text-track-src-change-expected.txt (0 => 220472)


--- trunk/LayoutTests/media/track/text-track-src-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/track/text-track-src-change-expected.txt	2017-08-09 19:13:51 UTC (rev 220472)
@@ -0,0 +1,14 @@
+Tests Track 'src' changing handling
+
+
+
+*** Testing Track 'src' changing
+EXPECTED (cues.length == '4') OK
+
+*** Changing 'src' attribute...
+EXPECTED (cues.length == '100') OK
+
+*** Changing back 'src' attribute...
+EXPECTED (cues.length == '4') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/track/text-track-src-change.html (0 => 220472)


--- trunk/LayoutTests/media/track/text-track-src-change.html	                        (rev 0)
+++ trunk/LayoutTests/media/track/text-track-src-change.html	2017-08-09 19:13:51 UTC (rev 220472)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script>
+            var stage = 0; 
+
+            function trackLoaded()
+            {
+                var testTrack = document.getElementById('testTrack');
+                switch (stage) {
+                    case 0:
+                        consoleWrite("<br>*** Testing Track 'src' changing");
+                        cues = testTrack.track.cues;
+                        testExpected("cues.length", 4);
+                        consoleWrite("<br>*** Changing 'src' attribute...");
+                        ++stage;
+                        testTrack.src = ""
+                        break;
+                    case 1:
+                        cues = testTrack.track.cues;
+                        testExpected("cues.length", 100);
+                        consoleWrite("<br>*** Changing back 'src' attribute...");
+                        ++stage;
+                        testTrack.src = ""
+                        break;
+                    case 2:
+                        cues = testTrack.track.cues;
+                        testExpected("cues.length", 4);
+                        endTest();
+                        break;
+                }
+            }
+
+            setCaptionDisplayMode('Automatic');
+        </script>
+    </head>
+    <body>
+        <p>Tests Track 'src' changing handling</p>
+        <video>
+            <track id="testTrack" src="" kind="captions" _onload_="trackLoaded()" default>
+        </video>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (220471 => 220472)


--- trunk/Source/WebCore/ChangeLog	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/Source/WebCore/ChangeLog	2017-08-09 19:13:51 UTC (rev 220472)
@@ -1,3 +1,20 @@
+2017-08-09  Kirill Ovchinnikov  <kirill.ovchinni...@lge.com>
+
+        Old subtitle track is not deleted on 'src' attribute change event
+        https://bugs.webkit.org/show_bug.cgi?id=175031
+
+        Reviewed by Eric Carlson.
+
+        Test: media/track/text-track-src-change.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::textTrackReadyStateChanged):
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::loadTimerFired):
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::clearTextDisplayContainer):
+        * html/shadow/MediaControls.h:
+
 2017-08-09  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r220457.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (220471 => 220472)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-09 19:13:51 UTC (rev 220472)
@@ -1855,6 +1855,15 @@
 
 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track)
 {
+    if (track->readinessState() != TextTrack::Loading
+        && track->mode() != TextTrack::Mode::Disabled) {
+        // The display trees exist as long as the track is active, in this case,
+        // and if the same track is loaded again (for example if the src attribute was changed),
+        // cues can be accumulated with the old ones, that's why they needs to be flushed
+        if (hasMediaControls())
+            mediaControls()->clearTextDisplayContainer();
+        updateTextTrackDisplay();
+    }
     if (m_player && m_textTracksWhenResourceSelectionBegan.contains(track)) {
         if (track->readinessState() != TextTrack::Loading)
             setReadyState(m_player->readyState());

Modified: trunk/Source/WebCore/html/HTMLTrackElement.cpp (220471 => 220472)


--- trunk/Source/WebCore/html/HTMLTrackElement.cpp	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/Source/WebCore/html/HTMLTrackElement.cpp	2017-08-09 19:13:51 UTC (rev 220472)
@@ -202,6 +202,10 @@
         return;
     }
 
+    // When src attribute is changed we need to flush all collected track data
+    if (m_track)
+        m_track->removeAllCues();
+
     track().scheduleLoad(url);
 }
 

Modified: trunk/Source/WebCore/html/shadow/MediaControls.cpp (220471 => 220472)


--- trunk/Source/WebCore/html/shadow/MediaControls.cpp	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/Source/WebCore/html/shadow/MediaControls.cpp	2017-08-09 19:13:51 UTC (rev 220472)
@@ -412,6 +412,12 @@
         m_textDisplayContainer->updateSizes(true);
 }
 
+void MediaControls::clearTextDisplayContainer()
+{
+    if (m_textDisplayContainer)
+        m_textDisplayContainer->removeChildren();
+}
+
 #endif
 
 void MediaControls::setSliderVolume()

Modified: trunk/Source/WebCore/html/shadow/MediaControls.h (220471 => 220472)


--- trunk/Source/WebCore/html/shadow/MediaControls.h	2017-08-09 18:31:24 UTC (rev 220471)
+++ trunk/Source/WebCore/html/shadow/MediaControls.h	2017-08-09 19:13:51 UTC (rev 220472)
@@ -101,6 +101,7 @@
     virtual void hideTextTrackDisplay();
     virtual void updateTextTrackDisplay();
     virtual void textTrackPreferencesChanged();
+    virtual void clearTextDisplayContainer();
 #endif
 
 protected:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to