layout: Support percentage widths in inline-blocks.

Improves Twitter.
This commit is contained in:
Patrick Walton 2015-05-08 16:33:30 -07:00
parent 0a737d90f2
commit d5ca1a18dc
6 changed files with 52 additions and 4 deletions

View file

@ -2134,9 +2134,9 @@ pub trait ISizeAndMarginsComputer {
}
fn containing_block_inline_size(&self,
_: &mut BlockFlow,
parent_flow_inline_size: Au,
_: &LayoutContext)
_: &mut BlockFlow,
parent_flow_inline_size: Au,
_: &LayoutContext)
-> Au {
parent_flow_inline_size
}

View file

@ -1897,6 +1897,19 @@ impl Fragment {
}
}
/// Determines the inline sizes of inline-block fragments. These cannot be fully computed until
/// inline size assignment has run for the child flow: thus it is computed "late", during
/// block size assignment.
pub fn update_late_computed_replaced_inline_size_if_necessary(&mut self) {
if let SpecificFragmentInfo::InlineBlock(ref mut inline_block_info) = self.specific {
let block_flow = inline_block_info.flow_ref.as_block();
let margin = block_flow.fragment.style.logical_margin();
self.border_box.size.inline = block_flow.fragment.border_box.size.inline +
MaybeAuto::from_style(margin.inline_start, Au(0)).specified_or_zero() +
MaybeAuto::from_style(margin.inline_end, Au(0)).specified_or_zero()
}
}
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
match self.specific {
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {

View file

@ -1283,10 +1283,11 @@ impl Flow for InlineFlow {
// TODO(pcwalton): Cache the line scanner?
debug!("assign_block_size_inline: floats in: {:?}", self.base.floats);
// Assign the block-size for the inline fragments.
// Assign the block-size and late-computed inline-sizes for the inline fragments.
let containing_block_block_size =
self.base.block_container_explicit_block_size.unwrap_or(Au(0));
for fragment in self.fragments.fragments.iter_mut() {
fragment.update_late_computed_replaced_inline_size_if_necessary();
fragment.assign_replaced_block_size_if_necessary(
containing_block_block_size);
}

View file

@ -233,6 +233,7 @@ experimental != overconstrained_block.html overconstrained_block_ref.html
== percent_height.html percent_height_ref.html
== percentage_height_float_a.html percentage_height_float_ref.html
== percentage_height_root.html percentage_height_root_ref.html
== percentage_width_inline_block_a.html percentage_width_inline_block_ref.html
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
== position_abs_cb_with_non_cb_kid_a.html position_abs_cb_with_non_cb_kid_b.html
== position_abs_height_width_a.html position_abs_height_width_b.html

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<style>
section {
display: inline-block;
width: 100%;
background: steelblue;
color: white;
}
</style>
</head>
<body>
Y<section>X</section>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<style>
section {
width: 100%;
background: steelblue;
color: white;
}
</style>
</head>
<body>
Y<section>X</section>
</body>
</html>