mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
auto merge of #4783 : mttr/servo/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.
This commit is contained in:
commit
986f9cb543
6 changed files with 70 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,8 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
|||
== inline_block_margin_a.html inline_block_margin_ref.html
|
||||
== inline_block_img_a.html inline_block_img_ref.html
|
||||
== inline_block_baseline_a.html inline_block_baseline_ref.html
|
||||
== inline_block_parent_width.html inline_block_parent_width_ref.html
|
||||
== inline_block_parent_width_percentage.html inline_block_parent_width_ref.html
|
||||
== float_table_a.html float_table_ref.html
|
||||
== table_containing_block_a.html table_containing_block_ref.html
|
||||
== link_style_order.html link_style_order_ref.html
|
||||
|
|
17
tests/ref/inline_block_parent_width.html
Normal file
17
tests/ref/inline_block_parent_width.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="display: block; width: 300px;">
|
||||
<div style="display: inline-block">
|
||||
Bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
17
tests/ref/inline_block_parent_width_percentage.html
Normal file
17
tests/ref/inline_block_parent_width_percentage.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="display: block; width: 600px;">
|
||||
<div style="width: 50%; display: inline-block;">
|
||||
Bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
17
tests/ref/inline_block_parent_width_ref.html
Normal file
17
tests/ref/inline_block_parent_width_ref.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="display: block; width: 300px; height: 8em;">
|
||||
<div style="display: inline-block; width: 300px;">
|
||||
Bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
bloobity bloobity bloobity bloobity
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue