mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-29 07:37:57 +02:00
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.
This commit is contained in:
parent
3538ef017f
commit
7cebdbd58c
14 changed files with 2019 additions and 366 deletions
|
@ -22,6 +22,7 @@ import {
|
|||
$finalize,
|
||||
$getAttributeIt,
|
||||
$getChildren,
|
||||
$getDataValue,
|
||||
$getParent,
|
||||
$getRealChildrenByNameIt,
|
||||
$global,
|
||||
|
@ -88,7 +89,7 @@ class Binder {
|
|||
|
||||
if (formNode[$hasSettableValue]()) {
|
||||
if (data[$isDataValue]()) {
|
||||
const value = data[$content].trim();
|
||||
const value = data[$getDataValue]();
|
||||
// TODO: use picture.
|
||||
formNode[$setValue](createText(value));
|
||||
formNode[$data] = data;
|
||||
|
@ -114,7 +115,7 @@ class Binder {
|
|||
}
|
||||
}
|
||||
|
||||
_findDataByNameToConsume(name, dataNode, global) {
|
||||
_findDataByNameToConsume(name, isValue, dataNode, global) {
|
||||
if (!name) {
|
||||
return null;
|
||||
}
|
||||
|
@ -130,9 +131,16 @@ class Binder {
|
|||
/* allTransparent = */ false,
|
||||
/* skipConsumed = */ true
|
||||
);
|
||||
match = generator.next().value;
|
||||
if (match) {
|
||||
return match;
|
||||
// Try to find a match of the same kind.
|
||||
while (true) {
|
||||
match = generator.next().value;
|
||||
if (!match) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (isValue === match[$isDataValue]()) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
if (
|
||||
dataNode[$namespaceId] === NamespaceIds.datasets.id &&
|
||||
|
@ -149,7 +157,7 @@ class Binder {
|
|||
|
||||
// Secondly, if global try to find it just under the root of datasets
|
||||
// (which is the location of global variables).
|
||||
generator = this.datasets[$getRealChildrenByNameIt](
|
||||
generator = this.data[$getRealChildrenByNameIt](
|
||||
name,
|
||||
/* allTransparent = */ false,
|
||||
/* skipConsumed = */ false
|
||||
|
@ -478,6 +486,7 @@ class Binder {
|
|||
if (child.bind) {
|
||||
switch (child.bind.match) {
|
||||
case "none":
|
||||
this._bindElement(child, dataNode);
|
||||
continue;
|
||||
case "global":
|
||||
global = true;
|
||||
|
@ -485,6 +494,7 @@ class Binder {
|
|||
case "dataRef":
|
||||
if (!child.bind.ref) {
|
||||
warn(`XFA - ref is empty in node ${child[$nodeName]}.`);
|
||||
this._bindElement(child, dataNode);
|
||||
continue;
|
||||
}
|
||||
ref = child.bind.ref;
|
||||
|
@ -545,6 +555,7 @@ class Binder {
|
|||
while (matches.length < max) {
|
||||
const found = this._findDataByNameToConsume(
|
||||
child.name,
|
||||
child[$hasSettableValue](),
|
||||
dataNode,
|
||||
global
|
||||
);
|
||||
|
@ -580,6 +591,8 @@ class Binder {
|
|||
}
|
||||
this._bindOccurrences(child, match, picture);
|
||||
} else if (min > 0) {
|
||||
this._setProperties(child, dataNode);
|
||||
this._bindItems(child, dataNode);
|
||||
this._bindElement(child, dataNode);
|
||||
} else {
|
||||
uselessNodes.push(child);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue