Bug 1276129 - part2 : change PositionAlign value in vtt.jsm. draft
authorAlastor Wu <alwu@mozilla.com>
Thu, 02 Jun 2016 10:51:27 +0800
changeset 374257 4be3e41f61b7d38c3954d90a9f7a8e39cf67e978
parent 374256 d0fd7628f26da2531387a301945d31a6da8f90e2
child 374258 51fd0161d2041b0cd3807268cf62f39603987b30
push id19965
push useralwu@mozilla.com
push dateThu, 02 Jun 2016 03:12:21 +0000
bugs1276129
milestone49.0a1
Bug 1276129 - part2 : change PositionAlign value in vtt.jsm. MozReview-Commit-ID: 71MtZzNxYbA
dom/media/webvtt/vtt.jsm
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -206,17 +206,17 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
           if (vals.length === 2) {
             settings.alt("lineAlign", vals[1], ["start", "middle", "end"]);
           }
           break;
         case "position":
           vals = v.split(",");
           settings.percent(k, vals[0]);
           if (vals.length === 2) {
-            settings.alt("positionAlign", vals[1], ["start", "middle", "end"]);
+            settings.alt("positionAlign", vals[1], ["line-left", "center", "line-right", "auto"]);
           }
           break;
         case "size":
           settings.percent(k, v);
           break;
         case "align":
           settings.alt(k, v, ["start", "middle", "end", "left", "right"]);
           break;
@@ -233,23 +233,17 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
       cue.align = settings.get("align", "middle");
       cue.position = settings.get("position", {
         start: 0,
         left: 0,
         middle: 50,
         end: 100,
         right: 100
       }, cue.align);
-      cue.positionAlign = settings.get("positionAlign", {
-        start: "start",
-        left: "start",
-        middle: "middle",
-        end: "end",
-        right: "end"
-      }, cue.align);
+      cue.positionAlign = settings.get("positionAlign", "center");
     }
 
     function skipWhitespace() {
       input = input.replace(/^\s+/, "");
     }
 
     // 4.1 WebVTT cue timings.
     skipWhitespace();
@@ -783,26 +777,27 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
     this.applyStyles(styles);
 
     this.div.appendChild(this.cueDiv);
 
     // Calculate the distance from the reference edge of the viewport to the text
     // position of the cue box. The reference edge will be resolved later when
     // the box orientation styles are applied.
     var textPos = 0;
-    switch (cue.positionAlign) {
-    case "start":
-      textPos = cue.position;
-      break;
-    case "middle":
-      textPos = cue.position - (cue.size / 2);
-      break;
-    case "end":
-      textPos = cue.position - cue.size;
-      break;
+    switch (cue.computedPositionAlign) {
+      // TODO : modify these fomula to follow the spec, see bug 1277437.
+      case "line-left":
+        textPos = cue.position;
+        break;
+      case "center":
+        textPos = cue.position - (cue.size / 2);
+        break;
+      case "line-right":
+        textPos = cue.position - cue.size;
+        break;
     }
 
     // Horizontal box orientation; textPos is the distance from the left edge of the
     // area to the left edge of the box and cue.size is the distance extending to
     // the right from there.
     if (cue.vertical === "") {
       this.applyStyles({
         left:  this.formatStyle(textPos, "%"),