@@ -90,6 +90,7 @@ protected BlockRenderer(IElement modelElement) {
90
90
public LayoutResult layout (LayoutContext layoutContext ) {
91
91
overrideHeightProperties ();
92
92
boolean wasHeightClipped = false ;
93
+ boolean wasParentsHeightClipped = layoutContext .getArea ().isClippedHeight ();
93
94
int pageNumber = layoutContext .getArea ().getPageNumber ();
94
95
95
96
boolean isPositioned = isPositioned ();
@@ -132,18 +133,18 @@ public LayoutResult layout(LayoutContext layoutContext) {
132
133
applyBordersPaddingsMargins (parentBBox , borders , paddings );
133
134
134
135
OverflowPropertyValue overflowX = this .<OverflowPropertyValue >getProperty (Property .OVERFLOW_X );
135
- OverflowPropertyValue overflowY = this .<OverflowPropertyValue >getProperty (Property .OVERFLOW_Y );
136
+ Float blockMaxHeight = retrieveMaxHeight ();
137
+ OverflowPropertyValue overflowY = (null == blockMaxHeight || blockMaxHeight > parentBBox .getHeight ()) && !wasParentsHeightClipped ? OverflowPropertyValue .FIT : this .<OverflowPropertyValue >getProperty (Property .OVERFLOW_Y );
136
138
137
139
if (blockWidth != null && (blockWidth < parentBBox .getWidth () || isPositioned || rotation != null || (null != overflowX && !OverflowPropertyValue .FIT .equals (overflowX )))) {
138
140
// TODO DEVSIX-1174
139
141
UnitValue widthVal = this .<UnitValue >getProperty (Property .WIDTH );
140
- if (widthVal != null && widthVal .isPercentValue () && widthVal .getValue () == 100 && ( null == overflowX || OverflowPropertyValue . FIT . equals ( overflowX )) ) {
142
+ if (widthVal != null && widthVal .isPercentValue () && widthVal .getValue () == 100 ) {
141
143
} else {
142
144
parentBBox .setWidth ((float ) blockWidth );
143
145
}
144
146
}
145
147
146
- Float blockMaxHeight = retrieveMaxHeight ();
147
148
if (!isFixedLayout () && null != blockMaxHeight && (blockMaxHeight < parentBBox .getHeight () || (null != overflowY && !OverflowPropertyValue .FIT .equals (overflowY )))
148
149
&& !Boolean .TRUE .equals (getPropertyAsBoolean (Property .FORCED_PLACEMENT ))) {
149
150
if (blockMaxHeight < parentBBox .getHeight ()) {
@@ -156,8 +157,6 @@ public LayoutResult layout(LayoutContext layoutContext) {
156
157
parentBBox .moveUp (heightDelta ).setHeight ((float ) blockMaxHeight );
157
158
}
158
159
159
- Rectangle contentBoxToFit = parentBBox .clone ();
160
-
161
160
List <Rectangle > areas ;
162
161
if (isPositioned ) {
163
162
areas = Collections .singletonList (parentBBox );
@@ -182,7 +181,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
182
181
if (marginsCollapsingEnabled ) {
183
182
childMarginsInfo = marginsCollapseHandler .startChildMarginsHandling (childRenderer , layoutBox );
184
183
}
185
- while ((result = childRenderer .setParent (this ).layout (new LayoutContext (new LayoutArea (pageNumber , layoutBox ), childMarginsInfo , floatRendererAreas )))
184
+ while ((result = childRenderer .setParent (this ).layout (new LayoutContext (new LayoutArea (pageNumber , layoutBox , wasHeightClipped || wasParentsHeightClipped ), childMarginsInfo , floatRendererAreas )))
186
185
.getStatus () != LayoutResult .FULL ) {
187
186
if (marginsCollapsingEnabled ) {
188
187
if (result .getStatus () != LayoutResult .NOTHING ) {
@@ -196,7 +195,10 @@ public LayoutResult layout(LayoutContext layoutContext) {
196
195
|| Boolean .TRUE .equals (getPropertyAsBoolean (Property .FILL_AVAILABLE_AREA ))) {
197
196
occupiedArea .setBBox (Rectangle .getCommonRectangle (occupiedArea .getBBox (), layoutBox ));
198
197
} else if (result .getOccupiedArea () != null && result .getStatus () != LayoutResult .NOTHING ) {
199
- occupiedArea .setBBox (Rectangle .getCommonRectangle (occupiedArea .getBBox (), result .getOccupiedArea ().getBBox ()).setWidth (occupiedArea .getBBox ().getWidth ()));
198
+ occupiedArea .setBBox (Rectangle .getCommonRectangle (occupiedArea .getBBox (), result .getOccupiedArea ().getBBox ()));
199
+ if (occupiedArea .getBBox ().getWidth () > layoutBox .getWidth ()) {
200
+ occupiedArea .getBBox ().setWidth (layoutBox .getWidth ());
201
+ }
200
202
}
201
203
202
204
if (FloatingHelper .isRendererFloating (this ) || isCellRenderer ) {
@@ -357,7 +359,10 @@ public LayoutResult layout(LayoutContext layoutContext) {
357
359
358
360
if (result .getOccupiedArea () != null ) {
359
361
if (!FloatingHelper .isRendererFloating (childRenderer )) { // this check is needed only if margins collapsing is enabled
360
- occupiedArea .setBBox (Rectangle .getCommonRectangle (occupiedArea .getBBox (), result .getOccupiedArea ().getBBox ()).setWidth (occupiedArea .getBBox ().getWidth ()));
362
+ occupiedArea .setBBox (Rectangle .getCommonRectangle (occupiedArea .getBBox (), result .getOccupiedArea ().getBBox ()));
363
+ if (occupiedArea .getBBox ().getWidth () > layoutBox .getWidth ()) {
364
+ occupiedArea .getBBox ().setWidth (layoutBox .getWidth ());
365
+ }
361
366
}
362
367
}
363
368
if (marginsCollapsingEnabled ) {
@@ -437,9 +442,17 @@ public LayoutResult layout(LayoutContext layoutContext) {
437
442
correctPositionedLayout (layoutBox );
438
443
}
439
444
440
- float overflowPartHeight = getOverflowPartHeight (overflowY , contentBoxToFit );
445
+ float overflowPartHeight = getOverflowPartHeight (overflowY , layoutBox );
441
446
applyPaddings (occupiedArea .getBBox (), paddings , true );
442
447
applyBorderBox (occupiedArea .getBBox (), borders , true );
448
+ if (positionedRenderers .size () > 0 ) {
449
+ LayoutArea area = new LayoutArea (occupiedArea .getPageNumber (), occupiedArea .getBBox ().clone (), wasHeightClipped || wasParentsHeightClipped );
450
+ applyBorderBox (area .getBBox (), false );
451
+ for (IRenderer childPositionedRenderer : positionedRenderers ) {
452
+ childPositionedRenderer .setParent (this ).layout (new LayoutContext (area ));
453
+ }
454
+ applyBorderBox (area .getBBox (), true );
455
+ }
443
456
applyMargins (occupiedArea .getBBox (), true );
444
457
445
458
applyAbsolutePositionIfNeeded (layoutContext );
@@ -472,6 +485,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
472
485
}
473
486
}
474
487
if (wasHeightClipped ) {
488
+ editedArea .getBBox ().moveUp (overflowPartHeight ).decreaseHeight (overflowPartHeight );
475
489
occupiedArea .getBBox ().moveUp (overflowPartHeight ).decreaseHeight (overflowPartHeight );
476
490
}
477
491
@@ -823,7 +837,8 @@ protected MinMaxWidth getMinMaxWidth(float availableWidth) {
823
837
824
838
MinMaxWidth correctMinMaxWidth (MinMaxWidth minMaxWidth ) {
825
839
Float width = retrieveWidth (-1 );
826
- if (width != null && width >= 0 && width >= minMaxWidth .getChildrenMinWidth ()) {
840
+ OverflowPropertyValue overflowX = this .<OverflowPropertyValue >getProperty (Property .OVERFLOW_X );
841
+ if (width != null && width >= 0 && (width >= minMaxWidth .getChildrenMinWidth () || !OverflowPropertyValue .FIT .equals (overflowX ))) {
827
842
minMaxWidth .setChildrenMaxWidth ((float ) width );
828
843
minMaxWidth .setChildrenMinWidth ((float ) width );
829
844
}
0 commit comments