Bug 882299 - Implement VTTCue::Line. r=smaug, r=rillian
☠☠ backed out by 7a4e6be6bea5 ☠ ☠
authorRick Eyre <rick.eyre@hotmail.com>
Mon, 16 Dec 2013 14:35:01 -0500
changeset 171825 6532bf066bb47d71cbcdeaa69e05725dfdbd42c1
parent 171824 df0855f26e4da9526990417023f08fe03b301356
child 171826 9ca7e64ef0d0d257c772961912f6f18b60385656
push id5166
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:47:54 +0000
treeherdermozilla-aurora@977eb2548b2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, rillian
bugs882299
milestone29.0a1
Bug 882299 - Implement VTTCue::Line. r=smaug, r=rillian
content/media/TextTrackCue.cpp
content/media/TextTrackCue.h
content/media/test/test_texttrackcue.html
dom/bindings/Codegen.py
dom/webidl/VTTCue.webidl
--- a/content/media/TextTrackCue.cpp
+++ b/content/media/TextTrackCue.cpp
@@ -5,19 +5,16 @@
 
 #include "mozilla/dom/HTMLTrackElement.h"
 #include "mozilla/dom/TextTrackCue.h"
 #include "nsIFrame.h"
 #include "nsVideoFrame.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 
-// Alternate value for the 'auto' keyword.
-#define WEBVTT_AUTO -1
-
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_4(TextTrackCue,
                                      nsDOMEventTargetHelper,
                                      mDocument,
                                      mTrack,
                                      mTrackElement,
@@ -34,17 +31,17 @@ StaticRefPtr<nsIWebVTTParserWrapper> Tex
 // in http://dev.w3.org/html5/webvtt/#parsing
 void
 TextTrackCue::SetDefaultCueSettings()
 {
   mPosition = 50;
   mSize = 100;
   mPauseOnExit = false;
   mSnapToLines = true;
-  mLine = WEBVTT_AUTO;
+  mLine.SetAsAutoKeyword() = AutoKeyword::Auto;
   mAlign = AlignSetting::Middle;
   mLineAlign = AlignSetting::Start;
   mVertical = DirectionSetting::_empty;
 }
 
 TextTrackCue::TextTrackCue(nsISupports* aGlobal,
                            double aStartTime,
                            double aEndTime,
--- a/content/media/TextTrackCue.h
+++ b/content/media/TextTrackCue.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/VTTCueBinding.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIWebVTTParserWrapper.h"
 #include "mozilla/StaticPtr.h"
 #include "nsIDocument.h"
+#include "mozilla/dom/UnionTypes.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTrackElement;
 class TextTrack;
 
 class TextTrackCue MOZ_FINAL : public nsDOMEventTargetHelper
@@ -157,26 +158,39 @@ public:
     if (mSnapToLines == aSnapToLines)
       return;
 
     mReset = true;
     mSnapToLines = aSnapToLines;
     CueChanged();
   }
 
-  double Line() const
+  void GetLine(OwningLongOrAutoKeyword& aLine) const
   {
-    return mLine;
+    if (mLine.IsLong()) {
+      aLine.SetAsLong() = mLine.GetAsLong();
+      return;
+    }
+    aLine.SetAsAutoKeyword() = mLine.GetAsAutoKeyword();
   }
 
-  void SetLine(double aLine)
+  void SetLine(const LongOrAutoKeyword& aLine)
   {
-    //XXX: TODO Line position can be a keyword auto. bug882299
-    mReset = true;
-    mLine = aLine;
+    if (aLine.IsLong() &&
+        (mLine.IsAutoKeyword() || (aLine.GetAsLong() != mLine.GetAsLong()))) {
+      mLine.SetAsLong() = aLine.GetAsLong();
+      CueChanged();
+      mReset = true;
+      return;
+    }
+    if (mLine.IsLong()) {
+      mLine.SetAsAutoKeyword() = aLine.GetAsAutoKeyword();
+      CueChanged();
+      mReset = true;
+    }
   }
 
   AlignSetting LineAlign() const
   {
     return mLineAlign;
   }
 
   void SetLineAlign(AlignSetting& aLineAlign, ErrorResult& aRv)
@@ -337,17 +351,17 @@ private:
   nsRefPtr<HTMLTrackElement> mTrackElement;
   nsString mId;
   int32_t mPosition;
   int32_t mSize;
   bool mPauseOnExit;
   bool mSnapToLines;
   nsString mRegionId;
   DirectionSetting mVertical;
-  int mLine;
+  LongOrAutoKeyword mLine;
   AlignSetting mAlign;
   AlignSetting mLineAlign;
 
   // Holds the computed DOM elements that represent the parsed cue text.
   // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-display-state
   nsCOMPtr<nsIContent> mDisplayState;
   // Tells whether or not we need to recompute mDisplayState. This is set
   // anytime a property that relates to the display of the TextTrackCue is
--- a/content/media/test/test_texttrackcue.html
+++ b/content/media/test/test_texttrackcue.html
@@ -95,16 +95,23 @@ SpecialPowers.pushPrefEnv({"set": [["med
 
       cue.lineAlign = "middle";
       is(cue.lineAlign, "middle", "Cue's line align should be middle.");
       cue.lineAlign = "START";
       is(cue.lineAlign, "middle", "Cue's line align should be middle.");
       cue.lineAlign = "end";
       is(cue.lineAlign, "end", "Cue's line align should be end.");
 
+      // Check cue.line
+      is(cue.line, "auto", "Cue's line value should initially be auto.");
+      cue.line = 12410
+      is(cue.line, 12410, "Cue's line value should now be 12410.");
+      cue.line = "auto";
+      is(cue.line, "auto", "Cue's line value should now be auto.");
+
       // Check that we can create and add new VTTCues
       var vttCue = new VTTCue(3.999, 4, "foo");
       trackElement.track.addCue(vttCue);
       is(cueList.length, 5, "Cue list length should now be 5.");
 
       // Check that new VTTCue was added correctly
       cue = cueList[4];
       is(cue.startTime, 3.999, "Cue's start time should be 3.999.");
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -835,17 +835,19 @@ def UnionTypes(descriptors, dictionaries
                     # For a dictionary, we need to see its declaration in
                     # UnionTypes.h so we have its sizeof and know how big to
                     # make our union.
                     headers.add(CGHeaders.getDeclarationFilename(f.inner))
                     # And if it needs rooting, we need RootedDictionary too
                     if typeNeedsRooting(f):
                         headers.add("mozilla/dom/RootedDictionary.h")
                 elif f.isEnum():
-                    headers.add(CGHeaders.getDeclarationFilename(f))
+                    # Need to see the actual definition of the enum,
+                    # unfortunately.
+                    headers.add(CGHeaders.getDeclarationFilename(f.inner))
 
     map(addInfoForType, getAllTypes(descriptors, dictionaries, callbacks))
 
     return (headers, implheaders, declarations,
             CGList(itertools.chain(SortedDictValues(unionStructs),
                                    SortedDictValues(owningUnionStructs)), "\n"))
 
 def UnionConversions(descriptors, dictionaries, callbacks, config):
--- a/dom/webidl/VTTCue.webidl
+++ b/dom/webidl/VTTCue.webidl
@@ -30,18 +30,17 @@ interface VTTCue : EventTarget {
 
   attribute DOMString id;
   attribute double startTime;
   attribute double endTime;
   attribute boolean pauseOnExit;
   attribute DOMString regionId;
   attribute DirectionSetting vertical;
   attribute boolean snapToLines;
-  // XXXhumph: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20651
-  // attribute (long or AutoKeyword) line;
+  attribute (long or AutoKeyword) line;
   [SetterThrows]
   attribute AlignSetting lineAlign;
   [SetterThrows]
   attribute long position;
   [SetterThrows]
   attribute long size;
   attribute AlignSetting align;
   attribute DOMString text;