mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Never resolve margin-left:auto to a negative amount (#30065)
With direction:ltr (and we don't support direction:rtl yet), the rules from https://drafts.csswg.org/css2/#blockwidth imply that margin-left shouldn't resolve auto to a negative amount. This aligns Servo with Gecko and Blink. WebKit may resolve to a negative amount in some cases.
This commit is contained in:
parent
1296ddf273
commit
d90e3078a6
4 changed files with 158 additions and 6 deletions
|
@ -1142,12 +1142,15 @@ fn solve_inline_margins_for_in_flow_block_level(
|
|||
pbm: &PaddingBorderMargin,
|
||||
inline_size: Length,
|
||||
) -> (Length, Length) {
|
||||
let available = containing_block.inline_size - pbm.padding_border_sums.inline - inline_size;
|
||||
match (pbm.margin.inline_start, pbm.margin.inline_end) {
|
||||
(LengthOrAuto::Auto, LengthOrAuto::Auto) => (available / 2., available / 2.),
|
||||
(LengthOrAuto::Auto, LengthOrAuto::LengthPercentage(end)) => (available - end, end),
|
||||
(LengthOrAuto::LengthPercentage(start), _) => (start, available - start),
|
||||
}
|
||||
let free_space = containing_block.inline_size - pbm.padding_border_sums.inline - inline_size;
|
||||
let margin_inline_start = match (pbm.margin.inline_start, pbm.margin.inline_end) {
|
||||
(LengthOrAuto::Auto, LengthOrAuto::Auto) => Length::zero().max(free_space / 2.),
|
||||
(LengthOrAuto::Auto, LengthOrAuto::LengthPercentage(end)) => {
|
||||
Length::zero().max(free_space - end)
|
||||
},
|
||||
(LengthOrAuto::LengthPercentage(start), _) => start,
|
||||
};
|
||||
(margin_inline_start, free_space - margin_inline_start)
|
||||
}
|
||||
|
||||
/// State that we maintain when placing blocks.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue