servo: Merge #10279 - Fix #10258 (from notriddle:issue_10258); r=mbrubeck
authorMichael Howell <michael@notriddle.com>
Wed, 30 Mar 2016 12:19:10 +0500
changeset 338359 287ae28aaa90b1e849efb15bd18c8ef45de9b6e6
parent 338358 303b58e4db53abf07f8c032e694ba673bc1b4b8f
child 338360 096b4338d97942fb5ba7daf04ce576e905d9b356
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 #10279 - Fix #10258 (from notriddle:issue_10258); r=mbrubeck Respect border-box when computing the relative sizes of children. Source-Repo: https://github.com/servo/servo Source-Revision: 77444d00be7b6346b632385cb0c1f5e858ff50a2
servo/components/layout/block.rs
--- a/servo/components/layout/block.rs
+++ b/servo/components/layout/block.rs
@@ -1303,18 +1303,25 @@ impl BlockFlow {
                                                                         WritingMode,
                                                                         &mut Au,
                                                                         &mut Au) {
         let flags = self.base.flags.clone();
 
         let opaque_self = OpaqueFlow::from_flow(self);
 
         // Calculate non-auto block size to pass to children.
+        let box_border = match self.fragment.style().get_box().box_sizing {
+            box_sizing::T::border_box => self.fragment.border_padding.block_start_end(),
+            box_sizing::T::content_box => Au(0),
+        };
         let parent_container_size = self.explicit_block_containing_size(layout_context);
-        let explicit_content_size = self.explicit_block_size(parent_container_size);
+        // https://drafts.csswg.org/css-ui-3/#box-sizing
+        let explicit_content_size = self
+                                    .explicit_block_size(parent_container_size)
+                                    .map(|x| if x < box_border { Au(0) } else { x - box_border });
 
         // Calculate containing block inline size.
         let containing_block_size = if flags.contains(IS_ABSOLUTELY_POSITIONED) {
             self.containing_block_size(&layout_context.shared_context().viewport_size, opaque_self).inline
         } else {
             content_inline_size
         };
         // FIXME (mbrubeck): Get correct mode for absolute containing block