XFA - Fix a breakBefore issue when target is a contentArea and startNew is 1 (bug 1739502)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1739502; - when the target area was the current content area, everything was pushed in it instead of creating a new one (and consequently a new pageArea is created). - the pdf shows an alignment issue on page 4: - the hAlign is "center" but the subform was the width of its parent, so compute the real width of the subform with tb layout; - there is an extra empty page at the end of the pdf: - there is a subform with some hidden elements which are not rendered for now (since there is no plugged JS engine it isn't possible to draw them in changing their visibility). - so in case a subform is empty and has no real dimensions (at least one is 0), we just consider it as empty.
This commit is contained in:
parent
611627f5a1
commit
a08763f4aa
@ -147,7 +147,10 @@ function addHTML(node, html, bbox) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "tb": {
|
case "tb": {
|
||||||
extra.width = availableSpace.width;
|
// Even if the subform can possibly take all the available width,
|
||||||
|
// we must compute the final width as it is in order to be able
|
||||||
|
// for example to center the subform within its parent.
|
||||||
|
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
||||||
extra.height += h;
|
extra.height += h;
|
||||||
extra.children.push(html);
|
extra.children.push(html);
|
||||||
break;
|
break;
|
||||||
|
@ -369,23 +369,32 @@ function handleBreak(node) {
|
|||||||
const pageArea = target && target[$getParent]();
|
const pageArea = target && target[$getParent]();
|
||||||
|
|
||||||
let index;
|
let index;
|
||||||
|
let nextPageArea = pageArea;
|
||||||
if (node.startNew) {
|
if (node.startNew) {
|
||||||
|
// startNew === 1 so we must create a new container (pageArea or
|
||||||
|
// contentArea).
|
||||||
if (target) {
|
if (target) {
|
||||||
const contentAreas = pageArea.contentArea.children;
|
const contentAreas = pageArea.contentArea.children;
|
||||||
index = contentAreas.findIndex(e => e === target) - 1;
|
const indexForCurrent = contentAreas.indexOf(currentContentArea);
|
||||||
|
const indexForTarget = contentAreas.indexOf(target);
|
||||||
|
if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
|
||||||
|
// The next container is after the current container so
|
||||||
|
// we can stay on the same page.
|
||||||
|
nextPageArea = null;
|
||||||
|
}
|
||||||
|
index = indexForTarget - 1;
|
||||||
} else {
|
} else {
|
||||||
index = currentPageArea.contentArea.children.findIndex(
|
index = currentPageArea.contentArea.children.indexOf(currentContentArea);
|
||||||
e => e === currentContentArea
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if (target && target !== currentContentArea) {
|
} else if (target && target !== currentContentArea) {
|
||||||
const contentAreas = pageArea.contentArea.children;
|
const contentAreas = pageArea.contentArea.children;
|
||||||
index = contentAreas.findIndex(e => e === target) - 1;
|
index = contentAreas.indexOf(target) - 1;
|
||||||
|
nextPageArea = pageArea === currentPageArea ? null : pageArea;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
node[$extra].target = pageArea === currentPageArea ? null : pageArea;
|
node[$extra].target = nextPageArea;
|
||||||
node[$extra].index = index;
|
node[$extra].index = index;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -5208,6 +5217,13 @@ class Subform extends XFAObject {
|
|||||||
style.height = measureToString(height);
|
style.height = measureToString(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(style.width === "0px" || style.height === "0px") &&
|
||||||
|
children.length === 0
|
||||||
|
) {
|
||||||
|
return HTMLResult.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
const html = {
|
const html = {
|
||||||
name: "div",
|
name: "div",
|
||||||
attributes,
|
attributes,
|
||||||
@ -5551,7 +5567,7 @@ class Template extends XFAObject {
|
|||||||
hasSomething ||
|
hasSomething ||
|
||||||
(html.html.children && html.html.children.length !== 0);
|
(html.html.children && html.html.children.length !== 0);
|
||||||
htmlContentAreas[i].children.push(html.html);
|
htmlContentAreas[i].children.push(html.html);
|
||||||
} else if (!hasSomething) {
|
} else if (!hasSomething && mainHtml.children.length > 1) {
|
||||||
mainHtml.children.pop();
|
mainHtml.children.pop();
|
||||||
}
|
}
|
||||||
return mainHtml;
|
return mainHtml;
|
||||||
|
1
test/pdfs/xfa_bug1739502.pdf.link
Normal file
1
test/pdfs/xfa_bug1739502.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://bugzilla.mozilla.org/attachment.cgi?id=9249303
|
@ -1033,6 +1033,14 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "xfa_bug1739502",
|
||||||
|
"file": "pdfs/xfa_bug1739502.pdf",
|
||||||
|
"md5": "a760a950cb225c3cbf25a55b5d95e264",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"enableXfa": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "xfa_bug1729877",
|
{ "id": "xfa_bug1729877",
|
||||||
"file": "pdfs/xfa_bug1729877.pdf",
|
"file": "pdfs/xfa_bug1729877.pdf",
|
||||||
"md5": "1bf5429ea13a090f52edcd49cb0c4a47",
|
"md5": "1bf5429ea13a090f52edcd49cb0c4a47",
|
||||||
|
Loading…
Reference in New Issue
Block a user