aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-01-23 08:55:44 -0800
committerGitHub <noreply@github.com>2017-01-23 08:55:44 -0800
commitb0f91193fd4fbb86fc75fc593a6fdc40dc95bfcd (patch)
tree5a030a5ff1136d90e43e9f8c0b8dcd1d73251698
parent1706ffd6e5a02f26f69970b3b41536a8a85ef6fe (diff)
parentd7a9c3f8e5d9224882e43a1b9b3533c11ad41aa6 (diff)
downloadservo-b0f91193fd4fbb86fc75fc593a6fdc40dc95bfcd.tar.gz
servo-b0f91193fd4fbb86fc75fc593a6fdc40dc95bfcd.zip
Auto merge of #13681 - gpoesia:master, r=mbrubeck
Fix margin size calculation for TableWrapper <!-- Please describe your changes on the following line: --> Fixes inline size calculation for TableWrapper. The table's width was always reaching the inline size equation solver as a specified variable, which was causing the system to be overdetermined when there was a margin specified for the table, and this caused the overflow reported in #12748. The fix consists in handling three cases when the table's width is not specified: if the preferred size of all columns fits, it is returned; if the minimum size does not fit, it is returned instead (it will overflow), otherwise, it is returned as a free variable (that should be solved together with the margin to some value above the minimum width and below the preferred width). --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12748 - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13681) <!-- Reviewable:end -->
-rw-r--r--components/layout/table_wrapper.rs8
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json24
-rw-r--r--tests/wpt/mozilla/tests/css/table_margin_a.html36
-rw-r--r--tests/wpt/mozilla/tests/css/table_margin_ref.html24
4 files changed, 91 insertions, 1 deletions
diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs
index 4f40a94e28e..01800ce3487 100644
--- a/components/layout/table_wrapper.rs
+++ b/components/layout/table_wrapper.rs
@@ -766,7 +766,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 98dbd60fcbb..a5ea9fc0845 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",
@@ -20586,6 +20598,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 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <link rel="match" href="table_margin_ref.html" />
+ <style type="text/css">
+ table.ombox {
+ margin: 0 0 0 50%;
+ background: #f9f9f9;
+ }
+
+ td, tr, table {
+ padding: 0;
+ margin: 0;
+ }
+
+ .template-documentation {
+ width: 100%;
+ background-color: #ecfcf4;
+ padding: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="template-documentation">
+ <table class="ombox">
+ <tr>
+ <td>
+ 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.
+ </td>
+ </tr>
+ </table>
+ </div>
+ </body>
+</html>
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 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style type="text/css">
+ .ombox {
+ margin-left: 50%;
+ background: #f9f9f9;
+ padding: 2px;
+ }
+ .template-documentation {
+ background-color: #ecfcf4;
+ width: 100%;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="template-documentation">
+ <div class="ombox">
+ 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.
+ </div>
+ </div>
+ </body>
+</html>