Revert "Support VTTCue.positionAlign and lineAlign for WebVTT"
This reverts commit 2c1d466d78db6df8b4c9fbe37ac5af1cb135bf34.
Reason for revert: https://crbug.com/814710
Conflicts with https://chromium-review.googlesource.com/836576 resolved.
Original change's description:
> Support VTTCue.positionAlign and lineAlign for WebVTT
>
> Implement VTTCue.[positionAlign and lineAlign] for WebVTT
> Updated parsing logic
> Exposed DOM API's
> Updated Layout algorithm
> Updated test expected results
>
> Bug: 633690
> Change-Id: I49970c068c53b462243ba8c7f314261b0e6455ce
> Reviewed-on: https://chromium-review.googlesource.com/756142
> Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
> Reviewed-by: srirama chandra sekhar <srirama.m@samsung.com>
> Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
> Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
> Reviewed-by: Fredrik Söderquist <fs@opera.com>
> Cr-Commit-Position: refs/heads/master@{#525659}
TBR=fs@opera.com,chrishtr@chromium.org,srirama.m@samsung.com,foolip@chromium.org,k2.nagaraju@samsung.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 633690
Change-Id: Ib9f0b3dd1a4b679076ec55ec635337551f8b8806
Reviewed-on: https://chromium-review.googlesource.com/931481
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#538429}(cherry picked from commit ce7509393d9dd7ec49b8e0fd10d94959288a7caf)
Reviewed-on: https://chromium-review.googlesource.com/935341
Cr-Commit-Position: refs/branch-heads/3325@{#575}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/constructor-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/constructor-expected.txt
new file mode 100644
index 0000000..087efc5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/constructor-expected.txt
@@ -0,0 +1,7 @@
+This is a testharness.js-based test.
+FAIL VTTCue(), initial values assert_equals: expected (string) "start" but got (undefined) undefined
+PASS VTTCue(), bad start time
+PASS VTTCue(), bad end time
+PASS VTTCue(), text formatting
+Harness: the test ran to completion.
+
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/lineAlign-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/lineAlign-expected.txt
new file mode 100644
index 0000000..e3cb95f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/lineAlign-expected.txt
@@ -0,0 +1,4 @@
+This is a testharness.js-based test.
+FAIL VTTCue.lineAlign, script-created cue assert_true: lineAlign is not supported expected true got false
+Harness: the test ran to completion.
+
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/positionAlign-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/positionAlign-expected.txt
new file mode 100644
index 0000000..83c37d8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/VTTCue/positionAlign-expected.txt
@@ -0,0 +1,4 @@
+This is a testharness.js-based test.
+FAIL VTTCue.positionAlign, script-created cue assert_true: positionAlign is not supported expected true got false
+Harness: the test ran to completion.
+
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/interfaces-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/interfaces-expected.txt
new file mode 100644
index 0000000..8c1f604c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/webvtt/api/interfaces-expected.txt
@@ -0,0 +1,56 @@
+This is a testharness.js-based test.
+Found 52 tests; 48 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
+PASS VTTCue interface: existence and properties of interface object
+PASS VTTCue interface object length
+PASS VTTCue interface object name
+PASS VTTCue interface: existence and properties of interface prototype object
+PASS VTTCue interface: existence and properties of interface prototype object's "constructor" property
+PASS VTTCue interface: attribute region
+PASS VTTCue interface: attribute vertical
+PASS VTTCue interface: attribute snapToLines
+PASS VTTCue interface: attribute line
+FAIL VTTCue interface: attribute lineAlign assert_true: The prototype object must have a property "lineAlign" expected true got false
+PASS VTTCue interface: attribute position
+FAIL VTTCue interface: attribute positionAlign assert_true: The prototype object must have a property "positionAlign" expected true got false
+PASS VTTCue interface: attribute size
+PASS VTTCue interface: attribute align
+PASS VTTCue interface: attribute text
+PASS VTTCue interface: operation getCueAsHTML()
+PASS VTTCue must be primary interface of new VTTCue(0, 0, "")
+PASS Stringification of new VTTCue(0, 0, "")
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "region" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "vertical" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "snapToLines" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "line" with the proper type
+FAIL VTTCue interface: new VTTCue(0, 0, "") must inherit property "lineAlign" with the proper type assert_inherits: property "lineAlign" not found in prototype chain
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "position" with the proper type
+FAIL VTTCue interface: new VTTCue(0, 0, "") must inherit property "positionAlign" with the proper type assert_inherits: property "positionAlign" not found in prototype chain
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "size" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "align" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "text" with the proper type
+PASS VTTCue interface: new VTTCue(0, 0, "") must inherit property "getCueAsHTML()" with the proper type
+PASS VTTRegion interface: existence and properties of interface object
+PASS VTTRegion interface object length
+PASS VTTRegion interface object name
+PASS VTTRegion interface: existence and properties of interface prototype object
+PASS VTTRegion interface: existence and properties of interface prototype object's "constructor" property
+PASS VTTRegion interface: attribute id
+PASS VTTRegion interface: attribute width
+PASS VTTRegion interface: attribute lines
+PASS VTTRegion interface: attribute regionAnchorX
+PASS VTTRegion interface: attribute regionAnchorY
+PASS VTTRegion interface: attribute viewportAnchorX
+PASS VTTRegion interface: attribute viewportAnchorY
+PASS VTTRegion interface: attribute scroll
+PASS VTTRegion must be primary interface of new VTTRegion()
+PASS Stringification of new VTTRegion()
+PASS VTTRegion interface: new VTTRegion() must inherit property "id" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "width" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "lines" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "regionAnchorX" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "regionAnchorY" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "viewportAnchorX" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "viewportAnchorY" with the proper type
+PASS VTTRegion interface: new VTTRegion() must inherit property "scroll" with the proper type
+Harness: the test ran to completion.
+
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/parsing/file-parsing/tests/settings-position-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/webvtt/parsing/file-parsing/tests/settings-position-expected.txt
new file mode 100644
index 0000000..124ce22
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/webvtt/parsing/file-parsing/tests/settings-position-expected.txt
@@ -0,0 +1,4 @@
+This is a testharness.js-based test.
+FAIL settings, position assert_equals: Failed with cue 0 expected (string) "auto" but got (undefined) undefined
+Harness: the test ran to completion.
+
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center-ref.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center-ref.html
deleted file mode 100644
index 29cb32a..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center-ref.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<style>
-.container {
- position: relative;
- display: inline-block;
- width: 320px;
- height: 240px;
-}
-.cue {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- overflow: hidden;
-}
-.cue.center {
- text-align: center;
-}
-.cue > span {
- font-family: sans-serif;
- background: green;
- color: green;
- font-size: 50px;
- padding: 2px;
-}
-</style>
-<div class="container">
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
-</video>
-<div class="cue center"><span>אבג</span></div>
-</div>
-</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center.html
deleted file mode 100644
index 05f4244..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-center.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<link rel="match" href="track-cue-rendering-position-align-rtl-center-ref.html">
-<script>
-function addTrackWithRtlCueData(video, cueData) {
- var track = video.addTextTrack('subtitles');
- var cue = new VTTCue(0, 10, '\u05d0\u05d1\u05d2');
- for (var prop in cueData)
- cue[prop] = cueData[prop];
- track.addCue(cue);
- track.mode = 'showing';
-}
-</script>
-<style>
-video::cue {
- font-size: 50px;
- color: green;
- background-color: green;
-}
-</style>
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
- <script>
- var video = document.currentScript.parentNode;
- addTrackWithRtlCueData(video, { position: 50, positionAlign: 'center', align: 'center', size: 50, line: 0 });
- </script>
-</video>
-</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left-ref.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left-ref.html
deleted file mode 100644
index 42ae433..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left-ref.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<style>
-.container {
- position: relative;
- display: inline-block;
- width: 320px;
- height: 240px;
-}
-.cue {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- overflow: hidden;
-}
-.cue.start {
- text-align: end;
-}
-.cue > span {
- font-family: sans-serif;
- background: green;
- color: green;
- font-size: 50px;
- padding: 2px;
-}
-</style>
-<div class="container">
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
-</video>
-<div class="cue start"><span>אבג</span></div>
-</div>
-</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left.html
deleted file mode 100644
index 7433d9f..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-left.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<link rel="match" href="track-cue-rendering-position-align-rtl-line-left-ref.html">
-<script>
-function addTrackWithRtlCueData(video, cueData) {
- var track = video.addTextTrack('subtitles');
- var cue = new VTTCue(0, 10, '\u05d0\u05d1\u05d2');
- for (var prop in cueData)
- cue[prop] = cueData[prop];
- track.addCue(cue);
- track.mode = 'showing';
-}
-</script>
-<style>
-video::cue {
- font-size: 50px;
- color: green;
- background-color: green;
-}
-</style>
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
- <script>
- var video = document.currentScript.parentNode;
- addTrackWithRtlCueData(video, { position: 50, positionAlign: 'line-left', align: 'start', size: 50, line: 0 });
- </script>
-</video>
-</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right-ref.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right-ref.html
deleted file mode 100644
index 374cbdf..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right-ref.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<style>
-.container {
- position: relative;
- display: inline-block;
- width: 320px;
- height: 240px;
-}
-.cue {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- overflow: hidden;
-}
-.cue.end {
- text-align: start;
-}
-.cue > span {
- font-family: sans-serif;
- background: green;
- color: green;
- font-size: 50px;
- padding: 2px;
-}
-</style>
-<div class="container">
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
-</video>
-<div class="cue end"><span>אבג</span></div>
-</div>
-</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right.html b/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right.html
deleted file mode 100644
index b0a0d74..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/webvtt/rendering/cues-with-video/processing-model/track-cue-rendering-position-align-rtl-line-right.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html class="reftest-wait">
-<script src="/common/reftest-wait.js"></script>
-<link rel="match" href="track-cue-rendering-position-align-rtl-line-right-ref.html">
-<script>
-function addTrackWithRtlCueData(video, cueData) {
- var track = video.addTextTrack('subtitles');
- var cue = new VTTCue(0, 10, '\u05d0\u05d1\u05d2');
- for (var prop in cueData)
- cue[prop] = cueData[prop];
- track.addCue(cue);
- track.mode = 'showing';
-}
-</script>
-<style>
-video::cue {
- font-size: 50px;
- color: green;
- background-color: green;
-}
-</style>
-<video width="320" height="240" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
- <source src="/media/white.webm" type="video/webm">
- <source src="/media/white.mp4" type="video/mp4">
- <script>
- var video = document.currentScript.parentNode;
- addTrackWithRtlCueData(video, { position: 50, positionAlign: 'line-right', align: 'end', size: 50, line: 0 });
- </script>
-</video>
-</html>
diff --git a/third_party/WebKit/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt b/third_party/WebKit/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt
index 473c92c..0abadb47 100644
--- a/third_party/WebKit/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt
+++ b/third_party/WebKit/LayoutTests/media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt
@@ -1,61 +1,61 @@
WEBVTT FILE
1
-00:00:00.000 --> 00:00:00.500 line:100% position:50%,center
+00:00:00.000 --> 00:00:00.500 line:100% position:50%
This is a demo track to illustrate positioning features of cues.
2
-00:00:00.500 --> 00:00:01.000 line:50% position:50%,center
+00:00:00.500 --> 00:00:01.000 line:50% position:50%
Using HTML5 captions, you can position the cues anywhere.
3
-00:00:01.000 --> 00:00:01.500 line:0% position:0%,line-left align:start
+00:00:01.000 --> 00:00:01.500 line:0% position:0% align:start
For example, here is a cue on the top left-corner.
4
-00:00:01.500 --> 00:00:02.000 line:0% position:100%,line-right align:end
+00:00:01.500 --> 00:00:02.000 line:0% position:100% align:end
Or on the top-right corner.
5
-00:00:02.000 --> 00:00:02.500 line:100% position:100%,line-right align:right
+00:00:02.000 --> 00:00:02.500 line:100% position:100% align:right
Bottom-right corner.
6
-00:00:02.500 --> 00:00:03.000 line:100% position:0%,line-left align:left
+00:00:02.500 --> 00:00:03.000 line:100% position:0% align:left
And, as you might expect, the bottom-left one.
7
-00:00:03.000 --> 00:00:03.500 line:50% position:50%,center
+00:00:03.000 --> 00:00:03.500 line:50% position:50%
Cues are implicitly displayed within the viewport area.
8
-00:00:03.500 --> 00:00:04.000 line:100% position:50%,center align:center
+00:00:03.500 --> 00:00:04.000 line:100% position:50% align:middle
And always on top of the controls, if these are visible.
9
-00:00:04.000 --> 00:00:05.000 line:50% position:50%,center
+00:00:04.000 --> 00:00:05.000 line:50% position:50%
You may even have multiple cues in the same time.
10
-00:00:04.000 --> 00:00:05.000 line:0% position:0%,line-left align:start
+00:00:04.000 --> 00:00:05.000 line:0% position:0% align:start
Top-left cue.
11
-00:00:04.000 --> 00:00:05.000 line:0% position:100%,line-right align:end
+00:00:04.000 --> 00:00:05.000 line:0% position:100% align:end
Top-right cue.
12
-00:00:04.000 --> 00:00:05.000 line:100% position:50%,center
+00:00:04.000 --> 00:00:05.000 line:100% position:50%
Bottom cue.
13
-00:00:04.000 --> 00:00:05.000 line:25% position:100%,line-right align:end
+00:00:04.000 --> 00:00:05.000 line:25% position:100% align:end
Random cue 1.
14
-00:00:04.000 --> 00:00:05.000 line:33% position:44%,line-left align:start
+00:00:04.000 --> 00:00:05.000 line:33% position:44% align:start
Random cue 2.
15
-00:00:04.000 --> 00:00:05.000 line:55% position:23%,line-left align:start
+00:00:04.000 --> 00:00:05.000 line:55% position:23% align:start
Random cue 3.
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-position-auto-rtl-expected.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-position-auto-rtl-expected.html
index 10e55e5..3971674 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-position-auto-rtl-expected.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-position-auto-rtl-expected.html
@@ -18,14 +18,14 @@
overflow: hidden;
}
.cue.start {
- right: 25%;
+ right: 50%;
text-align: end;
}
.cue.middle {
text-align: center;
}
.cue.end {
- left: 25%;
+ left: 50%;
text-align: start;
}
.cue > span {
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
index 5bdac13..088952b 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -6211,9 +6211,7 @@
attribute @@toStringTag
getter align
getter line
- getter lineAlign
getter position
- getter positionAlign
getter size
getter snapToLines
getter text
@@ -6222,9 +6220,7 @@
method getCueAsHTML
setter align
setter line
- setter lineAlign
setter position
- setter positionAlign
setter size
setter snapToLines
setter text
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
index 0c2b5a2..492f714f 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -7277,9 +7277,7 @@
attribute @@toStringTag
getter align
getter line
- getter lineAlign
getter position
- getter positionAlign
getter region
getter size
getter snapToLines
@@ -7289,9 +7287,7 @@
method getCueAsHTML
setter align
setter line
- setter lineAlign
setter position
- setter positionAlign
setter region
setter size
setter snapToLines
diff --git a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.cpp b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.cpp
index a5b167a..31c352c 100644
--- a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.cpp
+++ b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.cpp
@@ -59,16 +59,15 @@
CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr};
static_assert(WTF_ARRAY_LENGTH(kDisplayWritingModeMap) ==
VTTCue::kNumberOfWritingDirections,
- "kDisplayWritingModeMap should have the same number of elements "
- "as VTTCue::kNumberOfWritingDirections");
+ "displayWritingModeMap should have the same number of elements "
+ "as VTTCue::NumberOfWritingDirections");
static const CSSValueID kDisplayAlignmentMap[] = {
CSSValueStart, CSSValueCenter, CSSValueEnd, CSSValueLeft, CSSValueRight};
-static_assert(
- WTF_ARRAY_LENGTH(kDisplayAlignmentMap) ==
- static_cast<size_t>(VTTCue::TextAlignment::kNumberOfAlignments),
- "kDisplayAlignmentMap should have the same number of elements as "
- "VTTCue::TextAlignment::kNumberOfAlignments");
+static_assert(WTF_ARRAY_LENGTH(kDisplayAlignmentMap) ==
+ VTTCue::kNumberOfAlignments,
+ "displayAlignmentMap should have the same number of elements as "
+ "VTTCue::NumberOfAlignments");
static const String& AutoKeyword() {
DEFINE_STATIC_LOCAL(const String, auto_string, ("auto"));
@@ -100,16 +99,6 @@
return right;
}
-static const String& LineLeftKeyword() {
- DEFINE_STATIC_LOCAL(const String, line_left, ("line-left"));
- return line_left;
-}
-
-static const String& LineRightKeyword() {
- DEFINE_STATIC_LOCAL(const String, line_right, ("line-right"));
- return line_right;
-}
-
static const String& HorizontalKeyword() {
return g_empty_string;
}
@@ -152,14 +141,13 @@
VTTCueBox::VTTCueBox(Document& document)
: HTMLDivElement(document),
- snap_to_lines_position_(std::numeric_limits<float>::quiet_NaN()),
- line_align_(0) {
+ snap_to_lines_position_(std::numeric_limits<float>::quiet_NaN()) {
SetShadowPseudoId(AtomicString("-webkit-media-text-track-display"));
}
void VTTCueBox::ApplyCSSProperties(
const VTTDisplayParameters& display_parameters) {
- // https://w3c.github.io/webvtt/#applying-css-properties
+ // http://dev.w3.org/html5/webvtt/#applying-css-properties-to-webvtt-node-objects
// Initialize the (root) list of WebVTT Node Objects with the following CSS
// settings:
@@ -205,10 +193,8 @@
// text alignment:
SetInlineStyleProperty(CSSPropertyTextAlign, display_parameters.text_align);
- // The snap-to-lines position and line alignment is propagated to
- // LayoutVTTCue.
+ // The snap-to-lines position is propagated to LayoutVTTCue.
snap_to_lines_position_ = display_parameters.snap_to_lines_position;
- line_align_ = display_parameters.line_align;
}
LayoutObject* VTTCueBox::CreateLayoutObject(const ComputedStyle& style) {
@@ -219,7 +205,7 @@
if (style.GetPosition() == EPosition::kRelative)
return HTMLDivElement::CreateLayoutObject(style);
- return new LayoutVTTCue(this, snap_to_lines_position_, line_align_);
+ return new LayoutVTTCue(this, snap_to_lines_position_);
}
VTTCue::VTTCue(Document& document,
@@ -232,9 +218,7 @@
text_position_(std::numeric_limits<double>::quiet_NaN()),
cue_size_(100),
writing_direction_(kHorizontal),
- text_alignment_(TextAlignment::kCenter),
- position_alignment_(PositionAlignment::kAuto),
- line_alignment_(LineAlignment::kStart),
+ cue_alignment_(kCenter),
vtt_node_tree_(nullptr),
cue_background_box_(HTMLDivElement::Create(document)),
snap_to_lines_(true),
@@ -312,7 +296,7 @@
}
void VTTCue::setLine(const DoubleOrAutoKeyword& position) {
- // https://w3c.github.io/webvtt/#webvtt-line-cue-setting
+ // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line
// On setting, the WebVTT cue line must be set to the new value; if the new
// value is the string "auto", then it must be interpreted as the special
// value auto. ("auto" is translated to NaN.)
@@ -332,39 +316,6 @@
CueDidChange();
}
-const String& VTTCue::lineAlign() const {
- switch (line_alignment_) {
- case LineAlignment::kStart:
- return StartKeyword();
- case LineAlignment::kCenter:
- return CenterKeyword();
- case LineAlignment::kEnd:
- return EndKeyword();
- default:
- NOTREACHED();
- return g_empty_string;
- }
-}
-
-void VTTCue::setLineAlign(const String& value) {
- LineAlignment alignment = line_alignment_;
- if (value == StartKeyword())
- alignment = LineAlignment::kStart;
- else if (value == CenterKeyword())
- alignment = LineAlignment::kCenter;
- else if (value == EndKeyword())
- alignment = LineAlignment::kEnd;
- else
- NOTREACHED();
-
- if (alignment == line_alignment_)
- return;
-
- CueWillChange();
- line_alignment_ = alignment;
- CueDidChange();
-}
-
bool VTTCue::TextPositionIsAuto() const {
return std::isnan(text_position_);
}
@@ -378,7 +329,7 @@
void VTTCue::setPosition(const DoubleOrAutoKeyword& position,
ExceptionState& exception_state) {
- // https://w3c.github.io/webvtt/#dom-vttcue-position
+ // http://dev.w3.org/html5/webvtt/#dfn-vttcue-position
// On setting, if the new value is negative or greater than 100, then an
// IndexSizeError exception must be thrown. Otherwise, the WebVTT cue
// position must be set to the new value; if the new value is the string
@@ -402,51 +353,14 @@
CueDidChange();
}
-const String& VTTCue::positionAlign() const {
- switch (position_alignment_) {
- case PositionAlignment::kLineLeft:
- return LineLeftKeyword();
- case PositionAlignment::kCenter:
- return CenterKeyword();
- case PositionAlignment::kLineRight:
- return LineRightKeyword();
- case PositionAlignment::kAuto:
- return AutoKeyword();
- default:
- NOTREACHED();
- return g_empty_string;
- }
-}
-
-void VTTCue::setPositionAlign(const String& value) {
- PositionAlignment alignment = position_alignment_;
- if (value == LineLeftKeyword())
- alignment = PositionAlignment::kLineLeft;
- else if (value == CenterKeyword())
- alignment = PositionAlignment::kCenter;
- else if (value == LineRightKeyword())
- alignment = PositionAlignment::kLineRight;
- else if (value == AutoKeyword())
- alignment = PositionAlignment::kAuto;
- else
- NOTREACHED();
-
- if (alignment == position_alignment_)
- return;
-
- CueWillChange();
- position_alignment_ = alignment;
- CueDidChange();
-}
-
void VTTCue::setSize(double size, ExceptionState& exception_state) {
- // https://w3c.github.io/webvtt/#dom-vttcue-size
- // On setting, if the new value is negative or greater than 100, then
- // an IndexSizeError exception must be thrown.
+ // http://dev.w3.org/html5/webvtt/#dfn-vttcue-size
+ // On setting, if the new value is negative or greater than 100, then throw
+ // an IndexSizeError exception.
if (IsInvalidPercentage(size, exception_state))
return;
- // Otherwise, WebVTT cue size must be set to the new value.
+ // Otherwise, set the WebVTT cue size to the new value.
if (cue_size_ == size)
return;
@@ -456,16 +370,16 @@
}
const String& VTTCue::align() const {
- switch (text_alignment_) {
- case TextAlignment::kStart:
+ switch (cue_alignment_) {
+ case kStart:
return StartKeyword();
- case TextAlignment::kCenter:
+ case kCenter:
return CenterKeyword();
- case TextAlignment::kEnd:
+ case kEnd:
return EndKeyword();
- case TextAlignment::kLeft:
+ case kLeft:
return LeftKeyword();
- case TextAlignment::kRight:
+ case kRight:
return RightKeyword();
default:
NOTREACHED();
@@ -474,25 +388,25 @@
}
void VTTCue::setAlign(const String& value) {
- TextAlignment alignment = text_alignment_;
+ CueAlignment alignment = cue_alignment_;
if (value == StartKeyword())
- alignment = TextAlignment::kStart;
+ alignment = kStart;
else if (value == CenterKeyword())
- alignment = TextAlignment::kCenter;
+ alignment = kCenter;
else if (value == EndKeyword())
- alignment = TextAlignment::kEnd;
+ alignment = kEnd;
else if (value == LeftKeyword())
- alignment = TextAlignment::kLeft;
+ alignment = kLeft;
else if (value == RightKeyword())
- alignment = TextAlignment::kRight;
+ alignment = kRight;
else
NOTREACHED();
- if (alignment == text_alignment_)
+ if (alignment == cue_alignment_)
return;
CueWillChange();
- text_alignment_ = alignment;
+ cue_alignment_ = alignment;
CueDidChange();
}
@@ -544,27 +458,27 @@
CueDidChange();
}
-double VTTCue::CalculateComputedLine() const {
- // https://w3c.github.io/webvtt/#cue-computed-line
+double VTTCue::CalculateComputedLinePosition() const {
+ // http://dev.w3.org/html5/webvtt/#dfn-cue-computed-line
// A WebVTT cue has a computed line whose value is that returned by the
// following algorithm, which is defined in terms of the other aspects of
// the cue:
// 1. If the line is numeric, the WebVTT cue snap-to-lines flag of the
- // WebVTT cue is false, and the line is negative or greater than 100,
+ // WebVTT cue is not set, and the line is negative or greater than 100,
// then return 100 and abort these steps.
if (!LineIsAuto() && !snap_to_lines_ && IsInvalidPercentage(line_position_))
return 100;
// 2. If the line is numeric, return the value of the WebVTT cue line and
- // abort these steps. (Either the WebVTT cue snap-to-lines flag is true,
+ // abort these steps. (Either the WebVTT cue snap-to-lines flag is set,
// so any value, not just those in the range 0..100, is valid, or the
// value is in the range 0..100 and is thus valid regardless of the
// value of that flag.)
if (!LineIsAuto())
return line_position_;
- // 3. If the WebVTT cue snap-to-lines flag of the WebVTT cue is false,
+ // 3. If the WebVTT cue snap-to-lines flag of the WebVTT cue is not set,
// return the value 100 and abort these steps. (The WebVTT cue line is
// the special value auto.)
if (!snap_to_lines_)
@@ -644,44 +558,43 @@
return IsLtr(text_direction) ? CSSValueLtr : CSSValueRtl;
}
-double VTTCue::CalculateComputedPosition() const {
- // https://w3c.github.io/webvtt/#cue-computed-position
+double VTTCue::CalculateComputedTextPosition() const {
+ // http://dev.w3.org/html5/webvtt/#dfn-cue-computed-position
// 1. If the position is numeric, then return the value of the position and
// abort these steps. (Otherwise, the position is the special value auto.)
if (!TextPositionIsAuto())
return text_position_;
- // 2. If the cue text alignment is left, return 0 and abort these steps.
- if (text_alignment_ == TextAlignment::kLeft)
- return 0;
- // 3. If the cue text alignment is right, return 100 and abort these steps.
- if (text_alignment_ == TextAlignment::kRight)
- return 100;
- // 4. Otherwise, return 50 and abort these steps.
- return 50;
+ switch (cue_alignment_) {
+ // 2. If the cue text alignment is start or left, return 0 and abort these
+ // steps.
+ case kStart:
+ case kLeft:
+ return 0;
+ // 3. If the cue text alignment is end or right, return 100 and abort these
+ // steps.
+ case kEnd:
+ case kRight:
+ return 100;
+ // 4. If the cue text alignment is center, return 50 and abort these steps.
+ case kCenter:
+ return 50;
+ default:
+ NOTREACHED();
+ return 0;
+ }
}
-VTTCue::PositionAlignment VTTCue::CalculateComputedPositionAlignment() const {
- // https://w3c.github.io/webvtt/#cue-computed-position-alignment
-
- // 1. If the WebVTT cue position alignment is not auto, then return the value
- // of the WebVTT cue position alignment and abort these steps.
- if (position_alignment_ != PositionAlignment::kAuto)
- return position_alignment_;
-
- // 2. If the WebVTT cue text alignment is left, return line-left and
- // abort these steps.
- if (text_alignment_ == TextAlignment::kLeft)
- return PositionAlignment::kLineLeft;
-
- // 3. If the WebVTT cue text alignment is right, return line-right and
- // abort these steps.
- if (text_alignment_ == TextAlignment::kRight)
- return PositionAlignment::kLineRight;
-
- // 4. Otherwise, return center.
- return PositionAlignment::kCenter;
+VTTCue::CueAlignment VTTCue::CalculateComputedCueAlignment() const {
+ switch (cue_alignment_) {
+ case VTTCue::kLeft:
+ return VTTCue::kStart;
+ case VTTCue::kRight:
+ return VTTCue::kEnd;
+ default:
+ return cue_alignment_;
+ }
}
VTTDisplayParameters::VTTDisplayParameters()
@@ -689,11 +602,10 @@
direction(CSSValueNone),
text_align(CSSValueNone),
writing_mode(CSSValueNone),
- snap_to_lines_position(std::numeric_limits<float>::quiet_NaN()),
- line_align(0) {}
+ snap_to_lines_position(std::numeric_limits<float>::quiet_NaN()) {}
VTTDisplayParameters VTTCue::CalculateDisplayParameters() const {
- // https://w3c.github.io/webvtt/#apply-webvtt-cue-settings
+ // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings
VTTDisplayParameters display_parameters;
@@ -705,8 +617,7 @@
// Note: The 'text-align' property is also determined here so that
// VTTCueBox::applyCSSProperties need not have access to a VTTCue.
- display_parameters.text_align =
- kDisplayAlignmentMap[static_cast<size_t>(GetTextAlignment())];
+ display_parameters.text_align = kDisplayAlignmentMap[GetCueAlignment()];
// 3. If the cue writing direction is horizontal, then let block-flow be
// 'tb'. Otherwise, if the cue writing direction is vertical growing left,
@@ -714,22 +625,21 @@
// vertical growing right; let block-flow be 'rl'.
display_parameters.writing_mode = kDisplayWritingModeMap[writing_direction_];
- // Resolve the cue alignment to one of the values {line-left, line-right,
- // center}.
- PositionAlignment computed_position_alignment =
- CalculateComputedPositionAlignment();
+ // Resolve the cue alignment to one of the values {start, end, center}.
+ CueAlignment computed_cue_alignment = CalculateComputedCueAlignment();
// 4. Determine the value of maximum size for cue as per the appropriate
// rules from the following list:
- double computed_position = CalculateComputedPosition();
- double maximum_size = computed_position;
- if (computed_position_alignment == PositionAlignment::kLineLeft) {
- maximum_size = 100 - computed_position;
- } else if (computed_position_alignment == PositionAlignment::kLineRight) {
- maximum_size = computed_position;
- } else if (computed_position_alignment == PositionAlignment::kCenter) {
- maximum_size =
- computed_position <= 50 ? computed_position : (100 - computed_position);
+ double computed_text_position = CalculateComputedTextPosition();
+ double maximum_size = computed_text_position;
+ if (computed_cue_alignment == kStart) {
+ maximum_size = 100 - computed_text_position;
+ } else if (computed_cue_alignment == kEnd) {
+ maximum_size = computed_text_position;
+ } else if (computed_cue_alignment == kCenter) {
+ maximum_size = computed_text_position <= 50
+ ? computed_text_position
+ : (100 - computed_text_position);
maximum_size = maximum_size * 2;
} else {
NOTREACHED();
@@ -748,33 +658,33 @@
// 7. Determine the value of x-position or y-position for cue as per the
// appropriate rules from the following list:
if (writing_direction_ == kHorizontal) {
- switch (computed_position_alignment) {
- case PositionAlignment::kLineLeft:
- display_parameters.position.SetX(computed_position);
+ switch (computed_cue_alignment) {
+ case kStart:
+ display_parameters.position.SetX(computed_text_position);
break;
- case PositionAlignment::kLineRight:
- display_parameters.position.SetX(computed_position -
+ case kEnd:
+ display_parameters.position.SetX(computed_text_position -
display_parameters.size);
break;
- case PositionAlignment::kCenter:
- display_parameters.position.SetX(computed_position -
+ case kCenter:
+ display_parameters.position.SetX(computed_text_position -
display_parameters.size / 2);
break;
default:
NOTREACHED();
}
} else {
- // Cases for writing_direction_ being VerticalGrowing{Left|Right}
- switch (computed_position_alignment) {
- case PositionAlignment::kLineLeft:
- display_parameters.position.SetY(computed_position);
+ // Cases for m_writingDirection being VerticalGrowing{Left|Right}
+ switch (computed_cue_alignment) {
+ case kStart:
+ display_parameters.position.SetY(computed_text_position);
break;
- case PositionAlignment::kLineRight:
- display_parameters.position.SetY(computed_position -
+ case kEnd:
+ display_parameters.position.SetY(computed_text_position -
display_parameters.size);
break;
- case PositionAlignment::kCenter:
- display_parameters.position.SetY(computed_position -
+ case kCenter:
+ display_parameters.position.SetY(computed_text_position -
display_parameters.size / 2);
break;
default:
@@ -784,34 +694,29 @@
// A cue has a computed line whose value is defined in terms of
// the other aspects of the cue.
- double computed_line = CalculateComputedLine();
+ double computed_line_position = CalculateComputedLinePosition();
// 8. Determine the value of whichever of x-position or y-position is not
// yet calculated for cue as per the appropriate rules from the following
// list:
if (!snap_to_lines_) {
if (writing_direction_ == kHorizontal)
- display_parameters.position.SetY(computed_line);
+ display_parameters.position.SetY(computed_line_position);
else
- display_parameters.position.SetX(computed_line);
+ display_parameters.position.SetX(computed_line_position);
} else {
if (writing_direction_ == kHorizontal)
display_parameters.position.SetY(0);
else
display_parameters.position.SetX(0);
}
+
// Step 9 not implemented (margin == 0).
- // The snap-to-lines position and line alignment are propagated to
- // LayoutVTTCue.
- if (snap_to_lines_) {
- display_parameters.snap_to_lines_position = computed_line;
- } else {
- if (line_alignment_ == LineAlignment::kCenter)
- display_parameters.line_align = 50;
- else if (line_alignment_ == LineAlignment::kEnd)
- display_parameters.line_align = 100;
- }
+ // The snap-to-lines position is propagated to LayoutVTTCue.
+ display_parameters.snap_to_lines_position =
+ snap_to_lines_ ? computed_line_position
+ : std::numeric_limits<float>::quiet_NaN();
DCHECK(std::isfinite(display_parameters.size));
DCHECK_NE(display_parameters.direction, CSSValueNone);
@@ -932,7 +837,7 @@
if (cue_size_ != 100)
UseCounter::Count(GetDocument(), WebFeature::kVTTCueRenderSizeNot100);
- if (text_alignment_ != TextAlignment::kCenter)
+ if (cue_alignment_ != kCenter)
UseCounter::Count(GetDocument(), WebFeature::kVTTCueRenderAlignNotCenter);
VTTCueBox* display_box = GetDisplayTree();
@@ -975,7 +880,7 @@
}
static bool ScanPercentage(VTTScanner& input, double& number) {
- // https://w3c.github.io/webvtt/#parse-a-percentage-string
+ // http://dev.w3.org/html5/webvtt/#dfn-parse-a-percentage-string
// 1. Let input be the string being parsed.
// 2. If input contains any characters other than U+0025 PERCENT SIGN
@@ -1048,7 +953,7 @@
}
case kLine: {
// If name is a case-sensitive match for "line"
- // Steps 1 - 2 Handled below.
+ // Steps 1 - 2 skipped.
double number;
// 3. If linepos does not contain at least one ASCII digit, then
// jump to the step labeled next setting.
@@ -1091,74 +996,32 @@
if (is_negative && number)
number = -number;
}
- LineAlignment line_alignment = LineAlignment::kStart;
- if (input.Scan(',')) {
- // 6. If linealign is a case-sensitive match for the string "start",
- // then let cue's WebVTT cue line alignment be start alignment.
- if (input.Scan("start"))
- line_alignment = LineAlignment::kStart;
- // 7. If linealign is a case-sensitive match for the string "center",
- // then let cue's WebVTT cue line alignment be center alignment.
- else if (input.Scan("center"))
- line_alignment = LineAlignment::kCenter;
- // 8. If linealign is a case-sensitive match for the string
- // "end", then let cue's WebVTT cue line alignment be end
- // alignment.
- else if (input.Scan("end"))
- line_alignment = LineAlignment::kEnd;
- // 9. Otherwise, if linealign is not null, then jump to the
- // step labeled next setting.
- else
- break;
- }
if (!input.IsAt(value_run.end()))
break;
- // 9. Let cue's WebVTT cue line be number.
+ // 5. Let cue's WebVTT cue line be number.
line_position_ = number;
- line_alignment_ = line_alignment;
- // 10. If the last character in linepos is a U+0025 PERCENT SIGN
- // character (%), then let cue's WebVTT cue snap-to-lines
- // flag be false. Otherwise, let it be true.
+ // 6. If the last character in linepos is a U+0025 PERCENT SIGN
+ // character (%), then let cue's WebVTT cue snap-to-lines
+ // flag be false. Otherwise, let it be true.
snap_to_lines_ = !is_percentage;
+ // Steps 7 - 9 skipped.
break;
}
case kPosition: {
// If name is a case-sensitive match for "position".
double number;
- // Steps 1 - 2 Handled below.
+ // Steps 1 - 2 skipped.
// 3. If parse a percentage string from colpos doesn't fail, let
// number be the returned percentage, otherwise jump to the step
// labeled next setting (text track cue text position's value
// remains the special value auto).
if (!ScanPercentage(input, number))
break;
- PositionAlignment position_alignment = PositionAlignment::kAuto;
- if (input.Scan(',')) {
- // 4. If colalign is a case-sensitive match for the string
- // "line-left", then let cue's WebVTT cue position
- // alignment be line-left alignment.
- if (input.Scan("line-left"))
- position_alignment = PositionAlignment::kLineLeft;
- // 5. If colalign is a case-sensitive match for the string
- // "center", then let cue's WebVTT cue position alignment
- // be center alignment.
- else if (input.Scan("center"))
- position_alignment = PositionAlignment::kCenter;
- // 6. If colalign is a case-sensitive match for the string
- // "line-right", then let cue's WebVTT cue position alignment be
- // line-right alignment.
- else if (input.Scan("line-right"))
- position_alignment = PositionAlignment::kLineRight;
- // 7. Otherwise, if colalign is not null, then jump to the
- // step labeled next setting.
- else
- break;
- }
if (!input.IsAt(value_run.end()))
break;
- // 8. Let cue's cue position be number.
+ // 4. Let cue's cue position be number.
text_position_ = number;
- position_alignment_ = position_alignment;
+ // Steps 5 - 7 skipped.
break;
}
case kSize: {
@@ -1180,27 +1043,27 @@
// 1. If value is a case-sensitive match for the string "start",
// then let cue's WebVTT cue text alignment be start alignment.
if (input.ScanRun(value_run, StartKeyword()))
- text_alignment_ = TextAlignment::kStart;
+ cue_alignment_ = kStart;
// 2. If value is a case-sensitive match for the string "center",
// then let cue's WebVTT cue text alignment be center alignment.
else if (input.ScanRun(value_run, CenterKeyword()))
- text_alignment_ = TextAlignment::kCenter;
+ cue_alignment_ = kCenter;
// 3. If value is a case-sensitive match for the string "end", then
// let cue's WebVTT cue text alignment be end alignment.
else if (input.ScanRun(value_run, EndKeyword()))
- text_alignment_ = TextAlignment::kEnd;
+ cue_alignment_ = kEnd;
// 4. If value is a case-sensitive match for the string "left",
// then let cue's WebVTT cue text alignment be left alignment.
else if (input.ScanRun(value_run, LeftKeyword()))
- text_alignment_ = TextAlignment::kLeft;
+ cue_alignment_ = kLeft;
// 5. If value is a case-sensitive match for the string "right",
// then let cue's WebVTT cue text alignment be right alignment.
else if (input.ScanRun(value_run, RightKeyword()))
- text_alignment_ = TextAlignment::kRight;
+ cue_alignment_ = kRight;
break;
}
case kRegionId:
diff --git a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.h b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.h
index 0ed8df9..877bc92 100644
--- a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.h
+++ b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.h
@@ -55,7 +55,6 @@
CSSValueID text_align;
CSSValueID writing_mode;
double snap_to_lines_position;
- int line_align;
};
class VTTCueBox final : public HTMLDivElement {
@@ -75,7 +74,6 @@
// non-snap-to-lines layout where no adjustment should take place.
// This is set in applyCSSProperties and propagated to LayoutVTTCue.
float snap_to_lines_position_;
- int line_align_;
};
class VTTCue final : public TextTrackCue {
@@ -103,15 +101,9 @@
void line(DoubleOrAutoKeyword&) const;
void setLine(const DoubleOrAutoKeyword&);
- const String& lineAlign() const;
- void setLineAlign(const String&);
-
void position(DoubleOrAutoKeyword&) const;
void setPosition(const DoubleOrAutoKeyword&, ExceptionState&);
- const String& positionAlign() const;
- void setPositionAlign(const String&);
-
double size() const { return cue_size_; }
void setSize(double, ExceptionState&);
@@ -134,7 +126,7 @@
void RemoveDisplayTree(RemovalNotification) override;
- double CalculateComputedLine() const;
+ double CalculateComputedLinePosition() const;
enum WritingDirection {
kHorizontal = 0,
@@ -144,7 +136,7 @@
};
WritingDirection GetWritingDirection() const { return writing_direction_; }
- enum class TextAlignment {
+ enum CueAlignment {
kStart = 0,
kCenter,
kEnd,
@@ -152,13 +144,7 @@
kRight,
kNumberOfAlignments
};
- TextAlignment GetTextAlignment() const { return text_alignment_; }
-
- enum class PositionAlignment { kLineLeft, kCenter, kLineRight, kAuto };
- PositionAlignment GetPositionAlignment() const { return position_alignment_; }
-
- enum class LineAlignment { kStart, kCenter, kEnd };
- LineAlignment GetLineAlignment() const { return line_alignment_; }
+ CueAlignment GetCueAlignment() const { return cue_alignment_; }
ExecutionContext* GetExecutionContext() const override;
@@ -185,9 +171,8 @@
bool TextPositionIsAuto() const;
VTTDisplayParameters CalculateDisplayParameters() const;
- double CalculateComputedPosition() const;
- LineAlignment CalculateComputedLineAlignment() const;
- PositionAlignment CalculateComputedPositionAlignment() const;
+ double CalculateComputedTextPosition() const;
+ CueAlignment CalculateComputedCueAlignment() const;
enum CueSetting {
kNone,
@@ -205,9 +190,7 @@
double text_position_;
double cue_size_;
WritingDirection writing_direction_;
- TextAlignment text_alignment_;
- PositionAlignment position_alignment_;
- LineAlignment line_alignment_;
+ CueAlignment cue_alignment_;
Member<VTTRegion> region_;
Member<DocumentFragment> vtt_node_tree_;
diff --git a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.idl b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.idl
index 48df964c..060ab772 100644
--- a/third_party/WebKit/Source/core/html/track/vtt/VTTCue.idl
+++ b/third_party/WebKit/Source/core/html/track/vtt/VTTCue.idl
@@ -30,10 +30,9 @@
// https://w3c.github.io/webvtt/#the-vttcue-interface
enum AutoKeyword { "auto" };
-typedef (double or AutoKeyword) LineAndPositionSetting;
enum DirectionSetting { "" /* horizontal */, "rl", "lr" };
-enum LineAlignSetting { "start", "center", "end" };
-enum PositionAlignSetting { "line-left", "center", "line-right", "auto" };
+// enum LineAlignSetting { "start", "middle", "end" };
+// enum PositionAlignSetting { "start", "middle", "end", "auto" };
enum AlignSetting { "start", "center", "end", "left", "right" };
[
@@ -43,10 +42,10 @@
[RuntimeEnabled=WebVTTRegions] attribute VTTRegion? region;
attribute DirectionSetting vertical;
attribute boolean snapToLines;
- attribute LineAndPositionSetting line;
- attribute LineAlignSetting lineAlign;
- [RaisesException=Setter] attribute LineAndPositionSetting position;
- attribute PositionAlignSetting positionAlign;
+ attribute (double or AutoKeyword) line;
+ // attribute LineAlignSetting lineAlign;
+ [RaisesException=Setter] attribute (double or AutoKeyword) position;
+ // attribute PositionAlignSetting positionAlign;
[RaisesException=Setter] attribute double size;
attribute AlignSetting align;
attribute DOMString text;
diff --git a/third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp b/third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp
index c0fa452..a46f033 100644
--- a/third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp
@@ -89,7 +89,7 @@
if (IsFlippedBlocksWritingMode(writing_mode))
line_position = -(line_position + 1);
- // 9. Let position be the result of multiplying step and line.
+ // 9. Let position be the result of multiplying step and line offset.
LayoutUnit position = step * line_position;
// 10. Vertical Growing Left: Decrease position by the width of the
@@ -148,7 +148,7 @@
bool SnapToLinesLayouter::ShouldSwitchDirection(InlineFlowBox* first_line_box,
LayoutUnit step,
LayoutUnit margin) const {
- // 16. Horizontal: If step is negative and the top of the first line box in
+ // 17. Horizontal: If step is negative and the top of the first line box in
// boxes is now above the top of the title area, or if step is positive and
// the bottom of the first line box in boxes is now below the bottom of the
// title area, jump to the step labeled switch direction.
@@ -167,7 +167,7 @@
}
void SnapToLinesLayouter::UpdateLayout() {
- // https://w3c.github.io/webvtt/#apply-webvtt-cue-settings
+ // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings
// Step 13, "If cue's text track cue snap-to-lines flag is set".
InlineFlowBox* first_line_box = FindFirstLineBox();
@@ -236,8 +236,11 @@
// boxes in output, and all of the boxes in output are entirely within the
// title area box, then jump to the step labeled done positioning below.
while (IsOutside(title_area) || IsOverlapping()) {
+ // 16. Let current position score be the percentage of the area of the
+ // bounding box of the boxes in boxes that is outside the title area
+ // box.
if (!ShouldSwitchDirection(first_line_box, step, margin)) {
- // 17. Horizontal: Move all the boxes in boxes down by the distance
+ // 18. Horizontal: Move all the boxes in boxes down by the distance
// given by step. (If step is negative, then this will actually
// result in an upwards movement of the boxes in absolute terms.)
// Vertical: Move all the boxes in boxes right by the distance
@@ -245,11 +248,11 @@
// result in a leftwards movement of the boxes in absolute terms.)
MoveBoxesBy(step);
- // 18. Jump back to the step labeled step loop.
+ // 19. Jump back to the step labeled step loop.
continue;
}
- // 19. Switch direction: If switched is true, then remove all the boxes
+ // 20. Switch direction: If switched is true, then remove all the boxes
// in boxes, and jump to the step labeled done positioning below.
if (switched) {
// This does not "remove" the boxes, but rather just pushes them
@@ -259,68 +262,54 @@
break;
}
- // 20. Otherwise, move all the boxes in boxes back to their specified
+ // 21. Otherwise, move all the boxes in boxes back to their specified
// position as determined in the earlier step.
cue_box_.SetLocation(specified_position_);
- // 21. Negate step.
+ // 22. Negate step.
step = -step;
- // 22. Set switched to true.
+ // 23. Set switched to true.
switched = true;
- // 23. Jump back to the step labeled step loop.
+ // 24. Jump back to the step labeled step loop.
}
}
} // unnamed namespace
-LayoutVTTCue::LayoutVTTCue(ContainerNode* node,
- float snap_to_lines_position,
- int line_align)
- : LayoutBlockFlow(node),
- snap_to_lines_position_(snap_to_lines_position),
- line_align_(line_align) {}
+LayoutVTTCue::LayoutVTTCue(ContainerNode* node, float snap_to_lines_position)
+ : LayoutBlockFlow(node), snap_to_lines_position_(snap_to_lines_position) {}
void LayoutVTTCue::RepositionCueSnapToLinesNotSet() {
- // https://w3c.github.io/webvtt/#apply-webvtt-cue-settings
+ // FIXME: Implement overlapping detection when snap-to-lines is not set.
+ // http://wkb.ug/84296
+
+ // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings
// Step 13, "If cue's text track cue snap-to-lines flag is not set".
- if (line_align_) {
- // 1. Let bounding box be the bounding box of the boxes in boxes.
- LayoutRect bounding_box = ContentBoxRect();
+ // 1. Let bounding box be the bounding box of the boxes in boxes.
- WritingMode writing_mode = StyleRef().GetWritingMode();
- LayoutUnit extent = blink::IsHorizontalWritingMode(writing_mode)
- ? bounding_box.Height()
- : bounding_box.Width();
- // 2. Run the appropriate steps from the following list:
- // If the text track cue writing direction is horizontal
- // If the text track cue line alignment is center alignment
- // Move all the boxes in boxes up by half of the height of
- // bounding box.
- // If the text track cue line alignment is end alignment
- // Move all the boxes in boxes up by the height of bounding box.
- //
- // If the text track cue writing direction is vertical growing left or
- // vertical growing right
- // If the text track cue line alignment is center alignment
- // Move all the boxes in boxes left by half of the width of
- // bounding box.
- // If the text track cue line alignment is end alignment
- // Move all the boxes in boxes left by the width of bounding box.
- LayoutUnit fraction(line_align_);
- fraction /= 100;
- SetLogicalTop(LogicalTop() - extent * fraction);
- }
+ // 2. Run the appropriate steps from the following list:
+ // If the text track cue writing direction is horizontal
+ // If the text track cue line alignment is middle alignment
+ // Move all the boxes in boxes up by half of the height of
+ // bounding box.
+ // If the text track cue line alignment is end alignment
+ // Move all the boxes in boxes up by the height of bounding box.
+ //
+ // If the text track cue writing direction is vertical growing left or
+ // vertical growing right
+ // If the text track cue line alignment is middle alignment
+ // Move all the boxes in boxes left by half of the width of
+ // bounding box.
+ // If the text track cue line alignment is end alignment
+ // Move all the boxes in boxes left by the width of bounding box.
// 3. If none of the boxes in boxes would overlap any of the boxes in
// output, and all the boxes in output are within the video's rendering
// area, then jump to the step labeled done positioning below.
- // FIXME: Implement overlapping detection when snap-to-lines is not set.
- // http://wkb.ug/84296
-
// 4. If there is a position to which the boxes in boxes can be moved while
// maintaining the relative positions of the boxes in boxes to each other
// such that none of the boxes in boxes would overlap any of the boxes in
@@ -376,7 +365,7 @@
LayoutState state(*this);
- // https://w3c.github.io/webvtt/#apply-webvtt-cue-settings - step 13.
+ // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13.
if (!std::isnan(snap_to_lines_position_))
SnapToLinesLayouter(*this, ComputeControlsRect()).UpdateLayout();
else
diff --git a/third_party/WebKit/Source/core/layout/LayoutVTTCue.h b/third_party/WebKit/Source/core/layout/LayoutVTTCue.h
index 489da0d..59b71e39 100644
--- a/third_party/WebKit/Source/core/layout/LayoutVTTCue.h
+++ b/third_party/WebKit/Source/core/layout/LayoutVTTCue.h
@@ -34,7 +34,7 @@
class LayoutVTTCue final : public LayoutBlockFlow {
public:
- LayoutVTTCue(ContainerNode*, float snap_to_lines_position, int line_align);
+ LayoutVTTCue(ContainerNode*, float snap_to_lines_position);
// The computed line position for snap-to-lines layout, and NaN for
// non-snap-to-lines layout where no adjustment should take place.
@@ -47,7 +47,6 @@
void RepositionCueSnapToLinesNotSet();
float snap_to_lines_position_;
- int line_align_;
};
} // namespace blink