From f39c3ff38b8eaa85411ae4bdc6d8adccbb08cc04 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jan 2020 16:08:22 +0100 Subject: [PATCH] Apply `background-clip` to `background-color` --- components/layout_2020/display_list/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index 649dec78d3c..48b7de7912c 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -270,10 +270,11 @@ impl<'a> BuilderForBoxFragment<'a> { let b = self.fragment.style.get_background(); let background_color = self.fragment.style.resolve_color(b.background_color); if background_color.alpha > 0 { - let mut common = builder.common_properties(self.border_rect); - if let Some(clip_id) = self.border_edge_clip(builder) { - common.clip_id = clip_id - } + // https://drafts.csswg.org/css-backgrounds/#background-color + // “The background color is clipped according to the background-clip + // value associated with the bottom-most background image layer.” + let layer_index = b.background_image.0.len() - 1; + let (_, common) = background::painting_area(self, builder, layer_index); builder.wr.push_rect(&common, rgba(background_color)) } // Reverse because the property is top layer first, we want to paint bottom layer first.