mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Conditionsals over closures
This commit is contained in:
parent
c07c980501
commit
29067225a4
1 changed files with 10 additions and 12 deletions
|
@ -208,7 +208,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
padding_border_sum: Length,
|
padding_border_sum: Length,
|
||||||
computed_margin_start: LengthOrAuto,
|
computed_margin_start: LengthOrAuto,
|
||||||
computed_margin_end: LengthOrAuto,
|
computed_margin_end: LengthOrAuto,
|
||||||
solve_margins: impl FnOnce(Length) -> (Length, Length),
|
avoid_negative_margin_start: bool,
|
||||||
box_offsets: AbsoluteBoxOffsets,
|
box_offsets: AbsoluteBoxOffsets,
|
||||||
size: LengthOrAuto,
|
size: LengthOrAuto,
|
||||||
) -> (Anchor, LengthOrAuto, Length, Length) {
|
) -> (Anchor, LengthOrAuto, Length, Length) {
|
||||||
|
@ -243,9 +243,13 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
let margins = containing_size - start - end - padding_border_sum - s;
|
let margins = containing_size - start - end - padding_border_sum - s;
|
||||||
match (computed_margin_start, computed_margin_end) {
|
match (computed_margin_start, computed_margin_end) {
|
||||||
(LengthOrAuto::Auto, LengthOrAuto::Auto) => {
|
(LengthOrAuto::Auto, LengthOrAuto::Auto) => {
|
||||||
let (s, e) = solve_margins(margins);
|
if avoid_negative_margin_start && margins < Length::zero() {
|
||||||
margin_start = s;
|
margin_start = Length::zero();
|
||||||
margin_end = e;
|
margin_end = margins;
|
||||||
|
} else {
|
||||||
|
margin_start = margins / 2.;
|
||||||
|
margin_end = margins / 2.;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(LengthOrAuto::Auto, LengthOrAuto::LengthPercentage(end)) => {
|
(LengthOrAuto::Auto, LengthOrAuto::LengthPercentage(end)) => {
|
||||||
margin_start = margins - end;
|
margin_start = margins - end;
|
||||||
|
@ -289,13 +293,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
pb.inline_sum(),
|
pb.inline_sum(),
|
||||||
computed_margin.inline_start,
|
computed_margin.inline_start,
|
||||||
computed_margin.inline_end,
|
computed_margin.inline_end,
|
||||||
|margins| {
|
/* avoid_negative_margin_start */ true,
|
||||||
if margins.px() >= 0. {
|
|
||||||
(margins / 2., margins / 2.)
|
|
||||||
} else {
|
|
||||||
(Length::zero(), margins)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
self.box_offsets.inline,
|
self.box_offsets.inline,
|
||||||
size.inline,
|
size.inline,
|
||||||
);
|
);
|
||||||
|
@ -305,7 +303,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
||||||
pb.block_sum(),
|
pb.block_sum(),
|
||||||
computed_margin.block_start,
|
computed_margin.block_start,
|
||||||
computed_margin.block_end,
|
computed_margin.block_end,
|
||||||
|margins| (margins / 2., margins / 2.),
|
/* avoid_negative_margin_start */ false,
|
||||||
self.box_offsets.block,
|
self.box_offsets.block,
|
||||||
size.block,
|
size.block,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue