mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Move two AbsoluteBoxOffsets fields into a Vec2
This commit is contained in:
parent
f09c14aa6b
commit
1fcdde99cb
1 changed files with 18 additions and 22 deletions
|
@ -30,8 +30,7 @@ pub(crate) struct AbsolutelyPositionedFragment<'box_> {
|
||||||
/// static positions when going up the tree.
|
/// static positions when going up the tree.
|
||||||
pub(crate) tree_rank: usize,
|
pub(crate) tree_rank: usize,
|
||||||
|
|
||||||
inline_start: AbsoluteBoxOffsets,
|
box_offsets: Vec2<AbsoluteBoxOffsets>,
|
||||||
block_start: AbsoluteBoxOffsets,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -83,9 +82,6 @@ impl AbsolutelyPositionedBox {
|
||||||
initial_start_corner: Vec2<Length>,
|
initial_start_corner: Vec2<Length>,
|
||||||
tree_rank: usize,
|
tree_rank: usize,
|
||||||
) -> AbsolutelyPositionedFragment {
|
) -> AbsolutelyPositionedFragment {
|
||||||
let style = &self.contents.style;
|
|
||||||
let box_offsets = style.box_offsets();
|
|
||||||
|
|
||||||
fn absolute_box_offsets(
|
fn absolute_box_offsets(
|
||||||
initial_static_start: Length,
|
initial_static_start: Length,
|
||||||
start: LengthPercentageOrAuto,
|
start: LengthPercentageOrAuto,
|
||||||
|
@ -101,22 +97,22 @@ impl AbsolutelyPositionedBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let inline_start = absolute_box_offsets(
|
let box_offsets = self.contents.style.box_offsets();
|
||||||
initial_start_corner.inline,
|
|
||||||
box_offsets.inline_start,
|
|
||||||
box_offsets.inline_end,
|
|
||||||
);
|
|
||||||
let block_start = absolute_box_offsets(
|
|
||||||
initial_start_corner.block,
|
|
||||||
box_offsets.block_start,
|
|
||||||
box_offsets.block_end,
|
|
||||||
);
|
|
||||||
|
|
||||||
AbsolutelyPositionedFragment {
|
AbsolutelyPositionedFragment {
|
||||||
absolutely_positioned_box: self,
|
absolutely_positioned_box: self,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
inline_start,
|
box_offsets: Vec2 {
|
||||||
block_start,
|
inline: absolute_box_offsets(
|
||||||
|
initial_start_corner.inline,
|
||||||
|
box_offsets.inline_start,
|
||||||
|
box_offsets.inline_end,
|
||||||
|
),
|
||||||
|
block: absolute_box_offsets(
|
||||||
|
initial_start_corner.block,
|
||||||
|
box_offsets.block_start,
|
||||||
|
box_offsets.block_end,
|
||||||
|
),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +256,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
(Length::zero(), margins)
|
(Length::zero(), margins)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
self.inline_start,
|
self.box_offsets.inline,
|
||||||
box_size.inline,
|
box_size.inline,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -270,7 +266,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
computed_margin.block_start,
|
computed_margin.block_start,
|
||||||
computed_margin.block_end,
|
computed_margin.block_end,
|
||||||
|margins| (margins / 2., margins / 2.),
|
|margins| (margins / 2., margins / 2.),
|
||||||
self.block_start,
|
self.box_offsets.block,
|
||||||
box_size.block,
|
box_size.block,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -400,11 +396,11 @@ pub(crate) fn adjust_static_positions(
|
||||||
|
|
||||||
abspos_fragment.tree_rank = tree_rank_in_parent;
|
abspos_fragment.tree_rank = tree_rank_in_parent;
|
||||||
|
|
||||||
if let AbsoluteBoxOffsets::StaticStart { start } = &mut abspos_fragment.inline_start {
|
if let AbsoluteBoxOffsets::StaticStart { start } = &mut abspos_fragment.box_offsets.inline {
|
||||||
*start += child_fragment_rect.start_corner.inline;
|
*start += child_fragment_rect.start_corner.inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let AbsoluteBoxOffsets::StaticStart { start } = &mut abspos_fragment.block_start {
|
if let AbsoluteBoxOffsets::StaticStart { start } = &mut abspos_fragment.box_offsets.block {
|
||||||
*start += child_fragment_rect.start_corner.block;
|
*start += child_fragment_rect.start_corner.block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue