Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebVTT: Remove paddings around ::cue boxes
Before this change, captions with 2 or more lines at the bottom of a video are displayed out of order. This happens because captions are assigned initial positions that overlap with other captions or with the media controls and are then placed out of order. We can avoid overlap by making the following 2 changes. The first change removes the excess padding that wasn't accounted for in the position calculation. We tried to use the bounding box height that includes the padding in the position calculation but it changes cue placement depending on the number of lines in the cue which is not ideal. Safari and Firefox do not use paddings with their cues either so we have decided to go forward with the padding removal. Our PM has already reviewed and approved this change. Here is a screenshot showing the difference before and after the padding removal: https://screenshot.googleplex.com/3jg2r28G6nBzLd4 Also, the original CL that introduced window padding in the first place can be found here: crrev.com/c/1658914 The second change accounts for the height of the media controls (crrev.com/c/3804205) Bug: 1141592 Change-Id: I26e124fa838c6c066c94cc1ffa9bb50129762f9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3782908 Commit-Queue: Jocelyn Tran <jocelyntran@google.com> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Abigail Klein <abigailbklein@google.com> Reviewed-by: Alex Gough <ajgo@chromium.org> Cr-Commit-Position: refs/heads/main@{#1031268}
- Loading branch information
1 parent
0f987ac
commit 730e20a
Showing
15 changed files
with
42 additions
and
38 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
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
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
42 changes: 42 additions & 0 deletions
42
third_party/blink/web_tests/media/track/track-cue-rendering-negative-line-numbers.html
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,42 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<script src="../media-controls.js"></script> | ||
<style> | ||
::cue { font-size: 24px; } | ||
</style> | ||
<video src="../content/test.ogv" width="640"></video> | ||
<script> | ||
|
||
function animationFrame() { | ||
return new Promise(resolve => { requestAnimationFrame(resolve); }); | ||
} | ||
|
||
promise_test(async () => { | ||
let v = document.querySelector('video'); | ||
let track = v.addTextTrack('subtitles', 'label', 'en'); | ||
track.mode = 'showing'; | ||
let cue0 = new VTTCue(1, 60, 'First subtitle'); | ||
cue0.line = -3; | ||
track.addCue(cue0); | ||
let cue1 = new VTTCue(1, 60, 'Second subtitle'); | ||
cue1.line = -2; | ||
track.addCue(cue1); | ||
let cue2 = new VTTCue(1, 60, 'Third subtitle'); | ||
cue2.line = -1; | ||
track.addCue(cue2); | ||
|
||
v.currentTime = 3; | ||
await new Promise(resolve => { v.addEventListener('seeked', resolve, {once:true}); }); | ||
v.controls = false; | ||
await animationFrame(); | ||
await animationFrame(); | ||
// Now cues are shown. | ||
let top0 = textTrackCueElementByIndex(v, 0).offsetTop; | ||
let top1 = textTrackCueElementByIndex(v, 1).offsetTop; | ||
let top2 = textTrackCueElementByIndex(v, 2).offsetTop; | ||
assert_true(top0<top1, 'subtitle 1 is above subtitle 2'); | ||
assert_true(top1<top2, 'subtitle 2 is above subtitle 3'); | ||
}, 'Cues with negative line numbers should be displayed in order'); | ||
</script> |
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