Skip to content

VTT cue positioning algorithm should use floats instead of ints#69427

Open
danae404 wants to merge 1 commit into
WebKit:mainfrom
danae404:eng/VTT-cue-positioning-algorithm-should-use-floats-instead-of-ints
Open

VTT cue positioning algorithm should use floats instead of ints#69427
danae404 wants to merge 1 commit into
WebKit:mainfrom
danae404:eng/VTT-cue-positioning-algorithm-should-use-floats-instead-of-ints

Conversation

@danae404

@danae404 danae404 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

39c2c06

VTT cue positioning algorithm should use floats instead of ints
https://bugs.webkit.org/show_bug.cgi?id=319433
rdar://182250995

Reviewed by NOBODY (OOPS!).

Currently, WebKit fails WebVTT WPT 2_cues_overlapping_partially_move_up.html
and 2_cues_overlapping_partially_move_down.html. These tests check that when
a VTT file uses the line setting to position cues such that they overlap,
the browser moves the second cue as minimally as possible so that they do not overlap.

The rendered cues' top and bottom edges should be flush with each other, since the spec
expects the cue to be moved minimally and makes no indication that we should be
rounding to the nearest integer. However, WebKit's rendering of these vtt files
puts a gap between the two cues. This is caused by our use of integers in RenderVTTCue.
We should instead use floats.

No new test expectations due to bugs in the wpt tests that cause us to still fail them.
One a future patch fixes the tests the expectations will be updated.

* Source/WebCore/rendering/RenderVTTCue.cpp:
(WebCore::RenderVTTCue::unroundedAbsoluteBoundingBoxRect):
(WebCore::RenderVTTCue::isOutside const):
(WebCore::RenderVTTCue::rectIsWithinContainer const):
(WebCore::RenderVTTCue::overlappingObject const):
(WebCore::RenderVTTCue::overlappingObjectForRect const):
(WebCore::RenderVTTCue::moveIfNecessaryToKeepWithinContainer):
(WebCore::RenderVTTCue::findNonOverlappingPosition const):
(WebCore::RenderVTTCue::repositionCueSnapToLinesNotSet):
* Source/WebCore/rendering/RenderVTTCue.h:

39c2c06

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win loading 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests loading 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe loading 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ⏳ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
⏳ 🛠 ios-safer-cpp ⏳ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 api-gtk
✅ 🛠 vision-sim ⏳ 🧪 mac-intel-wk2 ⏳ 🛠 playstation
✅ 🧪 vision-wk2 ⏳ 🛠 mac-safer-cpp
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@danae404 danae404 self-assigned this Jul 15, 2026
@danae404 danae404 added the Media Bugs related to the HTML 5 Media elements. label Jul 15, 2026
@danae404 danae404 force-pushed the eng/VTT-cue-positioning-algorithm-should-use-floats-instead-of-ints branch from 7a4e3f1 to 32413eb Compare July 15, 2026 00:19
https://bugs.webkit.org/show_bug.cgi?id=319433
rdar://182250995

Reviewed by NOBODY (OOPS!).

Currently, WebKit fails WebVTT WPT 2_cues_overlapping_partially_move_up.html
and 2_cues_overlapping_partially_move_down.html. These tests check that when
a VTT file uses the line setting to position cues such that they overlap,
the browser moves the second cue as minimally as possible so that they do not overlap.

The rendered cues' top and bottom edges should be flush with each other, since the spec
expects the cue to be moved minimally and makes no indication that we should be
rounding to the nearest integer. However, WebKit's rendering of these vtt files
puts a gap between the two cues. This is caused by our use of integers in RenderVTTCue.
We should instead use floats.

No new test expectations due to bugs in the wpt tests that cause us to still fail them.
One a future patch fixes the tests the expectations will be updated.

* Source/WebCore/rendering/RenderVTTCue.cpp:
(WebCore::RenderVTTCue::unroundedAbsoluteBoundingBoxRect):
(WebCore::RenderVTTCue::isOutside const):
(WebCore::RenderVTTCue::rectIsWithinContainer const):
(WebCore::RenderVTTCue::overlappingObject const):
(WebCore::RenderVTTCue::overlappingObjectForRect const):
(WebCore::RenderVTTCue::moveIfNecessaryToKeepWithinContainer):
(WebCore::RenderVTTCue::findNonOverlappingPosition const):
(WebCore::RenderVTTCue::repositionCueSnapToLinesNotSet):
* Source/WebCore/rendering/RenderVTTCue.h:
@danae404 danae404 force-pushed the eng/VTT-cue-positioning-algorithm-should-use-floats-instead-of-ints branch from 32413eb to 39c2c06 Compare July 15, 2026 00:25
@danae404 danae404 requested a review from a team July 15, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Media Bugs related to the HTML 5 Media elements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants