From c9242309cbe38168b699dc6de13068009b5d4a6d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 6 Jan 2016 10:32:06 -0800 Subject: [PATCH 1/2] tests: Make `linear_gradients_lengths_a.html` and `linear_gradients_lengths_ref.html` use `background-clip: content-box`. The tests clearly expect the background painting area to have width of 100px, but since the default value of `background-clip` is `border-box` and the boxes in question have a 1-pixel border the background painting areas are actually 102px. This commit fixes the tests so that the width of the background painting area is actually 100px. --- tests/wpt/mozilla/tests/css/linear_gradients_lengths_a.html | 3 ++- tests/wpt/mozilla/tests/css/linear_gradients_lengths_ref.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/wpt/mozilla/tests/css/linear_gradients_lengths_a.html b/tests/wpt/mozilla/tests/css/linear_gradients_lengths_a.html index 7cc0c449f5f..36ab50d6866 100644 --- a/tests/wpt/mozilla/tests/css/linear_gradients_lengths_a.html +++ b/tests/wpt/mozilla/tests/css/linear_gradients_lengths_a.html @@ -9,9 +9,10 @@ section { width: 100px; height: 100px; border: solid black 1px; + background-clip: content-box; } #a { - background: linear-gradient(to right, white, white 30px, black 30px, black); + background-image: linear-gradient(to right, white, white 30px, black 30px, black); } diff --git a/tests/wpt/mozilla/tests/css/linear_gradients_lengths_ref.html b/tests/wpt/mozilla/tests/css/linear_gradients_lengths_ref.html index 3a9aec01525..a067067fff6 100644 --- a/tests/wpt/mozilla/tests/css/linear_gradients_lengths_ref.html +++ b/tests/wpt/mozilla/tests/css/linear_gradients_lengths_ref.html @@ -8,9 +8,10 @@ section { width: 100px; height: 100px; border: solid black 1px; + background-clip: content-box; } #a { - background: linear-gradient(to right, white, white 30%, black 30%, black); + background-image: linear-gradient(to right, white, white 30%, black 30%, black); } From fdb791bdd5f40d6d25c9350b39ac400b72747826 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 6 Jan 2016 10:34:30 -0800 Subject: [PATCH 2/2] layout: Take the value of `background-clip` into account when determining the painting area for background images and gradients. See: https://drafts.csswg.org/css-backgrounds-3/#the-background-clip --- components/layout/display_list_builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 7cc1d3f6311..99f26266189 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -335,7 +335,7 @@ impl FragmentDisplayListBuilding for Fragment { Some(computed::Image::LinearGradient(ref gradient)) => { self.build_display_list_for_background_linear_gradient(display_list, level, - absolute_bounds, + &bounds, &clip, gradient, style) @@ -345,7 +345,7 @@ impl FragmentDisplayListBuilding for Fragment { display_list, layout_context, level, - absolute_bounds, + &bounds, &clip, image_url) }