From 61c7ee917e3b9705aa2ae531ac9e59bf51f77e40 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 29 Mar 2016 13:49:23 -0700 Subject: [PATCH] Compute content box for children with box-sizing: border-box correctly. Fixes #10258 --- components/layout/block.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/layout/block.rs b/components/layout/block.rs index 73836d09ec1..01e38700e5b 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1308,8 +1308,15 @@ impl BlockFlow { 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) {