aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-03-30 12:48:40 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-03-30 12:48:40 +0530
commit77444d00be7b6346b632385cb0c1f5e858ff50a2 (patch)
tree037423d07f65efa83f7d9af04e9563bd3ca9b7e1
parent21e4936f6a4a99ed7071a8c94bc6e1d418944e67 (diff)
parent61c7ee917e3b9705aa2ae531ac9e59bf51f77e40 (diff)
downloadservo-77444d00be7b6346b632385cb0c1f5e858ff50a2.tar.gz
servo-77444d00be7b6346b632385cb0c1f5e858ff50a2.zip
Auto merge of #10279 - notriddle:issue_10258, r=mbrubeck
Fix #10258 Respect border-box when computing the relative sizes of children. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10279) <!-- Reviewable:end -->
-rw-r--r--components/layout/block.rs9
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json24
-rw-r--r--tests/wpt/mozilla/tests/css/image_percentage_dimen.html30
-rw-r--r--tests/wpt/mozilla/tests/css/image_percentage_dimen_ref.html29
4 files changed, 91 insertions, 1 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 9eab35bc49a..72bd5de12cd 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) {
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index 2a6f388a612..e3841e63a71 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -1916,6 +1916,18 @@
"url": "/_mozilla/css/iframe/stacking_context_position_a.html"
}
],
+ "css/image_percentage_dimen.html": [
+ {
+ "path": "css/image_percentage_dimen.html",
+ "references": [
+ [
+ "/_mozilla/css/image_percentage_dimen_ref.html",
+ "=="
+ ]
+ ],
+ "url": "/_mozilla/css/image_percentage_dimen.html"
+ }
+ ],
"css/image_rendering_auto_a.html": [
{
"path": "css/image_rendering_auto_a.html",
@@ -8302,6 +8314,18 @@
"url": "/_mozilla/css/iframe/stacking_context_position_a.html"
}
],
+ "css/image_percentage_dimen.html": [
+ {
+ "path": "css/image_percentage_dimen.html",
+ "references": [
+ [
+ "/_mozilla/css/image_percentage_dimen_ref.html",
+ "=="
+ ]
+ ],
+ "url": "/_mozilla/css/image_percentage_dimen.html"
+ }
+ ],
"css/image_rendering_auto_a.html": [
{
"path": "css/image_rendering_auto_a.html",
diff --git a/tests/wpt/mozilla/tests/css/image_percentage_dimen.html b/tests/wpt/mozilla/tests/css/image_percentage_dimen.html
new file mode 100644
index 00000000000..d25c607df30
--- /dev/null
+++ b/tests/wpt/mozilla/tests/css/image_percentage_dimen.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<!-- saved from url=(0042)http://testujem.eu/servo/circle-image.html -->
+<html>
+<head>
+ <link rel='match' href='image_percentage_dimen_ref.html'>
+ <style type="text/css">
+ .image {
+ border:15px solid red;
+ padding:28px;
+ width:230px;
+ height:230px;
+ box-sizing:border-box;
+ -moz-box-sizing:border-box;
+ float:left;
+ margin-right:8%
+ }
+ .image .img {
+ background-size:cover;
+ background-position:center center;
+ width:100%;
+ height:100%;
+ }
+ </style>
+</head>
+<body>
+ <div class="image">
+ <div class="img" style="background-image: url(test.jpeg);"></div>
+ </div>
+</body>
+</html>
diff --git a/tests/wpt/mozilla/tests/css/image_percentage_dimen_ref.html b/tests/wpt/mozilla/tests/css/image_percentage_dimen_ref.html
new file mode 100644
index 00000000000..713727faf6f
--- /dev/null
+++ b/tests/wpt/mozilla/tests/css/image_percentage_dimen_ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<!-- saved from url=(0042)http://testujem.eu/servo/circle-image.html -->
+<html>
+<head>
+ <style type="text/css">
+ .image {
+ border:15px solid red;
+ padding:28px;
+ width:230px;
+ height:230px;
+ box-sizing:border-box;
+ -moz-box-sizing:border-box;
+ float:left;
+ margin-right:8%
+ }
+ .image .img {
+ background-size:cover;
+ background-position:center center;
+ width:144px;
+ height:144px;
+ }
+ </style>
+</head>
+<body>
+ <div class="image">
+ <div class="img" style="background-image: url(test.jpeg);"></div>
+ </div>
+</body>
+</html>