Skip to content

Commit

Permalink
Refactor linePadding, multiRowAlign and fillLineGap
Browse files Browse the repository at this point in the history
* Line-based styles now supports all writing modes
* itts:linePadding now uses padding on p to reserve line padding space (fixes sandflow#95)
* Added global context to style resolution
  • Loading branch information
palemieux authored May 15, 2018
1 parent 1376a92 commit ea55677
Show file tree
Hide file tree
Showing 37 changed files with 1,233 additions and 10,242 deletions.
529 changes: 320 additions & 209 deletions src/main/js/html.js

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions src/main/js/isd.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@
/* create the ISD object from the IMSC1 doc */

var isd = new ISD(tt);

/* context */

var context = {

/* empty for now */

};

/* process regions */

for (var r in tt.head.layout.regions) {

/* post-order traversal of the body tree per [construct intermediate document] */

var c = isdProcessContentElement(tt, offset, tt.head.layout.regions[r], tt.body, null, '', tt.head.layout.regions[r], errorHandler);
var c = isdProcessContentElement(tt, offset, tt.head.layout.regions[r], tt.body, null, '', tt.head.layout.regions[r], errorHandler, context);

if (c !== null) {

Expand All @@ -72,7 +80,7 @@
return isd;
};

function isdProcessContentElement(doc, offset, region, body, parent, inherited_region_id, elem, errorHandler) {
function isdProcessContentElement(doc, offset, region, body, parent, inherited_region_id, elem, errorHandler, context) {

/* prune if temporally inactive (<br> are not included in timing) */

Expand Down Expand Up @@ -259,11 +267,12 @@
if (cs.compute !== null) {

var cstyle = cs.compute(
/*doc, parent, element, attr*/
/*doc, parent, element, attr, context*/
doc,
parent,
isd_element,
isd_element.styleAttrs[cs.qname]
isd_element.styleAttrs[cs.qname],
context
);

if (cstyle !== null) {
Expand Down Expand Up @@ -310,7 +319,7 @@

for (var x in contents) {

var c = isdProcessContentElement(doc, offset, region, body, isd_element, associated_region_id, contents[x]);
var c = isdProcessContentElement(doc, offset, region, body, isd_element, associated_region_id, contents[x], errorHandler, context);

/*
* keep child element only if they are non-null and their region match
Expand Down
16 changes: 8 additions & 8 deletions src/main/js/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}

},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

var h;
var w;
Expand Down Expand Up @@ -216,7 +216,7 @@
true,
true,
imscUtils.parseLength,
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

var fs;

Expand Down Expand Up @@ -307,7 +307,7 @@
return imscUtils.parseLength(str);
}
},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

var lh;

Expand Down Expand Up @@ -380,7 +380,7 @@
}

},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

var h;
var w;
Expand Down Expand Up @@ -457,7 +457,7 @@

return r;
},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

var padding;

Expand Down Expand Up @@ -587,7 +587,7 @@
function (str) {
return str;
},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

/* Section 7.16.9 of XSL */

Expand Down Expand Up @@ -659,7 +659,7 @@
}

},
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {

/*
* returns {color: <color>, thickness: <norm length>}
Expand Down Expand Up @@ -791,7 +791,7 @@
true,
false,
imscUtils.parseLength,
function (doc, parent, element, attr) {
function (doc, parent, element, attr, context) {
if (attr.unit === "c") {

return attr.value / doc.cellResolution.h;
Expand Down
84 changes: 42 additions & 42 deletions src/test/resources/generated/FillLineGap001/html/0.000000.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,59 @@
</span>
<br style="margin: 0px;">
<span style="margin: 0px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 24px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">T</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">h</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">q</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">u</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">i</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">c</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">k</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">T</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">h</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">q</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">u</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">i</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">c</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">k</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;"> </span>
</span>
<span style="margin: 0px; background-color: rgb(183, 88, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 36px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 3px;">b</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 3px;">r</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 3px;">o</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 3px;">w</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 3px;">n</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 5px;">b</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 5px;">r</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 5px;">o</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 5px;">w</span>
<span style="background-color: rgb(183, 88, 0); padding-top: 3px; padding-bottom: 5px;">n</span>
</span>
<span style="margin: 0px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 24px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">f</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 7px;">x</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">f</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 13px; padding-bottom: 9px;">x</span>
</span>
<br style="margin: 0px;">
<span style="margin: 0px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 24px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">j</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">u</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">m</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">p</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">s</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">v</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">r</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">t</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">h</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">j</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">u</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">m</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">p</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">s</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">v</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">r</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">t</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">h</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">e</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;"> </span>
</span>
<span style="margin: 0px; background-color: rgb(223, 187, 2); color: rgb(0, 0, 0); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 12px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(223, 187, 2); padding-top: 17px; padding-bottom: 11px;">l</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 17px; padding-bottom: 11px;">a</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 17px; padding-bottom: 11px;">z</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 17px; padding-bottom: 11px;">y</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 15px; padding-bottom: 11px;">l</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 15px; padding-bottom: 11px;">a</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 15px; padding-bottom: 11px;">z</span>
<span style="background-color: rgb(223, 187, 2); padding-top: 15px; padding-bottom: 11px;">y</span>
</span>
<span style="margin: 0px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 24px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">d</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 7px; padding-bottom: 8px;">g</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;"> </span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">d</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">o</span>
<span style="background-color: rgb(0, 0, 0); padding-top: 5px; padding-bottom: 8px;">g</span>
</span>
<br style="margin: 0px;">
<span style="margin: 0px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); direction: ltr; font-family: &quot;Courier New&quot;, &quot;Liberation Mono&quot;, Courier, monospace; font-size: 24px; font-style: normal; font-weight: normal; text-decoration: none; unicode-bidi: normal; visibility: visible; white-space: normal;">
Expand Down
Loading

0 comments on commit ea55677

Please sign in to comment.