servo: Merge #13681 - Fix margin size calculation for TableWrapper (from gpoesia:master); r=mbrubeck
authorGabriel Poesia <gabriel.poesia@gmail.com>
Mon, 23 Jan 2017 08:55:44 -0800
changeset 340634 7ba77a2374a35c20d65c2686e704c0a5ea8aee7b
parent 340633 43657bf6458152f8a99e25af3bd99094669f6642
child 340635 3722e15a67cccd2cda32fc4ad71b7d202fb6e706
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
servo: Merge #13681 - Fix margin size calculation for TableWrapper (from gpoesia:master); r=mbrubeck <!-- 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 Source-Repo: https://github.com/servo/servo Source-Revision: b0f91193fd4fbb86fc75fc593a6fdc40dc95bfcd
servo/components/layout/table_wrapper.rs
--- a/servo/components/layout/table_wrapper.rs
+++ b/servo/components/layout/table_wrapper.rs
@@ -761,17 +761,23 @@ fn initial_computed_inline_size(block: &
                                 minimum_width_of_all_columns: Au,
                                 preferred_width_of_all_columns: Au,
                                 table_border_padding: Au)
                                 -> MaybeAuto {
     let inline_size_from_style = MaybeAuto::from_style(block.fragment.style.content_inline_size(),
                                                        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,
                                      minimum_width_of_all_columns))
         }
     }
 }