Bug 965246 - Integrate bulk updates from vtt.js. r=rillian
authorRick Eyre <rick.eyre@hotmail.com>
Wed, 29 Jan 2014 09:28:06 -0500
changeset 182002 66a2d21bc2ef419b3b4ba705659624ea06904287
parent 182001 33c047525cdf7a8c2968dfa7e19acf6b21f04557
child 182003 c450eb3abde4924333607d9de7bb542da5e5ca2b
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs965246, 881976, 964625
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 965246 - Integrate bulk updates from vtt.js. r=rillian Relevant changes for bugs 881976 and 964625.
content/media/webvtt/vtt.jsm
--- a/content/media/webvtt/vtt.jsm
+++ b/content/media/webvtt/vtt.jsm
@@ -3,18 +3,35 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 this.EXPORTED_SYMBOLS = ["WebVTTParser"];
 
 /**
  * Code below is vtt.js the JS WebVTTParser.
  * Current source code can be found at http://github.com/andreasgal/vtt.js
  *
- * Code taken from commit 33a837b1ceef138a61a3b2f6fac90d5c70bd90d9
+ * Code taken from commit d819872e198d051dfcebcfb7ecf260462c9a9c6f
  */
+/**
+ * Copyright 2013 vtt.js Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
 (function(global) {
 
   function ParsingError(message) {
     this.name = "ParsingError";
     this.message = message || "";
   }
   ParsingError.prototype = Object.create(Error.prototype);
   ParsingError.prototype.constructor = ParsingError;
@@ -125,17 +142,17 @@ this.EXPORTED_SYMBOLS = ["WebVTTParser"]
   function parseCue(input, cue) {
     // 4.1 WebVTT timestamp
     function consumeTimeStamp() {
       var ts = parseTimeStamp(input);
       if (ts === null) {
         throw new ParsingError("Malformed time stamp.");
       }
       // Remove time stamp from input.
-      input = input.replace(/^[^\s-]+/, "");
+      input = input.replace(/^[^\sa-zA-Z-]+/, "");
       return ts;
     }
 
     // 4.4.2 WebVTT cue settings
     function consumeCueSettings(input, cue) {
       var settings = new Settings();
 
       parseOptions(input, function (k, v) {
@@ -627,23 +644,29 @@ this.EXPORTED_SYMBOLS = ["WebVTTParser"]
     return "ltr";
   }
 
   function computeLinePos(cue) {
     if (typeof cue.line === "number" &&
         (cue.snapToLines || (cue.line >= 0 && cue.line <= 100))) {
       return cue.line;
     }
-    if (!cue.track) {
+    if (!cue.track || !cue.track.textTrackList ||
+        !cue.track.textTrackList.mediaElement) {
       return -1;
     }
-    // TODO: Have to figure out a way to determine what the position of the
-    // Track is in the Media element's list of TextTracks and return that + 1,
-    // negated.
-    return 100;
+    var track = cue.track,
+        trackList = track.textTrackList,
+        count = 0;
+    for (var i = 0; i < trackList.length && trackList[i] !== track; i++) {
+      if (trackList[i].mode === "showing") {
+        count++;
+      }
+    }
+    return ++count * -1;
   }
 
   function BoundingBox() {
   }
 
   BoundingBox.prototype.applyStyles = function(styles) {
     var div = this.div;
     Object.keys(styles).forEach(function(style) {