Changeset 270738 in webkit
- Timestamp:
- Dec 12, 2020 11:39:51 AM (19 months ago)
- Location:
- trunk
- Files:
-
- 28 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt (modified) (1 diff)
-
LayoutTests/media/track/captions-webvtt/header-regions.vtt (modified) (1 diff)
-
LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt (modified) (1 diff)
-
LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute.html (modified) (3 diffs)
-
LayoutTests/media/track/regions-webvtt/vtt-region-parser-expected.txt (modified) (1 diff)
-
LayoutTests/media/track/regions-webvtt/vtt-region-parser.html (modified) (1 diff)
-
LayoutTests/media/track/track-add-remove-cue-expected.txt (modified) (2 diffs)
-
LayoutTests/media/track/track-add-remove-cue.html (modified) (2 diffs)
-
LayoutTests/media/track/track-cue-mutable-expected.txt (modified) (4 diffs)
-
LayoutTests/media/track/track-cue-mutable.html (modified) (4 diffs)
-
LayoutTests/media/track/track-vttcue-expected.txt (modified) (2 diffs)
-
LayoutTests/media/track/track-vttcue.html (modified) (2 diffs)
-
LayoutTests/media/track/track-webvtt-tc013-settings-expected.txt (modified) (2 diffs)
-
LayoutTests/media/track/track-webvtt-tc013-settings.html (modified) (2 diffs)
-
LayoutTests/media/track/track-webvtt-tc017-line-position-expected.txt (modified) (1 diff)
-
LayoutTests/media/track/track-webvtt-tc017-line-position.html (modified) (1 diff)
-
LayoutTests/media/track/track-webvtt-tc018-align-text-line-position-expected.txt (modified) (1 diff)
-
LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp (modified) (1 diff)
-
Source/WebCore/html/track/TextTrackCueGeneric.cpp (modified) (4 diffs)
-
Source/WebCore/html/track/TextTrackCueGeneric.h (modified) (1 diff)
-
Source/WebCore/html/track/VTTCue.cpp (modified) (15 diffs)
-
Source/WebCore/html/track/VTTCue.h (modified) (10 diffs)
-
Source/WebCore/html/track/VTTCue.idl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270735 r270738 1 2020-12-12 Frank Olivier <frankolivier@apple.com> 2 3 Implement WebVTT VTTCue region attribute 4 https://bugs.webkit.org/show_bug.cgi?id=168716 5 6 Updated VTTCue to current IDL 7 8 Reviewed by Eric Carlson. 9 10 * media/track/captions-webvtt/header-regions.vtt: 11 * media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt: 12 * media/track/regions-webvtt/text-track-cue-region-attribute.html: 13 * media/track/regions-webvtt/vtt-region-parser-expected.txt: 14 * media/track/regions-webvtt/vtt-region-parser.html: 15 * media/track/track-add-remove-cue-expected.txt: 16 * media/track/track-add-remove-cue.html: 17 * media/track/track-cue-container-rendering-position.html: 18 * media/track/track-cue-mutable-expected.txt: 19 * media/track/track-cue-mutable.html: 20 * media/track/track-vttcue-expected.txt: 21 * media/track/track-vttcue.html: 22 * media/track/track-webvtt-tc013-settings-expected.txt: 23 * media/track/track-webvtt-tc013-settings.html: 24 * media/track/track-webvtt-tc017-line-position-expected.txt: 25 * media/track/track-webvtt-tc017-line-position.html: 26 * media/track/track-webvtt-tc018-align-text-line-position-expected.txt: 27 * media/track/track-webvtt-tc018-align-text-line-position.html: 28 1 29 2020-12-12 Diego Pino Garcia <dpino@igalia.com> 2 30 -
trunk/LayoutTests/imported/w3c/ChangeLog
r270702 r270738 1 2020-12-12 Frank Olivier <frankolivier@apple.com> 2 3 Implement WebVTT VTTCue region attribute 4 https://bugs.webkit.org/show_bug.cgi?id=168716 5 6 Reviewed by Eric Carlson. 7 8 * web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt: 9 * web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt: 10 1 11 2020-12-11 Alexey Shvayka <shvaikalesh@gmail.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt
r242549 r270738 1 1 2 2 3 FAIL Cue alignment, line and text position from settings assert_equals: expected (string) "auto" but got (number) -1 3 PASS Cue alignment, line and text position from settings 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt
r242549 r270738 1 1 2 2 3 FAIL Cue line position from settings assert_equals: expected (string) "auto" but got (number) -1 3 PASS Cue line position from settings 4 4 -
trunk/LayoutTests/media/track/captions-webvtt/header-regions.vtt
r237270 r270738 29 29 : Invalid Header 30 30 31 REGION 32 id:someregionattributeid 33 31 34 1 32 35 00:00:00.000 --> 00:00:02.500 region:someregionattributeid -
trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt
r165867 r270738 1 Tests the region Idattribute of a cue.1 Tests the region attribute of a cue. 2 2 3 3 4 EXPECTED (!!window.VTTRegion == 'true') OK 4 5 5 6 ** Test the setter and getter through the JS API ** 6 EXPECTED (cue.regionId == '') OK 7 EXPECTED (cue.regionId == 'someId') OK 7 EXPECTED (cue.region == 'null') OK 8 8 9 9 ** Test parsing a region attribute of a cue ** 10 EXPECTED ( cue.regionId == 'someregionattributeid') OK10 EXPECTED (typeof cue.region == 'object') OK 11 11 12 12 ** Test that region attribute is ignored if either line position or cue size are specified or writing direction is not horizontal ** 13 EXPECTED (cue.region Id == '') OK14 EXPECTED (cue.region Id == '') OK15 EXPECTED (cue.region Id == '') OK13 EXPECTED (cue.region == 'null') OK 14 EXPECTED (cue.region == 'null') OK 15 EXPECTED (cue.region == 'null') OK 16 16 17 17 END OF TEST -
trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute.html
r204765 r270738 11 11 function startTest() 12 12 { 13 if (!window.VTTRegion) { 14 failTest(); 15 return; 16 } 13 testExpected("!!window.VTTRegion", true); 17 14 18 15 consoleWrite("<br>** Test the setter and getter through the JS API **"); 19 16 cue = new VTTCue(0.0, 1.0, "sample"); 20 17 21 testExpected("cue.regionId", ""); 22 cue.regionId = "someId"; 23 testExpected("cue.regionId", "someId"); 18 testExpected("cue.region", null); 24 19 25 20 consoleWrite("<br>** Test parsing a region attribute of a cue **"); … … 27 22 28 23 cue = video.textTracks[0].cues[0]; 29 testExpected(" cue.regionId", "someregionattributeid");24 testExpected("typeof cue.region", "object"); 30 25 31 26 consoleWrite("<br>** Test that region attribute is ignored if either line position or cue size are specified or writing direction is not horizontal **"); 32 27 for (i = 1; i < 4; ++i) { 33 28 cue = video.textTracks[0].cues[i]; 34 testExpected("cue.region Id", "");29 testExpected("cue.region", null); 35 30 } 36 31 … … 43 38 </head> 44 39 <body> 45 <p>Tests the region Idattribute of a cue.</p>40 <p>Tests the region attribute of a cue.</p> 46 41 <video controls> 47 42 <track src="../captions-webvtt/header-regions.vtt" kind="captions" default onload="startTest()"> -
trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser-expected.txt
r236403 r270738 2 2 3 3 4 EXPECTED (video.textTracks[0].regions.length == ' 4') OK4 EXPECTED (video.textTracks[0].regions.length == '5') OK 5 5 6 6 EXPECTED (region.id == 'region_without_settings') OK -
trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser.html
r236403 r270738 17 17 18 18 findMediaElement(); 19 testExpected("video.textTracks[0].regions.length", 4);19 testExpected("video.textTracks[0].regions.length", 5); 20 20 21 21 consoleWrite(""); -
trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt
r236531 r270738 20 20 EXPECTED (textCue.vertical == '') OK 21 21 EXPECTED (textCue.snapToLines == 'true') OK 22 EXPECTED (textCue.line == ' -1') OK22 EXPECTED (textCue.line == 'auto') OK 23 23 EXPECTED (textCue.position == 'auto') OK 24 24 EXPECTED (textCue.size == '100') OK … … 43 43 EXPECTED (newCue.vertical == '') OK 44 44 EXPECTED (newCue.snapToLines == 'true') OK 45 EXPECTED (newCue.line == ' -1') OK45 EXPECTED (newCue.line == 'auto') OK 46 46 EXPECTED (newCue.position == 'auto') OK 47 47 EXPECTED (newCue.size == '100') OK -
trunk/LayoutTests/media/track/track-add-remove-cue.html
r236531 r270738 32 32 testExpected("textCue.vertical", ""); 33 33 testExpected("textCue.snapToLines", true); 34 testExpected("textCue.line", -1);34 testExpected("textCue.line", 'auto'); 35 35 testExpected("textCue.position", 'auto'); 36 36 testExpected("textCue.size", 100); … … 57 57 testExpected("newCue.vertical", ""); 58 58 testExpected("newCue.snapToLines", true); 59 testExpected("newCue.line", -1);59 testExpected("newCue.line", 'auto'); 60 60 testExpected("newCue.position", 'auto'); 61 61 testExpected("newCue.size", 100); -
trunk/LayoutTests/media/track/track-cue-mutable-expected.txt
r236531 r270738 9 9 EXPECTED (textCue.vertical == '') OK 10 10 EXPECTED (textCue.snapToLines == 'true') OK 11 EXPECTED (textCue.line == ' -1') OK11 EXPECTED (textCue.line == 'auto') OK 12 12 EXPECTED (textCue.position == 'auto') OK 13 13 EXPECTED (textCue.size == '100') OK … … 23 23 RUN(textCue.pauseOnExit = true) 24 24 EXPECTED (textCue.pauseOnExit == 'true') OK 25 26 On setting, the text track cue writing direction must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.27 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical28 TEST(textCue.vertical = 'RL') THROWS(DOMException.SYNTAX_ERR) OK29 25 EXPECTED (textCue.vertical == '') OK 30 26 RUN(textCue.vertical = 'rl') … … 33 29 RUN(textCue.snapToLines = false) 34 30 EXPECTED (textCue.snapToLines == 'false') OK 35 36 On setting, if the text track cue snap-to-lines flag is not set, and the new value is negative or greater than 100, then throw an IndexSizeError exception.37 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line38 TEST(textCue.line = -2) THROWS(DOMException.INDEX_SIZE_ERR) OK39 TEST(textCue.line = 102) THROWS(DOMException.INDEX_SIZE_ERR) OK40 EXPECTED (textCue.line == '-1') OK41 31 RUN(textCue.line = 42) 42 32 EXPECTED (textCue.line == '42') OK … … 60 50 RUN(textCue.size = 57) 61 51 EXPECTED (textCue.size == '57') OK 62 63 On setting, the text track cue alignment must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception. 64 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align 65 TEST(textCue.align = 'End') THROWS(DOMException.SYNTAX_ERR) OK 52 RUN(textCue.align = 'End') 66 53 EXPECTED (textCue.align == 'center') OK 67 54 RUN(textCue.align = 'end') -
trunk/LayoutTests/media/track/track-cue-mutable.html
r236531 r270738 29 29 testExpected("textCue.vertical", ""); 30 30 testExpected("textCue.snapToLines", true); 31 testExpected("textCue.line", -1);31 testExpected("textCue.line", 'auto'); 32 32 testExpected("textCue.position", 'auto'); 33 33 testExpected("textCue.size", 100); … … 47 47 testExpected("textCue.pauseOnExit", true); 48 48 49 logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical", 50 "On setting, the text track cue writing direction must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception."); 51 testDOMException("textCue.vertical = 'RL'", "DOMException.SYNTAX_ERR"); 49 textCue.vertical = 'xyz'; 52 50 testExpected("textCue.vertical", ""); 53 51 run("textCue.vertical = 'rl'"); … … 58 56 testExpected("textCue.snapToLines", false); 59 57 60 logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line",61 "On setting, if the text track cue snap-to-lines flag is not set, and the new value is negative or greater than 100, then throw an IndexSizeError exception.");62 testDOMException("textCue.line = -2", "DOMException.INDEX_SIZE_ERR");63 testDOMException("textCue.line = 102", "DOMException.INDEX_SIZE_ERR");64 testExpected("textCue.line", -1);65 58 run("textCue.line = 42"); 66 59 testExpected("textCue.line", 42); … … 85 78 testExpected("textCue.size", 57); 86 79 87 logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align", 88 "On setting, the text track cue alignment must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception."); 89 testDOMException("textCue.align = 'End'", "DOMException.SYNTAX_ERR"); 80 run("textCue.align = 'End'"); 90 81 testExpected("textCue.align", "center"); 91 82 run("textCue.align = 'end'"); -
trunk/LayoutTests/media/track/track-vttcue-expected.txt
r236531 r270738 14 14 EXPECTED (trackCue.vertical == '') OK 15 15 EXPECTED (trackCue.snapToLines == 'true') OK 16 EXPECTED (trackCue.line == ' -1') OK16 EXPECTED (trackCue.line == 'auto') OK 17 17 EXPECTED (trackCue.position == 'auto') OK 18 18 EXPECTED (trackCue.size == '100') OK … … 32 32 EXPECTED (newCue.vertical == '') OK 33 33 EXPECTED (newCue.snapToLines == 'true') OK 34 EXPECTED (newCue.line == ' -1') OK34 EXPECTED (newCue.line == 'auto') OK 35 35 EXPECTED (newCue.position == 'auto') OK 36 36 EXPECTED (newCue.size == '100') OK -
trunk/LayoutTests/media/track/track-vttcue.html
r236531 r270738 33 33 testExpected("trackCue.vertical", ""); 34 34 testExpected("trackCue.snapToLines", true); 35 testExpected("trackCue.line", -1);35 testExpected("trackCue.line", 'auto'); 36 36 testExpected("trackCue.position", 'auto'); 37 37 testExpected("trackCue.size", 100); … … 53 53 testExpected("newCue.vertical", ""); 54 54 testExpected("newCue.snapToLines", true); 55 testExpected("newCue.line", -1);55 testExpected("newCue.line", 'auto'); 56 56 testExpected("newCue.position", 'auto'); 57 57 testExpected("newCue.size", 100); -
trunk/LayoutTests/media/track/track-webvtt-tc013-settings-expected.txt
r236531 r270738 13 13 EXPECTED (cues[1].align == 'center') OK 14 14 EXPECTED (cues[1].vertical == 'rl') OK 15 EXPECTED (cues[2].line == ' -1') OK15 EXPECTED (cues[2].line == 'auto') OK 16 16 EXPECTED (cues[2].position == '10') OK 17 17 EXPECTED (cues[2].align == 'center') OK … … 28 28 EXPECTED (cues[0].align == 'center') OK 29 29 EXPECTED (cues[0].vertical == '') OK 30 EXPECTED (cues[1].line == ' -1') OK30 EXPECTED (cues[1].line == 'auto') OK 31 31 EXPECTED (cues[1].position == '50') OK 32 32 EXPECTED (cues[1].align == 'end') OK 33 33 EXPECTED (cues[1].vertical == '') OK 34 EXPECTED (cues[2].line == ' -1') OK34 EXPECTED (cues[2].line == 'auto') OK 35 35 EXPECTED (cues[2].position == 'auto') OK 36 36 EXPECTED (cues[2].align == 'center') OK 37 37 EXPECTED (cues[2].vertical == '') OK 38 EXPECTED (cues[3].line == ' -1') OK38 EXPECTED (cues[3].line == 'auto') OK 39 39 EXPECTED (cues[3].position == '90') OK 40 40 EXPECTED (cues[3].align == 'center') OK -
trunk/LayoutTests/media/track/track-webvtt-tc013-settings.html
r236531 r270738 30 30 { 31 31 property : "line", 32 values : [100, 15, -1, 95],32 values : [100, 15, 'auto', 95], 33 33 }, 34 34 { … … 52 52 { 53 53 property : "line", 54 values : [43, -1, -1, -1],54 values : [43, 'auto', 'auto', 'auto'], 55 55 }, 56 56 { -
trunk/LayoutTests/media/track/track-webvtt-tc017-line-position-expected.txt
r170694 r270738 22 22 *** Testing text track 1 23 23 EXPECTED (cues.length == '6') OK 24 EXPECTED (cues[0].line == ' -1') OK24 EXPECTED (cues[0].line == 'auto') OK 25 25 EXPECTED (cues[0].snapToLines == 'true') OK 26 EXPECTED (cues[1].line == ' -1') OK26 EXPECTED (cues[1].line == '0.5'), OBSERVED 'auto' FAIL 27 27 EXPECTED (cues[1].snapToLines == 'true') OK 28 EXPECTED (cues[2].line == ' -1') OK28 EXPECTED (cues[2].line == 'auto') OK 29 29 EXPECTED (cues[2].snapToLines == 'true') OK 30 EXPECTED (cues[3].line == ' -1') OK30 EXPECTED (cues[3].line == 'auto') OK 31 31 EXPECTED (cues[3].snapToLines == 'true') OK 32 EXPECTED (cues[4].line == ' -1') OK32 EXPECTED (cues[4].line == 'auto') OK 33 33 EXPECTED (cues[4].snapToLines == 'true') OK 34 EXPECTED (cues[5].line == ' -1') OK34 EXPECTED (cues[5].line == 'auto') OK 35 35 EXPECTED (cues[5].snapToLines == 'true') OK 36 36 END OF TEST -
trunk/LayoutTests/media/track/track-webvtt-tc017-line-position.html
r170694 r270738 53 53 { 54 54 property : "line", 55 values : [ -1, -1, -1, -1, -1, -1, -1],55 values : ['auto', 0.5, 'auto', 'auto', 'auto', 'auto', 'auto'], 56 56 }, 57 57 { -
trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position-expected.txt
r236531 r270738 30 30 EXPECTED (cues[0].align == 'center') OK 31 31 EXPECTED (cues[0].position == 'auto') OK 32 EXPECTED (cues[0].line == ' -1') OK32 EXPECTED (cues[0].line == 'auto') OK 33 33 EXPECTED (cues[0].snapToLines == 'true') OK 34 34 EXPECTED (cues[1].align == 'end') OK 35 35 EXPECTED (cues[1].position == '0') OK 36 EXPECTED (cues[1].line == ' -1') OK36 EXPECTED (cues[1].line == 'auto') OK 37 37 EXPECTED (cues[1].snapToLines == 'true') OK 38 38 EXPECTED (cues[2].align == 'center') OK -
trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html
r236531 r270738 71 71 { 72 72 property : "line", 73 values : [ -1, -1, -3],73 values : ['auto', 'auto', -3], 74 74 }, 75 75 { -
trunk/Source/WebCore/ChangeLog
r270737 r270738 1 2020-12-12 Frank Olivier <frankolivier@apple.com> 2 3 Implement WebVTT VTTCue region attribute 4 https://bugs.webkit.org/show_bug.cgi?id=168716 5 6 Reviewed by Eric Carlson. 7 8 Updated existing region tests. 9 10 * WebCore.xcodeproj/project.pbxproj: 11 * html/shadow/MediaControlTextTrackContainerElement.cpp: 12 (WebCore::MediaControlTextTrackContainerElement::processActiveVTTCue): 13 * html/track/TextTrackCueGeneric.cpp: 14 (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): 15 (WebCore::TextTrackCueGeneric::setLine): 16 * html/track/TextTrackCueGeneric.h: 17 * html/track/VTTCue.cpp: 18 (WebCore::horizontalKeyword): 19 (WebCore::lineLeftKeyword): 20 (WebCore::lineRightKeyword): 21 (WebCore::autoKeyword): 22 (WebCore::VTTCueBox::applyCSSProperties): 23 (WebCore::VTTCue::setVertical): 24 (WebCore::VTTCue::line const): 25 (WebCore::VTTCue::setLine): 26 (WebCore::VTTCue::lineAlign const): 27 (WebCore::VTTCue::setLineAlign): 28 (WebCore::VTTCue::positionAlign const): 29 (WebCore::VTTCue::setPositionAlign): 30 (WebCore::VTTCue::setAlign): 31 (WebCore::VTTCue::setTrack): 32 (WebCore::VTTCue::setRegion): 33 (WebCore::VTTCue::region): 34 (WebCore::VTTCue::regionId): 35 (WebCore::VTTCue::calculateComputedLinePosition): 36 (WebCore::VTTCue::getDisplayTree): 37 (WebCore::VTTCue::removeDisplayTree): 38 (WebCore::VTTCue::settingName): 39 (WebCore::VTTCue::setCueSettings): 40 (WebCore::VTTCue::toJSON const): 41 (WebCore::VTTCue::setRegionId): Deleted. 42 * html/track/VTTCue.h: 43 (WebCore::VTTCue::line const): Deleted. 44 (WebCore::VTTCue::regionId const): Deleted. 45 * html/track/VTTCue.idl: 46 * rendering/RenderVTTCue.cpp: 47 (WebCore::RenderVTTCue::layout): 48 1 49 2020-12-12 Simon Fraser <simon.fraser@apple.com> 2 50 -
trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp
r269323 r270738 201 201 void MediaControlTextTrackContainerElement::processActiveVTTCue(VTTCue& cue) 202 202 { 203 DEBUG_LOG(LOGIDENTIFIER, "adding and positioning cue: \"", cue.text(), "\", start=", cue.startTime(), ", end=", cue.endTime() , ", line=", cue.line());203 DEBUG_LOG(LOGIDENTIFIER, "adding and positioning cue: \"", cue.text(), "\", start=", cue.startTime(), ", end=", cue.endTime()); 204 204 Ref<TextTrackCueBox> displayBox = *cue.getDisplayTree(m_videoDisplaySize.size(), m_fontSize); 205 205 -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp
r267074 r270738 85 85 86 86 double textPosition = cue->calculateComputedTextPosition(); 87 double linePosition = cue->calculateComputedLinePosition(); 87 88 88 89 CSSValueID alignment = cue->getCSSAlignment(); … … 93 94 } else { 94 95 setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(textPosition), CSSUnitType::CSS_PERCENTAGE); 95 setInlineStyleProperty(CSSPropertyTop, static_cast<float>( cue->line()), CSSUnitType::CSS_PERCENTAGE);96 setInlineStyleProperty(CSSPropertyTop, static_cast<float>(linePosition), CSSUnitType::CSS_PERCENTAGE); 96 97 97 98 double authorFontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100.0; … … 111 112 setInlineStyleProperty(CSSPropertyHeight, newCueSize, CSSUnitType::CSS_PERCENTAGE); 112 113 if ((alignment == CSSValueMiddle || alignment == CSSValueCenter) && multiplier != 1.0) 113 setInlineStyleProperty(CSSPropertyTop, static_cast<double>( cue->line()- (newCueSize - cue->getCSSSize()) / 2), CSSUnitType::CSS_PERCENTAGE);114 setInlineStyleProperty(CSSPropertyTop, static_cast<double>(linePosition - (newCueSize - cue->getCSSSize()) / 2), CSSUnitType::CSS_PERCENTAGE); 114 115 } 115 116 } … … 175 176 } 176 177 177 ExceptionOr<void> TextTrackCueGeneric::setLine( doubleline)178 ExceptionOr<void> TextTrackCueGeneric::setLine(const LineAndPositionSetting& line) 178 179 { 179 180 auto result = VTTCue::setLine(line); -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.h
r262695 r270738 39 39 WEBCORE_EXPORT static Ref<TextTrackCueGeneric> create(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String& content); 40 40 41 ExceptionOr<void> setLine( double) final;41 ExceptionOr<void> setLine(const LineAndPositionSetting&) final; 42 42 ExceptionOr<void> setPosition(const LineAndPositionSetting&) final; 43 43 -
trunk/Source/WebCore/html/track/VTTCue.cpp
r267074 r270738 124 124 } 125 125 126 static const String& lineLeftKeyword() 127 { 128 static NeverDestroyed<const String> lineLeft(MAKE_STATIC_STRING_IMPL("line-left")); 129 return lineLeft; 130 } 131 132 static const String& lineRightKeyword() 133 { 134 static NeverDestroyed<const String> lineRight(MAKE_STATIC_STRING_IMPL("line-right")); 135 return lineRight; 136 } 137 138 static const String& autoKeyword() 139 { 140 static NeverDestroyed<const String> autoX(MAKE_STATIC_STRING_IMPL("auto")); 141 return autoX; 142 } 143 126 144 // ---------------------------- 127 145 … … 337 355 direction = VerticalGrowingRight; 338 356 else 339 return Exception { SyntaxError};340 357 return { }; 358 341 359 if (direction == m_writingDirection) 342 360 return { }; … … 359 377 } 360 378 361 ExceptionOr<void> VTTCue::setLine(double position) 362 { 363 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line 364 // On setting, if the text track cue snap-to-lines flag is not set, and the new 365 // value is negative or greater than 100, then throw an IndexSizeError exception. 366 if (!m_snapToLines && !(position >= 0 && position <= 100)) 367 return Exception { IndexSizeError }; 368 369 // Otherwise, set the text track cue line position to the new value. 370 if (m_linePosition == position) 371 return { }; 379 VTTCue::LineAndPositionSetting VTTCue::line() const 380 { 381 if (std::isnan(m_linePosition)) 382 return Auto; 383 384 return m_linePosition; 385 } 386 387 ExceptionOr<void> VTTCue::setLine(const LineAndPositionSetting& position) 388 { 389 double linePosition = 0; 390 391 if (WTF::holds_alternative<AutoKeyword>(position)) { 392 if (std::isnan(m_linePosition)) 393 return { }; 394 linePosition = std::numeric_limits<double>::quiet_NaN(); 395 } else { 396 linePosition = WTF::get<double>(position); 397 398 if (m_linePosition == linePosition) 399 return { }; 400 } 372 401 373 402 willChange(); 374 m_linePosition = position;403 m_linePosition = linePosition; 375 404 m_computedLinePosition = calculateComputedLinePosition(); 376 405 didChange(); … … 378 407 return { }; 379 408 } 409 410 const String& VTTCue::lineAlign() const 411 { 412 switch (m_lineAlignment) { 413 case LignAlignmentStart: 414 return startKeyword(); 415 case LignAlignmentCenter: 416 return centerKeyword(); 417 case LignAlignmentEnd: 418 return endKeyword(); 419 default: 420 ASSERT_NOT_REACHED(); 421 return emptyString(); 422 } 423 } 424 425 ExceptionOr<void> VTTCue::setLineAlign(const String& value) 426 { 427 CueLignAlignment lineAlignment; 428 if (value == startKeyword()) 429 lineAlignment = LignAlignmentStart; 430 else if (value == centerKeyword()) 431 lineAlignment = LignAlignmentCenter; 432 else if (value == endKeyword()) 433 lineAlignment = LignAlignmentEnd; 434 else 435 return { }; 436 437 if (lineAlignment == m_lineAlignment) 438 return { }; 439 440 willChange(); 441 m_lineAlignment = lineAlignment; 442 didChange(); 443 444 return { }; 445 } 446 380 447 381 448 VTTCue::LineAndPositionSetting VTTCue::position() const … … 410 477 willChange(); 411 478 m_textPosition = textPosition; 479 didChange(); 480 481 return { }; 482 } 483 484 const String& VTTCue::positionAlign() const 485 { 486 switch (m_positionAlignment) { 487 case PositionAlignmentLignLeft: 488 return lineLeftKeyword(); 489 case PositionAlignmentLignCenter: 490 return centerKeyword(); 491 case PositionAlignmentLignRight: 492 return lineRightKeyword(); 493 case PositionAlignmentLignAuto: 494 return autoKeyword(); 495 default: 496 ASSERT_NOT_REACHED(); 497 return emptyString(); 498 } 499 } 500 501 ExceptionOr<void> VTTCue::setPositionAlign(const String& value) 502 { 503 CuePositionAlignment positionAlignment; 504 if (value == lineLeftKeyword()) 505 positionAlignment = PositionAlignmentLignLeft; 506 else if (value == centerKeyword()) 507 positionAlignment = PositionAlignmentLignCenter; 508 else if (value == lineRightKeyword()) 509 positionAlignment = PositionAlignmentLignRight; 510 else if (value == autoKeyword()) 511 positionAlignment = PositionAlignmentLignAuto; 512 else 513 return { }; 514 515 if (positionAlignment == m_positionAlignment) 516 return { }; 517 518 willChange(); 519 m_positionAlignment = positionAlignment; 412 520 didChange(); 413 521 … … 473 581 alignment = Right; 474 582 else 475 return Exception { SyntaxError};476 583 return { }; 584 477 585 if (alignment == m_cueAlignment) 478 586 return { }; … … 544 652 } 545 653 546 void VTTCue::setRegionId(const String& regionId)547 {548 if (m_regionId == regionId)549 return;550 551 willChange();552 m_regionId = regionId;553 didChange();554 }555 556 654 void VTTCue::notifyRegionWhenRemovingDisplayTree(bool notifyRegion) 557 655 { … … 572 670 } 573 671 672 void VTTCue::setTrack(TextTrack* track) 673 { 674 LOG(Media, "VTTCue::setTrack"); 675 TextTrackCue::setTrack(track); 676 if (!m_parsedRegionId.isEmpty()) { 677 if (track != nullptr) { 678 if (auto* regions = track->regions()) { 679 if (auto region = regions->getRegionById(m_parsedRegionId)) 680 m_region = RefPtr<VTTRegion>(region); 681 } 682 } 683 } 684 } 685 686 void VTTCue::setRegion(VTTRegion* region) 687 { 688 if (m_region != region) { 689 willChange(); 690 m_region = region; 691 didChange(); 692 } 693 } 694 695 VTTRegion* VTTCue::region() 696 { 697 if (!m_region) 698 return nullptr; 699 700 return &*m_region; 701 } 702 703 const String& VTTCue::regionId() 704 { 705 if (!m_region) 706 return emptyString(); 707 708 return m_region->id(); 709 } 710 574 711 int VTTCue::calculateComputedLinePosition() 575 712 { … … 578 715 // If the text track cue line position is numeric, then that is the text 579 716 // track cue computed line position. 580 if ( m_linePosition != undefinedPosition)717 if (!std::isnan(m_linePosition)) 581 718 return m_linePosition; 582 719 … … 903 1040 904 1041 if (track()) { 905 if (auto* regions = track()->regions()) { 906 if (auto region = regions->getRegionById(m_regionId)) 907 region->cueStyleChanged(); 908 } 1042 if (m_region) 1043 m_region->cueStyleChanged(); 909 1044 } 910 1045 … … 921 1056 // The region needs to be informed about the cue removal. 922 1057 if (m_notifyRegion && track()) { 923 if (VTTRegionList* regions = track()->regions()) { 924 if (RefPtr<VTTRegion> region = regions->getRegionById(m_regionId)) { 925 if (m_displayTree) 926 region->willRemoveTextTrackCueBox(m_displayTree.get()); 927 } 928 } 1058 if (m_region && m_displayTree) 1059 m_region->willRemoveTextTrackCueBox(m_displayTree.get()); 929 1060 } 930 1061 … … 988 1119 parsedSetting = Align; 989 1120 else if (input.scan("region")) 990 parsedSetting = Region Id;1121 parsedSetting = Region; 991 1122 992 1123 // Verify that a ':' follows. … … 1149 1280 break; 1150 1281 } 1151 case Region Id:1152 m_ regionId = input.extractString(valueRun);1282 case Region: { 1283 m_parsedRegionId = input.extractString(valueRun); 1153 1284 break; 1285 } 1154 1286 case None: 1155 1287 break; … … 1160 1292 } 1161 1293 1162 // If cue's line position is not auto or cue's size is not 100 or cue's1163 // writing direction is not horizontal, but cue's region identifier is not1164 // the empty string, let cue's region identifier be the empty string.1165 if (!m_regionId.isEmpty() && (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal))1166 m_regionId = emptyString();1167 1294 } 1168 1295 … … 1235 1362 object.setInteger("size"_s, m_cueSize); 1236 1363 object.setString("align"_s, align()); 1237 object.setString("regionId"_s, regionId());1238 1364 } 1239 1365 -
trunk/Source/WebCore/html/track/VTTCue.h
r267074 r270738 36 36 #include "HTMLElement.h" 37 37 #include "TextTrackCue.h" 38 #include "VTTRegion.h" 38 39 #include <wtf/TypeCasts.h> 39 40 … … 84 85 using LineAndPositionSetting = Variant<double, AutoKeyword>; 85 86 87 void setTrack(TextTrack*); 88 86 89 const String& vertical() const; 87 90 ExceptionOr<void> setVertical(const String&); … … 90 93 void setSnapToLines(bool); 91 94 92 double line() const { return m_linePosition; } 93 virtual ExceptionOr<void> setLine(double); 95 LineAndPositionSetting line() const; 96 virtual ExceptionOr<void> setLine(const LineAndPositionSetting&); 97 98 const String& lineAlign() const; 99 ExceptionOr<void> setLineAlign(const String&); 94 100 95 101 LineAndPositionSetting position() const; 96 102 virtual ExceptionOr<void> setPosition(const LineAndPositionSetting&); 97 103 104 const String& positionAlign() const; 105 ExceptionOr<void> setPositionAlign(const String&); 106 98 107 int size() const { return m_cueSize; } 99 108 ExceptionOr<void> setSize(int); … … 111 120 RefPtr<DocumentFragment> createCueRenderingTree(); 112 121 113 const String& regionId() const { return m_regionId; }114 void setRegionId(const String&);115 122 void notifyRegionWhenRemovingDisplayTree(bool); 123 124 VTTRegion* region(); 125 void setRegion(VTTRegion*); 126 127 const String& regionId(); 116 128 117 129 void setIsActive(bool) override; … … 153 165 CueAlignment getAlignment() const { return m_cueAlignment; } 154 166 167 enum CueLignAlignment { 168 LignAlignmentStart, 169 LignAlignmentCenter, 170 LignAlignmentEnd, 171 NumberOfCueLineAlignments 172 }; 173 174 enum CuePositionAlignment { 175 PositionAlignmentLignLeft, 176 PositionAlignmentLignCenter, 177 PositionAlignmentLignRight, 178 PositionAlignmentLignAuto, 179 NumberOfCuePositionAlignments 180 }; 181 155 182 void recalculateStyles() final { m_displayTreeShouldChange = true; } 156 183 void setFontSize(int, const IntSize&, bool important) override; … … 182 209 183 210 bool textPositionIsAuto() const; 184 211 185 212 void determineTextDirection(); 186 213 void calculateDisplayParameters(); … … 193 220 Size, 194 221 Align, 195 Region Id222 Region 196 223 }; 197 224 CueSetting settingName(VTTScanner&); … … 201 228 String m_content; 202 229 String m_settings; 203 double m_linePosition { undefinedPosition};204 double m_computedLinePosition { undefinedPosition};230 double m_linePosition { std::numeric_limits<double>::quiet_NaN() }; 231 double m_computedLinePosition { std::numeric_limits<double>::quiet_NaN() }; 205 232 double m_textPosition { std::numeric_limits<double>::quiet_NaN() }; 206 233 int m_cueSize { 100 }; … … 208 235 WritingDirection m_writingDirection { Horizontal }; 209 236 CueAlignment m_cueAlignment { Center }; 210 String m_regionId; 237 238 RefPtr<VTTRegion> m_region; 239 String m_parsedRegionId; 211 240 212 241 RefPtr<DocumentFragment> m_webVTTNodeTree; … … 227 256 bool m_displayTreeShouldChange : 1; 228 257 bool m_notifyRegion : 1; 258 259 CuePositionAlignment m_positionAlignment { PositionAlignmentLignAuto }; 260 CueLignAlignment m_lineAlignment { LignAlignmentStart }; 229 261 }; 230 262 -
trunk/Source/WebCore/html/track/VTTCue.idl
r267813 r270738 37 37 attribute DOMString vertical; 38 38 attribute boolean snapToLines; 39 attribute double line; 39 attribute LineAndPositionSetting line; 40 attribute DOMString lineAlign; 40 41 attribute LineAndPositionSetting position; 42 attribute DOMString positionAlign; 41 43 attribute double size; 42 44 attribute DOMString align; … … 44 46 DocumentFragment getCueAsHTML(); 45 47 46 attribute DOMString regionId;48 attribute VTTRegion? region; 47 49 };
Note: See TracChangeset
for help on using the changeset viewer.