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:
parent
8ab65ed32d
commit
dd55e76f5d
4 changed files with 76 additions and 24 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -281,8 +286,14 @@ function checkDimensions(node, space) {
|
|||
}
|
||||
|
||||
if (node.w !== "") {
|
||||
// True if width is enough.
|
||||
return Math.round(w - space.width) <= ERROR;
|
||||
if (Math.round(w - space.width) <= ERROR) {
|
||||
return true;
|
||||
}
|
||||
if (parent[$extra].numberInLine === 0) {
|
||||
return space.height > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return space.width > 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue