mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
layout: Make percentage heights propagate through inline flows.
I found this random bug during an attempt to improve Wikipedia.
This commit is contained in:
parent
08e004d106
commit
39d7bf93d6
6 changed files with 51 additions and 18 deletions
|
@ -513,10 +513,6 @@ pub struct BlockFlow {
|
|||
/// block formatting contexts.
|
||||
previous_float_inline_size: Option<Au>,
|
||||
|
||||
/// The block-size of the block container of this block, if it is an explicit size (does not
|
||||
/// depend on content heights). Used for computing percentage values for `height`.
|
||||
block_container_explicit_block_size: Option<Au>,
|
||||
|
||||
/// Additional floating flow members.
|
||||
pub float: Option<Box<FloatedBlockInfo>>
|
||||
}
|
||||
|
@ -529,7 +525,6 @@ impl BlockFlow {
|
|||
is_root: false,
|
||||
static_b_offset: Au::new(0),
|
||||
previous_float_inline_size: None,
|
||||
block_container_explicit_block_size: None,
|
||||
float: None
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +536,6 @@ impl BlockFlow {
|
|||
is_root: false,
|
||||
static_b_offset: Au::new(0),
|
||||
previous_float_inline_size: None,
|
||||
block_container_explicit_block_size: None,
|
||||
float: None
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +550,6 @@ impl BlockFlow {
|
|||
is_root: false,
|
||||
static_b_offset: Au::new(0),
|
||||
previous_float_inline_size: None,
|
||||
block_container_explicit_block_size: None,
|
||||
float: Some(box FloatedBlockInfo::new(float_kind, base.writing_mode)),
|
||||
base: base,
|
||||
}
|
||||
|
@ -983,7 +976,7 @@ impl BlockFlow {
|
|||
|
||||
let mut candidate_block_size_iterator = CandidateBSizeIterator::new(
|
||||
self.fragment.style(),
|
||||
self.block_container_explicit_block_size);
|
||||
self.base.block_container_explicit_block_size);
|
||||
for candidate_block_size in candidate_block_size_iterator {
|
||||
candidate_block_size_iterator.candidate_value = match candidate_block_size {
|
||||
Auto => block_size,
|
||||
|
@ -1324,11 +1317,11 @@ impl BlockFlow {
|
|||
self.base.position.start.b
|
||||
}
|
||||
|
||||
/// Assigns the computed inline-start content edge and inline-size to all the children of this block flow.
|
||||
/// Also computes whether each child will be impacted by floats.
|
||||
/// Assigns the computed inline-start content edge and inline-size to all the children of this
|
||||
/// block flow. Also computes whether each child will be impacted by floats.
|
||||
///
|
||||
/// `#[inline(always)]` because this is called only from block or table inline-size assignment and
|
||||
/// the code for block layout is significantly simpler.
|
||||
/// `#[inline(always)]` because this is called only from block or table inline-size assignment
|
||||
/// and the code for block layout is significantly simpler.
|
||||
#[inline(always)]
|
||||
pub fn propagate_assigned_inline_size_to_children(&mut self,
|
||||
inline_start_content_edge: Au,
|
||||
|
@ -1355,16 +1348,16 @@ impl BlockFlow {
|
|||
// This value is used only for table cells.
|
||||
let mut inline_start_margin_edge = inline_start_content_edge;
|
||||
|
||||
// The inline-size of the last float, if there was one. This is used for estimating the inline-sizes of
|
||||
// block formatting contexts. (We estimate that the inline-size of any block formatting context
|
||||
// that we see will be based on the inline-size of the containing block as well as the last float
|
||||
// seen before it.)
|
||||
// The inline-size of the last float, if there was one. This is used for estimating the
|
||||
// inline-sizes of block formatting contexts. (We estimate that the inline-size of any
|
||||
// block formatting context that we see will be based on the inline-size of the containing
|
||||
// block as well as the last float seen before it.)
|
||||
let mut last_float_inline_size = None;
|
||||
|
||||
// Calculate non-auto block size to pass to children.
|
||||
let content_block_size = self.fragment.style().content_block_size();
|
||||
let explicit_content_size = match (content_block_size,
|
||||
self.block_container_explicit_block_size) {
|
||||
self.base.block_container_explicit_block_size) {
|
||||
(LPA_Percentage(percent), Some(container_size)) => {
|
||||
Some(container_size.scale_by(percent))
|
||||
}
|
||||
|
@ -1373,6 +1366,8 @@ impl BlockFlow {
|
|||
};
|
||||
|
||||
for (i, kid) in self.base.child_iter().enumerate() {
|
||||
flow::mut_base(kid).block_container_explicit_block_size = explicit_content_size;
|
||||
|
||||
if kid.is_block_flow() {
|
||||
let kid_block = kid.as_block();
|
||||
kid_block.base.absolute_static_i_offset = absolute_static_i_offset;
|
||||
|
@ -1383,7 +1378,6 @@ impl BlockFlow {
|
|||
} else {
|
||||
kid_block.previous_float_inline_size = last_float_inline_size
|
||||
}
|
||||
kid_block.block_container_explicit_block_size = explicit_content_size;
|
||||
}
|
||||
|
||||
// The inline-start margin edge of the child flow is at our inline-start content edge, and its inline-size
|
||||
|
|
|
@ -704,6 +704,10 @@ pub struct BaseFlow {
|
|||
/// containing block. This is in tree order. This includes any direct children.
|
||||
pub abs_descendants: AbsDescendants,
|
||||
|
||||
/// The block-size of the block container of this flow, if it is an explicit size (does not
|
||||
/// depend on content heights). Used for computing percentage values for `height`.
|
||||
pub block_container_explicit_block_size: Option<Au>,
|
||||
|
||||
/// Offset wrt the nearest positioned ancestor - aka the Containing Block
|
||||
/// for any absolutely positioned elements.
|
||||
pub absolute_static_i_offset: Au,
|
||||
|
@ -786,6 +790,7 @@ impl BaseFlow {
|
|||
abs_descendants: Descendants::new(),
|
||||
absolute_static_i_offset: Au::new(0),
|
||||
fixed_static_i_offset: Au::new(0),
|
||||
block_container_explicit_block_size: None,
|
||||
absolute_cb: ContainingBlockLink::new(),
|
||||
display_list: DisplayList::new(),
|
||||
layers: DList::new(),
|
||||
|
|
|
@ -957,6 +957,13 @@ impl Flow for InlineFlow {
|
|||
fragment.assign_replaced_inline_size_if_necessary(inline_size);
|
||||
}
|
||||
}
|
||||
|
||||
// If there are any inline-block kids, propagate explicit block 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate and set the block-size of this flow. See CSS 2.1 § 10.6.1.
|
||||
|
|
|
@ -134,3 +134,4 @@ flaky_gpu,flaky_linux == acid2_noscroll.html acid2_ref_broken.html
|
|||
== table_padding_a.html table_padding_ref.html
|
||||
== img_block_display_a.html img_block_display_ref.html
|
||||
== after_block_iteration.html after_block_iteration_ref.html
|
||||
== inline_block_percentage_height_a.html inline_block_percentage_height_ref.html
|
||||
|
|
13
tests/ref/inline_block_percentage_height_a.html
Normal file
13
tests/ref/inline_block_percentage_height_a.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: 100px;">
|
||||
<span style="height: 100%;">
|
||||
<li style="height: 100%; background: red;"><span>Edit</span></li>
|
||||
</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
13
tests/ref/inline_block_percentage_height_ref.html
Normal file
13
tests/ref/inline_block_percentage_height_ref.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: 100px;">
|
||||
<div style="height: 100%;">
|
||||
<li style="height: 100%; background: red;"><span>Edit</span></li>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue