Skip to content

Commit 457bf65

Browse files
committed
run ./build/all.py
1 parent b6a49d8 commit 457bf65

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

lib/text/cue.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ shaka.text.Cue = function(startTime, endTime, payload) {
190190
* @exportInterface
191191
*/
192192
this.children = [];
193+
194+
/**
195+
* @override
196+
* @exportInterface
197+
*/
198+
this.spacer = false;
193199
};
194200

195201

lib/text/ttml_text_parser.js

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ shaka.text.TtmlTextParser.prototype.parseMedia = function(data, time) {
138138
styles,
139139
regionElements,
140140
cueRegions,
141-
whitespaceTrim);
141+
whitespaceTrim,
142+
false);
142143
if (cue) {
143144
ret.push(cue);
144145
}
@@ -292,6 +293,14 @@ shaka.text.TtmlTextParser.getLeafNodes_ = function(element) {
292293
return result;
293294
};
294295

296+
/**
297+
* Get the leaf nodes that can act as cues
298+
* (begin and end attributes)
299+
*
300+
* @param {Element} element
301+
* @return {!Array.<!Element>}
302+
* @private
303+
*/
295304
shaka.text.TtmlTextParser.getLeafCues_ = function(element) {
296305
if (!element) {
297306
return [];
@@ -300,6 +309,14 @@ shaka.text.TtmlTextParser.getLeafCues_ = function(element) {
300309
return Array.from(element.querySelectorAll('[begin][end]'));
301310
};
302311

312+
313+
/**
314+
* Trims and removes multiple spaces from a string
315+
*
316+
* @param {string} textContent
317+
* @return {string}
318+
* @private
319+
*/
303320
shaka.text.TtmlTextParser.sanitizeTextContent = function(textContent) {
304321
return textContent
305322
// Trim leading and trailing whitespace.
@@ -320,14 +337,15 @@ shaka.text.TtmlTextParser.sanitizeTextContent = function(textContent) {
320337
* @param {!Array.<!Element>} regionElements
321338
* @param {!Array.<!shaka.text.CueRegion>} cueRegions
322339
* @param {boolean} whitespaceTrim
340+
* @param {boolean} isChild
323341
* @return {shaka.text.Cue}
324342
* @private
325343
*/
326344
shaka.text.TtmlTextParser.parseCue_ = function(
327345
cueElement, offset, rateInfo, metadataElements, styles,
328346
regionElements, cueRegions, whitespaceTrim, isChild) {
329347
if (isChild && cueElement.nodeName === 'br') {
330-
const cue = new shaka.text.Cue();
348+
const cue = new shaka.text.Cue(0, 0, '');
331349
cue.spacer = true;
332350

333351
return cue;
@@ -373,7 +391,7 @@ shaka.text.TtmlTextParser.parseCue_ = function(
373391
for (let i = 0; i < cueElement.childNodes.length; i++) {
374392
const childNode = cueElement.childNodes[i];
375393
const childCue = shaka.text.TtmlTextParser.parseCue_(
376-
childNode,
394+
/** @type {!Element} */ (childNode),
377395
offset,
378396
rateInfo,
379397
metadataElements,
@@ -408,17 +426,17 @@ shaka.text.TtmlTextParser.parseCue_ = function(
408426
cue.children = children;
409427

410428
// Get other properties if available.
411-
const [regionElement] = shaka.text.TtmlTextParser.getElementFromCollection_(
412-
cueElement, 'region', regionElements, /* prefix= */ '');
429+
const regionElement = shaka.text.TtmlTextParser.getElementFromCollection_(
430+
cueElement, 'region', regionElements, /* prefix= */ '')[0];
413431
if (regionElement && regionElement.getAttribute('xml:id')) {
414432
let regionId = regionElement.getAttribute('xml:id');
415433
let regionsWithId = cueRegions.filter(function(region) {
416434
return region.id == regionId;
417435
});
418436
cue.region = regionsWithId[0];
419437
}
420-
const [imageElement] = shaka.text.TtmlTextParser.getElementFromCollection_(
421-
cueElement, 'smpte:backgroundImage', metadataElements, '#');
438+
const imageElement = shaka.text.TtmlTextParser.getElementFromCollection_(
439+
cueElement, 'smpte:backgroundImage', metadataElements, '#')[0];
422440
shaka.text.TtmlTextParser.addStyle_(
423441
cue,
424442
cueElement,
@@ -756,8 +774,9 @@ shaka.text.TtmlTextParser.getStyleAttributeFromRegion_ = function(
756774
}
757775
}
758776

759-
let [style] = shaka.text.TtmlTextParser.getElementFromCollection_(
760-
region, 'style', styles, /* prefix= */ '');
777+
const style = shaka.text.TtmlTextParser.getElementFromCollection_(
778+
region, 'style', styles, /* prefix= */ '')[0];
779+
761780
if (style) {
762781
return XmlUtils.getAttributeNS(style, ttsNs, attribute);
763782
}
@@ -794,7 +813,7 @@ shaka.text.TtmlTextParser.getStyleAttributeFromElement_ = function(
794813
const inheritedStyles = shaka.text.TtmlTextParser.getElementFromCollection_(
795814
cueElement, 'style', styles, /* prefix= */ '');
796815

797-
let styleValue;
816+
let styleValue = null;
798817

799818
// The last value in our styles stack takes the precedence over the others
800819
for (let i = 0; i < inheritedStyles.length; i++) {
@@ -821,7 +840,7 @@ shaka.text.TtmlTextParser.getStyleAttributeFromElement_ = function(
821840
* @param {string} attributeName
822841
* @param {!Array.<Element>} collection
823842
* @param {string} prefixName
824-
* @return {Element}
843+
* @return {Array.<!Element>}
825844
* @private
826845
*/
827846
shaka.text.TtmlTextParser.getElementFromCollection_ = function(

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
},
6464
"license": "Apache-2.0",
6565
"scripts": {
66-
"prepublish": "in-publish && python build/checkversion.py && python build/all.py --force || not-in-publish",
67-
"lint": "eslint './{demo,lib,ui}/**/*.js'"
66+
"prepublish": "in-publish && python build/checkversion.py && python build/all.py --force || not-in-publish"
6867
}
6968
}

ui/text_displayer.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ shaka.ui.TextDisplayer = class {
185185
}
186186
}
187187

188+
/**
189+
* Displays children cues of a cue
190+
*
191+
* @param {Element} container
192+
* @param {!shaka.extern.Cue} cue
193+
* @returns {Element} the created captions container
194+
* @private
195+
*/
188196
displayChildrenCue_(container, cue) {
189197
const captions = shaka.util.Dom.createHTMLElement('span');
190198

@@ -199,6 +207,13 @@ shaka.ui.TextDisplayer = class {
199207
return captions;
200208
}
201209

210+
/**
211+
* Displays a cue
212+
*
213+
* @param {Element} container
214+
* @param {!shaka.extern.Cue} cue
215+
* @private
216+
*/
202217
displayCue_(container, cue) {
203218
if (cue.children.length) {
204219
const childrenContainer = shaka.util.Dom.createHTMLElement('p');

0 commit comments

Comments
 (0)