Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ruby in WebVTT are not rendered correctly
https://bugs.webkit.org/show_bug.cgi?id=262064 rdar://116011365 Reviewed by Jer Noble and Eric Carlson. This patch creates a new class WebVTTRubyElement, a subclass of WebVTTElementImpl And RubyElement. Now, each ruby tag in a VTT is associated with a WebVTTRubyElement, Which has access to RubyElement::createElementRenderer() to render it appropriately. Added a layout test to check that ruby elements in WebVTT cues are positioned correctly. * LayoutTests/media/track/captions-webvtt/ruby.vtt: Added. * LayoutTests/media/track/webvtt-ruby.html: Added. * LayoutTests/media/track/webvtt-ruby-expected.txt: Added. * Source/WebCore/css/SelectorCheckerTestFunctions.h: (WebCore::matchesLangPseudoClass): (WebCore::matchesFutureCuePseudoClass): (WebCore::matchesPastCuePseudoClass): * Source/WebCore/dom/Node.h: (WebCore::Node::isWebVTTRubyElement const): (WebCore::Node::isWebVTTRubyTextElement const): * Source/WebCore/html/RubyElement.h: (): Deleted. * Source/WebCore/html/RubyTextElement.h: (): Deleted. * Source/WebCore/html/track/VTTCue.cpp: (WebCore::VTTCue::markFutureAndPastNodes): * Source/WebCore/html/track/WebVTTElement.cpp: (WebCore::WebVTTElement::WebVTTElement): (WebCore::WebVTTElementImpl::create): (WebCore::WebVTTElementImpl::cloneElementWithoutAttributesAndChildren): (WebCore::WebVTTElementImpl::createEquivalentHTMLElement): (WebCore::WebVTTElement::create): Deleted. (WebCore::WebVTTElement::cloneElementWithoutAttributesAndChildren): Deleted. (WebCore::WebVTTElement::createEquivalentHTMLElement): Deleted. * Source/WebCore/html/track/WebVTTElement.h: (WebCore::WebVTTElementImpl::WebVTTElementImpl): (isType): * Source/WebCore/html/track/WebVTTParser.cpp: (WebCore::WebVTTTreeBuilder::currentType const): (WebCore::WebVTTTreeBuilder::buildFromString): (WebCore::WebVTTTreeBuilder::constructTreeFromToken): * Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp: (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride const): * Source/WebCore/style/ElementRuleCollector.cpp: (WebCore::Style::ElementRuleCollector::collectMatchingShadowPseudoElementRules): Canonical link: https://commits.webkit.org/268746@main
- Loading branch information
Showing
13 changed files
with
218 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
WEBVTT | ||
00:00:00.000 --> 00:00:05.000 align:left | ||
This is a ruby <ruby>base<rt>ruby</rt></ruby> |
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,12 @@ | ||
|
||
EVENT(canplay) | ||
EVENT(addtrack) | ||
EXPECTED (video.textTracks.length == '1') OK | ||
RUN(video.textTracks[0].mode = 'showing') | ||
RUN(video.currentTime = 1) | ||
EVENT(seeked) | ||
EXPECTED (window.internals.shadowRoot(video).querySelector('rt') != 'null') OK | ||
EXPECTED (rubyText.offsetTop < rubyBase.offsetTop == 'true') OK | ||
EXPECTED (rubyBase.offsetTop == (rubyText.offsetTop + rubyText.offsetHeight) == 'true') OK | ||
END OF TEST | ||
|
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,38 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>WebVTTRubyText elements should appear above WebVTTRuby elements</title> | ||
<script src=../../resources/js-test-pre.js></script> | ||
<script src=../video-test.js></script> | ||
<script src=../media-file.js></script> | ||
<script> | ||
async function runTest() | ||
{ | ||
video = document.getElementById('video'); | ||
video.src = findMediaFile('video', '../content/test'); | ||
await waitFor(video, 'canplay'); | ||
let track = document.createElement('track'); | ||
track.src = 'captions-webvtt/ruby.vtt'; | ||
video.appendChild(track) | ||
|
||
await waitFor(video.textTracks, 'addtrack'); | ||
testExpected("video.textTracks.length", 1); | ||
run("video.textTracks[0].mode = 'showing'"); | ||
|
||
run("video.currentTime = 1"); | ||
await waitFor(video, 'seeked'); | ||
|
||
window.internals.ensureUserAgentShadowRoot(video); | ||
await testExpectedEventually("window.internals.shadowRoot(video).querySelector('rt')", null, "!=", 1000); | ||
rubyBase = window.internals.shadowRoot(video).querySelector('ruby'); | ||
rubyText = window.internals.shadowRoot(video).querySelector('rt'); | ||
await testExpected("rubyText.offsetTop < rubyBase.offsetTop", true); | ||
await testExpected("rubyBase.offsetTop == (rubyText.offsetTop + rubyText.offsetHeight)", true); | ||
endTest(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="runTest()"> | ||
<video id="video" width="320px" height="240px" paused></video> | ||
</body> | ||
</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
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
Oops, something went wrong.