Skip to content

Commit

Permalink
Shrink-to-fit inline-blocks with width set to auto
Browse files Browse the repository at this point in the history
  • Loading branch information
mttr committed Feb 2, 2015
1 parent 5b34059 commit 846fc64
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/layout/block.rs
Expand Up @@ -2153,7 +2153,7 @@ pub trait ISizeAndMarginsComputer {
/// available_inline-size
/// where available_inline-size = CB inline-size - (horizontal border + padding)
fn solve_block_inline_size_constraints(&self,
_: &mut BlockFlow,
block: &mut BlockFlow,
input: &ISizeConstraintInput)
-> ISizeConstraintSolution {
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
Expand All @@ -2180,7 +2180,7 @@ pub trait ISizeAndMarginsComputer {

// Invariant: inline-start_margin + inline-size + inline-end_margin ==
// 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) {
// If all have a computed value other than 'auto', the system is
// over-constrained so we discard the end margin.
Expand Down Expand Up @@ -2213,6 +2213,13 @@ pub trait ISizeAndMarginsComputer {
(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)
}
}
Expand Down

5 comments on commit 846fc64

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from mbrubeck
at mttr@846fc64

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mttr/servo/inline_block_percentage = 846fc64 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mttr/servo/inline_block_percentage = 846fc64 merged ok, testing candidate = 986f9cb

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 986f9cb

Please sign in to comment.