Skip to content

Commit

Permalink
Move from "height" to "lines" in region spec.
Browse files Browse the repository at this point in the history
Add 2 tests.
  • Loading branch information
silviapfeiffer committed Dec 9, 2013
1 parent 436db5e commit a0241e5
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cpc_video.vtt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WEBVTT
Region: id=r1 width=60% height=4 viewportanchor=50%,90% regionanchor=50%,100% scroll=up
Region: id=r1 width=60% lines=4 viewportanchor=50%,90% regionanchor=50%,100% scroll=up
0
00:00:00.967 --> 00:00:06.873
Expand Down
2 changes: 1 addition & 1 deletion dom_construction.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ var WebVTT2DocumentFragment = function() {
var width = regionAttributes.width * videoWidth / 100.0;
cssRegion += " width:" + width + "px;";

var height = regionAttributes.height * lineHeight;
var height = regionAttributes.lines * lineHeight;
cssRegion += " max-height:" + height + "px;";
cssRegion += " min-height:0px;";

Expand Down
4 changes: 2 additions & 2 deletions parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ <h1>Live <a href="http://dev.w3.org/html5/webvtt/">WebVTT</a> Validator</h1>
<textarea oninput="test()">WEBVTT
Kind: captions
Language: en-US
Region: id=fred width=80% height=3 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% height=4 viewportanchor=50%,50% regionanchor=50%,50%
Region: id=fred width=80% lines=3 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% lines=4 viewportanchor=50%,50% regionanchor=50%,50%

00:00:05.940 --> 00:00:10.610 line:25%
WHEN I GET A SICK BIRD,
Expand Down
8 changes: 4 additions & 4 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ var WebVTTMetadataParser = function(errorHandler) {
var regionAttributes = {
id:"",
width:100, /* % */
height:3,
lines:3,
regionanchorX:0, /* % */
regionanchorY:100, /* % */
viewportanchorX:0, /* % */
Expand Down Expand Up @@ -304,12 +304,12 @@ var WebVTTMetadataParser = function(errorHandler) {
}
break;

case ("height"): // height
case ("lines"): // lines
if (attributeValue[lastValueIndex] === "%") {
err("Region height cannot be a percentage.");
err("Region height in lines cannot be a percentage.");
continue;
}
regionAttributes.height = parseInt(attributeValue, 10);
regionAttributes.lines = parseInt(attributeValue, 10);
break;

case ("regionanchor"): // regionanchor
Expand Down
4 changes: 2 additions & 2 deletions player.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ <h1>Live <a href="http://dev.w3.org/html5/webvtt/">WebVTT</a> Renderer</h1>
<textarea oninput="test()">WEBVTT
Kind: captions
Language: en-US
Region: id=r1 width=80% height=4 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% height=4 viewportanchor=50%,50% regionanchor=50%,50%
Region: id=r1 width=80% lines=4 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% lines=4 viewportanchor=50%,50% regionanchor=50%,50%

17
00:00:00.781 --> 00:00:07.120 region:r1
Expand Down
2 changes: 1 addition & 1 deletion serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var WebVTTSerializer = function() {
result += " id=" + attributes.id;
}
result += " width=" + attributes.width + "%";
result += " height=" + attributes.height;
result += " lines=" + attributes.lines;
result += " regionanchor=" + attributes.regionanchorX + "%," + attributes.regionanchorY + "%";
result += " viewportanchor=" + attributes.viewportanchorX + "%," + attributes.viewportanchorY + "%";
if (attributes.scroll) {
Expand Down
1 change: 1 addition & 0 deletions tests/regions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
19 changes: 19 additions & 0 deletions tests/regions.vtt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
WEBVTT
Kind: captions
Language: en-US
Region: id=fred width=80% lines=3 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% lines=4 viewportanchor=50%,50% regionanchor=50%,50%
00:00:05.940 --> 00:00:10.610 line:25%
WHEN I GET A SICK BIRD,

00:00:07.040 --> 00:00:11.700 region:fred
THAT JUST <b>STOPS</b> EVERYTHING

1
00:00:09.410 --> 00:00:12.910 region:bill position:20%
FROM MOVING FROM MY PLACE

00:00:10.610 --> 00:00:14.100 size:50%
TO ANYWHERE
ELSE OR BEYOND
1 change: 1 addition & 0 deletions tests/timestamps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
30 changes: 30 additions & 0 deletions tests/timestamps.vtt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
WEBVTT
Kind: captions
Language: en-US
Region: id=r1 width=80% lines=4 viewportanchor=10%,90% regionanchor=0%,100% scroll=up
Region: id=bill width=50% lines=4 viewportanchor=50%,50% regionanchor=50%,50%
17
00:00:00.781 --> 00:00:07.120 region:r1
NO<00:00:00.814>W <00:00:00.847>TH<00:00:00.881>E <00:00:00.914>RO<00:00:00.947>LL<00:00:00.981>-U<00:00:01.014>P <00:00:01.048>MO<00:00:01.081>DE<00:00:01.114>.

18
00:00:02.884 --> 00:00:07.622 region:r1
TH<00:00:02.917>IS<00:00:02.950> M<00:00:02.984>OD<00:00:03.017>E <00:00:03.050>IS<00:00:03.084> N<00:00:03.117>OR<00:00:03.151>MA<00:00:03.184>LL<00:00:03.217>Y <00:00:03.251>US<00:00:03.284>ED

19
00:00:04.018 --> 00:00:08.789 region:r1
FO<00:00:04.051>R <00:00:04.084>TV<00:00:04.118> N<00:00:04.151>EW<00:00:04.184>S <00:00:04.218>PR<00:00:04.251>OG<00:00:04.285>RA<00:00:04.318>MS<00:00:04.351>.

20
00:00:06.187 --> 00:00:10.124 region:r1
CA<00:00:06.220>PT<00:00:06.253>IO<00:00:06.287>N <00:00:06.320>LI<00:00:06.353>NE<00:00:06.387>S <00:00:06.420>RO<00:00:06.454>LL<00:00:06.487> U<00:00:06.520>P

21
00:00:07.120 --> 00:00:10.124 region:r1
FR<00:00:07.655>OM<00:00:07.688> T<00:00:07.722>HE<00:00:07.755> S<00:00:07.788>CR<00:00:07.822>EE<00:00:07.855>N <00:00:07.889>BO<00:00:07.922>TT<00:00:07.955>OM

22
00:00:07.622 --> 00:00:10.124 region:r1
ON<00:00:08.822>E <00:00:08.855>LI<00:00:08.889>NE<00:00:08.922> A<00:00:08.955>T <00:00:08.989>A <00:00:09.022>TI<00:00:09.056>ME<00:00:09.089>.

0 comments on commit a0241e5

Please sign in to comment.