diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 42fab82567b..9fdd405a90d 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -633,6 +633,18 @@ fn build_border_radius_for_inner_rect(outer_rect: &Rect, radii } +fn build_inner_border_box_for_border_rect(border_box: &Rect, + style: &ServoComputedValues) + -> Rect { + let border_widths = style.logical_border_width().to_physical(style.writing_mode); + let mut inner_border_box = *border_box; + inner_border_box.origin.x += border_widths.left; + inner_border_box.origin.y += border_widths.top; + inner_border_box.size.width -= border_widths.right + border_widths.left; + inner_border_box.size.height -= border_widths.bottom + border_widths.top; + inner_border_box +} + fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) -> Vec { // Determine the position of each stop per CSS-IMAGES ยง 3.4. @@ -2524,10 +2536,11 @@ impl BlockFlowDisplayListBuilding for BlockFlow { root_type = ScrollRootType::Clip; } - let mut clip = ClippingRegion::from_rect(&content_box); + let clip_rect = build_inner_border_box_for_border_rect(&border_box, &self.fragment.style); + let mut clip = ClippingRegion::from_rect(&clip_rect); let radii = build_border_radius_for_inner_rect(&border_box, &self.fragment.style); if !radii.is_square() { - clip.intersect_with_rounded_rect(&content_box, &radii) + clip.intersect_with_rounded_rect(&clip_rect, &radii) } let parent_id = self.scroll_root_id(state.layout_context.id); diff --git a/tests/wpt/css-tests/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm b/tests/wpt/css-tests/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm index d3066d083b1..64bfbddda51 100644 --- a/tests/wpt/css-tests/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm +++ b/tests/wpt/css-tests/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm @@ -29,4 +29,4 @@ p { - \ No newline at end of file + diff --git a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm.ini b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm.ini new file mode 100644 index 00000000000..c58b15efad7 --- /dev/null +++ b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/attachment-local-clipping-image-6.htm.ini @@ -0,0 +1,3 @@ +[attachment-local-clipping-image-6.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 2421d6b2cff..6506961c996 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -4199,6 +4199,18 @@ {} ] ], + "css/overflow_hidden_clip.html": [ + [ + "/_mozilla/css/overflow_hidden_clip.html", + [ + [ + "/_mozilla/css/overflow_hidden_clip_ref.html", + "==" + ] + ], + {} + ] + ], "css/overflow_position_abs_inline_block.html": [ [ "/_mozilla/css/overflow_position_abs_inline_block.html", @@ -9267,6 +9279,11 @@ {} ] ], + "css/overflow_hidden_clip_ref.html": [ + [ + {} + ] + ], "css/overflow_position_abs_inline_block_ref.html": [ [ {} @@ -24829,6 +24846,14 @@ "f645ece68f6c7afe273daee4d1ec172c7d245632", "support" ], + "css/overflow_hidden_clip.html": [ + "bd829a86a3afba8d50bd95877b01d8f291428319", + "reftest" + ], + "css/overflow_hidden_clip_ref.html": [ + "1fb1cb37455ec869689beee8937e409e57422c73", + "support" + ], "css/overflow_position_abs_inline_block.html": [ "7550f9c9f3e91635c15554d9ae21e172944054e6", "reftest" diff --git a/tests/wpt/mozilla/tests/css/overflow_hidden_clip.html b/tests/wpt/mozilla/tests/css/overflow_hidden_clip.html new file mode 100644 index 00000000000..23ab290591b --- /dev/null +++ b/tests/wpt/mozilla/tests/css/overflow_hidden_clip.html @@ -0,0 +1,31 @@ + + + + + Size of clip used for overflow:hidden + + + + +
+
+
+
+ + diff --git a/tests/wpt/mozilla/tests/css/overflow_hidden_clip_ref.html b/tests/wpt/mozilla/tests/css/overflow_hidden_clip_ref.html new file mode 100644 index 00000000000..070d3772241 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/overflow_hidden_clip_ref.html @@ -0,0 +1,27 @@ + + + + + + + +
+
+ + +