Title: [149766] trunk
Revision
149766
Author
[email protected]
Date
2013-05-08 13:53:28 -0700 (Wed, 08 May 2013)

Log Message

TextTrackCue should support empty content
https://bugs.webkit.org/show_bug.cgi?id=115821

Reviewed by Jer Noble.

Source/WebCore:

Test: media/track/track-cue-empty-text-crash.html

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Don't bother trying to render
    cues with no content.

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::getCueAsHTML): Return early if there isn't a node tree.
(WebCore::TextTrackCue::createCueRenderingTree): Ditto.
(WebCore::TextTrackCue::determineTextDirection): Ditto.
(WebCore::TextTrackCue::updateDisplayTree): Return early if there isn't a cue rendering tree.

LayoutTests:

* media/track/track-cue-empty-text-crash-expected.txt: Added.
* media/track/track-cue-empty-text-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149765 => 149766)


--- trunk/LayoutTests/ChangeLog	2013-05-08 20:48:58 UTC (rev 149765)
+++ trunk/LayoutTests/ChangeLog	2013-05-08 20:53:28 UTC (rev 149766)
@@ -1,3 +1,13 @@
+2013-05-08  Eric Carlson  <[email protected]>
+
+        TextTrackCue should support empty content
+        https://bugs.webkit.org/show_bug.cgi?id=115821
+
+        Reviewed by Jer Noble.
+
+        * media/track/track-cue-empty-text-crash-expected.txt: Added.
+        * media/track/track-cue-empty-text-crash.html: Added.
+
 2013-05-08  Christophe Dumez  <[email protected]>
 
         Add layout test that lists all global constructors

Added: trunk/LayoutTests/media/track/track-cue-empty-text-crash-expected.txt (0 => 149766)


--- trunk/LayoutTests/media/track/track-cue-empty-text-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-cue-empty-text-crash-expected.txt	2013-05-08 20:53:28 UTC (rev 149766)
@@ -0,0 +1,10 @@
+** Add a text track to the video element...
+** Add an empty cue to the track...
+** Play the video so the cue is scheduled to render...
+
+EVENT(playing)
+
+PASS - no crash.
+
+END OF TEST
+

Added: trunk/LayoutTests/media/track/track-cue-empty-text-crash.html (0 => 149766)


--- trunk/LayoutTests/media/track/track-cue-empty-text-crash.html	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-cue-empty-text-crash.html	2013-05-08 20:53:28 UTC (rev 149766)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script>
+            function playing()
+            {
+                consoleWrite("<br>PASS - no crash.<br>");
+                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 an empty cue to the track...");
+                video.textTracks[0].addCue(new TextTrackCue(0.00, 4.00, ""));
+                video.textTracks[0].mode = "showing";
+
+                consoleWrite("** Play the video so the cue is scheduled to render...<br>");
+                video.play();
+                waitForEvent('playing', playing);
+              }
+        </script>
+    </head>
+
+    <body _onload_="startTest()">
+        <video controls />
+        <p>Tests that a cue with no text does not crash the browser.</p>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (149765 => 149766)


--- trunk/Source/WebCore/ChangeLog	2013-05-08 20:48:58 UTC (rev 149765)
+++ trunk/Source/WebCore/ChangeLog	2013-05-08 20:53:28 UTC (rev 149766)
@@ -1,3 +1,22 @@
+2013-05-08  Eric Carlson  <[email protected]>
+
+        TextTrackCue should support empty content
+        https://bugs.webkit.org/show_bug.cgi?id=115821
+
+        Reviewed by Jer Noble.
+
+        Test: media/track/track-cue-empty-text-crash.html
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Don't bother trying to render
+            cues with no content.
+
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::getCueAsHTML): Return early if there isn't a node tree.
+        (WebCore::TextTrackCue::createCueRenderingTree): Ditto.
+        (WebCore::TextTrackCue::determineTextDirection): Ditto.
+        (WebCore::TextTrackCue::updateDisplayTree): Return early if there isn't a cue rendering tree.
+
 2013-05-08  Roger Fong  <[email protected]>
 
         Unreviewed AppleWin build fix.

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (149765 => 149766)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2013-05-08 20:48:58 UTC (rev 149765)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2013-05-08 20:53:28 UTC (rev 149766)
@@ -1273,7 +1273,7 @@
         TextTrackCue* cue = activeCues[i].data();
 
         ASSERT(cue->isActive());
-        if (!cue->track() || !cue->track()->isRendered() || !cue->isActive())
+        if (!cue->track() || !cue->track()->isRendered() || !cue->isActive() || cue->text().isEmpty())
             continue;
 
         RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (149765 => 149766)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2013-05-08 20:48:58 UTC (rev 149765)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2013-05-08 20:53:28 UTC (rev 149766)
@@ -517,6 +517,9 @@
 PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML()
 {
     createWebVTTNodeTree();
+    if (!m_webVTTNodeTree)
+        return 0;
+
     RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument());
     copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get());
     return clonedFragment.release();
@@ -526,6 +529,9 @@
 {
     RefPtr<DocumentFragment> clonedFragment;
     createWebVTTNodeTree();
+    if (!m_webVTTNodeTree)
+        return 0;
+
     clonedFragment = DocumentFragment::create(ownerDocument());
     m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
     return clonedFragment.release();
@@ -613,6 +619,8 @@
 {
     DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt")));
     createWebVTTNodeTree();
+    if (!m_webVTTNodeTree)
+        return;
 
     // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the
     // concatenation of the values of each WebVTT Text Object in nodes, in a
@@ -782,6 +790,9 @@
 
     // Update the two sets containing past and future WebVTT objects.
     RefPtr<DocumentFragment> referenceTree = createCueRenderingTree();
+    if (!referenceTree)
+        return;
+
     markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
     m_cueBackgroundBox->appendChild(referenceTree);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to