Skip to content

Commit 9a4df5d

Browse files
committed
Fix conflict between parentBorderBox and max-width
DEVSIX-1195
1 parent 0979cc5 commit 9a4df5d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ protected Float retrieveWidth(float parentBoxWidth) {
10141014
} else if (minWidth != null) {
10151015
width = width < minWidth ? minWidth : width;
10161016
}
1017-
} else {
1018-
width = maxWidth;
1017+
} else if (maxWidth != null) {
1018+
width = maxWidth < parentBoxWidth ? maxWidth : null;
10191019
}
10201020

10211021
if (width != null && isBorderBoxSizing(this)) {

layout/src/test/java/com/itextpdf/layout/renderer/ImageWidthTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void imageWidthTest02() throws IOException, InterruptedException {
142142

143143
image.setProperty(Property.MAX_WIDTH, UnitValue.createPercentValue(50));
144144
minMaxWidth = renderer.getMinMaxWidth(5000);
145-
Assert.assertEquals(2500.0, minMaxWidth.getMaxWidth(), EPSILON);
145+
Assert.assertEquals(1024.0, minMaxWidth.getMaxWidth(), EPSILON);
146146
minMaxWidth = renderer.getMinMaxWidth(500);
147147
Assert.assertEquals(250.0, minMaxWidth.getMaxWidth(), EPSILON);
148148
image.setProperty(Property.MAX_HEIGHT, 100f);
@@ -154,12 +154,12 @@ public void imageWidthTest02() throws IOException, InterruptedException {
154154
image.setProperty(Property.MIN_WIDTH, UnitValue.createPointValue(2000));
155155
image.setProperty(Property.MAX_WIDTH, UnitValue.createPointValue(3000));
156156
minMaxWidth = renderer.getMinMaxWidth(5000);
157-
Assert.assertEquals(3000.0, minMaxWidth.getMaxWidth(), EPSILON);
157+
Assert.assertEquals(2000.0, minMaxWidth.getMaxWidth(), EPSILON);
158158
Assert.assertEquals(0.0, minMaxWidth.getMaxWidth() - minMaxWidth.getMinWidth(), EPSILON);
159159
image.setProperty(Property.MIN_HEIGHT, 100f);
160160
image.setProperty(Property.HEIGHT, 100f);
161161
minMaxWidth = renderer.getMinMaxWidth(5000);
162-
Assert.assertEquals( 3000, minMaxWidth.getMaxWidth(), EPSILON);
162+
Assert.assertEquals( 100.0 * 1024.0 / 768.0, minMaxWidth.getMaxWidth(), EPSILON);
163163
}
164164

165165
}

0 commit comments

Comments
 (0)