зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1488673 - part7 : huge replacement of 'var' by 'let'. r=heycam
In order to keep the local variable only visible inside the function scope, we should only use 'let' for those variables. Differential Revision: https://phabricator.services.mozilla.com/D20027 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3efd4f2e8f
Коммит
a84641d33a
|
@ -83,7 +83,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
|
return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
var timestamp = input.match(/^(\d+:)?(\d{2}):(\d{2})\.(\d+)/);
|
let timestamp = input.match(/^(\d+:)?(\d{2}):(\d{2})\.(\d+)/);
|
||||||
if (!timestamp || timestamp.length !== 5) {
|
if (!timestamp || timestamp.length !== 5) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
},
|
},
|
||||||
// Accept a setting if its one of the given alternatives.
|
// Accept a setting if its one of the given alternatives.
|
||||||
alt: function(k, v, a) {
|
alt: function(k, v, a) {
|
||||||
for (var n = 0; n < a.length; ++n) {
|
for (let n = 0; n < a.length; ++n) {
|
||||||
if (v === a[n]) {
|
if (v === a[n]) {
|
||||||
this.set(k, v);
|
this.set(k, v);
|
||||||
return true;
|
return true;
|
||||||
|
@ -143,7 +143,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
},
|
},
|
||||||
// Accept a setting if its a valid percentage.
|
// Accept a setting if its a valid percentage.
|
||||||
percent: function(k, v) {
|
percent: function(k, v) {
|
||||||
var m;
|
let m;
|
||||||
if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
|
if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
|
||||||
v = parseFloat(v);
|
v = parseFloat(v);
|
||||||
if (v >= 0 && v <= 100) {
|
if (v >= 0 && v <= 100) {
|
||||||
|
@ -164,27 +164,27 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
// Helper function to parse input into groups separated by 'groupDelim', and
|
// Helper function to parse input into groups separated by 'groupDelim', and
|
||||||
// interprete each group as a key/value pair separated by 'keyValueDelim'.
|
// interprete each group as a key/value pair separated by 'keyValueDelim'.
|
||||||
function parseOptions(input, callback, keyValueDelim, groupDelim) {
|
function parseOptions(input, callback, keyValueDelim, groupDelim) {
|
||||||
var groups = groupDelim ? input.split(groupDelim) : [input];
|
let groups = groupDelim ? input.split(groupDelim) : [input];
|
||||||
for (var i in groups) {
|
for (let i in groups) {
|
||||||
if (typeof groups[i] !== "string") {
|
if (typeof groups[i] !== "string") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var kv = groups[i].split(keyValueDelim);
|
let kv = groups[i].split(keyValueDelim);
|
||||||
if (kv.length !== 2) {
|
if (kv.length !== 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var k = kv[0];
|
let k = kv[0];
|
||||||
var v = kv[1];
|
let v = kv[1];
|
||||||
callback(k, v);
|
callback(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCue(input, cue, regionList) {
|
function parseCue(input, cue, regionList) {
|
||||||
// Remember the original input if we need to throw an error.
|
// Remember the original input if we need to throw an error.
|
||||||
var oInput = input;
|
let oInput = input;
|
||||||
// 4.1 WebVTT timestamp
|
// 4.1 WebVTT timestamp
|
||||||
function consumeTimeStamp() {
|
function consumeTimeStamp() {
|
||||||
var ts = collectTimeStamp(input);
|
let ts = collectTimeStamp(input);
|
||||||
if (ts === null) {
|
if (ts === null) {
|
||||||
throw new ParsingError(ParsingError.Errors.BadTimeStamp,
|
throw new ParsingError(ParsingError.Errors.BadTimeStamp,
|
||||||
"Malformed timestamp: " + oInput);
|
"Malformed timestamp: " + oInput);
|
||||||
|
@ -196,12 +196,12 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
|
|
||||||
// 4.4.2 WebVTT cue settings
|
// 4.4.2 WebVTT cue settings
|
||||||
function consumeCueSettings(input, cue) {
|
function consumeCueSettings(input, cue) {
|
||||||
var settings = new Settings();
|
let settings = new Settings();
|
||||||
parseOptions(input, function (k, v) {
|
parseOptions(input, function (k, v) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case "region":
|
case "region":
|
||||||
// Find the last region we parsed with the same region id.
|
// Find the last region we parsed with the same region id.
|
||||||
for (var i = regionList.length - 1; i >= 0; i--) {
|
for (let i = regionList.length - 1; i >= 0; i--) {
|
||||||
if (regionList[i].id === v) {
|
if (regionList[i].id === v) {
|
||||||
settings.set(k, regionList[i].region);
|
settings.set(k, regionList[i].region);
|
||||||
break;
|
break;
|
||||||
|
@ -211,9 +211,9 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
case "vertical":
|
case "vertical":
|
||||||
settings.alt(k, v, ["rl", "lr"]);
|
settings.alt(k, v, ["rl", "lr"]);
|
||||||
break;
|
break;
|
||||||
case "line":
|
case "line": {
|
||||||
var vals = v.split(","),
|
let vals = v.split(",");
|
||||||
vals0 = vals[0];
|
let vals0 = vals[0];
|
||||||
settings.digitsValue(k, vals0);
|
settings.digitsValue(k, vals0);
|
||||||
settings.percent(k, vals0) ? settings.set("snapToLines", false) : null;
|
settings.percent(k, vals0) ? settings.set("snapToLines", false) : null;
|
||||||
settings.alt(k, vals0, ["auto"]);
|
settings.alt(k, vals0, ["auto"]);
|
||||||
|
@ -221,8 +221,9 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
settings.alt("lineAlign", vals[1], ["start", "center", "end"]);
|
settings.alt("lineAlign", vals[1], ["start", "center", "end"]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "position":
|
}
|
||||||
vals = v.split(",");
|
case "position": {
|
||||||
|
let vals = v.split(",");
|
||||||
if (settings.percent(k, vals[0])) {
|
if (settings.percent(k, vals[0])) {
|
||||||
if (vals.length === 2) {
|
if (vals.length === 2) {
|
||||||
if (!settings.alt("positionAlign", vals[1], ["line-left", "center", "line-right"])) {
|
if (!settings.alt("positionAlign", vals[1], ["line-left", "center", "line-right"])) {
|
||||||
|
@ -233,6 +234,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "size":
|
case "size":
|
||||||
settings.percent(k, v);
|
settings.percent(k, v);
|
||||||
break;
|
break;
|
||||||
|
@ -338,7 +340,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var m = input.match(/^([^<]*)(<[^>]+>?)?/);
|
let m = input.match(/^([^<]*)(<[^>]+>?)?/);
|
||||||
// The input doesn't contain a complete tag.
|
// The input doesn't contain a complete tag.
|
||||||
if (!m[0]) {
|
if (!m[0]) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -353,6 +355,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return ESCAPE[e];
|
return ESCAPE[e];
|
||||||
}
|
}
|
||||||
function unescape(s) {
|
function unescape(s) {
|
||||||
|
let m;
|
||||||
while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
|
while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
|
||||||
s = s.replace(m[0], unescape1);
|
s = s.replace(m[0], unescape1);
|
||||||
}
|
}
|
||||||
|
@ -366,12 +369,12 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
|
|
||||||
// Create an element for this tag.
|
// Create an element for this tag.
|
||||||
function createElement(type, annotation) {
|
function createElement(type, annotation) {
|
||||||
var tagName = TAG_NAME[type];
|
let tagName = TAG_NAME[type];
|
||||||
if (!tagName) {
|
if (!tagName) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var element = window.document.createElement(tagName);
|
let element = window.document.createElement(tagName);
|
||||||
var name = TAG_ANNOTATION[type];
|
let name = TAG_ANNOTATION[type];
|
||||||
if (name) {
|
if (name) {
|
||||||
element[name] = annotation ? annotation.trim() : "";
|
element[name] = annotation ? annotation.trim() : "";
|
||||||
}
|
}
|
||||||
|
@ -381,10 +384,10 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
// https://w3c.github.io/webvtt/#webvtt-timestamp-object
|
// https://w3c.github.io/webvtt/#webvtt-timestamp-object
|
||||||
// Return hhhhh:mm:ss.fff
|
// Return hhhhh:mm:ss.fff
|
||||||
function normalizedTimeStamp(secondsWithFrag) {
|
function normalizedTimeStamp(secondsWithFrag) {
|
||||||
var totalsec = parseInt(secondsWithFrag, 10);
|
let totalsec = parseInt(secondsWithFrag, 10);
|
||||||
var hours = Math.floor(totalsec / 3600);
|
let hours = Math.floor(totalsec / 3600);
|
||||||
var minutes = Math.floor(totalsec % 3600 / 60);
|
let minutes = Math.floor(totalsec % 3600 / 60);
|
||||||
var seconds = Math.floor(totalsec % 60);
|
let seconds = Math.floor(totalsec % 60);
|
||||||
if (hours < 10) {
|
if (hours < 10) {
|
||||||
hours = "0" + hours;
|
hours = "0" + hours;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +397,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
if (seconds < 10) {
|
if (seconds < 10) {
|
||||||
seconds = "0" + seconds;
|
seconds = "0" + seconds;
|
||||||
}
|
}
|
||||||
var f = secondsWithFrag.toString().split(".");
|
let f = secondsWithFrag.toString().split(".");
|
||||||
if (f[1]) {
|
if (f[1]) {
|
||||||
f = f[1].slice(0, 3).padEnd(3, "0");
|
f = f[1].slice(0, 3).padEnd(3, "0");
|
||||||
} else {
|
} else {
|
||||||
|
@ -403,7 +406,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return hours + ':' + minutes + ':' + seconds + '.' + f;
|
return hours + ':' + minutes + ':' + seconds + '.' + f;
|
||||||
}
|
}
|
||||||
|
|
||||||
var root;
|
let root;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case PARSE_CONTENT_MODE.PSUEDO_CUE:
|
case PARSE_CONTENT_MODE.PSUEDO_CUE:
|
||||||
root = window.document.createElement("div", {pseudo: "::cue"});
|
root = window.document.createElement("div", {pseudo: "::cue"});
|
||||||
|
@ -417,7 +420,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var current = root,
|
let current = root,
|
||||||
t,
|
t,
|
||||||
tagStack = [];
|
tagStack = [];
|
||||||
|
|
||||||
|
@ -433,15 +436,15 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
// Otherwise just ignore the end tag.
|
// Otherwise just ignore the end tag.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var ts = collectTimeStamp(t.substr(1, t.length - 1));
|
let ts = collectTimeStamp(t.substr(1, t.length - 1));
|
||||||
var node;
|
let node;
|
||||||
if (ts) {
|
if (ts) {
|
||||||
// Timestamps are lead nodes as well.
|
// Timestamps are lead nodes as well.
|
||||||
node = window.document.createProcessingInstruction("timestamp", normalizedTimeStamp(ts));
|
node = window.document.createProcessingInstruction("timestamp", normalizedTimeStamp(ts));
|
||||||
current.appendChild(node);
|
current.appendChild(node);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);
|
let m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);
|
||||||
// If we can't parse the tag, skip to the next tag.
|
// If we can't parse the tag, skip to the next tag.
|
||||||
if (!m) {
|
if (!m) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -482,7 +485,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
// div on 'this'.
|
// div on 'this'.
|
||||||
StyleBox.prototype.applyStyles = function(styles, div) {
|
StyleBox.prototype.applyStyles = function(styles, div) {
|
||||||
div = div || this.div;
|
div = div || this.div;
|
||||||
for (var prop in styles) {
|
for (let prop in styles) {
|
||||||
if (styles.hasOwnProperty(prop)) {
|
if (styles.hasOwnProperty(prop)) {
|
||||||
div.style[prop] = styles[prop];
|
div.style[prop] = styles[prop];
|
||||||
}
|
}
|
||||||
|
@ -695,11 +698,11 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
function RegionNodeBox(window, region, container) {
|
function RegionNodeBox(window, region, container) {
|
||||||
StyleBox.call(this);
|
StyleBox.call(this);
|
||||||
|
|
||||||
var boxLineHeight = container.height * 0.0533 // 0.0533vh ? 5.33vh
|
let boxLineHeight = container.height * 0.0533 // 0.0533vh ? 5.33vh
|
||||||
var boxHeight = boxLineHeight * region.lines;
|
let boxHeight = boxLineHeight * region.lines;
|
||||||
var boxWidth = container.width * region.width / 100; // convert percentage to px
|
let boxWidth = container.width * region.width / 100; // convert percentage to px
|
||||||
|
|
||||||
var regionNodeStyles = {
|
let regionNodeStyles = {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
height: boxHeight + "px",
|
height: boxHeight + "px",
|
||||||
width: boxWidth + "px",
|
width: boxWidth + "px",
|
||||||
|
@ -731,7 +734,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
StyleBox.call(this);
|
StyleBox.call(this);
|
||||||
this.cueDiv = parseContent(window, cue.text, PARSE_CONTENT_MODE.REGION_CUE);
|
this.cueDiv = parseContent(window, cue.text, PARSE_CONTENT_MODE.REGION_CUE);
|
||||||
|
|
||||||
var regionCueStyles = {
|
let regionCueStyles = {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
writingMode: "horizontal-tb",
|
writingMode: "horizontal-tb",
|
||||||
unicodeBidi: "plaintext",
|
unicodeBidi: "plaintext",
|
||||||
|
@ -741,7 +744,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
};
|
};
|
||||||
// TODO: fix me, LTR and RTL ? using margin replace the "left/right"
|
// TODO: fix me, LTR and RTL ? using margin replace the "left/right"
|
||||||
// 6.1.14.3.3
|
// 6.1.14.3.3
|
||||||
var offset = cue.computedPosition * cue.region.width / 100;
|
let offset = cue.computedPosition * cue.region.width / 100;
|
||||||
// 6.1.14.3.4
|
// 6.1.14.3.4
|
||||||
switch (cue.align) {
|
switch (cue.align) {
|
||||||
case "start":
|
case "start":
|
||||||
|
@ -1068,8 +1071,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var controlBar;
|
let controlBar, controlBarShown;
|
||||||
var controlBarShown;
|
|
||||||
if (controls) {
|
if (controls) {
|
||||||
// controls is a <div> that is the children of the UA Widget Shadow Root.
|
// controls is a <div> that is the children of the UA Widget Shadow Root.
|
||||||
controlBar = controls.parentNode.getElementById("controlBar");
|
controlBar = controls.parentNode.getElementById("controlBar");
|
||||||
|
@ -1088,7 +1090,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < cues.length; i++) {
|
for (let i = 0; i < cues.length; i++) {
|
||||||
if (cues[i].hasBeenReset || !cues[i].displayState) {
|
if (cues[i].hasBeenReset || !cues[i].displayState) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1108,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
while (overlay.firstChild) {
|
while (overlay.firstChild) {
|
||||||
overlay.firstChild.remove();
|
overlay.firstChild.remove();
|
||||||
}
|
}
|
||||||
var rootOfCues = window.document.createElement("div");
|
let rootOfCues = window.document.createElement("div");
|
||||||
rootOfCues.style.position = "absolute";
|
rootOfCues.style.position = "absolute";
|
||||||
rootOfCues.style.left = "0";
|
rootOfCues.style.left = "0";
|
||||||
rootOfCues.style.right = "0";
|
rootOfCues.style.right = "0";
|
||||||
|
@ -1114,12 +1116,11 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
rootOfCues.style.bottom = "0";
|
rootOfCues.style.bottom = "0";
|
||||||
overlay.appendChild(rootOfCues);
|
overlay.appendChild(rootOfCues);
|
||||||
|
|
||||||
var boxPositions = [],
|
let boxPositions = [],
|
||||||
containerBox = new BoxPosition(rootOfCues);
|
containerBox = new BoxPosition(rootOfCues);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var styleBox, cue, controlBarBox;
|
let styleBox, cue, controlBarBox;
|
||||||
|
|
||||||
if (controlBarShown) {
|
if (controlBarShown) {
|
||||||
controlBarBox = new BoxPosition(controlBar);
|
controlBarBox = new BoxPosition(controlBar);
|
||||||
// Add an empty output box that cover the same region as video control bar.
|
// Add an empty output box that cover the same region as video control bar.
|
||||||
|
@ -1128,10 +1129,10 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
|
|
||||||
// https://w3c.github.io/webvtt/#processing-model 6.1.12.1
|
// https://w3c.github.io/webvtt/#processing-model 6.1.12.1
|
||||||
// Create regionNode
|
// Create regionNode
|
||||||
var regionNodeBoxes = {};
|
let regionNodeBoxes = {};
|
||||||
var regionNodeBox;
|
let regionNodeBox;
|
||||||
|
|
||||||
for (var i = 0; i < cues.length; i++) {
|
for (let i = 0; i < cues.length; i++) {
|
||||||
cue = cues[i];
|
cue = cues[i];
|
||||||
if (cue.region != null) {
|
if (cue.region != null) {
|
||||||
// 6.1.14.1
|
// 6.1.14.1
|
||||||
|
@ -1140,7 +1141,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
if (!regionNodeBoxes[cue.region.id]) {
|
if (!regionNodeBoxes[cue.region.id]) {
|
||||||
// create regionNode
|
// create regionNode
|
||||||
// Adjust the container hieght to exclude the controlBar
|
// Adjust the container hieght to exclude the controlBar
|
||||||
var adjustContainerBox = new BoxPosition(rootOfCues);
|
let adjustContainerBox = new BoxPosition(rootOfCues);
|
||||||
if (controlBarShown) {
|
if (controlBarShown) {
|
||||||
adjustContainerBox.height -= controlBarBox.height;
|
adjustContainerBox.height -= controlBarBox.height;
|
||||||
adjustContainerBox.bottom += controlBarBox.height;
|
adjustContainerBox.bottom += controlBarBox.height;
|
||||||
|
@ -1149,8 +1150,8 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
regionNodeBoxes[cue.region.id] = regionNodeBox;
|
regionNodeBoxes[cue.region.id] = regionNodeBox;
|
||||||
}
|
}
|
||||||
// 6.1.14.3
|
// 6.1.14.3
|
||||||
var currentRegionBox = regionNodeBoxes[cue.region.id];
|
let currentRegionBox = regionNodeBoxes[cue.region.id];
|
||||||
var currentRegionNodeDiv = currentRegionBox.div;
|
let currentRegionNodeDiv = currentRegionBox.div;
|
||||||
// 6.1.14.3.2
|
// 6.1.14.3.2
|
||||||
// TODO: fix me, it looks like the we need to set/change "top" attribute at the styleBox.div
|
// TODO: fix me, it looks like the we need to set/change "top" attribute at the styleBox.div
|
||||||
// to do the "scroll up", however, we do not implement it yet?
|
// to do the "scroll up", however, we do not implement it yet?
|
||||||
|
@ -1214,12 +1215,12 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
|
|
||||||
// This parser is line-based. Let's see if we have a line to parse.
|
// This parser is line-based. Let's see if we have a line to parse.
|
||||||
while (/\r\n|\n|\r/.test(this.buffer)) {
|
while (/\r\n|\n|\r/.test(this.buffer)) {
|
||||||
var buffer = this.buffer;
|
let buffer = this.buffer;
|
||||||
var pos = 0;
|
let pos = 0;
|
||||||
while (buffer[pos] !== '\r' && buffer[pos] !== '\n') {
|
while (buffer[pos] !== '\r' && buffer[pos] !== '\n') {
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
var line = buffer.substr(0, pos);
|
let line = buffer.substr(0, pos);
|
||||||
// Advance the buffer early in case we fail below.
|
// Advance the buffer early in case we fail below.
|
||||||
if (buffer[pos] === '\r') {
|
if (buffer[pos] === '\r') {
|
||||||
++pos;
|
++pos;
|
||||||
|
@ -1240,7 +1241,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
parseLine: function(line) {
|
parseLine: function(line) {
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
function createCueIfNeeded() {
|
function createCueIfNeeded() {
|
||||||
if (!self.cue) {
|
if (!self.cue) {
|
||||||
|
@ -1280,7 +1281,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
|
|
||||||
// 3.4 WebVTT region and WebVTT region settings syntax
|
// 3.4 WebVTT region and WebVTT region settings syntax
|
||||||
function parseRegion(input) {
|
function parseRegion(input) {
|
||||||
var settings = new Settings();
|
let settings = new Settings();
|
||||||
parseOptions(input, function (k, v) {
|
parseOptions(input, function (k, v) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case "id":
|
case "id":
|
||||||
|
@ -1293,14 +1294,14 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
settings.digitsValue(k, v);
|
settings.digitsValue(k, v);
|
||||||
break;
|
break;
|
||||||
case "regionanchor":
|
case "regionanchor":
|
||||||
case "viewportanchor":
|
case "viewportanchor": {
|
||||||
var xy = v.split(',');
|
let xy = v.split(',');
|
||||||
if (xy.length !== 2) {
|
if (xy.length !== 2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// We have to make sure both x and y parse, so use a temporary
|
// We have to make sure both x and y parse, so use a temporary
|
||||||
// settings object here.
|
// settings object here.
|
||||||
var anchor = new Settings();
|
let anchor = new Settings();
|
||||||
anchor.percent("x", xy[0]);
|
anchor.percent("x", xy[0]);
|
||||||
anchor.percent("y", xy[1]);
|
anchor.percent("y", xy[1]);
|
||||||
if (!anchor.has("x") || !anchor.has("y")) {
|
if (!anchor.has("x") || !anchor.has("y")) {
|
||||||
|
@ -1309,6 +1310,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
settings.set(k + "X", anchor.get("x"));
|
settings.set(k + "X", anchor.get("x"));
|
||||||
settings.set(k + "Y", anchor.get("y"));
|
settings.set(k + "Y", anchor.get("y"));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "scroll":
|
case "scroll":
|
||||||
settings.alt(k, v, ["up"]);
|
settings.alt(k, v, ["up"]);
|
||||||
break;
|
break;
|
||||||
|
@ -1320,7 +1322,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
// specified.
|
// specified.
|
||||||
if (settings.has("id")) {
|
if (settings.has("id")) {
|
||||||
try {
|
try {
|
||||||
var region = new self.window.VTTRegion();
|
let region = new self.window.VTTRegion();
|
||||||
region.id = settings.get("id", "");
|
region.id = settings.get("id", "");
|
||||||
region.width = settings.get("width", 100);
|
region.width = settings.get("width", 100);
|
||||||
region.lines = settings.get("lines", 3);
|
region.lines = settings.get("lines", 3);
|
||||||
|
@ -1339,7 +1341,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
dump("VTTRegion Error " + e + "\n");
|
dump("VTTRegion Error " + e + "\n");
|
||||||
var regionPref = Services.prefs.getBoolPref("media.webvtt.regions.enabled");
|
let regionPref = Services.prefs.getBoolPref("media.webvtt.regions.enabled");
|
||||||
dump("regionPref " + regionPref + "\n");
|
dump("regionPref " + regionPref + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1501,7 +1503,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "supportPseudo",
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
flush: function () {
|
flush: function () {
|
||||||
var self = this;
|
let self = this;
|
||||||
try {
|
try {
|
||||||
// Finish decoding the stream.
|
// Finish decoding the stream.
|
||||||
self.buffer += self.decoder.decode();
|
self.buffer += self.decoder.decode();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче