Skip to content

Commit 30c2776

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 Autoported commit. Original commit hash: [304ce6d86]
1 parent e0d6623 commit 30c2776

File tree

6 files changed

+9
-1
lines changed

6 files changed

+9
-1
lines changed

itext/itext.layout/itext/layout/renderer/FlexContainerRenderer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,23 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
7676
lines = FlexUtil.CalculateChildrenRectangles(layoutContextRectangle, this);
7777
IList<UnitValue> previousWidths = new List<UnitValue>();
7878
IList<UnitValue> previousHeights = new List<UnitValue>();
79+
IList<UnitValue> previousMinHeights = new List<UnitValue>();
7980
foreach (IList<FlexItemInfo> line in lines) {
8081
foreach (FlexItemInfo itemInfo in line) {
8182
Rectangle rectangleWithoutBordersMarginsPaddings = itemInfo.GetRenderer().ApplyMarginsBordersPaddings(itemInfo
8283
.GetRectangle().Clone(), false);
8384
previousWidths.Add(itemInfo.GetRenderer().GetProperty<UnitValue>(Property.WIDTH));
8485
previousHeights.Add(itemInfo.GetRenderer().GetProperty<UnitValue>(Property.HEIGHT));
86+
previousMinHeights.Add(itemInfo.GetRenderer().GetProperty<UnitValue>(Property.MIN_HEIGHT));
8587
itemInfo.GetRenderer().SetProperty(Property.WIDTH, UnitValue.CreatePointValue(rectangleWithoutBordersMarginsPaddings
8688
.GetWidth()));
8789
itemInfo.GetRenderer().SetProperty(Property.HEIGHT, UnitValue.CreatePointValue(rectangleWithoutBordersMarginsPaddings
8890
.GetHeight()));
91+
// TODO DEVSIX-1895 Once the ticket is closed, there will be no need in setting min-height
92+
// In case element takes less vertical space than expected, we need to make sure
93+
// it is extended to the height predicted by the algo
94+
itemInfo.GetRenderer().SetProperty(Property.MIN_HEIGHT, UnitValue.CreatePointValue(rectangleWithoutBordersMarginsPaddings
95+
.GetHeight()));
8996
}
9097
}
9198
LayoutResult result = base.Layout(layoutContext);
@@ -97,6 +104,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
97104
foreach (FlexItemInfo itemInfo in line) {
98105
itemInfo.GetRenderer().SetProperty(Property.WIDTH, previousWidths[counter]);
99106
itemInfo.GetRenderer().SetProperty(Property.HEIGHT, previousHeights[counter]);
107+
itemInfo.GetRenderer().SetProperty(Property.MIN_HEIGHT, previousMinHeights[counter]);
100108
++counter;
101109
}
102110
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ff71d20b0e8c5d31afb3e51285ffec1dba897767
1+
304ce6d86d44b034d84e409ffc93300db3d097a7

0 commit comments

Comments
 (0)