Skip to content

Commit

Permalink
Merge pull request #13554 from calixteman/layout3
Browse files Browse the repository at this point in the history
XFA - Add support for overflow element
  • Loading branch information
brendandahl authored Jun 15, 2021
2 parents 697c58e + 0ea5792 commit f9a0568
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 134 deletions.
46 changes: 28 additions & 18 deletions src/core/xfa/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,48 +146,58 @@ function addHTML(node, html, bbox) {

function getAvailableSpace(node) {
const availableSpace = node[$extra].availableSpace;
const [marginW, marginH] = node.margin
? [
node.margin.leftInset + node.margin.rightInset,
node.margin.topInset + node.margin.leftInset,
]
: [0, 0];
const marginH = node.margin
? node.margin.topInset + node.margin.bottomInset
: 0;

switch (node.layout) {
case "lr-tb":
case "rl-tb":
switch (node[$extra].attempt) {
case 0:
return {
width: availableSpace.width - marginW - node[$extra].currentWidth,
width: availableSpace.width - node[$extra].currentWidth,
height: availableSpace.height - marginH - node[$extra].prevHeight,
};
case 1:
return {
width: availableSpace.width - marginW,
width: availableSpace.width,
height: availableSpace.height - marginH - node[$extra].height,
};
default:
// Overflow must stay in the container.
return {
width: Infinity,
height: availableSpace.height - marginH - node[$extra].prevHeight,
height: Infinity,
};
}
case "rl-row":
case "row":
const width = node[$extra].columnWidths
.slice(node[$extra].currentColumn)
.reduce((a, x) => a + x);
return { width, height: availableSpace.height - marginH };
if (node[$extra].attempt === 0) {
const width = node[$extra].columnWidths
.slice(node[$extra].currentColumn)
.reduce((a, x) => a + x);
return { width, height: availableSpace.height - marginH };
}
// Overflow must stay in the container.
return { width: Infinity, height: Infinity };
case "table":
case "tb":
return {
width: availableSpace.width - marginW,
height: availableSpace.height - marginH - node[$extra].height,
};
if (node[$extra].attempt === 0) {
return {
width: availableSpace.width,
height: availableSpace.height - marginH - node[$extra].height,
};
}
// Overflow must stay in the container.
return { width: Infinity, height: Infinity };
case "position":
default:
return availableSpace;
if (node[$extra].attempt === 0) {
return availableSpace;
}
// Overflow must stay in the container.
return { width: Infinity, height: Infinity };
}
}

Expand Down
Loading

0 comments on commit f9a0568

Please sign in to comment.