diff --git a/content/media/TextTrackCue.cpp b/content/media/TextTrackCue.cpp
index e249fbddc17b87cefd955b375759dc7307aefb80..35f5a46ff2e31e6d27b28804c4e8680506ab918f 100644
--- a/content/media/TextTrackCue.cpp
+++ b/content/media/TextTrackCue.cpp
@@ -8,9 +8,6 @@
 #include "nsComponentManagerUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 
-// Alternate value for the 'auto' keyword.
-#define WEBVTT_AUTO -1
-
 namespace mozilla {
 namespace dom {
 
@@ -38,7 +35,7 @@ TextTrackCue::SetDefaultCueSettings()
   mSize = 100;
   mPauseOnExit = false;
   mSnapToLines = true;
-  mLine = WEBVTT_AUTO;
+  mLineIsAutoKeyword = true;
   mAlign = AlignSetting::Middle;
   mLineAlign = AlignSetting::Start;
   mVertical = DirectionSetting::_empty;
diff --git a/content/media/TextTrackCue.h b/content/media/TextTrackCue.h
index bda359574973cdadc891f02b7f37c33a60dca203..ab46596d046733d37634aeed0dd05ebca6581606 100644
--- a/content/media/TextTrackCue.h
+++ b/content/media/TextTrackCue.h
@@ -15,6 +15,7 @@
 #include "mozilla/StaticPtr.h"
 #include "nsIDocument.h"
 #include "mozilla/dom/HTMLDivElement.h"
+#include "mozilla/dom/UnionTypes.h"
 
 namespace mozilla {
 namespace dom {
@@ -168,16 +169,30 @@ public:
     CueChanged();
   }
 
-  double Line() const
+  void GetLine(OwningLongOrAutoKeyword& aLine) const
   {
-    return mLine;
+    if (mLineIsAutoKeyword) {
+      aLine.SetAsAutoKeyword() = AutoKeyword::Auto;
+      return;
+    }
+    aLine.SetAsLong() = mLineLong;
   }
 
-  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() &&
+        (mLineIsAutoKeyword || (aLine.GetAsLong() != mLineLong))) {
+      mLineIsAutoKeyword = false;
+      mLineLong = aLine.GetAsLong();
+      CueChanged();
+      mReset = true;
+      return;
+    }
+    if (aLine.IsAutoKeyword() && !mLineIsAutoKeyword) {
+      mLineIsAutoKeyword = true;
+      CueChanged();
+      mReset = true;
+    }
   }
 
   AlignSetting LineAlign() const
@@ -355,7 +370,8 @@ private:
   bool mSnapToLines;
   nsString mRegionId;
   DirectionSetting mVertical;
-  int mLine;
+  bool mLineIsAutoKeyword;
+  long mLineLong;
   AlignSetting mAlign;
   AlignSetting mLineAlign;
 
diff --git a/content/media/test/test_texttrackcue.html b/content/media/test/test_texttrackcue.html
index b4145280ca0f5f5b8b33f0112596640a903e9cdf..907f2bd007b3f9957c93ead895ebbe6470018c6e 100644
--- a/content/media/test/test_texttrackcue.html
+++ b/content/media/test/test_texttrackcue.html
@@ -130,6 +130,13 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
       cue.positionAlign = "end";
       is(cue.positionAlign, "end", "Cue's position 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);
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 941ad5f2dbb7c3edbe9db65362a71872024f2c43..15701fcb05989f49a634c307c882e1409f169dc8 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -840,7 +840,9 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
                     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))
 
diff --git a/dom/webidl/VTTCue.webidl b/dom/webidl/VTTCue.webidl
index 60d5f8b190a07d34cae6a642e6c6727f474200f4..fa79c8707bda518ceadc367ec475b516608ff3e8 100644
--- a/dom/webidl/VTTCue.webidl
+++ b/dom/webidl/VTTCue.webidl
@@ -35,8 +35,7 @@ interface VTTCue : EventTarget {
   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]