diff options
author | Oriol Brufau <obrufau@igalia.com> | 2023-06-23 19:56:55 +0200 |
---|---|---|
committer | Oriol Brufau <obrufau@igalia.com> | 2023-06-29 11:00:45 +0200 |
commit | 6b2bbdd02d88cc45d54e331537c10942b6cde990 (patch) | |
tree | 619ad528587e55ab1590f7afd9d129a00056bf70 /components/layout_2020/fragment_tree/box_fragment.rs | |
parent | a725380db0b9fba31993409f7d0f4b2d11ca8f7d (diff) | |
download | servo-6b2bbdd02d88cc45d54e331537c10942b6cde990.tar.gz servo-6b2bbdd02d88cc45d54e331537c10942b6cde990.zip |
Layout 2020: implement clearance as Option<Length>
Clearance was implemented as a Length, where zero meant no clearance.
However, having a clearance of 0px should be different than having
no clearance, since the former can still prevent margin collapse.
This patch keeps the existing behavior, so it won't be possible to get
a clearance of Some(Length::zero()), but it prepares the terrain for
a follow-up to fix calculate_clearance to return the proper thing.
Diffstat (limited to 'components/layout_2020/fragment_tree/box_fragment.rs')
-rw-r--r-- | components/layout_2020/fragment_tree/box_fragment.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/components/layout_2020/fragment_tree/box_fragment.rs b/components/layout_2020/fragment_tree/box_fragment.rs index 6f697ef23fd..9c06c212d33 100644 --- a/components/layout_2020/fragment_tree/box_fragment.rs +++ b/components/layout_2020/fragment_tree/box_fragment.rs @@ -31,7 +31,13 @@ pub(crate) struct BoxFragment { pub border: Sides<Length>, pub margin: Sides<Length>, - pub clearance: Length, + /// When the `clear` property is not set to `none`, it may introduce clearance. + /// Clearance is some extra spacing that is added above the top margin, + /// so that the element doesn't overlap earlier floats in the same BFC. + /// The presence of clearance prevents the top margin from collapsing with + /// earlier margins or with the bottom margin of the parent block. + /// https://drafts.csswg.org/css2/#clearance + pub clearance: Option<Length>, pub block_margins_collapsed_with_children: CollapsedBlockMargins, @@ -51,7 +57,7 @@ impl BoxFragment { padding: Sides<Length>, border: Sides<Length>, margin: Sides<Length>, - clearance: Length, + clearance: Option<Length>, block_margins_collapsed_with_children: CollapsedBlockMargins, ) -> BoxFragment { let position = style.get_box().position; @@ -85,7 +91,7 @@ impl BoxFragment { padding: Sides<Length>, border: Sides<Length>, margin: Sides<Length>, - clearance: Length, + clearance: Option<Length>, block_margins_collapsed_with_children: CollapsedBlockMargins, overconstrained: PhysicalSize<bool>, ) -> BoxFragment { |