Title: [126350] trunk
Revision
126350
Author
[email protected]
Date
2012-08-22 14:24:29 -0700 (Wed, 22 Aug 2012)

Log Message

Update the TextTrackCue Constructor
https://bugs.webkit.org/show_bug.cgi?id=88583

Reviewed by Eric Carlson.

The TextTrackCue constructor has been changed to:
[Constructor(double startTime, double endTime, DOMString text)]
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#texttrackcue

Source/WebCore:

No new tests.  Update to media/track/track-add-remove-cue.html

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::TextTrackCue):
* html/track/TextTrackCue.h:
(WebCore::TextTrackCue::create):
(TextTrackCue):
* html/track/TextTrackCue.idl:
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::createNewCue):

LayoutTests:

* media/track/track-add-remove-cue-expected.txt:
* media/track/track-add-remove-cue.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126349 => 126350)


--- trunk/LayoutTests/ChangeLog	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/LayoutTests/ChangeLog	2012-08-22 21:24:29 UTC (rev 126350)
@@ -1,3 +1,17 @@
+2012-08-22  Anna Cavender  <[email protected]>
+
+        Update the TextTrackCue Constructor
+        https://bugs.webkit.org/show_bug.cgi?id=88583
+
+        Reviewed by Eric Carlson.
+
+        The TextTrackCue constructor has been changed to:
+        [Constructor(double startTime, double endTime, DOMString text)]
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#texttrackcue
+
+        * media/track/track-add-remove-cue-expected.txt:
+        * media/track/track-add-remove-cue.html:
+
 2012-08-22  Erik Arvidsson  <[email protected]>
 
         Changing class attribute is not reflected in the classList property

Modified: trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt (126349 => 126350)


--- trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt	2012-08-22 21:24:29 UTC (rev 126350)
@@ -10,9 +10,9 @@
 EXPECTED (cues.getCueById('junk') == 'undefined') OK
 
 *** Create a new cue, check values
-RUN(textCue = new TextTrackCue('sausage-cue', 33, 3.4, 'Sausage?'))
+RUN(textCue = new TextTrackCue(33, 3.4, 'Sausage?'))
 EXPECTED (textCue.track == 'null') OK
-EXPECTED (textCue.id == 'sausage-cue') OK
+EXPECTED (textCue.id == '') OK
 EXPECTED (textCue.startTime == '33') OK
 EXPECTED (textCue.endTime == '3.4') OK
 EXPECTED (textCue.pauseOnExit == 'false') OK
@@ -32,10 +32,10 @@
 
 *** create a new cue and add it to a track created with video.addTextTrack, make sure it is inserted correctly.
 RUN(newTrack = video.addTextTrack("subtitles", "French subtitles", "fr"))
-RUN(newTrack.addCue(new TextTrackCue("test", 0.0, 1.0, "Test!")))
+RUN(newTrack.addCue(new TextTrackCue(0.0, 1.0, "Test!")))
 RUN(newCue = newTrack.cues[0])
 EXPECTED (newCue.track == '[object TextTrack]') OK
-EXPECTED (newCue.id == 'test') OK
+EXPECTED (newCue.id == '') OK
 EXPECTED (newCue.startTime == '0') OK
 EXPECTED (newCue.endTime == '1') OK
 EXPECTED (newCue.pauseOnExit == 'false') OK
@@ -46,6 +46,16 @@
 EXPECTED (newCue.size == '100') OK
 EXPECTED (newCue.align == 'middle') OK
 
+*** Create an old-style cue with an id.
+RUN(oldStyleCue = new TextTrackCue('sausage-cue', 33, 3.4, 'Sausage?'))
+EXPECTED (oldStyleCue.id == '') OK
+EXPECTED (oldStyleCue.startTime.toString() == 'NaN') OK
+EXPECTED (oldStyleCue.endTime == '33') OK
+*** Make sure the old-style cue is not inserted because its start time is not a number.
+EXPECTED (testTrack.track.cues.length == '5') OK
+RUN(testTrack.track.addCue(oldStyleCue))
+EXPECTED (testTrack.track.cues.length == '5') OK
+
 *** Remove a cue created with addCue().
 RUN(testTrack.track.removeCue(textCue))
 EXPECTED (textCue.track == 'null') OK

Modified: trunk/LayoutTests/media/track/track-add-remove-cue.html (126349 => 126350)


--- trunk/LayoutTests/media/track/track-add-remove-cue.html	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/LayoutTests/media/track/track-add-remove-cue.html	2012-08-22 21:24:29 UTC (rev 126350)
@@ -23,9 +23,9 @@
                 testExpected("cues.getCueById('junk')", undefined);
 
                 consoleWrite("<br>*** Create a new cue, check values");
-                run("textCue = new TextTrackCue('sausage-cue', 33, 3.4, 'Sausage?')");
+                run("textCue = new TextTrackCue(33, 3.4, 'Sausage?')");
                 testExpected("textCue.track", null);
-                testExpected("textCue.id", "sausage-cue");
+                testExpected("textCue.id", '');
                 testExpected("textCue.startTime", 33);
                 testExpected("textCue.endTime", 3.4);
                 testExpected("textCue.pauseOnExit", false);
@@ -47,10 +47,10 @@
                 findMediaElement();
                 run('newTrack = video.addTextTrack("subtitles", "French subtitles", "fr")');
                 newTrack.mode = 2;
-                run('newTrack.addCue(new TextTrackCue("test", 0.0, 1.0, "Test!"))');
+                run('newTrack.addCue(new TextTrackCue(0.0, 1.0, "Test!"))');
                 run('newCue = newTrack.cues[0]');
                 testExpected("newCue.track", newTrack);
-                testExpected("newCue.id", "test");
+                testExpected("newCue.id", "");
                 testExpected("newCue.startTime", 0.0);
                 testExpected("newCue.endTime", 1.0);
                 testExpected("newCue.pauseOnExit", false);
@@ -61,6 +61,16 @@
                 testExpected("newCue.size", 100);
                 testExpected("newCue.align", "middle");
 
+                consoleWrite("<br>*** Create an old-style cue with an id.");
+                run("oldStyleCue = new TextTrackCue('sausage-cue', 33, 3.4, 'Sausage?')");
+                testExpected("oldStyleCue.id", "");
+                testExpected("oldStyleCue.startTime.toString()", "NaN");
+                testExpected("oldStyleCue.endTime", 33);
+                consoleWrite("*** Make sure the old-style cue is not inserted because its start time is not a number.");
+                testExpected("testTrack.track.cues.length", 5);
+                run("testTrack.track.addCue(oldStyleCue)");
+                testExpected("testTrack.track.cues.length", 5);
+
                 consoleWrite("<br>*** Remove a cue created with addCue().");
                 run("testTrack.track.removeCue(textCue)");
                 testExpected("textCue.track", null);

Modified: trunk/Source/WebCore/ChangeLog (126349 => 126350)


--- trunk/Source/WebCore/ChangeLog	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/ChangeLog	2012-08-22 21:24:29 UTC (rev 126350)
@@ -1,3 +1,25 @@
+2012-08-22  Anna Cavender  <[email protected]>
+
+        Update the TextTrackCue Constructor
+        https://bugs.webkit.org/show_bug.cgi?id=88583
+
+        Reviewed by Eric Carlson.
+
+        The TextTrackCue constructor has been changed to:
+        [Constructor(double startTime, double endTime, DOMString text)]
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#texttrackcue
+
+        No new tests.  Update to media/track/track-add-remove-cue.html
+
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::TextTrackCue):
+        * html/track/TextTrackCue.h:
+        (WebCore::TextTrackCue::create):
+        (TextTrackCue):
+        * html/track/TextTrackCue.idl:
+        * html/track/WebVTTParser.cpp:
+        (WebCore::WebVTTParser::createNewCue):
+
 2012-08-22  Erik Arvidsson  <[email protected]>
 
         Changing class attribute is not reflected in the classList property

Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (126349 => 126350)


--- trunk/Source/WebCore/html/track/TextTrack.cpp	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp	2012-08-22 21:24:29 UTC (rev 126350)
@@ -199,7 +199,7 @@
     RefPtr<TextTrackCue> cue = prpCue;
 
     // TODO(93143): Add spec-compliant behavior for negative time values.
-    if (cue->startTime() < 0 || cue->endTime() < 0)
+    if (isnan(cue->startTime()) || isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0)
         return;
 
     // 4.8.10.12.4 Text track API

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (126349 => 126350)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-08-22 21:24:29 UTC (rev 126350)
@@ -88,9 +88,8 @@
     return verticallr;
 }
 
-TextTrackCue::TextTrackCue(ScriptExecutionContext* context, const String& id, double start, double end, const String& content, const String& settings, bool pauseOnExit)
-    : m_id(id)
-    , m_startTime(start)
+TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double end, const String& content)
+    : m_startTime(start)
     , m_endTime(end)
     , m_content(content)
     , m_linePosition(undefinedPosition)
@@ -103,7 +102,7 @@
     , m_documentFragment(0)
     , m_scriptExecutionContext(context)
     , m_isActive(false)
-    , m_pauseOnExit(pauseOnExit)
+    , m_pauseOnExit(false)
     , m_snapToLines(true)
     , m_hasInnerTimestamps(false)
     , m_pastDocumentNodes(HTMLDivElement::create(static_cast<Document*>(context)))
@@ -121,8 +120,6 @@
     m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalLr;
     m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalRl;
 
-    parseSettings(settings);
-
     // A text track cue has a text track cue computed line position whose value
     // is defined in terms of the other aspects of the cue.
     m_computedLinePosition = calculateComputedLinePosition();
@@ -732,7 +729,7 @@
     return None;
 }
 
-void TextTrackCue::parseSettings(const String& input)
+void TextTrackCue::setCueSettings(const String& input)
 {
     unsigned position = 0;
 

Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (126349 => 126350)


--- trunk/Source/WebCore/html/track/TextTrackCue.h	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h	2012-08-22 21:24:29 UTC (rev 126350)
@@ -47,9 +47,9 @@
 
 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTarget {
 public:
-    static PassRefPtr<TextTrackCue> create(ScriptExecutionContext* context, const String& id, double start, double end, const String& content, const String& settings, bool pauseOnExit)
+    static PassRefPtr<TextTrackCue> create(ScriptExecutionContext* context, double start, double end, const String& content)
     {
-        return adoptRef(new TextTrackCue(context, id, start, end, content, settings, pauseOnExit));
+        return adoptRef(new TextTrackCue(context, start, end, content));
     }
 
     virtual ~TextTrackCue();
@@ -90,6 +90,8 @@
     const String& text() const { return m_content; }
     void setText(const String&);
 
+    void setCueSettings(const String&);
+
     int cueIndex();
     void invalidateCueIndex();
 
@@ -119,10 +121,8 @@
     virtual EventTargetData* ensureEventTargetData();
 
 private:
-    TextTrackCue(ScriptExecutionContext*, const String& id, double start, double end, const String& content, const String& settings, bool pauseOnExit);
+    TextTrackCue(ScriptExecutionContext*, double start, double end, const String& content);
 
-    void parseSettings(const String&);
-
     int calculateComputedLinePosition();
     void calculateDisplayParameters();
 

Modified: trunk/Source/WebCore/html/track/TextTrackCue.idl (126349 => 126350)


--- trunk/Source/WebCore/html/track/TextTrackCue.idl	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/html/track/TextTrackCue.idl	2012-08-22 21:24:29 UTC (rev 126350)
@@ -29,7 +29,7 @@
         Conditional=VIDEO_TRACK,
         V8EnabledAtRuntime=webkitVideoTrack,
         JSGenerateToNativeObject,
-        Constructor(in DOMString id, in double startTime, in double endTime, in DOMString text, in [Optional=DefaultIsUndefined] DOMString settings, in [Optional=DefaultIsUndefined] boolean pauseOnExit),
+        Constructor(in double startTime, in double endTime, in DOMString text),
         CallWith=ScriptExecutionContext,
         EventTarget,
         JSCustomMarkFunction,

Modified: trunk/Source/WebCore/html/track/WebVTTParser.cpp (126349 => 126350)


--- trunk/Source/WebCore/html/track/WebVTTParser.cpp	2012-08-22 21:19:29 UTC (rev 126349)
+++ trunk/Source/WebCore/html/track/WebVTTParser.cpp	2012-08-22 21:24:29 UTC (rev 126350)
@@ -262,7 +262,9 @@
     if (!m_currentContent.length())
         return;
 
-    RefPtr<TextTrackCue> cue = TextTrackCue::create(m_scriptExecutionContext, m_currentId, m_currentStartTime, m_currentEndTime, m_currentContent.toString(), m_currentSettings, false);
+    RefPtr<TextTrackCue> cue = TextTrackCue::create(m_scriptExecutionContext, m_currentStartTime, m_currentEndTime, m_currentContent.toString());
+    cue->setId(m_currentId);
+    cue->setCueSettings(m_currentSettings);
 
     m_cuelist.append(cue);
     if (m_client)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to