1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

XFA - Avoid to have containers not pushed in the html

- it aims to fix issue #13668.
This commit is contained in:
Calixte Denizet 2021-07-11 19:12:50 +02:00
parent 70434c132f
commit fccc6c2242
4 changed files with 66 additions and 22 deletions

View file

@ -52,10 +52,21 @@ import { measureToString } from "./html_utils.js";
* returning.
*/
function createLine(node, children) {
return {
name: "div",
attributes: {
class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"],
},
children,
};
}
function flushHTML(node) {
if (!node[$extra]) {
return null;
}
const attributes = node[$extra].attributes;
const html = {
name: "div",
@ -66,7 +77,11 @@ function flushHTML(node) {
if (node[$extra].failingNode) {
const htmlFromFailing = node[$extra].failingNode[$flushHTML]();
if (htmlFromFailing) {
html.children.push(htmlFromFailing);
if (node.layout.endsWith("-tb")) {
html.children.push(createLine(node, [htmlFromFailing]));
} else {
html.children.push(htmlFromFailing);
}
}
}
@ -74,10 +89,6 @@ function flushHTML(node) {
return null;
}
node[$extra].children = [];
delete node[$extra].line;
node[$extra].numberInLine = 0;
return html;
}
@ -96,13 +107,7 @@ function addHTML(node, html, bbox) {
case "lr-tb":
case "rl-tb":
if (!extra.line || extra.attempt === 1) {
extra.line = {
name: "div",
attributes: {
class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"],
},
children: [],
};
extra.line = createLine(node, []);
extra.children.push(extra.line);
extra.numberInLine = 0;
}