mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Support percentage widths in inline-blocks.
Improves Twitter.
This commit is contained in:
parent
0a737d90f2
commit
d5ca1a18dc
6 changed files with 52 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
17
tests/ref/percentage_width_inline_block_a.html
Normal file
17
tests/ref/percentage_width_inline_block_a.html
Normal 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>
|
||||
|
16
tests/ref/percentage_width_inline_block_ref.html
Normal file
16
tests/ref/percentage_width_inline_block_ref.html
Normal 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>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue