Skip to content

Commit f9a0568

Browse files
authored
Merge pull request #13554 from calixteman/layout3
XFA - Add support for overflow element
2 parents 697c58e + 0ea5792 commit f9a0568

8 files changed

+237
-134
lines changed

src/core/xfa/layout.js

+28-18
Original file line numberDiff line numberDiff line change
@@ -146,48 +146,58 @@ function addHTML(node, html, bbox) {
146146

147147
function getAvailableSpace(node) {
148148
const availableSpace = node[$extra].availableSpace;
149-
const [marginW, marginH] = node.margin
150-
? [
151-
node.margin.leftInset + node.margin.rightInset,
152-
node.margin.topInset + node.margin.leftInset,
153-
]
154-
: [0, 0];
149+
const marginH = node.margin
150+
? node.margin.topInset + node.margin.bottomInset
151+
: 0;
155152

156153
switch (node.layout) {
157154
case "lr-tb":
158155
case "rl-tb":
159156
switch (node[$extra].attempt) {
160157
case 0:
161158
return {
162-
width: availableSpace.width - marginW - node[$extra].currentWidth,
159+
width: availableSpace.width - node[$extra].currentWidth,
163160
height: availableSpace.height - marginH - node[$extra].prevHeight,
164161
};
165162
case 1:
166163
return {
167-
width: availableSpace.width - marginW,
164+
width: availableSpace.width,
168165
height: availableSpace.height - marginH - node[$extra].height,
169166
};
170167
default:
168+
// Overflow must stay in the container.
171169
return {
172170
width: Infinity,
173-
height: availableSpace.height - marginH - node[$extra].prevHeight,
171+
height: Infinity,
174172
};
175173
}
176174
case "rl-row":
177175
case "row":
178-
const width = node[$extra].columnWidths
179-
.slice(node[$extra].currentColumn)
180-
.reduce((a, x) => a + x);
181-
return { width, height: availableSpace.height - marginH };
176+
if (node[$extra].attempt === 0) {
177+
const width = node[$extra].columnWidths
178+
.slice(node[$extra].currentColumn)
179+
.reduce((a, x) => a + x);
180+
return { width, height: availableSpace.height - marginH };
181+
}
182+
// Overflow must stay in the container.
183+
return { width: Infinity, height: Infinity };
182184
case "table":
183185
case "tb":
184-
return {
185-
width: availableSpace.width - marginW,
186-
height: availableSpace.height - marginH - node[$extra].height,
187-
};
186+
if (node[$extra].attempt === 0) {
187+
return {
188+
width: availableSpace.width,
189+
height: availableSpace.height - marginH - node[$extra].height,
190+
};
191+
}
192+
// Overflow must stay in the container.
193+
return { width: Infinity, height: Infinity };
188194
case "position":
189195
default:
190-
return availableSpace;
196+
if (node[$extra].attempt === 0) {
197+
return availableSpace;
198+
}
199+
// Overflow must stay in the container.
200+
return { width: Infinity, height: Infinity };
191201
}
192202
}
193203

0 commit comments

Comments
 (0)