mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Shrink-to-fit inline-blocks with width set to auto
This commit is contained in:
parent
5b340599f2
commit
846fc6453a
1 changed files with 9 additions and 2 deletions
|
@ -2153,7 +2153,7 @@ pub trait ISizeAndMarginsComputer {
|
||||||
/// available_inline-size
|
/// available_inline-size
|
||||||
/// where available_inline-size = CB inline-size - (horizontal border + padding)
|
/// where available_inline-size = CB inline-size - (horizontal border + padding)
|
||||||
fn solve_block_inline_size_constraints(&self,
|
fn solve_block_inline_size_constraints(&self,
|
||||||
_: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
input: &ISizeConstraintInput)
|
input: &ISizeConstraintInput)
|
||||||
-> ISizeConstraintSolution {
|
-> ISizeConstraintSolution {
|
||||||
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
|
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
|
||||||
|
@ -2180,7 +2180,7 @@ pub trait ISizeAndMarginsComputer {
|
||||||
|
|
||||||
// Invariant: inline-start_margin + inline-size + inline-end_margin ==
|
// Invariant: inline-start_margin + inline-size + inline-end_margin ==
|
||||||
// available_inline-size
|
// available_inline-size
|
||||||
let (inline_start_margin, inline_size, inline_end_margin) =
|
let (inline_start_margin, mut inline_size, inline_end_margin) =
|
||||||
match (inline_start_margin, computed_inline_size, inline_end_margin) {
|
match (inline_start_margin, computed_inline_size, inline_end_margin) {
|
||||||
// If all have a computed value other than 'auto', the system is
|
// If all have a computed value other than 'auto', the system is
|
||||||
// over-constrained so we discard the end margin.
|
// over-constrained so we discard the end margin.
|
||||||
|
@ -2213,6 +2213,13 @@ pub trait ISizeAndMarginsComputer {
|
||||||
(margin, inline_size, margin)
|
(margin, inline_size, margin)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If inline-size is set to 'auto', and this is an inline block, use the
|
||||||
|
// shrink to fit algorithm (see CSS 2.1 § 10.3.9)
|
||||||
|
if computed_inline_size == MaybeAuto::Auto && block.is_inline_block() {
|
||||||
|
inline_size = block.get_shrink_to_fit_inline_size(inline_size);
|
||||||
|
}
|
||||||
|
|
||||||
ISizeConstraintSolution::new(inline_size, inline_start_margin, inline_end_margin)
|
ISizeConstraintSolution::new(inline_size, inline_start_margin, inline_end_margin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue