Title: [117811] trunk
Revision
117811
Author
ann...@chromium.org
Date
2012-05-21 13:34:21 -0700 (Mon, 21 May 2012)

Log Message

Only render text track cues if kind=captions or kind=subtitles.
https://bugs.webkit.org/show_bug.cgi?id=83321

Reviewed by Eric Carlson.

Source/WebCore:

No new tests. Modification to media/track/track-kind.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackKindChanged):
   If the kind changes from a 'visible' kind to a 'non-visible' kind,
   update the track's mode to HIDDEN.

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
    Do not render cues from tracks that are not captions or subtitles.

* html/track/TextTrack.cpp:
(WebCore::TextTrack::setMode):
    If the track's mode changes from SHOWING to HIDDEN or DISABLED,
    ensure any currently visible cues will no longer be rendered.

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::removeDisplayTree): New method.
* html/track/TextTrackCue.h:
(TextTrackCue):

LayoutTests:

* media/track/track-kind-expected.txt:
* media/track/track-kind.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (117810 => 117811)


--- trunk/LayoutTests/ChangeLog	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/LayoutTests/ChangeLog	2012-05-21 20:34:21 UTC (rev 117811)
@@ -1,3 +1,14 @@
+2012-05-21  Anna Cavender  <ann...@chromium.org>
+
+        Only render text track cues if kind=captions or kind=subtitles.
+        https://bugs.webkit.org/show_bug.cgi?id=83321
+
+        Reviewed by Eric Carlson.
+
+        * media/track/track-kind-expected.txt:
+        * media/track/track-kind.html:
+
+
 2012-05-21  Peter Kasting  <pkast...@google.com>
 
         [chromium] More accurate test expectations.

Modified: trunk/LayoutTests/media/track/track-kind-expected.txt (117810 => 117811)


--- trunk/LayoutTests/media/track/track-kind-expected.txt	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/LayoutTests/media/track/track-kind-expected.txt	2012-05-21 20:34:21 UTC (rev 117811)
@@ -1,6 +1,5 @@
-Tests that the 'addtrack' event is fired when a TextTrack is created.
+Tests that the 'kind' attribute is set properly and that cues are only visible when 'kind' is set to 'captions' or 'subtitles'.
 
-
 ++ Test default attribute value
 EXPECTED (trackElement.getAttribute('kind') == 'null') OK
 EXPECTED (trackElement.kind == 'subtitles') OK
@@ -34,6 +33,7 @@
 EXPECTED (trackElement.kind == 'subtitles') OK
 EXPECTED (trackElement.track.kind == 'subtitles') OK
 EXPECTED (trackElement.getAttribute('kind') == 'subtitles') OK
+EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem ipsum dolor sit amet, ') OK
 
 ++ 'captions'
 set via DOM
@@ -48,6 +48,7 @@
 EXPECTED (trackElement.kind == 'captions') OK
 EXPECTED (trackElement.track.kind == 'captions') OK
 EXPECTED (trackElement.getAttribute('kind') == 'captions') OK
+EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem ipsum dolor sit amet, ') OK
 
 ++ 'descriptions'
 set via DOM
@@ -62,6 +63,7 @@
 EXPECTED (trackElement.kind == 'descriptions') OK
 EXPECTED (trackElement.track.kind == 'descriptions') OK
 EXPECTED (trackElement.getAttribute('kind') == 'descriptions') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
 
 ++ 'chapters'
 set via DOM
@@ -76,6 +78,7 @@
 EXPECTED (trackElement.kind == 'chapters') OK
 EXPECTED (trackElement.track.kind == 'chapters') OK
 EXPECTED (trackElement.getAttribute('kind') == 'chapters') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
 
 ++ 'metadata'
 set via DOM
@@ -90,6 +93,7 @@
 EXPECTED (trackElement.kind == 'metadata') OK
 EXPECTED (trackElement.track.kind == 'metadata') OK
 EXPECTED (trackElement.getAttribute('kind') == 'metadata') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
 
 END OF TEST
 

Modified: trunk/LayoutTests/media/track/track-kind.html (117810 => 117811)


--- trunk/LayoutTests/media/track/track-kind.html	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/LayoutTests/media/track/track-kind.html	2012-05-21 20:34:21 UTC (rev 117811)
@@ -4,11 +4,13 @@
 
         <script src=""
         <script src=""
+        <script src=""
         <script>
 
             var trackElement;
             function setKind(value)
             {
+                consoleWrite("<b>++ '" + value + "'</b>");
                 consoleWrite("<b> set via DOM</b>");
                 run("trackElement.removeAttribute('kind')");
                 run("trackElement.kind = '" + value + "'");
@@ -21,17 +23,13 @@
                 testExpected("trackElement.kind", value);
                 testExpected("trackElement.track.kind", value);
                 testExpected("trackElement.getAttribute('kind')", value);
+                testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem ipsum dolor sit amet, ");
                 consoleWrite("");
 
             }
 
-            function start()
+            function testKind()
             {
-                findMediaElement();
-                consoleWrite("");
-
-                trackElement = document.getElementById('track_1');
-
                 consoleWrite("<b>++ Test default attribute value</b>");
                 testExpected("trackElement.getAttribute('kind')", null);
                 testExpected("trackElement.kind", "subtitles");
@@ -55,30 +53,35 @@
                 consoleWrite("");
 
                 consoleWrite("<b>*** Set to known values</b>");
-                consoleWrite("<b>++ 'subtitles'</b>");
                 setKind("subtitles");
 
-                consoleWrite("<b>++ 'captions'</b>");
                 setKind("captions");
 
-                consoleWrite("<b>++ 'descriptions'</b>");
                 setKind("descriptions");
 
-                consoleWrite("<b>++ 'chapters'</b>");
                 setKind("chapters");
 
-                consoleWrite("<b>++ 'metadata'</b>");
                 setKind("metadata");
 
                 endTest();
             }
+            
+            function loaded()
+            {
+                findMediaElement();
+                trackElement = document.getElementById('track_1');
 
+                waitForEventsAndCall([[video, 'canplaythrough'], [trackElement, 'load']], testKind);
+
+                video.src = "" '../content/counting');
+            }
+
         </script>
     </head>
-    <body _onload_="start()">
-        <p>Tests that the 'addtrack' event is fired when a TextTrack is created.</p>
+    <body _onload_="loaded()">
+        <p>Tests that the 'kind' attribute is set properly and that cues are only visible when 'kind' is set to 'captions' or 'subtitles'.</p>
         <video>
-            <track id=track_1>
+            <track id=track_1 src="" default>
         </video>
     </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (117810 => 117811)


--- trunk/Source/WebCore/ChangeLog	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/ChangeLog	2012-05-21 20:34:21 UTC (rev 117811)
@@ -1,3 +1,31 @@
+2012-05-21 Anna Cavender  <ann...@chromium.org>
+
+        Only render text track cues if kind=captions or kind=subtitles.
+        https://bugs.webkit.org/show_bug.cgi?id=83321
+
+        Reviewed by Eric Carlson.
+
+        No new tests. Modification to media/track/track-kind.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::textTrackKindChanged):
+           If the kind changes from a 'visible' kind to a 'non-visible' kind,
+           update the track's mode to HIDDEN.
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
+            Do not render cues from tracks that are not captions or subtitles.
+
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::setMode):
+            If the track's mode changes from SHOWING to HIDDEN or DISABLED,
+            ensure any currently visible cues will no longer be rendered.
+
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::removeDisplayTree): New method.
+        * html/track/TextTrackCue.h:
+        (TextTrackCue):
+ 
 2012-05-21  Andreas Kling  <kl...@webkit.org>
 
         CSS: Move duplicate property elimination to parser.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (117810 => 117811)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-21 20:34:21 UTC (rev 117811)
@@ -1285,9 +1285,10 @@
     configureTextTrackDisplay();
 }
 
-void HTMLMediaElement::textTrackKindChanged(TextTrack*)
+void HTMLMediaElement::textTrackKindChanged(TextTrack* track)
 {
-    // FIXME(62885): Implement.
+    if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->mode() == TextTrack::SHOWING)
+        track->setMode(TextTrack::HIDDEN, ASSERT_NO_EXCEPTION);
 }
 
 void HTMLMediaElement::textTrackAddCues(TextTrack*, const TextTrackCueList* cues) 

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (117810 => 117811)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-05-21 20:34:21 UTC (rev 117811)
@@ -1284,6 +1284,9 @@
         TextTrackCue* cue = activeCues[i].data();
 
         ASSERT(cue->isActive());
+        if (cue->track()->kind() != TextTrack::captionsKeyword() && cue->track()->kind() != TextTrack::subtitlesKeyword())
+            continue;
+
         if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
             continue;
 

Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (117810 => 117811)


--- trunk/Source/WebCore/html/track/TextTrack.cpp	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp	2012-05-21 20:34:21 UTC (rev 117811)
@@ -142,7 +142,11 @@
     // If mode changes to disabled, remove this track's cues from the client
     // because they will no longer be accessible from the cues() function.
     if (mode == TextTrack::DISABLED && m_client && m_cues)
-         m_client->textTrackRemoveCues(this, m_cues.get());
+        m_client->textTrackRemoveCues(this, m_cues.get());
+         
+    if (mode != TextTrack::SHOWING && m_cues)
+        for (size_t i = 0; i < m_cues->length(); ++i)
+            m_cues->item(i)->removeDisplayTree();
 
     //  ... Note: If the mode had been showing by default, this will change it to showing, 
     // even though the value of mode would appear not to change.

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (117810 => 117811)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-05-21 20:34:21 UTC (rev 117811)
@@ -608,6 +608,12 @@
     return m_displayTree;
 }
 
+void TextTrackCue::removeDisplayTree()
+{
+    if (m_displayTree->parentNode())
+        m_displayTree->remove(ASSERT_NO_EXCEPTION);
+}
+
 std::pair<double, double> TextTrackCue::getPositionCoordinates()
 {
     std::pair<double, double> coordinates;

Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (117810 => 117811)


--- trunk/Source/WebCore/html/track/TextTrackCue.h	2012-05-21 20:06:27 UTC (rev 117810)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h	2012-05-21 20:34:21 UTC (rev 117811)
@@ -102,6 +102,7 @@
     void setIsActive(bool);
 
     PassRefPtr<HTMLDivElement> getDisplayTree();
+    void removeDisplayTree();
 
     virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to