@@ -146,48 +146,58 @@ function addHTML(node, html, bbox) {
146
146
147
147
function getAvailableSpace ( node ) {
148
148
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 ;
155
152
156
153
switch ( node . layout ) {
157
154
case "lr-tb" :
158
155
case "rl-tb" :
159
156
switch ( node [ $extra ] . attempt ) {
160
157
case 0 :
161
158
return {
162
- width : availableSpace . width - marginW - node [ $extra ] . currentWidth ,
159
+ width : availableSpace . width - node [ $extra ] . currentWidth ,
163
160
height : availableSpace . height - marginH - node [ $extra ] . prevHeight ,
164
161
} ;
165
162
case 1 :
166
163
return {
167
- width : availableSpace . width - marginW ,
164
+ width : availableSpace . width ,
168
165
height : availableSpace . height - marginH - node [ $extra ] . height ,
169
166
} ;
170
167
default :
168
+ // Overflow must stay in the container.
171
169
return {
172
170
width : Infinity ,
173
- height : availableSpace . height - marginH - node [ $extra ] . prevHeight ,
171
+ height : Infinity ,
174
172
} ;
175
173
}
176
174
case "rl-row" :
177
175
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 } ;
182
184
case "table" :
183
185
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 } ;
188
194
case "position" :
189
195
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 } ;
191
201
}
192
202
}
193
203
0 commit comments