From d7a9c3f8e5d9224882e43a1b9b3533c11ad41aa6 Mon Sep 17 00:00:00 2001 From: Gabriel Poesia Date: Mon, 10 Oct 2016 16:12:17 -0300 Subject: [PATCH] TableWrapper: fix content inline size calculation The preferred size of all columns was always being used before, but this caused problems when it does not fit along with margins. --- components/layout/table_wrapper.rs | 8 ++++- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++ .../wpt/mozilla/tests/css/table_margin_a.html | 36 +++++++++++++++++++ .../mozilla/tests/css/table_margin_ref.html | 24 +++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/css/table_margin_a.html create mode 100644 tests/wpt/mozilla/tests/css/table_margin_ref.html diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 372fdbd086f..96008268c5e 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -778,7 +778,13 @@ fn initial_computed_inline_size(block: &mut BlockFlow, containing_block_inline_size); match inline_size_from_style { MaybeAuto::Auto => { - MaybeAuto::Specified(min(containing_block_inline_size, preferred_width_of_all_columns)) + if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size { + MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding) + } else if minimum_width_of_all_columns > containing_block_inline_size { + MaybeAuto::Specified(minimum_width_of_all_columns) + } else { + MaybeAuto::Auto + } } MaybeAuto::Specified(inline_size_from_style) => { MaybeAuto::Specified(max(inline_size_from_style - table_border_padding, diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index ca2f3db7589..5c14777c084 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -5220,6 +5220,18 @@ "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" } ], + "css/table_margin_a.html": [ + { + "path": "css/table_margin_a.html", + "references": [ + [ + "/_mozilla/css/table_margin_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/table_margin_a.html" + } + ], "css/table_margin_auto_a.html": [ { "path": "css/table_margin_auto_a.html", @@ -20286,6 +20298,18 @@ "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" } ], + "css/table_margin_a.html": [ + { + "path": "css/table_margin_a.html", + "references": [ + [ + "/_mozilla/css/table_margin_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/table_margin_a.html" + } + ], "css/table_margin_auto_a.html": [ { "path": "css/table_margin_auto_a.html", diff --git a/tests/wpt/mozilla/tests/css/table_margin_a.html b/tests/wpt/mozilla/tests/css/table_margin_a.html new file mode 100644 index 00000000000..b95a3a3ef29 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/table_margin_a.html @@ -0,0 +1,36 @@ + + + + + + + + +
+ + + + +
+ This is a test. This line is large, large enough so that it will wrap. + Issue #12748, for which this test was created, is about the table margin not behaving correctly. +
+
+ + diff --git a/tests/wpt/mozilla/tests/css/table_margin_ref.html b/tests/wpt/mozilla/tests/css/table_margin_ref.html new file mode 100644 index 00000000000..fa5c4f88d82 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/table_margin_ref.html @@ -0,0 +1,24 @@ + + + + + + +
+
+ This is a test. This line is large, large enough so that it will wrap. + Issue #12748, for which this test was created, is about the table margin not behaving correctly. +
+
+ +