Skip to content

Commit e6e0381

Browse files
arjanmelsArjan Mels
andauthored
Correct margin collapse (#1237)
Co-authored-by: Arjan Mels <[email protected]>
1 parent 298b986 commit e6e0381

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/html_parser.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -756,20 +756,13 @@ class HtmlParser extends StatelessWidget {
756756
tree.children[i - 1].style.margin?.bottom?.value ?? 0;
757757
final thisTop = tree.children[i].style.margin?.top?.value ?? 0;
758758
final newInternalMargin = max(previousSiblingBottom, thisTop);
759-
760-
if (tree.children[i - 1].style.margin == null) {
761-
tree.children[i - 1].style.margin =
762-
Margins.only(bottom: newInternalMargin);
763-
} else {
764-
tree.children[i - 1].style.margin = tree.children[i - 1].style.margin!
765-
.copyWithEdge(bottom: newInternalMargin);
766-
}
759+
final newTop = newInternalMargin - previousSiblingBottom;
767760

768761
if (tree.children[i].style.margin == null) {
769-
tree.children[i].style.margin = Margins.only(top: newInternalMargin);
762+
tree.children[i].style.margin = Margins.only(top: newTop);
770763
} else {
771-
tree.children[i].style.margin = tree.children[i].style.margin!
772-
.copyWithEdge(top: newInternalMargin);
764+
tree.children[i].style.margin =
765+
tree.children[i].style.margin!.copyWithEdge(top: newTop);
773766
}
774767
}
775768
}

0 commit comments

Comments
 (0)