diff --git a/lib/text/ttml_text_parser.js b/lib/text/ttml_text_parser.js
index 5f8b50de1c..fc8cbfddfb 100644
--- a/lib/text/ttml_text_parser.js
+++ b/lib/text/ttml_text_parser.js
@@ -379,7 +379,6 @@ shaka.text.TtmlTextParser = class {
parentCueElement, 'region', regionElements, /* prefix= */ '')[0];
}
-
shaka.text.TtmlTextParser.addStyle_(
cue,
cueElement,
@@ -527,14 +526,13 @@ shaka.text.TtmlTextParser = class {
}
const align = TtmlTextParser.getStyleAttribute_(
- cueElement, region, styles, 'textAlign', shouldInheritRegionStyles);
+ cueElement, region, styles, 'textAlign', true);
if (align) {
cue.positionAlign = TtmlTextParser.textAlignToPositionAlign_[align];
cue.lineAlign = TtmlTextParser.textAlignToLineAlign_[align];
goog.asserts.assert(align.toUpperCase() in Cue.textAlign,
- align.toUpperCase() +
- ' Should be in Cue.textAlign values!');
+ align.toUpperCase() + ' Should be in Cue.textAlign values!');
cue.textAlign = Cue.textAlign[align.toUpperCase()];
} else {
@@ -543,7 +541,7 @@ shaka.text.TtmlTextParser = class {
}
const displayAlign = TtmlTextParser.getStyleAttribute_(
- cueElement, region, styles, 'displayAlign', shouldInheritRegionStyles);
+ cueElement, region, styles, 'displayAlign', true);
if (displayAlign) {
goog.asserts.assert(displayAlign.toUpperCase() in Cue.displayAlign,
displayAlign.toUpperCase() +
diff --git a/test/text/ttml_text_parser_unit.js b/test/text/ttml_text_parser_unit.js
index 5355ffd104..da1c70bf42 100644
--- a/test/text/ttml_text_parser_unit.js
+++ b/test/text/ttml_text_parser_unit.js
@@ -1827,8 +1827,8 @@ describe('TtmlTextParser', () => {
// Styles from regionStyle should apply only to the nested cue.
backgroundColor: '',
color: '',
- displayAlign: Cue.displayAlign.AFTER, // displayAlign default value.
- textAlign: Cue.textAlign.START, // textAlign default value.
+ displayAlign: Cue.displayAlign.CENTER,
+ textAlign: Cue.textAlign.CENTER,
nestedCues: [
{
@@ -1853,7 +1853,7 @@ describe('TtmlTextParser', () => {
// Styles inherited from backgroundStyle via regionStyle via
// spanStyle
displayAlign: Cue.displayAlign.CENTER,
- textAlign: Cue.textAlign.CENTER,
+ textAlign: Cue.textAlign.END,
},
],
},
@@ -1867,7 +1867,7 @@ describe('TtmlTextParser', () => {
// spanStyle inherits attributes from regionStyle
' ' +
' ' +
+ ' tts:backgroundColor="white" tts:textAlign="end" />' +
// regionStyle inherits attributes from backgroundStyle
' ' +
@@ -1886,6 +1886,39 @@ describe('TtmlTextParser', () => {
{startTime: 0, endTime: 60});
});
+ it('inherits alignment from parent regions', () => {
+ verifyHelper(
+ [
+ {
+ startTime: 0,
+ endTime: 60,
+ payload: '',
+ fontSize: '',
+ textAlign: Cue.textAlign.END,
+ displayAlign: Cue.displayAlign.CENTER,
+ nestedCues: [
+ {
+ startTime: 0,
+ endTime: 60,
+ payload: 'Hello!',
+ textAlign: Cue.textAlign.END,
+ displayAlign: Cue.displayAlign.CENTER,
+ },
+ ],
+ },
+ ],
+ '' +
+ '' +
+ '' +
+ '' +
+ '',
+ {periodStart: 0, segmentStart: 0, segmentEnd: 0},
+ {startTime: 0, endTime: 60},
+ );
+ });
+
// Regression test for https://github.com/google/shaka-player/issues/3743
it('inherits styles from other styles on nestedCues', () => {
verifyHelper(