From 16bc829d1fcbfa8f55e32cfb597e4cd4778c7017 Mon Sep 17 00:00:00 2001 From: Arjan Mels Date: Sat, 4 Mar 2023 16:19:40 +0100 Subject: [PATCH 1/2] Corrected margin collapse --- lib/html_parser.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/html_parser.dart b/lib/html_parser.dart index a739b2b987..77a2de2e5b 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -756,20 +756,13 @@ class HtmlParser extends StatelessWidget { tree.children[i - 1].style.margin?.bottom?.value ?? 0; final thisTop = tree.children[i].style.margin?.top?.value ?? 0; final newInternalMargin = max(previousSiblingBottom, thisTop); - - if (tree.children[i - 1].style.margin == null) { - tree.children[i - 1].style.margin = - Margins.only(bottom: newInternalMargin); - } else { - tree.children[i - 1].style.margin = tree.children[i - 1].style.margin! - .copyWithEdge(bottom: newInternalMargin); - } + final newTop = newInternalMargin - previousSiblingBottom; if (tree.children[i].style.margin == null) { - tree.children[i].style.margin = Margins.only(top: newInternalMargin); + tree.children[i].style.margin = Margins.only(top: newTop); } else { tree.children[i].style.margin = tree.children[i].style.margin! - .copyWithEdge(top: newInternalMargin); + .copyWithEdge(top: newTop); } } } From a868c2120261370514eb628ae04b995f574921fb Mon Sep 17 00:00:00 2001 From: Arjan Mels Date: Sat, 4 Mar 2023 16:51:14 +0100 Subject: [PATCH 2/2] Corrected code formatting --- lib/html_parser.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/html_parser.dart b/lib/html_parser.dart index 77a2de2e5b..e10d8efa3d 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -761,8 +761,8 @@ class HtmlParser extends StatelessWidget { if (tree.children[i].style.margin == null) { tree.children[i].style.margin = Margins.only(top: newTop); } else { - tree.children[i].style.margin = tree.children[i].style.margin! - .copyWithEdge(top: newTop); + tree.children[i].style.margin = + tree.children[i].style.margin!.copyWithEdge(top: newTop); } } }