Replace TextTrackCue "getCueAsSource" method with "text" attribute
https://bugs.webkit.org/show_bug.cgi?id=75646
Reviewed by Darin Adler.
Source/WebCore:
Test: media/track/track-cue-mutable-text.html
* html/HTMLMediaElement.h: getCueAsSource() -> text().
* html/TextTrackCue.cpp:
(WebCore::TextTrackCue::setText): New. Set cue text and clear the document fragment.
(WebCore::TextTrackCue::getCueAsHTML): Allocate the document fragment if it doesn't exist.
* html/TextTrackCue.h:
(WebCore::TextTrackCue::text):
* html/TextTrackCue.idl: getCueAsSource() -> text().
* html/shadow/MediaControlRootElement.cpp:
(WebCore::MediaControlRootElement::updateTextTrackDisplay): getCueAsSource() -> text().
* html/shadow/MediaControlRootElementChromium.cpp:
(WebCore::MediaControlRootElementChromium::updateTextTrackDisplay): getCueAsSource() -> text().
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::collectCueText): processCueText is dead, long live createNewCue.
(WebCore::WebVTTParser::createDocumentFragmentFromCueText): New, split out of processCueText.
Create a document fragment from the String argument.
(WebCore::WebVTTParser::createNewCue): Split out of processCueText.
(WebCore::WebVTTParser::constructTreeFromToken): Add a comment pointing to the spec section
with the rules for DOM construction.
* html/track/WebVTTParser.h:
LayoutTests:
* media/track/track-cue-mutable-text-expected.txt: Added.
* media/track/track-cue-mutable-text.html: Added. New test for mutable cue text.
* media/track/track-cue-nothing-to-render-expected.txt: getCueAsSource() -> text.
* media/track/track-cue-nothing-to-render.html: Ditto.
* media/track/track-cue-rendering-expected.txt: Ditto.
* media/track/track-cue-rendering.html: Ditto.
* media/track/track-webvtt-tc001-utf8-expected.txt: Ditto.
* media/track/track-webvtt-tc001-utf8.html: Ditto.
* media/track/track-webvtt-tc002-bom-expected.txt: Ditto.
* media/track/track-webvtt-tc002-bom.html: Ditto.
* media/track/track-webvtt-tc003-newlines-expected.txt: Ditto.
* media/track/track-webvtt-tc003-newlines.html: Ditto.
* media/track/track-webvtt-tc004-magic-header-expected.txt: Ditto.
* media/track/track-webvtt-tc004-magic-header.html: Ditto.
* media/track/track-webvtt-tc005-header-comment-expected.txt: Ditto.
* media/track/track-webvtt-tc005-header-comment.html: Ditto.
* media/track/track-webvtt-tc006-cue-identifiers-expected.txt: Ditto.
* media/track/track-webvtt-tc006-cue-identifiers.html: Ditto.
* media/track/track-webvtt-tc007-cue-no-id-expected.txt: Ditto.
* media/track/track-webvtt-tc007-cue-no-id.html: Ditto.
* media/track/track-webvtt-tc008-timings-no-hours-expected.txt: Ditto.
* media/track/track-webvtt-tc008-timings-no-hours.html: Ditto.
* media/track/track-webvtt-tc009-timings-hour-expected.txt: Ditto.
* media/track/track-webvtt-tc009-timings-hour.html: Ditto.
* media/track/track-webvtt-tc011-blank-lines-expected.txt: Ditto.
* media/track/track-webvtt-tc011-blank-lines.html: Ditto.
* media/track/track-webvtt-tc028-unsupported-markup-expected.txt: Ditto.
* media/track/track-webvtt-tc028-unsupported-markup.html: Ditto.
* platform/mac/fast/dom/Window/window-properties-expected.txt: Remove getCueAsSource.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ceab9f5..4002929 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,40 @@
+2012-01-10 Eric Carlson <eric.carlson@apple.com>
+
+ Replace TextTrackCue "getCueAsSource" method with "text" attribute
+ https://bugs.webkit.org/show_bug.cgi?id=75646
+
+ Reviewed by Darin Adler.
+
+ * media/track/track-cue-mutable-text-expected.txt: Added.
+ * media/track/track-cue-mutable-text.html: Added. New test for mutable cue text.
+ * media/track/track-cue-nothing-to-render-expected.txt: getCueAsSource() -> text.
+ * media/track/track-cue-nothing-to-render.html: Ditto.
+ * media/track/track-cue-rendering-expected.txt: Ditto.
+ * media/track/track-cue-rendering.html: Ditto.
+ * media/track/track-webvtt-tc001-utf8-expected.txt: Ditto.
+ * media/track/track-webvtt-tc001-utf8.html: Ditto.
+ * media/track/track-webvtt-tc002-bom-expected.txt: Ditto.
+ * media/track/track-webvtt-tc002-bom.html: Ditto.
+ * media/track/track-webvtt-tc003-newlines-expected.txt: Ditto.
+ * media/track/track-webvtt-tc003-newlines.html: Ditto.
+ * media/track/track-webvtt-tc004-magic-header-expected.txt: Ditto.
+ * media/track/track-webvtt-tc004-magic-header.html: Ditto.
+ * media/track/track-webvtt-tc005-header-comment-expected.txt: Ditto.
+ * media/track/track-webvtt-tc005-header-comment.html: Ditto.
+ * media/track/track-webvtt-tc006-cue-identifiers-expected.txt: Ditto.
+ * media/track/track-webvtt-tc006-cue-identifiers.html: Ditto.
+ * media/track/track-webvtt-tc007-cue-no-id-expected.txt: Ditto.
+ * media/track/track-webvtt-tc007-cue-no-id.html: Ditto.
+ * media/track/track-webvtt-tc008-timings-no-hours-expected.txt: Ditto.
+ * media/track/track-webvtt-tc008-timings-no-hours.html: Ditto.
+ * media/track/track-webvtt-tc009-timings-hour-expected.txt: Ditto.
+ * media/track/track-webvtt-tc009-timings-hour.html: Ditto.
+ * media/track/track-webvtt-tc011-blank-lines-expected.txt: Ditto.
+ * media/track/track-webvtt-tc011-blank-lines.html: Ditto.
+ * media/track/track-webvtt-tc028-unsupported-markup-expected.txt: Ditto.
+ * media/track/track-webvtt-tc028-unsupported-markup.html: Ditto.
+ * platform/mac/fast/dom/Window/window-properties-expected.txt: Remove getCueAsSource.
+
2012-01-10 Chris Marrin <cmarrin@apple.com>
Turn off the FilterTrigger in WebKit and WebKit2
diff --git a/LayoutTests/media/track/track-cue-mutable-text-expected.txt b/LayoutTests/media/track/track-cue-mutable-text-expected.txt
new file mode 100644
index 0000000..cea90a0
--- /dev/null
+++ b/LayoutTests/media/track/track-cue-mutable-text-expected.txt
@@ -0,0 +1,23 @@
+Test that cue text is mutable.
+
+
+** Test initial cue info
+EXPECTED (testTrack.track.activeCues.length == '0') OK
+EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+EXPECTED (testTrack.track.cues[0].startTime == '1') OK
+EXPECTED (testTrack.track.cues[1].startTime == '3') OK
+EXPECTED (testTrack.track.cues[0].text == 'Lorem ipsum dolor sit amet,') OK
+EXPECTED (fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()) == 'true') OK
+
+** Change the start time of cue #1, it should become visible.
+RUN(testTrack.track.cues[0].startTime = 0)
+EXPECTED (testTrack.track.cues[0].startTime == '0') OK
+EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem ipsum dolor sit amet,') OK
+
+** Change the cue text, getCueAsHTML() should return a new, correct fragment.
+RUN(testTrack.track.cues[0].text = 'Lorem ipsum dolor sit amet,')
+EXPECTED (testTrack.track.cues[0].text == 'Lorem ipsum dolor sit amet,') OK
+EXPECTED (fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()) == 'true') OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/track/track-cue-mutable-text.html b/LayoutTests/media/track/track-cue-mutable-text.html
new file mode 100644
index 0000000..0e380f9
--- /dev/null
+++ b/LayoutTests/media/track/track-cue-mutable-text.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=../media-file.js></script>
+ <script src=../video-test.js></script>
+ <script src=../media-controls.js></script>
+
+ <script>
+
+ var testTrack;
+ var fragment;
+ function test()
+ {
+ consoleWrite("<br>** Test initial cue info");
+
+ testExpected("testTrack.track.activeCues.length", 0);
+ testExpected("textTrackDisplayElement(video, 'display').innerText", "");
+
+ testExpected("testTrack.track.cues[0].startTime", 1.0);
+ testExpected("testTrack.track.cues[1].startTime", 3.0);
+
+ testExpected("testTrack.track.cues[0].text", "Lorem ipsum dolor sit amet,");
+ fragment = document.createDocumentFragment();
+ fragment.appendChild(document.createTextNode("Lorem ipsum dolor sit amet,"));
+ testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML())", true);
+
+ consoleWrite("<br>** Change the start time of cue #1, it should become visible.");
+ run("testTrack.track.cues[0].startTime = 0");
+ testExpected("testTrack.track.cues[0].startTime", 0);
+ testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem ipsum dolor sit amet,");
+
+ consoleWrite("<br>** Change the cue text, getCueAsHTML() should return a new, correct fragment.");
+ run("testTrack.track.cues[0].text = 'Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,'");
+ testExpected("testTrack.track.cues[0].text", "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,");
+
+ fragment = document.createDocumentFragment();
+ fragment.appendChild(document.createTextNode("Lorem "));
+
+ var bold = document.createElement("b");
+ bold.appendChild(document.createTextNode("ipsum"));
+ fragment.appendChild(bold);
+
+ fragment.appendChild(document.createTextNode(" "));
+
+ var underline = document.createElement("u");
+ underline.appendChild(document.createTextNode("dolor"));
+ fragment.appendChild(underline);
+
+ fragment.appendChild(document.createTextNode(" "));
+
+ var italics = document.createElement("i");
+ italics.className = "sit";
+ italics.appendChild(document.createTextNode("sit"));
+ fragment.appendChild(italics);
+
+ fragment.appendChild(document.createTextNode(" amet,"));
+
+ testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML())", true);
+
+ consoleWrite("");
+ endTest();
+ }
+
+ function loaded()
+ {
+ findMediaElement();
+ testTrack = document.querySelector('track');
+ video.src = findMediaFile('video', '../content/counting');
+ }
+
+ </script>
+ </head>
+ <body onload="loaded()">
+ <video controls >
+ <track src="captions-webvtt/captions-gaps.vtt" kind="captions" default onload="test()">
+ </video>
+ <p>Test that cue text is mutable.</p>
+ </body>
+</html>
diff --git a/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt b/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
index 1025252..f6a5f88 100644
--- a/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
+++ b/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
@@ -8,7 +8,7 @@
RUN(video.currentTime = 1.5)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '1.5') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'Lorem ipsum dolor sit amet,') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'Lorem ipsum dolor sit amet,') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem ipsum dolor sit amet,') OK
RUN(video.currentTime = 2.5)
@@ -19,7 +19,7 @@
RUN(video.currentTime = 3.3)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '3.3') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'consectetuer adipiscing elit,') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'consectetuer adipiscing elit,') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'consectetuer adipiscing elit,') OK
RUN(video.currentTime = 0.6)
@@ -30,7 +30,7 @@
RUN(video.currentTime = 5.9)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '5.9') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'sed diam nonummy nibh euismod tincidunt') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'sed diam nonummy nibh euismod tincidunt') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'sed diam nonummy nibh euismod tincidunt') OK
RUN(video.currentTime = 4.4)
@@ -41,7 +41,7 @@
RUN(video.currentTime = 7.9)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '7.9') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'ut laoreet dolore magna aliquam erat volutpat.') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'ut laoreet dolore magna aliquam erat volutpat.') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'ut laoreet dolore magna aliquam erat volutpat.') OK
END OF TEST
diff --git a/LayoutTests/media/track/track-cue-nothing-to-render.html b/LayoutTests/media/track/track-cue-nothing-to-render.html
index 7f473ea..f5cb292 100644
--- a/LayoutTests/media/track/track-cue-nothing-to-render.html
+++ b/LayoutTests/media/track/track-cue-nothing-to-render.html
@@ -30,7 +30,7 @@
testExpected("video.currentTime.toFixed(1)", time.toFixed(1));
if (cueText.length)
- testExpected("testTrack.track.activeCues[0].getCueAsSource()", cueText);
+ testExpected("testTrack.track.activeCues[0].text", cueText);
testExpected("textTrackDisplayElement(video, 'display').innerText", cueText);
if (seekedCount >= info.length) {
diff --git a/LayoutTests/media/track/track-cue-rendering-expected.txt b/LayoutTests/media/track/track-cue-rendering-expected.txt
index 06ba839..1f2cedf 100644
--- a/LayoutTests/media/track/track-cue-rendering-expected.txt
+++ b/LayoutTests/media/track/track-cue-rendering-expected.txt
@@ -3,28 +3,28 @@
EVENT(seeked)
EXPECTED (video.currentTime == '0.5') OK
EXPECTED (testTrack.track.activeCues.length == '1') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'Lorem') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'Lorem') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem') OK
RUN(video.currentTime = 1.5)
EVENT(seeked)
EXPECTED (video.currentTime == '1.5') OK
EXPECTED (testTrack.track.activeCues.length == '1') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'ipsum') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'ipsum') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'ipsum') OK
RUN(video.currentTime = 2.5)
EVENT(seeked)
EXPECTED (video.currentTime == '2.5') OK
EXPECTED (testTrack.track.activeCues.length == '1') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'dolor') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'dolor') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'dolor') OK
RUN(video.currentTime = 3.5)
EVENT(seeked)
EXPECTED (video.currentTime == '3.5') OK
EXPECTED (testTrack.track.activeCues.length == '1') OK
-EXPECTED (testTrack.track.activeCues[0].getCueAsSource() == 'sit') OK
+EXPECTED (testTrack.track.activeCues[0].text == 'sit') OK
EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'sit') OK
Test the cue display colors and font.
diff --git a/LayoutTests/media/track/track-cue-rendering.html b/LayoutTests/media/track/track-cue-rendering.html
index c695bca..69a09cf 100644
--- a/LayoutTests/media/track/track-cue-rendering.html
+++ b/LayoutTests/media/track/track-cue-rendering.html
@@ -48,7 +48,7 @@
testExpected("video.currentTime", seekedCount + .5);
testExpected("testTrack.track.activeCues.length", 1);
- testExpected("testTrack.track.activeCues[0].getCueAsSource()", info[seekedCount]);
+ testExpected("testTrack.track.activeCues[0].text", info[seekedCount]);
testExpected("textTrackDisplayElement(video, 'display').innerText", info[seekedCount]);
if (++seekedCount == info.length)
diff --git a/LayoutTests/media/track/track-webvtt-tc001-utf8-expected.txt b/LayoutTests/media/track/track-webvtt-tc001-utf8-expected.txt
index 8880035..0f34e24 100644
--- a/LayoutTests/media/track/track-webvtt-tc001-utf8-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc001-utf8-expected.txt
@@ -6,11 +6,11 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == '景気判断') OK
+EXPECTED (cues[0].text == '景気判断') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == '電力不足') OK
+EXPECTED (cues[1].text == '電力不足') OK
*** Testing text track 1
EXPECTED (cues.length == '2') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc001-utf8.html b/LayoutTests/media/track/track-webvtt-tc001-utf8.html
index 66f6853..d5f110d 100644
--- a/LayoutTests/media/track/track-webvtt-tc001-utf8.html
+++ b/LayoutTests/media/track/track-webvtt-tc001-utf8.html
@@ -39,7 +39,7 @@
values : [30.5, 1200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["景気判断", "電力不足"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc002-bom-expected.txt b/LayoutTests/media/track/track-webvtt-tc002-bom-expected.txt
index c219c05..bb15e79 100644
--- a/LayoutTests/media/track/track-webvtt-tc002-bom-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc002-bom-expected.txt
@@ -6,10 +6,10 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
END OF TEST
diff --git a/LayoutTests/media/track/track-webvtt-tc002-bom.html b/LayoutTests/media/track/track-webvtt-tc002-bom.html
index d20180a..4cb3d39 100644
--- a/LayoutTests/media/track/track-webvtt-tc002-bom.html
+++ b/LayoutTests/media/track/track-webvtt-tc002-bom.html
@@ -28,7 +28,7 @@
values : [30.5, 1200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc003-newlines-expected.txt b/LayoutTests/media/track/track-webvtt-tc003-newlines-expected.txt
index 0d43bad..3d91c70 100644
--- a/LayoutTests/media/track/track-webvtt-tc003-newlines-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc003-newlines-expected.txt
@@ -6,13 +6,13 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '1') OK
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
END OF TEST
diff --git a/LayoutTests/media/track/track-webvtt-tc003-newlines.html b/LayoutTests/media/track/track-webvtt-tc003-newlines.html
index cd56603..dfce10a 100644
--- a/LayoutTests/media/track/track-webvtt-tc003-newlines.html
+++ b/LayoutTests/media/track/track-webvtt-tc003-newlines.html
@@ -39,7 +39,7 @@
values : [30.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc004-magic-header-expected.txt b/LayoutTests/media/track/track-webvtt-tc004-magic-header-expected.txt
index e8ea069..74efbf2 100644
--- a/LayoutTests/media/track/track-webvtt-tc004-magic-header-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc004-magic-header-expected.txt
@@ -6,22 +6,22 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '2') OK
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
*** Testing text track 2
EXPECTED (cues.length == '0') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc004-magic-header.html b/LayoutTests/media/track/track-webvtt-tc004-magic-header.html
index 465f18f..18998c5 100644
--- a/LayoutTests/media/track/track-webvtt-tc004-magic-header.html
+++ b/LayoutTests/media/track/track-webvtt-tc004-magic-header.html
@@ -40,7 +40,7 @@
values : [30.5, 1200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc005-header-comment-expected.txt b/LayoutTests/media/track/track-webvtt-tc005-header-comment-expected.txt
index 3e71276..927b66f 100644
--- a/LayoutTests/media/track/track-webvtt-tc005-header-comment-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc005-header-comment-expected.txt
@@ -6,21 +6,21 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '2') OK
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '1200.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
END OF TEST
diff --git a/LayoutTests/media/track/track-webvtt-tc005-header-comment.html b/LayoutTests/media/track/track-webvtt-tc005-header-comment.html
index 914fee0..0293ea9 100644
--- a/LayoutTests/media/track/track-webvtt-tc005-header-comment.html
+++ b/LayoutTests/media/track/track-webvtt-tc005-header-comment.html
@@ -38,7 +38,7 @@
values : [30.5, 1200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers-expected.txt b/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers-expected.txt
index 7078e00..a2959de 100644
--- a/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers-expected.txt
@@ -6,19 +6,19 @@
EXPECTED (cues[0].id == 'random_id') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == 'another random identifier') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '60.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
EXPECTED (cues[2].id == 'identifier--too') OK
EXPECTED (cues[2].startTime == '61') OK
EXPECTED (cues[2].endTime == '120.5') OK
-EXPECTED (cues[2].getCueAsSource() == 'I said Bear is coming now!!!!') OK
+EXPECTED (cues[2].text == 'I said Bear is coming now!!!!') OK
EXPECTED (cues[3].id == 'identifier--too') OK
EXPECTED (cues[3].startTime == '121') OK
EXPECTED (cues[3].endTime == '180.5') OK
-EXPECTED (cues[3].getCueAsSource() == 'Duplicate identifier') OK
+EXPECTED (cues[3].text == 'Duplicate identifier') OK
*** Testing text track 1
EXPECTED (cues.length == '0') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers.html b/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers.html
index 83b7d19..0b94c36 100644
--- a/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers.html
+++ b/LayoutTests/media/track/track-webvtt-tc006-cue-identifiers.html
@@ -40,7 +40,7 @@
values : [30.5, 60.5, 120.5, 180.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!", "I said Bear is coming now!!!!", "Duplicate identifier"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc007-cue-no-id-expected.txt b/LayoutTests/media/track/track-webvtt-tc007-cue-no-id-expected.txt
index aa73933..ac07bbd 100644
--- a/LayoutTests/media/track/track-webvtt-tc007-cue-no-id-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc007-cue-no-id-expected.txt
@@ -6,15 +6,15 @@
EXPECTED (cues[0].id == '') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '60.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
EXPECTED (cues[2].id == '') OK
EXPECTED (cues[2].startTime == '61') OK
EXPECTED (cues[2].endTime == '1200.5') OK
-EXPECTED (cues[2].getCueAsSource() == 'I said Bear is coming now!!!!') OK
+EXPECTED (cues[2].text == 'I said Bear is coming now!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '0') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc007-cue-no-id.html b/LayoutTests/media/track/track-webvtt-tc007-cue-no-id.html
index daade49..aa4eb6b 100644
--- a/LayoutTests/media/track/track-webvtt-tc007-cue-no-id.html
+++ b/LayoutTests/media/track/track-webvtt-tc007-cue-no-id.html
@@ -40,7 +40,7 @@
values : [30.5, 60.5, 1200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!", "I said Bear is coming now!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours-expected.txt b/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours-expected.txt
index 422d9e7..3cf08f7 100644
--- a/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours-expected.txt
@@ -6,19 +6,19 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '60.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
EXPECTED (cues[2].id == '3') OK
EXPECTED (cues[2].startTime == '61') OK
EXPECTED (cues[2].endTime == '120.5') OK
-EXPECTED (cues[2].getCueAsSource() == 'I said Bear is coming now!!!!') OK
+EXPECTED (cues[2].text == 'I said Bear is coming now!!!!') OK
EXPECTED (cues[3].id == '4') OK
EXPECTED (cues[3].startTime == '121') OK
EXPECTED (cues[3].endTime == '180.5') OK
-EXPECTED (cues[3].getCueAsSource() == 'tab separators') OK
+EXPECTED (cues[3].text == 'tab separators') OK
*** Testing text track 1
EXPECTED (cues.length == '0') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours.html b/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours.html
index f90b0a0..2a9e21e 100644
--- a/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours.html
+++ b/LayoutTests/media/track/track-webvtt-tc008-timings-no-hours.html
@@ -39,7 +39,7 @@
values : [30.5, 60.5, 120.5, 180.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!", "I said Bear is coming now!!!!", "tab separators"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc009-timings-hour-expected.txt b/LayoutTests/media/track/track-webvtt-tc009-timings-hour-expected.txt
index e643d8a..14e1562 100644
--- a/LayoutTests/media/track/track-webvtt-tc009-timings-hour-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc009-timings-hour-expected.txt
@@ -6,15 +6,15 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '60.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
EXPECTED (cues[2].id == '3') OK
EXPECTED (cues[2].startTime == '61') OK
EXPECTED (cues[2].endTime == '361200.5') OK
-EXPECTED (cues[2].getCueAsSource() == 'I said Bear is coming now!!!!') OK
+EXPECTED (cues[2].text == 'I said Bear is coming now!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '0') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc009-timings-hour.html b/LayoutTests/media/track/track-webvtt-tc009-timings-hour.html
index 0547bf6..e2f12c6 100644
--- a/LayoutTests/media/track/track-webvtt-tc009-timings-hour.html
+++ b/LayoutTests/media/track/track-webvtt-tc009-timings-hour.html
@@ -39,7 +39,7 @@
values : [30.5, 60.5, 361200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!", "I said Bear is coming now!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc011-blank-lines-expected.txt b/LayoutTests/media/track/track-webvtt-tc011-blank-lines-expected.txt
index 5a8c4a9..98b66de 100644
--- a/LayoutTests/media/track/track-webvtt-tc011-blank-lines-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc011-blank-lines-expected.txt
@@ -6,15 +6,15 @@
EXPECTED (cues[0].id == '1') OK
EXPECTED (cues[0].startTime == '0') OK
EXPECTED (cues[0].endTime == '30.5') OK
-EXPECTED (cues[0].getCueAsSource() == 'Bear is Coming!!!!!') OK
+EXPECTED (cues[0].text == 'Bear is Coming!!!!!') OK
EXPECTED (cues[1].id == '2') OK
EXPECTED (cues[1].startTime == '31') OK
EXPECTED (cues[1].endTime == '60.5') OK
-EXPECTED (cues[1].getCueAsSource() == 'I said Bear is coming!!!!') OK
+EXPECTED (cues[1].text == 'I said Bear is coming!!!!') OK
EXPECTED (cues[2].id == '3') OK
EXPECTED (cues[2].startTime == '61') OK
EXPECTED (cues[2].endTime == '361200.5') OK
-EXPECTED (cues[2].getCueAsSource() == 'I said Bear is coming now!!!!') OK
+EXPECTED (cues[2].text == 'I said Bear is coming now!!!!') OK
*** Testing text track 1
EXPECTED (cues.length == '1') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc011-blank-lines.html b/LayoutTests/media/track/track-webvtt-tc011-blank-lines.html
index bd4a308..bb3c20d 100644
--- a/LayoutTests/media/track/track-webvtt-tc011-blank-lines.html
+++ b/LayoutTests/media/track/track-webvtt-tc011-blank-lines.html
@@ -39,7 +39,7 @@
values : [30.5, 60.5, 361200.5],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!", "I said Bear is coming now!!!!"],
},
],
diff --git a/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup-expected.txt b/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup-expected.txt
index 0c285f7..3d19a77 100644
--- a/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup-expected.txt
+++ b/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup-expected.txt
@@ -4,19 +4,19 @@
*** Testing text track 0
EXPECTED (cues.length == '3') OK
EXPECTED (cues[0].getCueAsHTML().textContent == 'Bear is Coming!!!!! And what kind of a bear it is - just have look.') OK
-EXPECTED (cues[0].getCueAsSource() == '
+EXPECTED (cues[0].text == '
Bear is Coming!!!!!
And what kind of a bear it is - just have look.
') OK
EXPECTED (cues[1].getCueAsHTML().textContent == ' I said Bear is coming!!!! I said Bear is still coming!!!! ') OK
-EXPECTED (cues[1].getCueAsSource() == '
+EXPECTED (cues[1].text == '
I said Bear is coming!!!!
I said Bear is still coming!!!!
') OK
EXPECTED (cues[2].getCueAsHTML().textContent == ' I said Bear is coming now!!!! ') OK
-EXPECTED (cues[2].getCueAsSource() == '
+EXPECTED (cues[2].text == '
I said Bear is coming now!!!!
') OK
diff --git a/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html b/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html
index 5975b0a..0203462 100644
--- a/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html
+++ b/LayoutTests/media/track/track-webvtt-tc028-unsupported-markup.html
@@ -22,7 +22,7 @@
"\n I said Bear is coming now!!!!\n \n \n"],
},
{
- property : "getCueAsSource()",
+ property : "text",
values : ["<h1>Bear is Coming!!!!!</h1>\n<p>And what kind of a bear it is - just have <a href=\"webpage.html\">look</a>.</p>",
"<ul>\n <li>I said Bear is coming!!!!</li>\n <li>I said Bear is still coming!!!!</li>\n</ul>",
"<ol>\n <li>I said Bear is coming now!!!!</li>\n <li><img src=\"bear.png\" alt=\"mighty bear\"></li>\n <li><video src=\"bear_ad.webm\" controls></video></li>\n</ol>"],
diff --git a/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt b/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt
index 19fe1fe..3a32ddd 100644
--- a/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt
+++ b/LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt
@@ -2158,7 +2158,6 @@
window.TextTrackCue.prototype.addEventListener [function]
window.TextTrackCue.prototype.dispatchEvent [function]
window.TextTrackCue.prototype.getCueAsHTML [function]
-window.TextTrackCue.prototype.getCueAsSource [function]
window.TextTrackCue.prototype.removeEventListener [function]
window.TextTrackCueList [object TextTrackCueListConstructor]
window.TextTrackCueList.prototype [object TextTrackCueListPrototype]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6bc6801..3b44e3a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2012-01-10 Eric Carlson <eric.carlson@apple.com>
+
+ Replace TextTrackCue "getCueAsSource" method with "text" attribute
+ https://bugs.webkit.org/show_bug.cgi?id=75646
+
+ Reviewed by Darin Adler.
+
+ Test: media/track/track-cue-mutable-text.html
+
+ * html/HTMLMediaElement.h: getCueAsSource() -> text().
+
+ * html/TextTrackCue.cpp:
+ (WebCore::TextTrackCue::setText): New. Set cue text and clear the document fragment.
+ (WebCore::TextTrackCue::getCueAsHTML): Allocate the document fragment if it doesn't exist.
+ * html/TextTrackCue.h:
+ (WebCore::TextTrackCue::text):
+ * html/TextTrackCue.idl: getCueAsSource() -> text().
+
+ * html/shadow/MediaControlRootElement.cpp:
+ (WebCore::MediaControlRootElement::updateTextTrackDisplay): getCueAsSource() -> text().
+ * html/shadow/MediaControlRootElementChromium.cpp:
+ (WebCore::MediaControlRootElementChromium::updateTextTrackDisplay): getCueAsSource() -> text().
+
+ * html/track/WebVTTParser.cpp:
+ (WebCore::WebVTTParser::collectCueText): processCueText is dead, long live createNewCue.
+ (WebCore::WebVTTParser::createDocumentFragmentFromCueText): New, split out of processCueText.
+ Create a document fragment from the String argument.
+ (WebCore::WebVTTParser::createNewCue): Split out of processCueText.
+ (WebCore::WebVTTParser::constructTreeFromToken): Add a comment pointing to the spec section
+ with the rules for DOM construction.
+ * html/track/WebVTTParser.h:
+
2012-01-10 Jer Noble <jer.noble@apple.com>
REGRESSION (r102024): Having the Bing homepage open prevents idle sleep
diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h
index 4486298..198b9b2 100644
--- a/Source/WebCore/html/HTMLMediaElement.h
+++ b/Source/WebCore/html/HTMLMediaElement.h
@@ -609,7 +609,7 @@
struct ValueToString<TextTrackCue*> {
static String string(TextTrackCue* const& cue)
{
- return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), cue->getCueAsSource().utf8().data());
+ return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), cue->text().utf8().data());
}
};
#endif
diff --git a/Source/WebCore/html/TextTrackCue.cpp b/Source/WebCore/html/TextTrackCue.cpp
index 1bd0fe5..e1c0126 100644
--- a/Source/WebCore/html/TextTrackCue.cpp
+++ b/Source/WebCore/html/TextTrackCue.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -161,7 +162,7 @@
cueDidChange();
}
-String TextTrackCue::direction() const
+const String& TextTrackCue::direction() const
{
switch (m_writingDirection) {
case Horizontal:
@@ -172,7 +173,7 @@
return verticallrKeyword();
default:
ASSERT_NOT_REACHED();
- return "";
+ return emptyString();
}
}
@@ -269,7 +270,7 @@
cueDidChange();
}
-String TextTrackCue::alignment() const
+const String& TextTrackCue::alignment() const
{
switch (m_cueAlignment) {
case Start:
@@ -280,7 +281,7 @@
return endKeyword();
default:
ASSERT_NOT_REACHED();
- return "";
+ return emptyString();
}
}
@@ -310,13 +311,24 @@
cueDidChange();
}
-String TextTrackCue::getCueAsSource()
+void TextTrackCue::setText(const String& text)
{
- return m_content;
+ if (m_content == text)
+ return;
+
+ cueWillChange();
+ // Clear the document fragment but don't bother to create it again just yet as we can do that
+ // when it is requested.
+ m_documentFragment = 0;
+ m_content = text;
+ cueDidChange();
}
PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML()
{
+ if (!m_documentFragment)
+ m_documentFragment = WebVTTParser::create(0, m_scriptExecutionContext)->createDocumentFragmentFromCueText(m_content);
+
return m_documentFragment;
}
diff --git a/Source/WebCore/html/TextTrackCue.h b/Source/WebCore/html/TextTrackCue.h
index d0b1306..16faf63 100644
--- a/Source/WebCore/html/TextTrackCue.h
+++ b/Source/WebCore/html/TextTrackCue.h
@@ -59,7 +59,7 @@
TextTrack* track() const;
void setTrack(PassRefPtr<TextTrack>);
- String id() const { return m_id; }
+ const String& id() const { return m_id; }
void setId(const String&);
double startTime() const { return m_startTime; }
@@ -71,7 +71,7 @@
bool pauseOnExit() const { return m_pauseOnExit; }
void setPauseOnExit(bool);
- String direction() const;
+ const String& direction() const;
void setDirection(const String&, ExceptionCode&);
bool snapToLines() const { return m_snapToLines; }
@@ -86,10 +86,11 @@
int size() const { return m_cueSize; }
void setSize(int, ExceptionCode&);
- String alignment() const;
+ const String& alignment() const;
void setAlignment(const String&, ExceptionCode&);
- String getCueAsSource();
+ const String& text() const { return m_content; }
+ void setText(const String&);
PassRefPtr<DocumentFragment> getCueAsHTML();
void setCueHTML(PassRefPtr<DocumentFragment>);
diff --git a/Source/WebCore/html/TextTrackCue.idl b/Source/WebCore/html/TextTrackCue.idl
index a02af67..913a9bd 100644
--- a/Source/WebCore/html/TextTrackCue.idl
+++ b/Source/WebCore/html/TextTrackCue.idl
@@ -54,7 +54,7 @@
attribute DOMString alignment
setter raises (DOMException);
- DOMString getCueAsSource();
+ attribute DOMString text;
DocumentFragment getCueAsHTML();
attribute EventListener onenter;
diff --git a/Source/WebCore/html/shadow/MediaControlRootElement.cpp b/Source/WebCore/html/shadow/MediaControlRootElement.cpp
index 47f88bc..46db413 100644
--- a/Source/WebCore/html/shadow/MediaControlRootElement.cpp
+++ b/Source/WebCore/html/shadow/MediaControlRootElement.cpp
@@ -642,7 +642,7 @@
if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
continue;
- String cueText = cue->getCueAsSource();
+ String cueText = cue->text();
if (!cueText.isEmpty()) {
if (!nothingToDisplay)
m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
diff --git a/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp b/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
index dea66fb..f2ce626 100644
--- a/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
+++ b/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
@@ -376,7 +376,7 @@
if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
continue;
- String cueText = cue->getCueAsSource();
+ String cueText = cue->text();
if (!cueText.isEmpty()) {
if (!nothingToDisplay)
m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
diff --git a/Source/WebCore/html/track/WebVTTParser.cpp b/Source/WebCore/html/track/WebVTTParser.cpp
index 9d61952..114978f 100644
--- a/Source/WebCore/html/track/WebVTTParser.cpp
+++ b/Source/WebCore/html/track/WebVTTParser.cpp
@@ -222,7 +222,7 @@
WebVTTParser::ParseState WebVTTParser::collectCueText(const String& line, unsigned length, unsigned position)
{
if (line.isEmpty()) {
- processCueText();
+ createNewCue();
return Id;
}
if (!m_currentContent.isEmpty())
@@ -230,7 +230,7 @@
m_currentContent.append(line);
if (position >= length)
- processCueText();
+ createNewCue();
return CueText;
}
@@ -242,30 +242,42 @@
return Id;
}
-void WebVTTParser::processCueText()
+PassRefPtr<DocumentFragment> WebVTTParser::createDocumentFragmentFromCueText(const String& text)
{
- // 51 - Cue text processing based on
+ // Cue text processing based on
// 4.8.10.13.4 WebVTT cue text parsing rules and
// 4.8.10.13.5 WebVTT cue text DOM construction rules.
- if (m_currentContent.length() <= 0)
- return;
+
+ if (!text.length())
+ return 0;
ASSERT(m_scriptExecutionContext->isDocument());
Document* document = static_cast<Document*>(m_scriptExecutionContext);
-
- m_attachmentRoot = DocumentFragment::create(document);
- m_currentNode = m_attachmentRoot;
+
+ RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
+ m_currentNode = fragment;
m_tokenizer->reset();
m_token.clear();
-
- SegmentedString content(m_currentContent.toString());
+
+ SegmentedString content(text);
while (m_tokenizer->nextToken(content, m_token))
constructTreeFromToken(document);
+ return fragment.release();
+}
+
+void WebVTTParser::createNewCue()
+{
+ if (!m_currentContent.length())
+ return;
+
+ RefPtr<DocumentFragment> attachmentRoot = createDocumentFragmentFromCueText(m_currentContent.toString());
+
RefPtr<TextTrackCue> cue = TextTrackCue::create(m_scriptExecutionContext, m_currentId, m_currentStartTime, m_currentEndTime, m_currentContent.toString(), m_currentSettings, false);
- cue->setCueHTML(m_attachmentRoot);
+ cue->setCueHTML(attachmentRoot);
m_cuelist.append(cue);
- m_client->newCuesParsed();
+ if (m_client)
+ m_client->newCuesParsed();
}
void WebVTTParser::resetCueValues()
@@ -342,6 +354,8 @@
AtomicString tokenTagName(m_token.name().data(), m_token.name().size());
QualifiedName tagName(nullAtom, tokenTagName, xhtmlNamespaceURI);
+ // http://dev.w3.org/html5/webvtt/#webvtt-cue-text-dom-construction-rules
+
switch (m_token.type()) {
case WebVTTTokenTypes::Character: {
String content(m_token.characters().data(), m_token.characters().size());
diff --git a/Source/WebCore/html/track/WebVTTParser.h b/Source/WebCore/html/track/WebVTTParser.h
index 244ee8f..4e1dc04 100644
--- a/Source/WebCore/html/track/WebVTTParser.h
+++ b/Source/WebCore/html/track/WebVTTParser.h
@@ -84,10 +84,12 @@
static String collectWord(const String&, unsigned*);
// Input data to the parser to parse.
- virtual void parseBytes(const char* data, unsigned length);
+ void parseBytes(const char* data, unsigned length);
// Transfers ownership of last parsed cues to caller.
- virtual void getNewCues(Vector<RefPtr<TextTrackCue> >&);
+ void getNewCues(Vector<RefPtr<TextTrackCue> >&);
+
+ PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String&);
protected:
WebVTTParser(WebVTTParserClient*, ScriptExecutionContext*);
@@ -101,7 +103,7 @@
ParseState collectCueText(const String&, unsigned length, unsigned);
ParseState ignoreBadCue(const String&);
- void processCueText();
+ void createNewCue();
void resetCueValues();
double collectTimeStamp(const String&, unsigned*);
void skipWhiteSpace(const String&, unsigned*);
@@ -119,7 +121,6 @@
WebVTTToken m_token;
OwnPtr<WebVTTTokenizer> m_tokenizer;
- RefPtr<DocumentFragment> m_attachmentRoot;
RefPtr<ContainerNode> m_currentNode;
WebVTTParserClient* m_client;