servo: Merge #4783 - Fix 'inline-block' sizing issues (from mttr:inline_block_percentage); r=mbrubeck

The first commit fixes #3624, and the second commit fixes a bug uncovered by the first fix and caught by a reftest (according to CSS 2.1, inline-blocks should have the shrink-to-fit algorithm run on them when size is set to 'auto'). The two new reftests included here fail before the fix and pass afterwards.

Source-Repo: https://github.com/servo/servo
Source-Revision: 986f9cb5432dc51e37e0c47a4f430c0353c6dc75
This commit is contained in:
Matthew Rasmus 2015-02-02 17:45:50 -07:00
Родитель 6c95f2190b
Коммит 7cd0fd06de
2 изменённых файлов: 17 добавлений и 7 удалений

Просмотреть файл

@ -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) =
@ -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.
@ -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)
}
}

Просмотреть файл

@ -1117,10 +1117,10 @@ impl Flow for InlineFlow {
debug!("InlineFlow::assign_inline_sizes: floats in: {:?}", self.base.floats);
self.base.position.size.inline = self.base.block_container_inline_size;
let inline_size = self.base.block_container_inline_size;
self.base.position.size.inline = inline_size;
{
let inline_size = self.base.position.size.inline;
let this = &mut *self;
for fragment in this.fragments.fragments.iter_mut() {
fragment.compute_border_and_padding(inline_size);
@ -1130,11 +1130,14 @@ impl Flow for InlineFlow {
}
}
// If there are any inline-block kids, propagate explicit block sizes down to them.
// If there are any inline-block kids, propagate explicit block and inline
// sizes down to them.
let block_container_explicit_block_size = self.base.block_container_explicit_block_size;
for kid in self.base.child_iter() {
flow::mut_base(kid).block_container_explicit_block_size =
block_container_explicit_block_size;
let kid_base = flow::mut_base(kid);
kid_base.block_container_inline_size = inline_size;
kid_base.block_container_explicit_block_size = block_container_explicit_block_size;
}
}