aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout/table_wrapper.rs16
-rw-r--r--tests/ref/basic.list1
-rw-r--r--tests/ref/table_percentage_capping_a.html12
-rw-r--r--tests/ref/table_percentage_capping_ref.html12
4 files changed, 38 insertions, 3 deletions
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 60f5e65171f..e53bcc6da93 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 @@
+<!doctype html>
+<title>Test for capping percentages</title>
+<style>
+div { width:300px; background:yellow; height:50px; }
+table { width:150%; }
+td { background:blue; }
+</style>
+<div>
+ <table cellspacing="0" cellpadding="0" border="0">
+ <tr><td>parent div float=left</td></tr>
+ </table>
+</div>
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 @@
+<!doctype html>
+<title>Test for capping percentages</title>
+<style>
+div { width:300px; background:yellow; height:50px; }
+table { width:450px; }
+td { background:blue; }
+</style>
+<div>
+ <table cellspacing="0" cellpadding="0" border="0">
+ <tr><td>parent div float=left</td></tr>
+ </table>
+</div>