Skip to content

Commit

Permalink
fix(WebVTT): Fix support for line:0 vertical alignment (#5632)
Browse files Browse the repository at this point in the history
Related to #4446
  • Loading branch information
avelad authored and joeyparrish committed Sep 13, 2023
1 parent ba9a852 commit 5074de7
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/text/ui_text_displayer.js
Expand Up @@ -617,7 +617,15 @@ shaka.text.UITextDisplayer = class {
// TODO: Implement line alignment with line number.
// TODO: Implement lineAlignment of 'CENTER'.
if (cue.line != null) {
if (cue.lineInterpretation == Cue.lineInterpretation.PERCENTAGE) {
let lineInterpretation = cue.lineInterpretation;
// HACK: the current implementation of UITextDisplayer only handled
// PERCENTAGE, as cue.line=0 is zero, we can interpret it as percentage
// safely.
if (cue.line == 0 &&
lineInterpretation == Cue.lineInterpretation.LINE_NUMBER) {
lineInterpretation = Cue.lineInterpretation.PERCENTAGE;
}
if (lineInterpretation == Cue.lineInterpretation.PERCENTAGE) {
style.position = 'absolute';
if (cue.writingMode == Cue.writingMode.HORIZONTAL_TOP_TO_BOTTOM) {
style.width = '100%';
Expand Down
Binary file modified test/test/assets/screenshots/chrome-Android/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/chrome-Linux/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/chrome-Mac/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/chrome-Windows/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/firefox-Linux/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/firefox-Mac/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/firefox-Windows/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/msedge-Linux/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/msedge-Mac/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/msedge-Windows/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/test/assets/screenshots/safari-Mac/webvtt-ui-line-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion test/text/web_vtt_layout_integration.js
Expand Up @@ -213,7 +213,6 @@ filterDescribe('WebVTT layout', shaka.test.TextLayoutTests.supported, () => {
await helper.checkScreenshot('line-negative-2');
});

// FIXME: UI version is wrong: not positioned by line
it('line 0', async () => {
parseAndDisplay([
'WEBVTT\n',
Expand Down

0 comments on commit 5074de7

Please sign in to comment.