-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes the TTML parser to not allow cue regions to be inherited to the children of the element the region was originally assigned on, except for the purposes of styles (colors, etc). To allow regions on elements "above" the cues in TTML, such as the <body> or <div> elements, this also changes the TTML parser to render the full structure of the TTML file as a tree of cues. The end result will be a single cue representing the <body>, with children representing the <div> elements inside it, and those <divs> will have children that represent the actual cues. Now that our text displayer can intelligently update child cues as they enter or leave the display window, this approach should be possible. Closes #3850 Closes #3741 Change-Id: Ia8d750daa06920610c04e9b26e29d2d304eaf8a9
- Loading branch information
1 parent
6e384e3
commit 4980195
Showing
7 changed files
with
534 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/*! @license | ||
* Shaka Player | ||
* Copyright 2016 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
goog.provide('shaka.test.TtmlUtils'); | ||
|
||
shaka.test.TtmlUtils = class { | ||
/** | ||
* @param {!Array} expectedCues | ||
* @param {!Array} actualCues | ||
* @param {!Object} bodyProperties | ||
* @param {Object=} divProperties | ||
*/ | ||
static verifyHelper(expectedCues, actualCues, bodyProperties, divProperties) { | ||
const mapExpected = (cue) => { | ||
if (cue.region) { | ||
cue.region = jasmine.objectContaining(cue.region); | ||
} | ||
|
||
if (cue.nestedCues && (cue.nestedCues instanceof Array)) { | ||
cue.nestedCues = cue.nestedCues.map(mapExpected); | ||
} | ||
|
||
if (cue.isContainer == undefined) { | ||
// If not specified to be true, check for isContainer to be false. | ||
cue.isContainer = false; | ||
} | ||
|
||
return jasmine.objectContaining(cue); | ||
}; | ||
|
||
/** | ||
* @param {!Object} properties | ||
* @return {!shaka.extern.Cue} | ||
*/ | ||
const makeContainer = (properties) => { | ||
const region = { | ||
id: '', | ||
viewportAnchorX: 0, | ||
viewportAnchorY: 0, | ||
regionAnchorX: 0, | ||
regionAnchorY: 0, | ||
width: 100, | ||
height: 100, | ||
widthUnits: shaka.text.CueRegion.units.PERCENTAGE, | ||
heightUnits: shaka.text.CueRegion.units.PERCENTAGE, | ||
viewportAnchorUnits: shaka.text.CueRegion.units.PERCENTAGE, | ||
scroll: '', | ||
}; | ||
const containerCue = /** @type {!shaka.extern.Cue} */ ({ | ||
region, | ||
nestedCues: jasmine.any(Object), | ||
payload: '', | ||
startTime: 0, | ||
endTime: Infinity, | ||
isContainer: true, | ||
}); | ||
Object.assign(containerCue, properties); | ||
return mapExpected(containerCue); | ||
}; | ||
|
||
if (expectedCues.length == 0 && !divProperties) { | ||
expect(actualCues.length).toBe(0); | ||
} else { | ||
// Body. | ||
expect(actualCues.length).toBe(1); | ||
const body = actualCues[0]; | ||
expect(body).toEqual(makeContainer(bodyProperties)); | ||
|
||
// Div. | ||
expect(body.nestedCues.length).toBe(1); | ||
const div = body.nestedCues[0]; | ||
expect(div).toEqual(makeContainer(divProperties || bodyProperties)); | ||
|
||
// Cues. | ||
expect(div.nestedCues).toEqual(expectedCues.map(mapExpected)); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.