layout: Make geom.rs logical geoemetry types more ergonomic (#32633)

Make using the logical geometry types more ergonomic by having them all
implement `Copy` (at most 4 64-bit numbers), similar to what `euclid`
does. In addition add an implementation of `Neg` for `LogicalVec` and
`LogicalSides` as it will be used in upcoming table implementation code.
This commit is contained in:
Martin Robinson 2024-06-28 10:20:50 +02:00 committed by GitHub
parent e9cf4d4971
commit adc0fc984d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 80 additions and 102 deletions

View file

@ -897,7 +897,7 @@ impl FloatBox {
// or non-replaced.
let pbm = style.padding_border_margin(containing_block);
let margin = pbm.margin.auto_is(Au::zero);
let pbm_sums = &(&pbm.padding + &pbm.border) + &margin.clone();
let pbm_sums = pbm.padding + pbm.border + margin;
let (content_size, children);
match self.contents {
@ -1208,10 +1208,10 @@ impl SequentialLayoutState {
block_start_of_containing_block_in_bfc + block_offset_from_containing_block_top,
);
let pbm_sums = &(&box_fragment.padding + &box_fragment.border) + &box_fragment.margin;
let content_rect = box_fragment.content_rect.clone();
let pbm_sums = box_fragment.padding + box_fragment.border + box_fragment.margin;
let content_rect = &box_fragment.content_rect;
let margin_box_start_corner = self.floats.add_float(&PlacementInfo {
size: &content_rect.size + &pbm_sums.sum(),
size: content_rect.size + pbm_sums.sum(),
side: FloatSide::from_style(&box_fragment.style).expect("Float box wasn't floated!"),
clear: box_fragment.style.get_box().clear,
});
@ -1219,7 +1219,7 @@ impl SequentialLayoutState {
// This is the position of the float in the float-containing block formatting context. We add the
// existing start corner here because we may have already gotten some relative positioning offset.
let new_position_in_bfc =
&(&margin_box_start_corner + &pbm_sums.start_offset()) + &content_rect.start_corner;
margin_box_start_corner + pbm_sums.start_offset() + content_rect.start_corner;
// This is the position of the float relative to the containing block start.
let new_position_in_containing_block = LogicalVec2 {