mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Box block_margins_collapsed_with_children
member of BoxFragment
(#36474)
This reduces the size of `BoxFragment` by around 20 bytes. Testing: This just changes the layout of a data structure, so is covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
3c4ec17180
commit
a4a308e434
7 changed files with 29 additions and 42 deletions
|
@ -76,7 +76,7 @@ pub(crate) struct BoxFragment {
|
|||
/// to things such as tables and inline formatting contexts.
|
||||
baselines: Baselines,
|
||||
|
||||
pub block_margins_collapsed_with_children: CollapsedBlockMargins,
|
||||
block_margins_collapsed_with_children: Option<Box<CollapsedBlockMargins>>,
|
||||
|
||||
/// The scrollable overflow of this box fragment.
|
||||
pub scrollable_overflow_from_children: PhysicalRect<Au>,
|
||||
|
@ -103,7 +103,6 @@ impl BoxFragment {
|
|||
border: PhysicalSides<Au>,
|
||||
margin: PhysicalSides<Au>,
|
||||
clearance: Option<Au>,
|
||||
block_margins_collapsed_with_children: CollapsedBlockMargins,
|
||||
) -> BoxFragment {
|
||||
let scrollable_overflow_from_children =
|
||||
children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
||||
|
@ -120,7 +119,7 @@ impl BoxFragment {
|
|||
margin,
|
||||
clearance,
|
||||
baselines: Baselines::default(),
|
||||
block_margins_collapsed_with_children,
|
||||
block_margins_collapsed_with_children: None,
|
||||
scrollable_overflow_from_children,
|
||||
resolved_sticky_insets: AtomicRefCell::default(),
|
||||
background_mode: BackgroundMode::Normal,
|
||||
|
@ -182,6 +181,14 @@ impl BoxFragment {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_block_margins_collapsed_with_children(
|
||||
mut self,
|
||||
collapsed_margins: CollapsedBlockMargins,
|
||||
) -> Self {
|
||||
self.block_margins_collapsed_with_children = Some(collapsed_margins.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn scrollable_overflow(&self) -> PhysicalRect<Au> {
|
||||
let physical_padding_rect = self.padding_rect();
|
||||
let content_origin = self.content_rect.origin.to_vector();
|
||||
|
@ -374,4 +381,11 @@ impl BoxFragment {
|
|||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn block_margins_collapsed_with_children(&self) -> CollapsedBlockMargins {
|
||||
match self.block_margins_collapsed_with_children.as_ref() {
|
||||
Some(collapsed_block_margins) => *(collapsed_block_margins).clone(),
|
||||
_ => CollapsedBlockMargins::zero(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue