XFA - Avoid to put something in very small areas

- it aims to fix #13855.
This commit is contained in:
Calixte Denizet 2021-08-03 16:22:52 +02:00
parent 4ad5c5d52a
commit be1ee155d1
3 changed files with 18 additions and 7 deletions

View File

@ -290,13 +290,13 @@ function checkDimensions(node, space) {
return true; return true;
} }
if (parent[$extra].numberInLine === 0) { if (parent[$extra].numberInLine === 0) {
return space.height > 0; return space.height > ERROR;
} }
return false; return false;
} }
return space.width > 0; return space.width > ERROR;
} }
// No layout failure. // No layout failure.
@ -307,7 +307,7 @@ function checkDimensions(node, space) {
return Math.round(w - space.width) <= ERROR; return Math.round(w - space.width) <= ERROR;
} }
return space.width > 0; return space.width > ERROR;
} }
// Second attempt: try to put the element on the next line. // Second attempt: try to put the element on the next line.
@ -322,14 +322,14 @@ function checkDimensions(node, space) {
} }
if (node.w === "" || Math.round(w - space.width) <= ERROR) { if (node.w === "" || Math.round(w - space.width) <= ERROR) {
return space.height > 0; return space.height > ERROR;
} }
if (parent[$isThereMoreWidth]()) { if (parent[$isThereMoreWidth]()) {
return false; return false;
} }
return space.height > 0; return space.height > ERROR;
case "table": case "table":
case "tb": case "tb":
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) { if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
@ -345,14 +345,14 @@ function checkDimensions(node, space) {
// in the provided space and maybe a children won't fit. // in the provided space and maybe a children won't fit.
if (node.w === "" || Math.round(w - space.width) <= ERROR) { if (node.w === "" || Math.round(w - space.width) <= ERROR) {
return space.height > 0; return space.height > ERROR;
} }
if (parent[$isThereMoreWidth]()) { if (parent[$isThereMoreWidth]()) {
return false; return false;
} }
return space.height > 0; return space.height > ERROR;
case "position": case "position":
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) { if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
return true; return true;

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/6924738/imm5710f.1.pdf

View File

@ -1246,6 +1246,16 @@
"enableXfa": true, "enableXfa": true,
"type": "eq" "type": "eq"
}, },
{ "id": "xfa_issue13855",
"file": "pdfs/xfa_issue13855.pdf",
"md5": "0aaaf62ff979c7837c2c63df44456238",
"link": true,
"rounds": 1,
"firstPage": 3,
"lastPage": 3,
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_issue13584", { "id": "xfa_issue13584",
"file": "pdfs/xfa_issue13584.pdf", "file": "pdfs/xfa_issue13584.pdf",
"md5": "c41af0754dabd81996a0d54db1900beb", "md5": "c41af0754dabd81996a0d54db1900beb",