From 182f1a0d0178119580906e346d051bffc1c0e4f2 Mon Sep 17 00:00:00 2001 From: Matthew Rasmus Date: Fri, 9 Jan 2015 15:30:30 -0800 Subject: [PATCH] table_wrapper.rs: Fix for percentage widths Fixes #4421 --- components/layout/table_wrapper.rs | 16 +++++++++++++--- tests/ref/basic.list | 1 + tests/ref/table_percentage_capping_a.html | 12 ++++++++++++ tests/ref/table_percentage_capping_ref.html | 12 ++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tests/ref/table_percentage_capping_a.html create mode 100644 tests/ref/table_percentage_capping_ref.html diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 5a856db7334..d696de85ddc 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -28,7 +28,7 @@ use servo_util::geometry::Au; use std::cmp::{max, min}; use std::fmt; use style::{ComputedValues, CSSFloat}; -use style::computed_values::table_layout; +use style::computed_values::{table_layout, LengthOrPercentageOrAuto}; use std::sync::Arc; #[deriving(Copy, Encodable, Show)] @@ -128,8 +128,18 @@ impl TableWrapperFlow { // FIXME(pcwalton, spec): INTRINSIC § 8 does not properly define how to compute this, but // says "the basic idea is the same as the shrink-to-fit width that CSS2.1 defines". So we // just use the shrink-to-fit inline size. - let available_inline_size = - self.block_flow.get_shrink_to_fit_inline_size(available_inline_size); + let available_inline_size = match self.block_flow.fragment.style().content_inline_size() { + LengthOrPercentageOrAuto::Auto => self.block_flow + .get_shrink_to_fit_inline_size(available_inline_size), + // FIXME(mttr) This fixes #4421 without breaking our current reftests, but I'm + // not completely sure this is "correct". + // + // That said, `available_inline_size` is, as far as I can tell, equal to the table's + // computed width property (W) and is used from this point forward in a way that seems + // to correspond with CSS 2.1 § 17.5.2.2 under "Column and caption widths + // influence the final table width as follows: ..." + _ => available_inline_size, + }; // Compute all the guesses for the column sizes, and sum them. let mut total_guess = AutoLayoutCandidateGuess::new(); diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 94f35425363..436cfccaeab 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -174,6 +174,7 @@ fragment=top != ../html/acid2.html acid2_ref.html == many_brs_a.html many_brs_ref.html == table_expansion_to_fit_a.html table_expansion_to_fit_ref.html == table_percentage_width_a.html table_percentage_width_ref.html +== table_percentage_capping_a.html table_percentage_capping_ref.html == legacy_input_size_attribute_override_a.html legacy_input_size_attribute_override_ref.html == legacy_td_width_attribute_a.html legacy_td_width_attribute_ref.html == box_sizing_sanity_check_a.html box_sizing_sanity_check_ref.html diff --git a/tests/ref/table_percentage_capping_a.html b/tests/ref/table_percentage_capping_a.html new file mode 100644 index 00000000000..820c360e391 --- /dev/null +++ b/tests/ref/table_percentage_capping_a.html @@ -0,0 +1,12 @@ + +Test for capping percentages + +
+ + +
parent div float=left
+
diff --git a/tests/ref/table_percentage_capping_ref.html b/tests/ref/table_percentage_capping_ref.html new file mode 100644 index 00000000000..1287f1db2c3 --- /dev/null +++ b/tests/ref/table_percentage_capping_ref.html @@ -0,0 +1,12 @@ + +Test for capping percentages + +
+ + +
parent div float=left
+