Skip to content
Permalink
Browse files
table_wrapper.rs: Fix for percentage widths
Fixes #4421
  • Loading branch information
mttr committed Jan 11, 2015
1 parent ffdbf29 commit 182f1a0d0178119580906e346d051bffc1c0e4f2
@@ -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();
@@ -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
@@ -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>
@@ -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>

9 comments on commit 182f1a0

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 11, 2015

saw approval from pcwalton
at mttr@182f1a0

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 11, 2015

merging mttr/servo/table_percentage = 182f1a0 into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 11, 2015

mttr/servo/table_percentage = 182f1a0 merged ok, testing candidate = 94e8079

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 11, 2015

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 13, 2015

saw approval from pcwalton
at mttr@182f1a0

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 13, 2015

merging mttr/servo/table_percentage = 182f1a0 into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 13, 2015

mttr/servo/table_percentage = 182f1a0 merged ok, testing candidate = 62d1761

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Jan 13, 2015

fast-forwarding master to auto = 62d1761

Please sign in to comment.