Skip to content

Commit 304ce6d

Browse files
ars18wrwiText-CI
authored andcommitted
Respect flex item's height calculated during the algo
It should be set as min-height as well, so that the element's height is extended if needed DEVSIX-5178
1 parent ff71d20 commit 304ce6d

File tree

5 files changed

+8
-0
lines changed

5 files changed

+8
-0
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/FlexContainerRenderer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,25 @@ public LayoutResult layout(LayoutContext layoutContext) {
8989
lines = FlexUtil.calculateChildrenRectangles(layoutContextRectangle, this);
9090
final List<UnitValue> previousWidths = new ArrayList<>();
9191
final List<UnitValue> previousHeights = new ArrayList<>();
92+
final List<UnitValue> previousMinHeights = new ArrayList<>();
9293
for (final List<FlexItemInfo> line : lines) {
9394
for (final FlexItemInfo itemInfo : line) {
9495
final Rectangle rectangleWithoutBordersMarginsPaddings =
9596
itemInfo.getRenderer().applyMarginsBordersPaddings(itemInfo.getRectangle().clone(), false);
9697

9798
previousWidths.add(itemInfo.getRenderer().<UnitValue>getProperty(Property.WIDTH));
9899
previousHeights.add(itemInfo.getRenderer().<UnitValue>getProperty(Property.HEIGHT));
100+
previousMinHeights.add(itemInfo.getRenderer().<UnitValue>getProperty(Property.MIN_HEIGHT));
99101

100102
itemInfo.getRenderer().setProperty(Property.WIDTH,
101103
UnitValue.createPointValue(rectangleWithoutBordersMarginsPaddings.getWidth()));
102104
itemInfo.getRenderer().setProperty(Property.HEIGHT,
103105
UnitValue.createPointValue(rectangleWithoutBordersMarginsPaddings.getHeight()));
106+
// TODO DEVSIX-1895 Once the ticket is closed, there will be no need in setting min-height
107+
// In case element takes less vertical space than expected, we need to make sure
108+
// it is extended to the height predicted by the algo
109+
itemInfo.getRenderer().setProperty(Property.MIN_HEIGHT,
110+
UnitValue.createPointValue(rectangleWithoutBordersMarginsPaddings.getHeight()));
104111
}
105112
}
106113
final LayoutResult result = super.layout(layoutContext);
@@ -113,6 +120,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
113120
for (final FlexItemInfo itemInfo : line) {
114121
itemInfo.getRenderer().setProperty(Property.WIDTH, previousWidths.get(counter));
115122
itemInfo.getRenderer().setProperty(Property.HEIGHT, previousHeights.get(counter));
123+
itemInfo.getRenderer().setProperty(Property.MIN_HEIGHT, previousMinHeights.get(counter));
116124
++counter;
117125
}
118126
}

0 commit comments

Comments
 (0)