Skip to content

Commit aa879b8

Browse files
Snuffleupagusbh213
authored andcommitted
XFA - Always compute the transformed BBox values in checkDimensions (PR 13691 follow-up)
This way we ensure that these BBox values are *always* defined as expected for every `case`-block, and we also don't need to duplicate the lookup in multiple places. (Also, the patch removes a couple of unnecessary line-breaks in existing comments.) Fixes mozilla#13691 (review), which was flagged by LGTM.
1 parent 4b11673 commit aa879b8

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/core/xfa/layout.js

+6-15
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ function getAvailableSpace(node) {
191191
}
192192

193193
function getTransformedBBox(node) {
194-
// Take into account rotation and anchor the get the
195-
// real bounding box.
194+
// Take into account rotation and anchor to get the real bounding box.
196195
let w = node.w === "" ? NaN : node.w;
197196
let h = node.h === "" ? NaN : node.h;
198197
let [centerX, centerY] = [0, 0];
@@ -223,8 +222,7 @@ function getTransformedBBox(node) {
223222
break;
224223
}
225224

226-
let x;
227-
let y;
225+
let x, y;
228226
switch (node.rotate || 0) {
229227
case 0:
230228
[x, y] = [-centerX, -centerY];
@@ -268,14 +266,11 @@ function checkDimensions(node, space) {
268266
const ERROR = 2;
269267
const parent = node[$getSubformParent]();
270268
const attempt = (parent[$extra] && parent[$extra].attempt) || 0;
271-
let y, w, h;
269+
270+
const [, y, w, h] = getTransformedBBox(node);
272271
switch (parent.layout) {
273272
case "lr-tb":
274273
case "rl-tb":
275-
if (node.w !== "" || node.h !== "") {
276-
[, , w, h] = getTransformedBBox(node);
277-
}
278-
279274
if (attempt === 0) {
280275
// Try to put an element in the line.
281276

@@ -330,11 +325,9 @@ function checkDimensions(node, space) {
330325
return true;
331326
}
332327

333-
// If the node has a height then check
334-
// if it's fine with available height. If the node
335-
// is breakable then we can return true.
328+
// If the node has a height then check if it's fine with available height.
329+
// If the node is breakable then we can return true.
336330
if (node.h !== "" && !node[$isSplittable]()) {
337-
[, , , h] = getTransformedBBox(node);
338331
return Math.round(h - space.height) <= ERROR;
339332
}
340333
// Else wait and see: this node will be layed out itself
@@ -354,7 +347,6 @@ function checkDimensions(node, space) {
354347
return true;
355348
}
356349

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

370362
if (node.h !== "") {
371-
[, , , h] = getTransformedBBox(node);
372363
return Math.round(h - space.height) <= ERROR;
373364
}
374365
return true;

0 commit comments

Comments
 (0)