Diff
Modified: trunk/LayoutTests/ChangeLog (270737 => 270738)
--- trunk/LayoutTests/ChangeLog 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/ChangeLog 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,3 +1,31 @@
+2020-12-12 Frank Olivier <[email protected]>
+
+ Implement WebVTT VTTCue region attribute
+ https://bugs.webkit.org/show_bug.cgi?id=168716
+
+ Updated VTTCue to current IDL
+
+ Reviewed by Eric Carlson.
+
+ * media/track/captions-webvtt/header-regions.vtt:
+ * media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt:
+ * media/track/regions-webvtt/text-track-cue-region-attribute.html:
+ * media/track/regions-webvtt/vtt-region-parser-expected.txt:
+ * media/track/regions-webvtt/vtt-region-parser.html:
+ * media/track/track-add-remove-cue-expected.txt:
+ * media/track/track-add-remove-cue.html:
+ * media/track/track-cue-container-rendering-position.html:
+ * media/track/track-cue-mutable-expected.txt:
+ * media/track/track-cue-mutable.html:
+ * media/track/track-vttcue-expected.txt:
+ * media/track/track-vttcue.html:
+ * media/track/track-webvtt-tc013-settings-expected.txt:
+ * media/track/track-webvtt-tc013-settings.html:
+ * media/track/track-webvtt-tc017-line-position-expected.txt:
+ * media/track/track-webvtt-tc017-line-position.html:
+ * media/track/track-webvtt-tc018-align-text-line-position-expected.txt:
+ * media/track/track-webvtt-tc018-align-text-line-position.html:
+
2020-12-12 Diego Pino Garcia <[email protected]>
[GLIB][GTK] Unreviewed test gardening. Remove tests passing after r270734.
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (270737 => 270738)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,3 +1,13 @@
+2020-12-12 Frank Olivier <[email protected]>
+
+ Implement WebVTT VTTCue region attribute
+ https://bugs.webkit.org/show_bug.cgi?id=168716
+
+ Reviewed by Eric Carlson.
+
+ * web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt:
+ * web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt:
+
2020-12-11 Alexey Shvayka <[email protected]>
Reflect.preventExtensions should not throw if called on WindowProxy or Location
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt (270737 => 270738)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-align-text-line-position-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,4 +1,4 @@
-FAIL Cue alignment, line and text position from settings assert_equals: expected (string) "auto" but got (number) -1
+PASS Cue alignment, line and text position from settings
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt (270737 => 270738)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-line-position-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,4 +1,4 @@
-FAIL Cue line position from settings assert_equals: expected (string) "auto" but got (number) -1
+PASS Cue line position from settings
Modified: trunk/LayoutTests/media/track/captions-webvtt/header-regions.vtt (270737 => 270738)
--- trunk/LayoutTests/media/track/captions-webvtt/header-regions.vtt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/captions-webvtt/header-regions.vtt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -28,6 +28,9 @@
invalid_settings values but region still created
: Invalid Header
+REGION
+id:someregionattributeid
+
1
00:00:00.000 --> 00:00:02.500 region:someregionattributeid
We are in New York City
Modified: trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,18 +1,18 @@
-Tests the regionId attribute of a cue.
+Tests the region attribute of a cue.
+EXPECTED (!!window.VTTRegion == 'true') OK
** Test the setter and getter through the JS API **
-EXPECTED (cue.regionId == '') OK
-EXPECTED (cue.regionId == 'someId') OK
+EXPECTED (cue.region == 'null') OK
** Test parsing a region attribute of a cue **
-EXPECTED (cue.regionId == 'someregionattributeid') OK
+EXPECTED (typeof cue.region == 'object') OK
** Test that region attribute is ignored if either line position or cue size are specified or writing direction is not horizontal **
-EXPECTED (cue.regionId == '') OK
-EXPECTED (cue.regionId == '') OK
-EXPECTED (cue.regionId == '') OK
+EXPECTED (cue.region == 'null') OK
+EXPECTED (cue.region == 'null') OK
+EXPECTED (cue.region == 'null') OK
END OF TEST
Modified: trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute.html (270737 => 270738)
--- trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/regions-webvtt/text-track-cue-region-attribute.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -10,28 +10,23 @@
function startTest()
{
- if (!window.VTTRegion) {
- failTest();
- return;
- }
+ testExpected("!!window.VTTRegion", true);
consoleWrite("<br>** Test the setter and getter through the JS API **");
cue = new VTTCue(0.0, 1.0, "sample");
- testExpected("cue.regionId", "");
- cue.regionId = "someId";
- testExpected("cue.regionId", "someId");
+ testExpected("cue.region", null);
consoleWrite("<br>** Test parsing a region attribute of a cue **");
findMediaElement();
cue = video.textTracks[0].cues[0];
- testExpected("cue.regionId", "someregionattributeid");
+ testExpected("typeof cue.region", "object");
consoleWrite("<br>** Test that region attribute is ignored if either line position or cue size are specified or writing direction is not horizontal **");
for (i = 1; i < 4; ++i) {
cue = video.textTracks[0].cues[i];
- testExpected("cue.regionId", "");
+ testExpected("cue.region", null);
}
consoleWrite("");
@@ -42,7 +37,7 @@
</script>
</head>
<body>
- <p>Tests the regionId attribute of a cue.</p>
+ <p>Tests the region attribute of a cue.</p>
<video controls>
<track src="" kind="captions" default _onload_="startTest()">
</video>
Modified: trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,7 +1,7 @@
Tests proper parsing of various regions present in WebVTT header area.
-EXPECTED (video.textTracks[0].regions.length == '4') OK
+EXPECTED (video.textTracks[0].regions.length == '5') OK
EXPECTED (region.id == 'region_without_settings') OK
Modified: trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser.html (270737 => 270738)
--- trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/regions-webvtt/vtt-region-parser.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -16,7 +16,7 @@
}
findMediaElement();
- testExpected("video.textTracks[0].regions.length", 4);
+ testExpected("video.textTracks[0].regions.length", 5);
consoleWrite("");
region = video.textTracks[0].regions[0];
Modified: trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-add-remove-cue-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -19,7 +19,7 @@
EXPECTED (textCue.pauseOnExit == 'false') OK
EXPECTED (textCue.vertical == '') OK
EXPECTED (textCue.snapToLines == 'true') OK
-EXPECTED (textCue.line == '-1') OK
+EXPECTED (textCue.line == 'auto') OK
EXPECTED (textCue.position == 'auto') OK
EXPECTED (textCue.size == '100') OK
EXPECTED (textCue.align == 'center') OK
@@ -42,7 +42,7 @@
EXPECTED (newCue.pauseOnExit == 'false') OK
EXPECTED (newCue.vertical == '') OK
EXPECTED (newCue.snapToLines == 'true') OK
-EXPECTED (newCue.line == '-1') OK
+EXPECTED (newCue.line == 'auto') OK
EXPECTED (newCue.position == 'auto') OK
EXPECTED (newCue.size == '100') OK
EXPECTED (newCue.align == 'center') OK
Modified: trunk/LayoutTests/media/track/track-add-remove-cue.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-add-remove-cue.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-add-remove-cue.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -31,7 +31,7 @@
testExpected("textCue.pauseOnExit", false);
testExpected("textCue.vertical", "");
testExpected("textCue.snapToLines", true);
- testExpected("textCue.line", -1);
+ testExpected("textCue.line", 'auto');
testExpected("textCue.position", 'auto');
testExpected("textCue.size", 100);
testExpected("textCue.align", "center");
@@ -56,7 +56,7 @@
testExpected("newCue.pauseOnExit", false);
testExpected("newCue.vertical", "");
testExpected("newCue.snapToLines", true);
- testExpected("newCue.line", -1);
+ testExpected("newCue.line", 'auto');
testExpected("newCue.position", 'auto');
testExpected("newCue.size", 100);
testExpected("newCue.align", "center");
Modified: trunk/LayoutTests/media/track/track-cue-mutable-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-cue-mutable-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-cue-mutable-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -8,7 +8,7 @@
EXPECTED (textCue.pauseOnExit == 'false') OK
EXPECTED (textCue.vertical == '') OK
EXPECTED (textCue.snapToLines == 'true') OK
-EXPECTED (textCue.line == '-1') OK
+EXPECTED (textCue.line == 'auto') OK
EXPECTED (textCue.position == 'auto') OK
EXPECTED (textCue.size == '100') OK
EXPECTED (textCue.align == 'center') OK
@@ -22,10 +22,6 @@
RUN(textCue.pauseOnExit = true)
EXPECTED (textCue.pauseOnExit == 'true') OK
-
-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.
-http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
-TEST(textCue.vertical = 'RL') THROWS(DOMException.SYNTAX_ERR) OK
EXPECTED (textCue.vertical == '') OK
RUN(textCue.vertical = 'rl')
EXPECTED (textCue.vertical == 'rl') OK
@@ -32,12 +28,6 @@
RUN(textCue.snapToLines = false)
EXPECTED (textCue.snapToLines == 'false') OK
-
-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.
-http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
-TEST(textCue.line = -2) THROWS(DOMException.INDEX_SIZE_ERR) OK
-TEST(textCue.line = 102) THROWS(DOMException.INDEX_SIZE_ERR) OK
-EXPECTED (textCue.line == '-1') OK
RUN(textCue.line = 42)
EXPECTED (textCue.line == '42') OK
RUN(textCue.snapToLines = true)
@@ -59,10 +49,7 @@
TEST(textCue.size = 110) THROWS(DOMException.INDEX_SIZE_ERR) OK
RUN(textCue.size = 57)
EXPECTED (textCue.size == '57') OK
-
-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.
-http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
-TEST(textCue.align = 'End') THROWS(DOMException.SYNTAX_ERR) OK
+RUN(textCue.align = 'End')
EXPECTED (textCue.align == 'center') OK
RUN(textCue.align = 'end')
EXPECTED (textCue.align == 'end') OK
Modified: trunk/LayoutTests/media/track/track-cue-mutable.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-cue-mutable.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-cue-mutable.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -28,7 +28,7 @@
testExpected("textCue.pauseOnExit", false);
testExpected("textCue.vertical", "");
testExpected("textCue.snapToLines", true);
- testExpected("textCue.line", -1);
+ testExpected("textCue.line", 'auto');
testExpected("textCue.position", 'auto');
testExpected("textCue.size", 100);
testExpected("textCue.align", "center");
@@ -46,9 +46,7 @@
run("textCue.pauseOnExit = true");
testExpected("textCue.pauseOnExit", true);
- logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical",
- "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.");
- testDOMException("textCue.vertical = 'RL'", "DOMException.SYNTAX_ERR");
+ textCue.vertical = 'xyz';
testExpected("textCue.vertical", "");
run("textCue.vertical = 'rl'");
testExpected("textCue.vertical", "rl");
@@ -57,11 +55,6 @@
run("textCue.snapToLines = false");
testExpected("textCue.snapToLines", false);
- logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line",
- "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.");
- testDOMException("textCue.line = -2", "DOMException.INDEX_SIZE_ERR");
- testDOMException("textCue.line = 102", "DOMException.INDEX_SIZE_ERR");
- testExpected("textCue.line", -1);
run("textCue.line = 42");
testExpected("textCue.line", 42);
run("textCue.snapToLines = true");
@@ -84,9 +77,7 @@
run("textCue.size = 57");
testExpected("textCue.size", 57);
- logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align",
- "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.");
- testDOMException("textCue.align = 'End'", "DOMException.SYNTAX_ERR");
+ run("textCue.align = 'End'");
testExpected("textCue.align", "center");
run("textCue.align = 'end'");
testExpected("textCue.align", "end");
Modified: trunk/LayoutTests/media/track/track-vttcue-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-vttcue-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-vttcue-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -13,7 +13,7 @@
EXPECTED (trackCue instanceof 'function VTTCue() { [native code] }') OK
EXPECTED (trackCue.vertical == '') OK
EXPECTED (trackCue.snapToLines == 'true') OK
-EXPECTED (trackCue.line == '-1') OK
+EXPECTED (trackCue.line == 'auto') OK
EXPECTED (trackCue.position == 'auto') OK
EXPECTED (trackCue.size == '100') OK
EXPECTED (trackCue.align == 'center') OK
@@ -31,7 +31,7 @@
EXPECTED (newCue instanceof 'function VTTCue() { [native code] }') OK
EXPECTED (newCue.vertical == '') OK
EXPECTED (newCue.snapToLines == 'true') OK
-EXPECTED (newCue.line == '-1') OK
+EXPECTED (newCue.line == 'auto') OK
EXPECTED (newCue.position == 'auto') OK
EXPECTED (newCue.size == '100') OK
EXPECTED (newCue.align == 'center') OK
Modified: trunk/LayoutTests/media/track/track-vttcue.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-vttcue.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-vttcue.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -32,7 +32,7 @@
testExpected("trackCue", VTTCue, "instanceof");
testExpected("trackCue.vertical", "");
testExpected("trackCue.snapToLines", true);
- testExpected("trackCue.line", -1);
+ testExpected("trackCue.line", 'auto');
testExpected("trackCue.position", 'auto');
testExpected("trackCue.size", 100);
testExpected("trackCue.align", "center");
@@ -52,7 +52,7 @@
testExpected("newCue", VTTCue, "instanceof");
testExpected("newCue.vertical", "");
testExpected("newCue.snapToLines", true);
- testExpected("newCue.line", -1);
+ testExpected("newCue.line", 'auto');
testExpected("newCue.position", 'auto');
testExpected("newCue.size", 100);
testExpected("newCue.align", "center");
Modified: trunk/LayoutTests/media/track/track-webvtt-tc013-settings-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc013-settings-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc013-settings-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -12,7 +12,7 @@
EXPECTED (cues[1].position == '40') OK
EXPECTED (cues[1].align == 'center') OK
EXPECTED (cues[1].vertical == 'rl') OK
-EXPECTED (cues[2].line == '-1') OK
+EXPECTED (cues[2].line == 'auto') OK
EXPECTED (cues[2].position == '10') OK
EXPECTED (cues[2].align == 'center') OK
EXPECTED (cues[2].vertical == '') OK
@@ -27,15 +27,15 @@
EXPECTED (cues[0].position == '10') OK
EXPECTED (cues[0].align == 'center') OK
EXPECTED (cues[0].vertical == '') OK
-EXPECTED (cues[1].line == '-1') OK
+EXPECTED (cues[1].line == 'auto') OK
EXPECTED (cues[1].position == '50') OK
EXPECTED (cues[1].align == 'end') OK
EXPECTED (cues[1].vertical == '') OK
-EXPECTED (cues[2].line == '-1') OK
+EXPECTED (cues[2].line == 'auto') OK
EXPECTED (cues[2].position == 'auto') OK
EXPECTED (cues[2].align == 'center') OK
EXPECTED (cues[2].vertical == '') OK
-EXPECTED (cues[3].line == '-1') OK
+EXPECTED (cues[3].line == 'auto') OK
EXPECTED (cues[3].position == '90') OK
EXPECTED (cues[3].align == 'center') OK
EXPECTED (cues[3].vertical == 'lr') OK
Modified: trunk/LayoutTests/media/track/track-webvtt-tc013-settings.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc013-settings.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc013-settings.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -29,7 +29,7 @@
[
{
property : "line",
- values : [100, 15, -1, 95],
+ values : [100, 15, 'auto', 95],
},
{
property : "position",
@@ -51,7 +51,7 @@
[
{
property : "line",
- values : [43, -1, -1, -1],
+ values : [43, 'auto', 'auto', 'auto'],
},
{
property : "position",
Modified: trunk/LayoutTests/media/track/track-webvtt-tc017-line-position-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc017-line-position-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc017-line-position-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -21,17 +21,17 @@
*** Testing text track 1
EXPECTED (cues.length == '6') OK
-EXPECTED (cues[0].line == '-1') OK
+EXPECTED (cues[0].line == 'auto') OK
EXPECTED (cues[0].snapToLines == 'true') OK
-EXPECTED (cues[1].line == '-1') OK
+EXPECTED (cues[1].line == '0.5'), OBSERVED 'auto' FAIL
EXPECTED (cues[1].snapToLines == 'true') OK
-EXPECTED (cues[2].line == '-1') OK
+EXPECTED (cues[2].line == 'auto') OK
EXPECTED (cues[2].snapToLines == 'true') OK
-EXPECTED (cues[3].line == '-1') OK
+EXPECTED (cues[3].line == 'auto') OK
EXPECTED (cues[3].snapToLines == 'true') OK
-EXPECTED (cues[4].line == '-1') OK
+EXPECTED (cues[4].line == 'auto') OK
EXPECTED (cues[4].snapToLines == 'true') OK
-EXPECTED (cues[5].line == '-1') OK
+EXPECTED (cues[5].line == 'auto') OK
EXPECTED (cues[5].snapToLines == 'true') OK
END OF TEST
Modified: trunk/LayoutTests/media/track/track-webvtt-tc017-line-position.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc017-line-position.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc017-line-position.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -52,7 +52,7 @@
[
{
property : "line",
- values : [-1, -1, -1, -1, -1, -1, -1],
+ values : ['auto', 0.5, 'auto', 'auto', 'auto', 'auto', 'auto'],
},
{
property : "snapToLines",
Modified: trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position-expected.txt (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position-expected.txt 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position-expected.txt 2020-12-12 19:39:51 UTC (rev 270738)
@@ -29,11 +29,11 @@
EXPECTED (cues.length == '3') OK
EXPECTED (cues[0].align == 'center') OK
EXPECTED (cues[0].position == 'auto') OK
-EXPECTED (cues[0].line == '-1') OK
+EXPECTED (cues[0].line == 'auto') OK
EXPECTED (cues[0].snapToLines == 'true') OK
EXPECTED (cues[1].align == 'end') OK
EXPECTED (cues[1].position == '0') OK
-EXPECTED (cues[1].line == '-1') OK
+EXPECTED (cues[1].line == 'auto') OK
EXPECTED (cues[1].snapToLines == 'true') OK
EXPECTED (cues[2].align == 'center') OK
EXPECTED (cues[2].position == '60') OK
Modified: trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html (270737 => 270738)
--- trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html 2020-12-12 19:39:51 UTC (rev 270738)
@@ -70,7 +70,7 @@
},
{
property : "line",
- values : [-1, -1, -3],
+ values : ['auto', 'auto', -3],
},
{
property : "snapToLines",
Modified: trunk/Source/WebCore/ChangeLog (270737 => 270738)
--- trunk/Source/WebCore/ChangeLog 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/ChangeLog 2020-12-12 19:39:51 UTC (rev 270738)
@@ -1,3 +1,51 @@
+2020-12-12 Frank Olivier <[email protected]>
+
+ Implement WebVTT VTTCue region attribute
+ https://bugs.webkit.org/show_bug.cgi?id=168716
+
+ Reviewed by Eric Carlson.
+
+ Updated existing region tests.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/shadow/MediaControlTextTrackContainerElement.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::processActiveVTTCue):
+ * html/track/TextTrackCueGeneric.cpp:
+ (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
+ (WebCore::TextTrackCueGeneric::setLine):
+ * html/track/TextTrackCueGeneric.h:
+ * html/track/VTTCue.cpp:
+ (WebCore::horizontalKeyword):
+ (WebCore::lineLeftKeyword):
+ (WebCore::lineRightKeyword):
+ (WebCore::autoKeyword):
+ (WebCore::VTTCueBox::applyCSSProperties):
+ (WebCore::VTTCue::setVertical):
+ (WebCore::VTTCue::line const):
+ (WebCore::VTTCue::setLine):
+ (WebCore::VTTCue::lineAlign const):
+ (WebCore::VTTCue::setLineAlign):
+ (WebCore::VTTCue::positionAlign const):
+ (WebCore::VTTCue::setPositionAlign):
+ (WebCore::VTTCue::setAlign):
+ (WebCore::VTTCue::setTrack):
+ (WebCore::VTTCue::setRegion):
+ (WebCore::VTTCue::region):
+ (WebCore::VTTCue::regionId):
+ (WebCore::VTTCue::calculateComputedLinePosition):
+ (WebCore::VTTCue::getDisplayTree):
+ (WebCore::VTTCue::removeDisplayTree):
+ (WebCore::VTTCue::settingName):
+ (WebCore::VTTCue::setCueSettings):
+ (WebCore::VTTCue::toJSON const):
+ (WebCore::VTTCue::setRegionId): Deleted.
+ * html/track/VTTCue.h:
+ (WebCore::VTTCue::line const): Deleted.
+ (WebCore::VTTCue::regionId const): Deleted.
+ * html/track/VTTCue.idl:
+ * rendering/RenderVTTCue.cpp:
+ (WebCore::RenderVTTCue::layout):
+
2020-12-12 Simon Fraser <[email protected]>
Scroll performance logging: rubberbanding should not trigger "Exposed tileless area" logging
Modified: trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp (270737 => 270738)
--- trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp 2020-12-12 19:39:51 UTC (rev 270738)
@@ -200,7 +200,7 @@
void MediaControlTextTrackContainerElement::processActiveVTTCue(VTTCue& cue)
{
- DEBUG_LOG(LOGIDENTIFIER, "adding and positioning cue: \"", cue.text(), "\", start=", cue.startTime(), ", end=", cue.endTime(), ", line=", cue.line());
+ DEBUG_LOG(LOGIDENTIFIER, "adding and positioning cue: \"", cue.text(), "\", start=", cue.startTime(), ", end=", cue.endTime());
Ref<TextTrackCueBox> displayBox = *cue.getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
if (auto region = cue.track()->regions()->getRegionById(cue.regionId())) {
Modified: trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp (270737 => 270738)
--- trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2020-12-12 19:39:51 UTC (rev 270738)
@@ -84,6 +84,7 @@
Ref<HTMLSpanElement> cueElement = cue->element();
double textPosition = cue->calculateComputedTextPosition();
+ double linePosition = cue->calculateComputedLinePosition();
CSSValueID alignment = cue->getCSSAlignment();
float size = static_cast<float>(cue->getCSSSize());
@@ -92,7 +93,7 @@
setInlineStyleProperty(CSSPropertyMarginBottom, 1.0, CSSUnitType::CSS_PERCENTAGE);
} else {
setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(textPosition), CSSUnitType::CSS_PERCENTAGE);
- setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSUnitType::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyTop, static_cast<float>(linePosition), CSSUnitType::CSS_PERCENTAGE);
double authorFontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100.0;
if (!authorFontSize)
@@ -110,7 +111,7 @@
} else {
setInlineStyleProperty(CSSPropertyHeight, newCueSize, CSSUnitType::CSS_PERCENTAGE);
if ((alignment == CSSValueMiddle || alignment == CSSValueCenter) && multiplier != 1.0)
- setInlineStyleProperty(CSSPropertyTop, static_cast<double>(cue->line() - (newCueSize - cue->getCSSSize()) / 2), CSSUnitType::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyTop, static_cast<double>(linePosition - (newCueSize - cue->getCSSSize()) / 2), CSSUnitType::CSS_PERCENTAGE);
}
}
@@ -174,7 +175,7 @@
return TextTrackCueGenericBoxElement::create(ownerDocument(), *this);
}
-ExceptionOr<void> TextTrackCueGeneric::setLine(double line)
+ExceptionOr<void> TextTrackCueGeneric::setLine(const LineAndPositionSetting& line)
{
auto result = VTTCue::setLine(line);
if (!result.hasException())
Modified: trunk/Source/WebCore/html/track/TextTrackCueGeneric.h (270737 => 270738)
--- trunk/Source/WebCore/html/track/TextTrackCueGeneric.h 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/track/TextTrackCueGeneric.h 2020-12-12 19:39:51 UTC (rev 270738)
@@ -38,7 +38,7 @@
public:
WEBCORE_EXPORT static Ref<TextTrackCueGeneric> create(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String& content);
- ExceptionOr<void> setLine(double) final;
+ ExceptionOr<void> setLine(const LineAndPositionSetting&) final;
ExceptionOr<void> setPosition(const LineAndPositionSetting&) final;
bool useDefaultPosition() const { return m_useDefaultPosition; }
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (270737 => 270738)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2020-12-12 19:39:51 UTC (rev 270738)
@@ -123,6 +123,24 @@
return verticallr;
}
+static const String& lineLeftKeyword()
+{
+ static NeverDestroyed<const String> lineLeft(MAKE_STATIC_STRING_IMPL("line-left"));
+ return lineLeft;
+}
+
+static const String& lineRightKeyword()
+{
+ static NeverDestroyed<const String> lineRight(MAKE_STATIC_STRING_IMPL("line-right"));
+ return lineRight;
+}
+
+static const String& autoKeyword()
+{
+ static NeverDestroyed<const String> autoX(MAKE_STATIC_STRING_IMPL("auto"));
+ return autoX;
+}
+
// ----------------------------
Ref<VTTCueBox> VTTCueBox::create(Document& document, VTTCue& cue)
@@ -336,8 +354,8 @@
else if (value == verticalGrowingRightKeyword())
direction = VerticalGrowingRight;
else
- return Exception { SyntaxError };
-
+ return { };
+
if (direction == m_writingDirection)
return { };
@@ -358,20 +376,31 @@
didChange();
}
-ExceptionOr<void> VTTCue::setLine(double position)
+VTTCue::LineAndPositionSetting VTTCue::line() const
{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
- // 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.
- if (!m_snapToLines && !(position >= 0 && position <= 100))
- return Exception { IndexSizeError };
+ if (std::isnan(m_linePosition))
+ return Auto;
- // Otherwise, set the text track cue line position to the new value.
- if (m_linePosition == position)
- return { };
+ return m_linePosition;
+}
+ExceptionOr<void> VTTCue::setLine(const LineAndPositionSetting& position)
+{
+ double linePosition = 0;
+
+ if (WTF::holds_alternative<AutoKeyword>(position)) {
+ if (std::isnan(m_linePosition))
+ return { };
+ linePosition = std::numeric_limits<double>::quiet_NaN();
+ } else {
+ linePosition = WTF::get<double>(position);
+
+ if (m_linePosition == linePosition)
+ return { };
+ }
+
willChange();
- m_linePosition = position;
+ m_linePosition = linePosition;
m_computedLinePosition = calculateComputedLinePosition();
didChange();
@@ -378,6 +407,44 @@
return { };
}
+const String& VTTCue::lineAlign() const
+{
+ switch (m_lineAlignment) {
+ case LignAlignmentStart:
+ return startKeyword();
+ case LignAlignmentCenter:
+ return centerKeyword();
+ case LignAlignmentEnd:
+ return endKeyword();
+ default:
+ ASSERT_NOT_REACHED();
+ return emptyString();
+ }
+}
+
+ExceptionOr<void> VTTCue::setLineAlign(const String& value)
+{
+ CueLignAlignment lineAlignment;
+ if (value == startKeyword())
+ lineAlignment = LignAlignmentStart;
+ else if (value == centerKeyword())
+ lineAlignment = LignAlignmentCenter;
+ else if (value == endKeyword())
+ lineAlignment = LignAlignmentEnd;
+ else
+ return { };
+
+ if (lineAlignment == m_lineAlignment)
+ return { };
+
+ willChange();
+ m_lineAlignment = lineAlignment;
+ didChange();
+
+ return { };
+}
+
+
VTTCue::LineAndPositionSetting VTTCue::position() const
{
if (textPositionIsAuto())
@@ -414,6 +481,47 @@
return { };
}
+const String& VTTCue::positionAlign() const
+{
+ switch (m_positionAlignment) {
+ case PositionAlignmentLignLeft:
+ return lineLeftKeyword();
+ case PositionAlignmentLignCenter:
+ return centerKeyword();
+ case PositionAlignmentLignRight:
+ return lineRightKeyword();
+ case PositionAlignmentLignAuto:
+ return autoKeyword();
+ default:
+ ASSERT_NOT_REACHED();
+ return emptyString();
+ }
+}
+
+ExceptionOr<void> VTTCue::setPositionAlign(const String& value)
+{
+ CuePositionAlignment positionAlignment;
+ if (value == lineLeftKeyword())
+ positionAlignment = PositionAlignmentLignLeft;
+ else if (value == centerKeyword())
+ positionAlignment = PositionAlignmentLignCenter;
+ else if (value == lineRightKeyword())
+ positionAlignment = PositionAlignmentLignRight;
+ else if (value == autoKeyword())
+ positionAlignment = PositionAlignmentLignAuto;
+ else
+ return { };
+
+ if (positionAlignment == m_positionAlignment)
+ return { };
+
+ willChange();
+ m_positionAlignment = positionAlignment;
+ didChange();
+
+ return { };
+}
+
ExceptionOr<void> VTTCue::setSize(int size)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
@@ -472,8 +580,8 @@
else if (value == rightKeyword())
alignment = Right;
else
- return Exception { SyntaxError };
-
+ return { };
+
if (alignment == m_cueAlignment)
return { };
@@ -543,16 +651,6 @@
return clonedFragment;
}
-void VTTCue::setRegionId(const String& regionId)
-{
- if (m_regionId == regionId)
- return;
-
- willChange();
- m_regionId = regionId;
- didChange();
-}
-
void VTTCue::notifyRegionWhenRemovingDisplayTree(bool notifyRegion)
{
m_notifyRegion = notifyRegion;
@@ -571,6 +669,45 @@
}
}
+void VTTCue::setTrack(TextTrack* track)
+{
+ LOG(Media, "VTTCue::setTrack");
+ TextTrackCue::setTrack(track);
+ if (!m_parsedRegionId.isEmpty()) {
+ if (track != nullptr) {
+ if (auto* regions = track->regions()) {
+ if (auto region = regions->getRegionById(m_parsedRegionId))
+ m_region = RefPtr<VTTRegion>(region);
+ }
+ }
+ }
+}
+
+void VTTCue::setRegion(VTTRegion* region)
+{
+ if (m_region != region) {
+ willChange();
+ m_region = region;
+ didChange();
+ }
+}
+
+VTTRegion* VTTCue::region()
+{
+ if (!m_region)
+ return nullptr;
+
+ return &*m_region;
+}
+
+const String& VTTCue::regionId()
+{
+ if (!m_region)
+ return emptyString();
+
+ return m_region->id();
+}
+
int VTTCue::calculateComputedLinePosition()
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-computed-line-position
@@ -577,7 +714,7 @@
// If the text track cue line position is numeric, then that is the text
// track cue computed line position.
- if (m_linePosition != undefinedPosition)
+ if (!std::isnan(m_linePosition))
return m_linePosition;
// If the text track cue snap-to-lines flag of the text track cue is not
@@ -902,10 +1039,8 @@
m_displayTreeShouldChange = false;
if (track()) {
- if (auto* regions = track()->regions()) {
- if (auto region = regions->getRegionById(m_regionId))
- region->cueStyleChanged();
- }
+ if (m_region)
+ m_region->cueStyleChanged();
}
// 10.15. Let cue's text track cue display state have the CSS boxes in
@@ -920,12 +1055,8 @@
// The region needs to be informed about the cue removal.
if (m_notifyRegion && track()) {
- if (VTTRegionList* regions = track()->regions()) {
- if (RefPtr<VTTRegion> region = regions->getRegionById(m_regionId)) {
- if (m_displayTree)
- region->willRemoveTextTrackCueBox(m_displayTree.get());
- }
- }
+ if (m_region && m_displayTree)
+ m_region->willRemoveTextTrackCueBox(m_displayTree.get());
}
// The display tree is never exposed to author scripts so it's safe to dispatch events here.
@@ -987,7 +1118,7 @@
else if (input.scan("align"))
parsedSetting = Align;
else if (input.scan("region"))
- parsedSetting = RegionId;
+ parsedSetting = Region;
// Verify that a ':' follows.
if (parsedSetting != None && input.scan(':'))
@@ -1148,9 +1279,10 @@
break;
}
- case RegionId:
- m_regionId = input.extractString(valueRun);
+ case Region: {
+ m_parsedRegionId = input.extractString(valueRun);
break;
+ }
case None:
break;
}
@@ -1159,11 +1291,6 @@
input.skipRun(valueRun);
}
- // If cue's line position is not auto or cue's size is not 100 or cue's
- // writing direction is not horizontal, but cue's region identifier is not
- // the empty string, let cue's region identifier be the empty string.
- if (!m_regionId.isEmpty() && (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal))
- m_regionId = emptyString();
}
CSSValueID VTTCue::getCSSAlignment() const
@@ -1234,7 +1361,6 @@
object.setDouble("position"_s, m_textPosition);
object.setInteger("size"_s, m_cueSize);
object.setString("align"_s, align());
- object.setString("regionId"_s, regionId());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/html/track/VTTCue.h (270737 => 270738)
--- trunk/Source/WebCore/html/track/VTTCue.h 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/track/VTTCue.h 2020-12-12 19:39:51 UTC (rev 270738)
@@ -35,6 +35,7 @@
#include "HTMLElement.h"
#include "TextTrackCue.h"
+#include "VTTRegion.h"
#include <wtf/TypeCasts.h>
namespace WebCore {
@@ -83,6 +84,8 @@
enum AutoKeyword { Auto };
using LineAndPositionSetting = Variant<double, AutoKeyword>;
+ void setTrack(TextTrack*);
+
const String& vertical() const;
ExceptionOr<void> setVertical(const String&);
@@ -89,12 +92,18 @@
bool snapToLines() const { return m_snapToLines; }
void setSnapToLines(bool);
- double line() const { return m_linePosition; }
- virtual ExceptionOr<void> setLine(double);
+ LineAndPositionSetting line() const;
+ virtual ExceptionOr<void> setLine(const LineAndPositionSetting&);
+ const String& lineAlign() const;
+ ExceptionOr<void> setLineAlign(const String&);
+
LineAndPositionSetting position() const;
virtual ExceptionOr<void> setPosition(const LineAndPositionSetting&);
+ const String& positionAlign() const;
+ ExceptionOr<void> setPositionAlign(const String&);
+
int size() const { return m_cueSize; }
ExceptionOr<void> setSize(int);
@@ -110,10 +119,13 @@
RefPtr<DocumentFragment> getCueAsHTML() final;
RefPtr<DocumentFragment> createCueRenderingTree();
- const String& regionId() const { return m_regionId; }
- void setRegionId(const String&);
void notifyRegionWhenRemovingDisplayTree(bool);
+ VTTRegion* region();
+ void setRegion(VTTRegion*);
+
+ const String& regionId();
+
void setIsActive(bool) override;
bool hasDisplayTree() const { return m_displayTree; }
@@ -152,6 +164,21 @@
};
CueAlignment getAlignment() const { return m_cueAlignment; }
+ enum CueLignAlignment {
+ LignAlignmentStart,
+ LignAlignmentCenter,
+ LignAlignmentEnd,
+ NumberOfCueLineAlignments
+ };
+
+ enum CuePositionAlignment {
+ PositionAlignmentLignLeft,
+ PositionAlignmentLignCenter,
+ PositionAlignmentLignRight,
+ PositionAlignmentLignAuto,
+ NumberOfCuePositionAlignments
+ };
+
void recalculateStyles() final { m_displayTreeShouldChange = true; }
void setFontSize(int, const IntSize&, bool important) override;
@@ -181,7 +208,7 @@
void parseSettings(const String&);
bool textPositionIsAuto() const;
-
+
void determineTextDirection();
void calculateDisplayParameters();
@@ -192,7 +219,7 @@
Position,
Size,
Align,
- RegionId
+ Region
};
CueSetting settingName(VTTScanner&);
@@ -200,15 +227,17 @@
String m_content;
String m_settings;
- double m_linePosition { undefinedPosition };
- double m_computedLinePosition { undefinedPosition };
+ double m_linePosition { std::numeric_limits<double>::quiet_NaN() };
+ double m_computedLinePosition { std::numeric_limits<double>::quiet_NaN() };
double m_textPosition { std::numeric_limits<double>::quiet_NaN() };
int m_cueSize { 100 };
WritingDirection m_writingDirection { Horizontal };
CueAlignment m_cueAlignment { Center };
- String m_regionId;
+ RefPtr<VTTRegion> m_region;
+ String m_parsedRegionId;
+
RefPtr<DocumentFragment> m_webVTTNodeTree;
RefPtr<HTMLSpanElement> m_cueHighlightBox;
RefPtr<HTMLDivElement> m_cueBackdropBox;
@@ -226,6 +255,9 @@
bool m_snapToLines : 1;
bool m_displayTreeShouldChange : 1;
bool m_notifyRegion : 1;
+
+ CuePositionAlignment m_positionAlignment { PositionAlignmentLignAuto };
+ CueLignAlignment m_lineAlignment { LignAlignmentStart };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/track/VTTCue.idl (270737 => 270738)
--- trunk/Source/WebCore/html/track/VTTCue.idl 2020-12-12 19:29:02 UTC (rev 270737)
+++ trunk/Source/WebCore/html/track/VTTCue.idl 2020-12-12 19:39:51 UTC (rev 270738)
@@ -36,12 +36,14 @@
attribute DOMString vertical;
attribute boolean snapToLines;
- attribute double line;
+ attribute LineAndPositionSetting line;
+ attribute DOMString lineAlign;
attribute LineAndPositionSetting position;
+ attribute DOMString positionAlign;
attribute double size;
attribute DOMString align;
attribute DOMString text;
DocumentFragment getCueAsHTML();
- attribute DOMString regionId;
+ attribute VTTRegion? region;
};