in src/core/xfa/layout.js [266:385]
function checkDimensions(node, space) {
if (node[$getTemplateRoot]()[$extra].firstUnsplittable === null) {
return true;
}
if (node.w === 0 || node.h === 0) {
return true;
}
const ERROR = 2;
const parent = node[$getSubformParent]();
const attempt = parent[$extra]?.attempt || 0;
const [, y, w, h] = getTransformedBBox(node);
switch (parent.layout) {
case "lr-tb":
case "rl-tb":
if (attempt === 0) {
// Try to put an element in the line.
if (!node[$getTemplateRoot]()[$extra].noLayoutFailure) {
if (node.h !== "" && Math.round(h - space.height) > ERROR) {
// Not enough height.
return false;
}
if (node.w !== "") {
if (Math.round(w - space.width) <= ERROR) {
return true;
}
if (parent[$extra].numberInLine === 0) {
return space.height > ERROR;
}
return false;
}
return space.width > ERROR;
}
// No layout failure.
// Put the element on the line but we can fail
// and then in the second step (next line) we'll accept.
if (node.w !== "") {
return Math.round(w - space.width) <= ERROR;
}
return space.width > ERROR;
}
// Second attempt: try to put the element on the next line.
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
// We cannot fail.
return true;
}
if (node.h !== "" && Math.round(h - space.height) > ERROR) {
return false;
}
if (node.w === "" || Math.round(w - space.width) <= ERROR) {
return space.height > ERROR;
}
if (parent[$isThereMoreWidth]()) {
return false;
}
return space.height > ERROR;
case "table":
case "tb":
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
return true;
}
// If the node has a height then check if it's fine with available height.
// If the node is breakable then we can return true.
if (node.h !== "" && !node[$isSplittable]()) {
return Math.round(h - space.height) <= ERROR;
}
// Else wait and see: this node will be layed out itself
// in the provided space and maybe a children won't fit.
if (node.w === "" || Math.round(w - space.width) <= ERROR) {
return space.height > ERROR;
}
if (parent[$isThereMoreWidth]()) {
return false;
}
return space.height > ERROR;
case "position":
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
return true;
}
if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
return true;
}
const area = node[$getTemplateRoot]()[$extra].currentContentArea;
return h + y > area.h;
case "rl-row":
case "row":
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
return true;
}
if (node.h !== "") {
return Math.round(h - space.height) <= ERROR;
}
return true;
default:
// No layout, so accept everything.
return true;
}
}