mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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.
This commit is contained in:
parent
a725380db0
commit
6b2bbdd02d
6 changed files with 42 additions and 24 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue