Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XFA - Always compute the transformed BBox values in checkDimensions (PR 13691 follow-up) #13712

Merged
merged 1 commit into from
Jul 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/core/xfa/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ function getAvailableSpace(node) {
}

function getTransformedBBox(node) {
// Take into account rotation and anchor the get the
// real bounding box.
// Take into account rotation and anchor to get the real bounding box.
let w = node.w === "" ? NaN : node.w;
let h = node.h === "" ? NaN : node.h;
let [centerX, centerY] = [0, 0];
Expand Down Expand Up @@ -223,8 +222,7 @@ function getTransformedBBox(node) {
break;
}

let x;
let y;
let x, y;
switch (node.rotate || 0) {
case 0:
[x, y] = [-centerX, -centerY];
Expand Down Expand Up @@ -268,14 +266,11 @@ function checkDimensions(node, space) {
const ERROR = 2;
const parent = node[$getSubformParent]();
const attempt = (parent[$extra] && parent[$extra].attempt) || 0;
let y, w, h;

const [, y, w, h] = getTransformedBBox(node);
switch (parent.layout) {
case "lr-tb":
case "rl-tb":
if (node.w !== "" || node.h !== "") {
[, , w, h] = getTransformedBBox(node);
}

if (attempt === 0) {
// Try to put an element in the line.

Expand Down Expand Up @@ -330,11 +325,9 @@ function checkDimensions(node, space) {
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 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]()) {
[, , , h] = getTransformedBBox(node);
return Math.round(h - space.height) <= ERROR;
}
// Else wait and see: this node will be layed out itself
Expand All @@ -354,7 +347,6 @@ function checkDimensions(node, space) {
return true;
}

[, y, , h] = getTransformedBBox(node);
if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
return true;
}
Expand All @@ -368,7 +360,6 @@ function checkDimensions(node, space) {
}

if (node.h !== "") {
[, , , h] = getTransformedBBox(node);
return Math.round(h - space.height) <= ERROR;
}
return true;
Expand Down