Skip to content

Commit 7cebdbd

Browse files
committed
XFA - Fix lot of layout issues
- I thought it was possible to rely on browser layout engine to handle layout stuff but it isn't possible - mainly because when a contentArea overflows, we must continue to layout in the next contentArea - when no more contentArea is available then we must go to the next page... - we must handle breakBefore and breakAfter which allows to "break" the layout to go to the next container - Sometimes some containers don't provide their dimensions so we must compute them in order to know where to put them in their parents but to compute those dimensions we need to layout the container itself... - See top of file layout.js for more explanations about layout. - fix few bugs in other places I met during my work on layout.
1 parent 3538ef0 commit 7cebdbd

14 files changed

+2016
-363
lines changed

src/core/xfa/bind.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
$finalize,
2323
$getAttributeIt,
2424
$getChildren,
25+
$getDataValue,
2526
$getParent,
2627
$getRealChildrenByNameIt,
2728
$global,
@@ -88,7 +89,7 @@ class Binder {
8889

8990
if (formNode[$hasSettableValue]()) {
9091
if (data[$isDataValue]()) {
91-
const value = data[$content].trim();
92+
const value = data[$getDataValue]();
9293
// TODO: use picture.
9394
formNode[$setValue](createText(value));
9495
formNode[$data] = data;
@@ -114,7 +115,7 @@ class Binder {
114115
}
115116
}
116117

117-
_findDataByNameToConsume(name, dataNode, global) {
118+
_findDataByNameToConsume(name, isValue, dataNode, global) {
118119
if (!name) {
119120
return null;
120121
}
@@ -130,9 +131,16 @@ class Binder {
130131
/* allTransparent = */ false,
131132
/* skipConsumed = */ true
132133
);
133-
match = generator.next().value;
134-
if (match) {
135-
return match;
134+
// Try to find a match of the same kind.
135+
while (true) {
136+
match = generator.next().value;
137+
if (!match) {
138+
break;
139+
}
140+
141+
if (isValue === match[$isDataValue]()) {
142+
return match;
143+
}
136144
}
137145
if (
138146
dataNode[$namespaceId] === NamespaceIds.datasets.id &&
@@ -149,7 +157,7 @@ class Binder {
149157

150158
// Secondly, if global try to find it just under the root of datasets
151159
// (which is the location of global variables).
152-
generator = this.datasets[$getRealChildrenByNameIt](
160+
generator = this.data[$getRealChildrenByNameIt](
153161
name,
154162
/* allTransparent = */ false,
155163
/* skipConsumed = */ false
@@ -478,13 +486,15 @@ class Binder {
478486
if (child.bind) {
479487
switch (child.bind.match) {
480488
case "none":
489+
this._bindElement(child, dataNode);
481490
continue;
482491
case "global":
483492
global = true;
484493
break;
485494
case "dataRef":
486495
if (!child.bind.ref) {
487496
warn(`XFA - ref is empty in node ${child[$nodeName]}.`);
497+
this._bindElement(child, dataNode);
488498
continue;
489499
}
490500
ref = child.bind.ref;
@@ -545,6 +555,7 @@ class Binder {
545555
while (matches.length < max) {
546556
const found = this._findDataByNameToConsume(
547557
child.name,
558+
child[$hasSettableValue](),
548559
dataNode,
549560
global
550561
);
@@ -580,6 +591,8 @@ class Binder {
580591
}
581592
this._bindOccurrences(child, match, picture);
582593
} else if (min > 0) {
594+
this._setProperties(child, dataNode);
595+
this._bindItems(child, dataNode);
583596
this._bindElement(child, dataNode);
584597
} else {
585598
uselessNodes.push(child);

src/core/xfa/builder.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
1717
import {
1818
$cleanup,
1919
$finalize,
20+
$ids,
2021
$nsAttributes,
2122
$onChild,
2223
$resolvePrototypes,
@@ -27,13 +28,11 @@ import { Template } from "./template.js";
2728
import { UnknownNamespace } from "./unknown.js";
2829
import { warn } from "../../shared/util.js";
2930

30-
const _ids = Symbol();
31-
3231
class Root extends XFAObject {
3332
constructor(ids) {
3433
super(-1, "root", Object.create(null));
3534
this.element = null;
36-
this[_ids] = ids;
35+
this[$ids] = ids;
3736
}
3837

3938
[$onChild](child) {
@@ -44,7 +43,8 @@ class Root extends XFAObject {
4443
[$finalize]() {
4544
super[$finalize]();
4645
if (this.element.template instanceof Template) {
47-
this.element.template[$resolvePrototypes](this[_ids]);
46+
this.element.template[$resolvePrototypes](this[$ids]);
47+
this.element.template[$ids] = this[$ids];
4848
}
4949
}
5050
}

0 commit comments

Comments
 (0)