Auto merge of #7274 - pcwalton:table-minimum-width, r=mbrubeck

layout: Make table cells' minimum inline sizes override explicitly specified widths if the latter are too small.

Improves ebay.com.

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7274)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-19 03:20:37 -06:00
commit 30a1339ed1
12 changed files with 47 additions and 56 deletions

View file

@ -1494,42 +1494,15 @@ impl BlockFlow {
surrounding_inline_size,
}
}
}
impl Flow for BlockFlow {
fn class(&self) -> FlowClass {
FlowClass::Block
}
fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
self
}
fn as_block<'a>(&'a self) -> &'a BlockFlow {
self
}
/// Pass 1 of reflow: computes minimum and preferred inline-sizes.
///
/// Recursively (bottom-up) determine the flow's minimum and preferred inline-sizes. When
/// called on this flow, all child flows have had their minimum and preferred inline-sizes set.
/// This function must decide minimum/preferred inline-sizes based on its children's
/// inline-sizes and the dimensions of any fragments it is responsible for flowing.
fn bubble_inline_sizes(&mut self) {
/// Computes intrinsic widths for a block.
pub fn bubble_inline_sizes_for_block(&mut self, consult_children: bool) {
let _scope = layout_debug_scope!("block::bubble_inline_sizes {:x}", self.base.debug_id());
let mut flags = self.base.flags;
flags.remove(HAS_LEFT_FLOATED_DESCENDANTS);
flags.remove(HAS_RIGHT_FLOATED_DESCENDANTS);
// If this block has a fixed width, just use that for the minimum
// and preferred width, rather than bubbling up children inline
// width.
let fixed_width = match self.fragment.style().get_box().width {
LengthOrPercentageOrAuto::Length(_) => true,
_ => false,
};
// Find the maximum inline-size from children.
let mut computation = self.fragment.compute_intrinsic_inline_sizes();
let (mut left_float_width, mut right_float_width) = (Au(0), Au(0));
@ -1539,7 +1512,7 @@ impl Flow for BlockFlow {
flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED);
let child_base = flow::mut_base(kid);
let float_kind = child_base.flags.float_kind();
if !is_absolutely_positioned && !fixed_width {
if !is_absolutely_positioned && consult_children {
computation.content_intrinsic_sizes.minimum_inline_size =
max(computation.content_intrinsic_sizes.minimum_inline_size,
child_base.intrinsic_inline_sizes.minimum_inline_size);
@ -1591,6 +1564,36 @@ impl Flow for BlockFlow {
}
self.base.flags = flags
}
}
impl Flow for BlockFlow {
fn class(&self) -> FlowClass {
FlowClass::Block
}
fn as_mut_block<'a>(&'a mut self) -> &'a mut BlockFlow {
self
}
fn as_block<'a>(&'a self) -> &'a BlockFlow {
self
}
/// Pass 1 of reflow: computes minimum and preferred inline-sizes.
///
/// Recursively (bottom-up) determine the flow's minimum and preferred inline-sizes. When
/// called on this flow, all child flows have had their minimum and preferred inline-sizes set.
/// This function must decide minimum/preferred inline-sizes based on its children's
/// inline-sizes and the dimensions of any fragments it is responsible for flowing.
fn bubble_inline_sizes(&mut self) {
// If this block has a fixed width, just use that for the minimum and preferred width,
// rather than bubbling up children inline width.
let consult_children = match self.fragment.style().get_box().width {
LengthOrPercentageOrAuto::Length(_) => false,
_ => true,
};
self.bubble_inline_sizes_for_block(consult_children)
}
/// Recursively (top-down) determines the actual inline-size of child contexts and fragments.
/// When called on this context, the context has had its inline-size set by the parent context.

View file

@ -576,11 +576,17 @@ impl ISizeAndMarginsComputer for InternalTable {
block: &mut BlockFlow,
layout_context: &LayoutContext,
parent_flow_inline_size: Au) {
let input = self.compute_inline_size_constraint_inputs(block,
parent_flow_inline_size,
layout_context);
let solution = self.solve_inline_size_constraints(block, &input);
let mut input = self.compute_inline_size_constraint_inputs(block,
parent_flow_inline_size,
layout_context);
// Tables are always at least as wide as their minimum inline size.
let minimum_inline_size =
block.base.intrinsic_inline_sizes.minimum_inline_size -
block.fragment.border_padding.inline_start_end();
input.available_inline_size = cmp::max(input.available_inline_size, minimum_inline_size);
let solution = self.solve_inline_size_constraints(block, &input);
self.set_inline_size_constraint_solutions(block, solution);
}

View file

@ -106,7 +106,7 @@ impl Flow for TableCellFlow {
let _scope = layout_debug_scope!("table_cell::bubble_inline_sizes {:x}",
self.block_flow.base.debug_id());
self.block_flow.bubble_inline_sizes();
self.block_flow.bubble_inline_sizes_for_block(true);
let specified_inline_size = MaybeAuto::from_style(self.block_flow
.fragment
.style()

View file

@ -68,4 +68,4 @@
<div id="overlapping-green"></div>
</body>
</html>
</html>

View file

@ -1,3 +1,3 @@
[top-applies-to-001.htm]
[c5501-mrgn-t-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +1,3 @@
[left-applies-to-001.htm]
[c5503-mrgn-b-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[line-height-applies-to-005.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[line-height-applies-to-014.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[margin-bottom-applies-to-005.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[margin-top-applies-to-014.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[vertical-align-applies-to-005.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[vertical-align-applies-to-014.htm]
type: reftest
expected: FAIL