Skip to content

Commit e82a285

Browse files
committed
Fix conflict between parentBorderBox and max-width
DEVSIX-1195 Autoported commit. Original commit hash: [9a4df5d34]
1 parent 25e9b63 commit e82a285

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

itext.tests/itext.layout.tests/itext/layout/renderer/ImageWidthTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public virtual void ImageWidthTest02() {
126126
NUnit.Framework.Assert.AreEqual(0.0, minMaxWidth.GetMaxWidth() - minMaxWidth.GetMinWidth(), EPSILON);
127127
image.SetProperty(Property.MAX_WIDTH, UnitValue.CreatePercentValue(50));
128128
minMaxWidth = renderer.GetMinMaxWidth(5000);
129-
NUnit.Framework.Assert.AreEqual(2500.0, minMaxWidth.GetMaxWidth(), EPSILON);
129+
NUnit.Framework.Assert.AreEqual(1024.0, minMaxWidth.GetMaxWidth(), EPSILON);
130130
minMaxWidth = renderer.GetMinMaxWidth(500);
131131
NUnit.Framework.Assert.AreEqual(250.0, minMaxWidth.GetMaxWidth(), EPSILON);
132132
image.SetProperty(Property.MAX_HEIGHT, 100f);
@@ -137,12 +137,12 @@ public virtual void ImageWidthTest02() {
137137
image.SetProperty(Property.MIN_WIDTH, UnitValue.CreatePointValue(2000));
138138
image.SetProperty(Property.MAX_WIDTH, UnitValue.CreatePointValue(3000));
139139
minMaxWidth = renderer.GetMinMaxWidth(5000);
140-
NUnit.Framework.Assert.AreEqual(3000.0, minMaxWidth.GetMaxWidth(), EPSILON);
140+
NUnit.Framework.Assert.AreEqual(2000.0, minMaxWidth.GetMaxWidth(), EPSILON);
141141
NUnit.Framework.Assert.AreEqual(0.0, minMaxWidth.GetMaxWidth() - minMaxWidth.GetMinWidth(), EPSILON);
142142
image.SetProperty(Property.MIN_HEIGHT, 100f);
143143
image.SetProperty(Property.HEIGHT, 100f);
144144
minMaxWidth = renderer.GetMinMaxWidth(5000);
145-
NUnit.Framework.Assert.AreEqual(3000, minMaxWidth.GetMaxWidth(), EPSILON);
145+
NUnit.Framework.Assert.AreEqual(100.0 * 1024.0 / 768.0, minMaxWidth.GetMaxWidth(), EPSILON);
146146
}
147147
}
148148
}
Binary file not shown.

itext/itext.layout/itext/layout/renderer/AbstractRenderer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ internal static bool IsBorderBoxSizing(IRenderer renderer) {
940940
}
941941
}
942942
else {
943-
width = maxWidth;
943+
if (maxWidth != null) {
944+
width = maxWidth < parentBoxWidth ? maxWidth : null;
945+
}
944946
}
945947
if (width != null && IsBorderBoxSizing(this)) {
946948
width -= CalculatePaddingBorderWidth(this);

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0979cc53a791b61b0108af67dd2fd747decb65f7
1+
9a4df5d34a752d544b5a267c6e59c1cd4e486c89

0 commit comments

Comments
 (0)