Skip to content

Commit 09ffb6b

Browse files
authored
* Add support for LWSP in color expressions (#125)
* Fix horizontal padding in px (#123)
1 parent c306d7f commit 09ffb6b

File tree

8 files changed

+67
-48
lines changed

8 files changed

+67
-48
lines changed

nbproject/project.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ files.encoding=UTF-8
2626
site.root.folder=${file.reference.build-public_html}
2727
source.folder=${file.reference.main-js}
2828
start.file=gen-renders.html
29-
test.folder=${file.reference.test-js}
3029
web.context.root=/imsc1proc

nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<type>org.netbeans.modules.web.clientproject</type>
44
<configuration>
55
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
6-
<name>imscJS</name>
6+
<name>imscJS 1.0.1</name>
77
</data>
88
</configuration>
99
</project>

package.json

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
{
2-
"name" : "imsc",
3-
"description" : "Renders IMSC1 documents to HTML5 fragments",
4-
"version" : "1.0.1-rc.3",
5-
"license" : "BSD-2-Clause",
6-
"homepage" : "https://github.com/sandflow/imscJS",
7-
"bugs" : "https://github.com/sandflow/imscJS/issues",
8-
"repository" : "github:sandflow/imscJS",
9-
"files" : ["src/main/js", "README.txt"],
10-
"keywords" : ["imsc1", "ttml", "imsc"],
11-
"author" : "Pierre-Anthony Lemieux <[email protected]>",
12-
"main" : "src/main/js/main.js",
2+
"name": "imsc",
3+
"description": "Renders IMSC1 documents to HTML5 fragments",
4+
"version": "1.0.1-rc.3",
5+
"license": "BSD-2-Clause",
6+
"homepage": "https://github.com/sandflow/imscJS",
7+
"bugs": "https://github.com/sandflow/imscJS/issues",
8+
"repository": "github:sandflow/imscJS",
9+
"files": [
10+
"src/main/js",
11+
"README.txt"
12+
],
13+
"keywords": [
14+
"imsc1",
15+
"ttml",
16+
"imsc"
17+
],
18+
"author": "Pierre-Anthony Lemieux <[email protected]>",
19+
"main": "src/main/js/main.js",
1320
"dependencies": {
14-
"sax" : "1.2.1"
21+
"sax": "1.2.1"
1522
},
16-
"devDependencies" : {
23+
"devDependencies": {
1724
"grunt": "latest",
1825
"grunt-sync": "latest",
19-
"grunt-contrib-clean" : "latest",
20-
"grunt-npmcopy" : "latest",
21-
"qunit-assert-close" : "latest",
22-
"qunitjs" : "latest",
23-
"grunt-browserify" : "latest",
24-
"grunt-contrib-jshint" : "latest",
25-
"jszip" : "latest",
26-
"filesaver.js-npm" : "latest"
26+
"grunt-contrib-clean": "latest",
27+
"grunt-npmcopy": "latest",
28+
"qunit-assert-close": "latest",
29+
"qunitjs": "latest",
30+
"grunt-browserify": "latest",
31+
"grunt-contrib-jshint": "latest",
32+
"jszip": "latest",
33+
"filesaver.js-npm": "latest"
2734
}
2835
}

src/main/js/styles.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,16 @@
551551
out[i] = padding[i].value / doc.cellResolution.h;
552552

553553
} else if (padding[i].unit === "px") {
554+
555+
if (i === "0" || i === "2") {
556+
557+
out[i] = padding[i].value / doc.pxDimensions.h;
554558

555-
out[i] = padding[i].value / doc.pxDimensions.h;
559+
} else {
556560

561+
out[i] = padding[i].value / doc.pxDimensions.w;
562+
}
563+
557564
} else {
558565

559566
return null;

src/main/js/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
*/
5656

5757
var HEX_COLOR_RE = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?/;
58-
var DEC_COLOR_RE = /rgb\((\d+),(\d+),(\d+)\)/;
59-
var DEC_COLORA_RE = /rgba\((\d+),(\d+),(\d+),(\d+)\)/;
58+
var DEC_COLOR_RE = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
59+
var DEC_COLORA_RE = /rgba\(\s*(\d+),\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
6060
var NAMED_COLOR = {
6161
transparent: [0, 0, 0, 0],
6262
black: [0, 0, 0, 255],

src/test/resources/unit-tests/colorExpressions.ttml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ xmlns:ittp="http://www.w3.org/ns/ttml/profile/imsc1#parameter">
1010
<p tts:color="#FFFFFF">#FFFFFF</p>
1111
<p tts:color="#FFFFFF7F">#FFFFFF7F</p>
1212
<p tts:color="rgb(255,128,255)">rgb(255,128,255)</p>
13+
<p tts:color="rgb( 255, 128 , 255 )">rgb(255,128,255)</p>
1314
<p tts:color="rgba(128,255,255,63)">rgba(128,255,255,63)</p>
1415
<p tts:color="transparent">transparent</p>
1516
<p tts:color="black">black</p>

src/test/webapp/js/unit-tests.js

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,104 +66,109 @@ QUnit.test(
6666
doc.body.contents[0].contents[2].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
6767
[255, 128, 255, 255]
6868
);
69-
69+
7070
assert.deepEqual(
7171
doc.body.contents[0].contents[3].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
72-
[128, 255, 255, 63]
72+
[255, 128, 255, 255]
7373
);
7474

7575
assert.deepEqual(
7676
doc.body.contents[0].contents[4].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
77-
[0, 0, 0, 0]
77+
[128, 255, 255, 63]
7878
);
7979

8080
assert.deepEqual(
8181
doc.body.contents[0].contents[5].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
82+
[0, 0, 0, 0]
83+
);
84+
85+
assert.deepEqual(
86+
doc.body.contents[0].contents[6].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
8287
[0, 0, 0, 255]
8388
);
8489

8590
assert.deepEqual(
86-
doc.body.contents[0].contents[6].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
91+
doc.body.contents[0].contents[7].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
8792
[0xc0, 0xc0, 0xc0, 255]
8893
);
8994

9095
assert.deepEqual(
91-
doc.body.contents[0].contents[7].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
96+
doc.body.contents[0].contents[8].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
9297
[0x80, 0x80, 0x80, 255]
9398
);
9499

95100
assert.deepEqual(
96-
doc.body.contents[0].contents[8].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
101+
doc.body.contents[0].contents[9].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
97102
[255, 255, 255, 255]
98103
);
99104

100105
assert.deepEqual(
101-
doc.body.contents[0].contents[9].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
106+
doc.body.contents[0].contents[10].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
102107
[0x80, 0, 0, 255]
103108
);
104109

105110
assert.deepEqual(
106-
doc.body.contents[0].contents[10].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
111+
doc.body.contents[0].contents[11].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
107112
[255, 0, 0, 255]
108113
);
109114

110115
assert.deepEqual(
111-
doc.body.contents[0].contents[11].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
116+
doc.body.contents[0].contents[12].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
112117
[0x80, 0, 0x80, 255]
113118
);
114119

115120
assert.deepEqual(
116-
doc.body.contents[0].contents[12].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
121+
doc.body.contents[0].contents[13].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
117122
[255, 0, 255, 255]
118123
);
119124

120125
assert.deepEqual(
121-
doc.body.contents[0].contents[13].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
126+
doc.body.contents[0].contents[14].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
122127
[255, 0, 255, 255]
123128
);
124129

125130
assert.deepEqual(
126-
doc.body.contents[0].contents[14].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
131+
doc.body.contents[0].contents[15].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
127132
[0, 0x80, 0, 255]
128133
);
129134

130135
assert.deepEqual(
131-
doc.body.contents[0].contents[15].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
136+
doc.body.contents[0].contents[16].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
132137
[0, 255, 0, 255]
133138
);
134139

135140
assert.deepEqual(
136-
doc.body.contents[0].contents[16].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
141+
doc.body.contents[0].contents[17].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
137142
[0x80, 0x80, 0, 255]
138143
);
139144

140145
assert.deepEqual(
141-
doc.body.contents[0].contents[17].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
146+
doc.body.contents[0].contents[18].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
142147
[255, 255, 0, 255]
143148
);
144149

145150
assert.deepEqual(
146-
doc.body.contents[0].contents[18].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
151+
doc.body.contents[0].contents[19].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
147152
[0, 0, 0x80, 255]
148153
);
149154

150155
assert.deepEqual(
151-
doc.body.contents[0].contents[19].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
156+
doc.body.contents[0].contents[20].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
152157
[0, 0, 255, 255]
153158
);
154159

155160
assert.deepEqual(
156-
doc.body.contents[0].contents[20].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
161+
doc.body.contents[0].contents[21].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
157162
[0, 0x80, 0x80, 255]
158163
);
159164

160165
assert.deepEqual(
161-
doc.body.contents[0].contents[21].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
166+
doc.body.contents[0].contents[22].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
162167
[0, 255, 255, 255]
163168
);
164169

165170
assert.deepEqual(
166-
doc.body.contents[0].contents[22].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
171+
doc.body.contents[0].contents[23].styleAttrs["http://www.w3.org/ns/ttml#styling color"],
167172
[0, 255, 255, 255]
168173
);
169174

@@ -200,7 +205,7 @@ QUnit.test(
200205
);
201206

202207
QUnit.test(
203-
"Parse Color Expressions",
208+
"Parse Length Expressions",
204209
function (assert) {
205210

206211
return getIMSC1Document("unit-tests/lengthExpressions.ttml").then(

0 commit comments

Comments
 (0)