From 3be418547e312539ca9cb0cdedde44b9a05d32d1 Mon Sep 17 00:00:00 2001 From: Dmitry Radchuk Date: Sun, 10 Nov 2024 21:33:56 +0000 Subject: [PATCH] Fix margin collapse for flex container DEVSIX-8693 Autoported commit. Original commit hash: [97e38c41f] --- .../itext/layout/CollapsingMarginsTest.cs | 25 ++++++++++++++++++ .../cmp_collapsingMarginsTest06.pdf | Bin 0 -> 1228 bytes .../margincollapse/MarginsCollapseHandler.cs | 5 +++- port-hash | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 itext.tests/itext.layout.tests/resources/itext/layout/CollapsingMarginsTest/cmp_collapsingMarginsTest06.pdf diff --git a/itext.tests/itext.layout.tests/itext/layout/CollapsingMarginsTest.cs b/itext.tests/itext.layout.tests/itext/layout/CollapsingMarginsTest.cs index 5d79139ff1..c6368ba930 100644 --- a/itext.tests/itext.layout.tests/itext/layout/CollapsingMarginsTest.cs +++ b/itext.tests/itext.layout.tests/itext/layout/CollapsingMarginsTest.cs @@ -198,6 +198,31 @@ public virtual void CollapsingMarginsTest05() { , "diff")); } + [NUnit.Framework.Test] + public virtual void CollapsingMarginsTest06() { + String outFileName = destinationFolder + "collapsingMarginsTest06.pdf"; + String cmpFileName = sourceFolder + "cmp_collapsingMarginsTest06.pdf"; + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); + DrawPageBorders(pdfDocument, 1); + Document doc = new Document(pdfDocument); + doc.SetProperty(Property.COLLAPSING_MARGINS, true); + Div container = new Div(); + container.SetBackgroundColor(new DeviceRgb(209, 247, 29)); + container.SetMarginBottom(30.0f); + container.SetMarginTop(30.0f); + List list = new List(); + ListItem listItem = new ListItem("test"); + listItem.SetProperty(Property.COLLAPSING_MARGINS, null); + listItem.SetMargins(20.0f, 5.0f, 20.0f, 5.0f); + listItem.SetBackgroundColor(new DeviceRgb(65, 151, 29)); + list.Add(listItem); + container.Add(list); + doc.Add(container); + doc.Close(); + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + , "diff")); + } + [NUnit.Framework.Test] public virtual void ElementCollapsingMarginsTest01() { String outFileName = destinationFolder + "elementCollapsingMarginsTest01.pdf"; diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/CollapsingMarginsTest/cmp_collapsingMarginsTest06.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/CollapsingMarginsTest/cmp_collapsingMarginsTest06.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f23f61b4153f0d39613f388a75da070ad20bcf1a GIT binary patch literal 1228 zcmc&zO=#3W6sB5HgD8k#wU<#`+bY}4B$-TB%i_A*KWf`$cTutJAwQEgb(^$FR;wVM zJg6v$=tU161Sz86Nu?FVpMxTb3jP(LC|HD^^d^)#6W6X<@ai0rneTn?&3oT_6U$~= z;;4}bv5%jgzY;Kjz%vGgrY5n)DTdS+TZ(!}Gt~4fD(<3ge>eaTmXpaK^r=21j9xr- z`o_xpa7E_e(POPO%SL)9AD^h+zOmNWfAZn$mvd{|tEzHKH+9^cI5=JP%ujuNyJ+kA zv-bu*kIYO}x7OSnZ);zEr(^xOj@38N={JKl&C?Hx$8WE>`sVHg=-hJa@{aG<@Qaak zFRpxfG`3;($@q%N#T%A9oxMP=pXu4#`QgaE>DrlZi<qU31cm3)&1 zTp8xge+a1DmSjsT_|DLR2!%t#l!fW1$s|vQCxMtpSzvAm%HbnsS`YQ2*Iyya6>^%X z9Xg(yVcn?DY?Gj*AOtbONR#1KDAz$)*C2L!*1ri^-?K_4_3NDi9SyI8wC7WhXoQU@ zp6^O!^KIP)&|9Bs&F%sRs2{KkdmF%*1R;#`D?w`5KNL{V>U*VO(6zgvk}H>@T-Z)M zpj;!djTR5k&@pwf*<}Odxc%ZD$4$9`Gk?yPjF79u1whd^lD86<%U_P0_DZZDNbGQ| zpoe!e*Z0#SQnKPQ>Qh^QfCwz@@&YQxG6pvIg~_T0A{%h$F_kdE`T7l0&_YaNk^bgE zv=GDEZ&>K-PLcZjWwmEOPZL1~)@@Zz*hH3~rI;GgBv~d