[webvtt] use actual cue box height as a step to adjust cue's position
Categories
(Core :: Audio/Video: Playback, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: alwu, Assigned: alwu)
References
(Blocks 2 open bugs)
Details
Attachments
(5 files, 3 obsolete files)
Now we're using font size as a step to adjust cue's position. However, it would cause accumulated error because there is a difference (< 1px) between the font size and the cue box's height.
In this bug, we should do
(1) use actual cue box's height as a positioning step
(2) get the correct line height when the cue text are wrapped into multiple line
(3) get the correct line height when applying CSS transformation
Assignee | ||
Comment 1•6 years ago
|
||
Now I'm trying to find the correct fuzzy
threshold for those tests we will enable in this bug, because there are some weird white pixel color difference (difference <2 per channel) in the background.
Assignee | ||
Comment 2•6 years ago
|
||
There is a tiny difference between font size and actual line box height, we should use actual line box's height or width to adjust cue's position in order to eliminate the positioning error.
As we use line's bounding box height, we should also consider the effect which CSS scale brings, because the bounding box which we get have already been applied transformation (eg. scaled).
Therefore, we would use the unscaled bounding box length to do the calculation.
In addition, when the text is wrapped into multiple lines due to the line box is not large enough to show all text in the single line, we would calculate what the single line box height is.
Assignee | ||
Comment 3•6 years ago
|
||
Assignee | ||
Comment 4•6 years ago
|
||
Sometime there would be some color rendering differences between the test and the reference, which is small enough to be ignored because human can't aware that difference.
Assignee | ||
Comment 5•6 years ago
|
||
Now these two tests would permanently fail, not being timeout.
Assignee | ||
Comment 6•6 years ago
|
||
There two tests should be permanently fail now.
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 7•6 years ago
|
||
There is a weird fail that the white video frame would be rendered to black, it's Android only fail. I've filed bug1546128 for investigation.
Assignee | ||
Comment 8•6 years ago
|
||
There are two problems we have to do in this bug.
- Find correct height of the cue box
As we are usingfont
size as the cue box's height, but it has a difference from the real box height, which causes having a small positioning difference and resulted in the wpt ref test failures.
Therefore, we should use the actual box's size for positioning. There are three attributes we might use, offsetHeight
, clientHeight
and bounding box's height
. It seems that we should use the bounding box's height, however, it's value would be affected by CSS transformation, we can only get the adjusted value.
Using adjusted value would cause incorrect result, so we would like to have a value which is not affected by any CSS tranformation. So we should consider offsetHeight
or clientHeight
. According to [1], clientHeight
seems what we eager for.
However, during testing, I found that sometime the clientHeight
is not equal to the actual box's height, there would have a tiny difference. After some investigate, I finally found that the difference is just because clientHeight
we return is integer [2], not double!
After discussed with :heycam, I am going to add new chrome-only APIs to get the double version clientHeight
and clientWidth
.
- Get the single line height
As cue box might contain multiple line, using the cue box's height directly as a basic positioning unit is wrong. We should find the single line and get its height.
The spec said [3]
Let step be the heigh or width of the first line box in boxes
We can use getClientRects()
to get the independent line boxes, and then use the first box's height as a basic unit.
[1] https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements
[2] https://searchfox.org/mozilla-central/rev/f0ef51bfafc8ad0c3a2f523bf076edc57dc4891a/dom/base/Element.h#1277
[3] See step2, https://www.w3.org/TR/webvtt1/#ref-for-webvtt-cue-snap-to-lines-flag-12
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 9•6 years ago
|
||
According to the spec [1] 7.2.10.2, we should use the first line box's height or width as positioning unit to adjust box's position.
We will also use this value to adjust box when snap-to-line
is false.
There, we implement a new chrome-only API to acquire this information, which would return the first line box's size in the block
frame.
[1] https://www.w3.org/TR/webvtt1/#ref-for-webvtt-cue-snap-to-lines-flag-12
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 10•6 years ago
|
||
When adjusting box's position, we would choose a axis first and move the box along this axis to see whether we can place this box without overlapping with other boxes and fully inside the rendering area.
If the box has been over the boundary along the moving direction, we should move box back to the original position and change the moving direction to see whether we can find another best place for the box.
Although the adjustment can run without timeout now, it still doesn't match the result of the reference, so change the state to fail
.
Assignee | ||
Comment 11•6 years ago
|
||
In order to prevent causing any fail, push patches to try server after rebasing, and the result [1] looks good.
Comment 12•6 years ago
|
||
Comment 13•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2d810269b72e
https://hg.mozilla.org/mozilla-central/rev/1fa720d18b38
https://hg.mozilla.org/mozilla-central/rev/9250cfd8c4e4
https://hg.mozilla.org/mozilla-central/rev/f009e75ac871
https://hg.mozilla.org/mozilla-central/rev/f40e952d1552
Assignee | ||
Updated•6 years ago
|
Description
•