Truly independent web browser
LibWeb+Compositor: Cast box shadows from shaped borders
Andreas Kling18118b98db8f
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rsindex 6c95b459255..928f3fac1e2 100644--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs@@ -31,6 +31,7 @@ pub enum DisplayListCommandType {PaintConicGradient,PaintOuterBoxShadow,PaintInnerBoxShadow,+ PaintPathBoxShadow,PaintTextShadow,FillRectWithRoundedCorners,FillRoundedRectRing,@@ -138,6 +139,7 @@ impl DisplayListCommandType {Self::PaintConicGradient => "PaintConicGradient",Self::PaintOuterBoxShadow => "PaintOuterBoxShadow",Self::PaintInnerBoxShadow => "PaintInnerBoxShadow",+ Self::PaintPathBoxShadow => "PaintPathBoxShadow",Self::PaintTextShadow => "PaintTextShadow",Self::FillRectWithRoundedCorners => "FillRectWithRoundedCorners",Self::FillRoundedRectRing => "FillRoundedRectRing",@@ -1039,6 +1041,50 @@ impl DisplayListCommand for PaintInnerBoxShadow {}}+/// A box shadow of a box whose shape is a path: an outer shadow drawn outside the shape, or an inner one drawn inside+/// it. The shadow's shape is the box's shape grown by the spread distance for an outer shadow, or what lies outside+/// the box's shape shrunk by it for an inner one, moved by the offset.+#[derive(Clone, Copy, Debug, PartialEq)]+#[repr(C)]+pub struct PaintPathBoxShadow {+ pub color: Color,+ pub blur_radius: i32,+ pub spread_distance: f32,+ pub offset: FloatPoint,+ pub shape_path_bounding_rect: FloatRect,+ pub shape_path_data: DisplayListDataSpan,+ pub inner: bool,+}+ffi_bytes_fields!(PaintPathBoxShadow {+ color,+ blur_radius,+ spread_distance,+ offset,+ shape_path_bounding_rect,+ shape_path_data,+ inner+});++impl DisplayListCommand for PaintPathBoxShadow {+ const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::PaintPathBoxShadow;+ fn bounding_rect(&self) -> Option<IntRect> {+ let shape_rect = enclosing_int_rect(self.shape_path_bounding_rect);+ if self.inner {+ return Some(shape_rect);+ }+ // NB: The player grows the shape by the outline of a miter-joined stroke, whose miters reach out to Skia's default+ // miter limit of 4 times half the stroke width, so up to 4 times the spread at sharp corners.+ const MITER_LIMIT: f32 = 4.0;+ let margin = (self.spread_distance.max(0.0) * MITER_LIMIT).ceil() as i32 + self.blur_radius * 2;+ let mut shadow_rect = shape_rect.inflated_edges(margin, margin, margin, margin);+ shadow_rect.x += self.offset.x.floor() as i32;+ shadow_rect.y += self.offset.y.floor() as i32;+ shadow_rect.width += 1;+ shadow_rect.height += 1;+ Some(shadow_rect)+ }+}+#[derive(Clone, Copy, Debug, PartialEq)]#[repr(C)]pub struct TextShadowLayer {diff --git a/Libraries/LibCompositing/Rust/src/display_list/summary.rs b/Libraries/LibCompositing/Rust/src/display_list/summary.rsindex 6c5cfeb7f36..90a857b2bd8 100644--- a/Libraries/LibCompositing/Rust/src/display_list/summary.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/summary.rs@@ -117,6 +117,7 @@ fn note_referenced_ids(command_type: DisplayListCommandType, payload: &[u8], ids| T::PaintConicGradient| T::PaintOuterBoxShadow| T::PaintInnerBoxShadow+ | T::PaintPathBoxShadow| T::FillRectWithRoundedCorners| T::FillRoundedRectRing| T::FillPath@@ -268,6 +269,7 @@ fn command_blend(| T::DrawVideoFrame| T::PaintOuterBoxShadow| T::PaintInnerBoxShadow+ | T::PaintPathBoxShadow| T::PaintTextShadow| T::FillRectWithRoundedCorners| T::FillRoundedRectRingdiff --git a/Libraries/LibCompositing/Rust/src/display_list/validate.rs b/Libraries/LibCompositing/Rust/src/display_list/validate.rsindex 43a7688a6ee..0a88a4eccfc 100644--- a/Libraries/LibCompositing/Rust/src/display_list/validate.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/validate.rs@@ -308,6 +308,7 @@ fn command_struct_size(command_type: DisplayListCommandType) -> usize {T::PaintConicGradient => size_of::<PaintConicGradient>(),T::PaintOuterBoxShadow => size_of::<PaintOuterBoxShadow>(),T::PaintInnerBoxShadow => size_of::<PaintInnerBoxShadow>(),+ T::PaintPathBoxShadow => size_of::<PaintPathBoxShadow>(),T::PaintTextShadow => size_of::<PaintTextShadow>(),T::FillRectWithRoundedCorners => size_of::<FillRectWithRoundedCorners>(),T::FillRoundedRectRing => size_of::<FillRoundedRectRing>(),@@ -455,6 +456,10 @@ fn validate_command_fields(p.array_span_at::<TextShadowLayer>(offset_of!(PaintTextShadow, layers))?;p.enum_at::<Orientation>(offset_of!(PaintTextShadow, orientation))?;}+ T::PaintPathBoxShadow => {+ p.span_at(offset_of!(PaintPathBoxShadow, shape_path_data))?;+ p.bool_at(offset_of!(PaintPathBoxShadow, inner))?;+ }T::FillPath => {p.span_at(offset_of!(FillPath, path_data))?;validate_paint_style(diff --git a/Libraries/LibWeb/Rust/src/painting/border_shape.rs b/Libraries/LibWeb/Rust/src/painting/border_shape.rsindex e3ca41a7969..d8fa396c5b9 100644--- a/Libraries/LibWeb/Rust/src/painting/border_shape.rs+++ b/Libraries/LibWeb/Rust/src/painting/border_shape.rs@@ -29,6 +29,8 @@ pub(crate) enum BorderShape {fill_rule: WindingRule,/// The shape against its reference box shrunk by half the stroke width, along the inner edge of the stroke.inner_edge: OwnedPath,+ /// The shape against its reference box grown by half the stroke width, along the outer edge of the stroke.+ outer_edge: OwnedPath,width: f32,color: Option<Color>,},@@ -63,6 +65,19 @@ impl BorderShape {}}+ /// https://drafts.csswg.org/css-borders-4/#border-shape-shadow-interaction+ /// An outer box-shadow is cast as if the shape defined by the outer path were opaque. An inner box-shadow is cast+ /// as if everything outside the shape defined by the inner path were opaque. A single shape's outer and inner+ /// paths are the edges of its stroke.+ pub(crate) fn into_shadow_paths(self) -> (OwnedPath, OwnedPath) {+ match self {+ Self::Stroke {+ outer_edge, inner_edge, ..+ } => (outer_edge, inner_edge),+ Self::Fill { outer, inner, .. } => (outer, inner),+ }+ }+/// The inner border-shape clips the background. A single shape clips it along its path, under the stroke.pub(crate) fn background_clip_path(&self) -> (&OwnedPath, WindingRule) {match self {@@ -209,19 +224,23 @@ impl BorderShape {let reference = reference_box(layout_arena, slot, style, geometry_box, keyword::HALF_BORDER_BOX);let (path, fill_rule) = basic_shape_device_path(shape, reference, pixel_ratio);let half_width = relevant_side_width(style, edge).scaled(0.5);+ let inset_reference = |by: CssPixels| {+ CssPixelRect::new(+ reference.x + by,+ reference.y + by,+ reference.width - by - by,+ reference.height - by - by,+ )+ };// FIXME: Moving the reference box by half the stroke width only offsets coordinates given as// percentages. Shapes with absolute lengths need the edges of the stroke's outline instead.- let inner_edge_reference = CssPixelRect::new(- reference.x + half_width,- reference.y + half_width,- reference.width - half_width - half_width,- reference.height - half_width - half_width,- );- let (inner_edge, _) = basic_shape_device_path(shape, inner_edge_reference, pixel_ratio);+ let (inner_edge, _) = basic_shape_device_path(shape, inset_reference(half_width), pixel_ratio);+ let (outer_edge, _) = basic_shape_device_path(shape, inset_reference(-half_width), pixel_ratio);Some(Self::Stroke {path,fill_rule,inner_edge,+ outer_edge,width: side.width as f32,color,})diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rsindex d57213678fd..d44686b1bb0 100644--- a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs+++ b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs@@ -437,6 +437,19 @@ fn dump_command(output: &mut String, command_type: DisplayListCommandType, paylowrite!(output, " blur_radius={}", command.blur_radius).unwrap();write_field(output, "color", command.color);}+ DisplayListCommandType::PaintPathBoxShadow => {+ let command = read_command::<PaintPathBoxShadow>(payload);+ write_field(output, "shape_path_bounding_rect", command.shape_path_bounding_rect);+ write_field(output, "offset", command.offset);+ write!(+ output,+ " blur_radius={} spread_distance={}",+ command.blur_radius, command.spread_distance+ )+ .unwrap();+ write!(output, " inner={}", command.inner).unwrap();+ write_field(output, "color", command.color);+ }DisplayListCommandType::PaintTextShadow => {let command = read_command::<PaintTextShadow>(payload);write_field(output, "shadows_rect", command.shadows_bounding_rect);diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rsindex bd0beb58c4a..56f0dbec5f1 100644--- a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs+++ b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs@@ -1079,6 +1079,33 @@ impl DisplayListRecorder {self.append_command(&shadow, &[]);}+ /// Paints a box shadow cast from the shape `shape_path`, outside the shape, or inside it when `inner`.+ #[allow(clippy::too_many_arguments)]+ pub fn paint_path_box_shadow(+ &mut self,+ color: Color,+ blur_radius: i32,+ spread_distance: f32,+ offset: FloatPoint,+ shape_path: &libgfx_rust::path::OwnedPath,+ inner: bool,+ force_dark_role: ForceDarkRole,+ ) {+ let color = self.resolve_color(color, force_dark_role);+ let mut payload = CommandPayloadBuilder::new::<PaintPathBoxShadow>(&self.builder);+ let shape_path_data = payload.append_data(&shape_path.serialize_to_bytes(), std::mem::align_of::<u32>());+ let command = PaintPathBoxShadow {+ color,+ blur_radius,+ spread_distance,+ offset,+ shape_path_bounding_rect: FloatRect::from_array(shape_path.bounding_box()),+ shape_path_data,+ inner,+ };+ self.append_command(&command, payload.inline_data());+ }+pub fn paint_inner_box_shadow(&mut self, mut shadow: PaintInnerBoxShadow, force_dark_role: ForceDarkRole) {shadow.color = self.resolve_color(shadow.color, force_dark_role);self.append_command(&shadow, &[]);diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rsindex c059bcb4259..9fd4532c3c6 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs@@ -11,10 +11,12 @@ use crate::css::css_pixels::CssPixelRect;use crate::css::css_pixels::CssPixels;use crate::layout::node_data::NodeSlotId;use crate::painting::border_radii::BorderRadii;+use crate::painting::corner_shape::{CornerShapes, Insets, border_contour_path};use crate::painting::display_list::commands::{PaintInnerBoxShadow, PaintOuterBoxShadow};use crate::painting::force_dark::ForceDarkRole;use crate::painting::record::PaintRecorder;-use libgfx_rust::{Color, CornerRadii, IntRect};+use libgfx_rust::path::OwnedPath;+use libgfx_rust::{Color, CornerRadii, FloatPoint, IntRect};fn add_spread_distance_to_border_radius(border_radius: &mut i32, spread_distance: i32) {if *border_radius == 0 || spread_distance == 0 {@@ -58,6 +60,7 @@ pub(crate) fn paint_box_shadow<O: Observer>(}paint_box_shadow_layers(recorder,+ paintable,bordered_content_rect,borderless_content_rect,border_radii,@@ -67,6 +70,7 @@ pub(crate) fn paint_box_shadow<O: Observer>(fn paint_box_shadow_layers<O: Observer>(recorder: &mut PaintRecorder<'_, O>,+ paintable: NodeSlotId,bordered_content_rect: CssPixelRect,borderless_content_rect: CssPixelRect,border_radii: BorderRadii,@@ -74,6 +78,7 @@ fn paint_box_shadow_layers<O: Observer>() {let converter = recorder.converter;let corner_radii = border_radii.as_corners(&converter);+ let shadow_shapes = ShadowShapes::of(recorder, paintable, bordered_content_rect, corner_radii);// Force-dark judges a box shadow as a background, so a dark drop shadow stays dark rather than turning into a// light glow — as Blink's ResolveShadowColor does, passing DarkModeFilter::ElementRole::kBackground.@@ -91,7 +96,24 @@ fn paint_box_shadow_layers<O: Observer>(converter.rounded_device_rect(bordered_content_rect)};- if inner {+ if let Some(shadow_shapes) = &shadow_shapes {+ recorder.recorder.paint_path_box_shadow(+ Color(layer.color),+ blur_radius,+ spread_distance as f32,+ FloatPoint {+ x: offset_x as f32,+ y: offset_y as f32,+ },+ if inner {+ &shadow_shapes.inner+ } else {+ &shadow_shapes.outer+ },+ inner,+ ForceDarkRole::Background,+ );+ } else if inner {let mut outer_shadow_rect = IntRect::new(device_content_rect.x + offset_x,device_content_rect.y + offset_y,@@ -158,3 +180,48 @@ fn paint_box_shadow_layers<O: Observer>(}}}++/// The shapes a box's shadows are cast from when they are not its rounded border and padding boxes: the shape outer+/// shadows are cast from, and the shape whose outside casts inner shadows.+struct ShadowShapes {+ outer: OwnedPath,+ inner: OwnedPath,+}++impl ShadowShapes {+ fn of<O: Observer>(+ recorder: &PaintRecorder<'_, O>,+ paintable: NodeSlotId,+ border_box_rect: CssPixelRect,+ corner_radii: CornerRadii,+ ) -> Option<Self> {+ let converter = recorder.converter;+ // https://drafts.csswg.org/css-borders-4/#border-shape-shadow-interaction+ if let Some(border_shape) =+ crate::painting::border_shape::BorderShape::for_paintable(recorder.source, paintable, &converter)+ {+ let (outer, inner) = border_shape.into_shadow_paths();+ return Some(Self { outer, inner });+ }+ // https://drafts.csswg.org/css-borders-4/#corner-shape-rendering+ // Each shadow of an element's box-shadow is shaped by the border contour path given the element and the inset+ // between its border edge and the shadow's edge.+ let style = recorder.source.node_style_if_live(paintable)?;+ let shapes = CornerShapes::of(style);+ if !shapes.needs_contour(corner_radii) {+ return None;+ }+ let border_rect = converter.rounded_device_rect(border_box_rect).to_float();+ let width = |width: CssPixels| f64::from(converter.rounded_device_pixels(width));+ let border_widths = Insets {+ top: width(style.border_top_width()),+ right: width(style.border_right_width()),+ bottom: width(style.border_bottom_width()),+ left: width(style.border_left_width()),+ };+ Some(Self {+ outer: border_contour_path(border_rect, corner_radii, shapes, Insets::default()),+ inner: border_contour_path(border_rect, corner_radii, shapes, border_widths),+ })+ }+}diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cppindex 57677c442bd..a05fb9b5fcd 100644--- a/Services/Compositor/DisplayListPlayerSkia.cpp+++ b/Services/Compositor/DisplayListPlayerSkia.cpp@@ -17,6 +17,7 @@#include <core/SkMaskFilter.h>#include <core/SkPath.h>#include <core/SkPathEffect.h>+#include <core/SkPathUtils.h>#include <core/SkPicture.h>#include <core/SkPictureRecorder.h>#include <core/SkRRect.h>@@ -811,6 +812,48 @@ void DisplayListPlayerSkia::play_command(PaintOuterBoxShadow const& command)canvas.restore();}+// An outer shadow is drawn outside the box's shape and an inner one inside it, blurred as the rounded rectangle box+// shadows are.+void DisplayListPlayerSkia::play_command(PaintPathBoxShadow const& command)+{+ auto shape = Gfx::to_skia_path(path_from_data(command.shape_path_data));++ // The spread distance grows the shape of an outer shadow, and shrinks the shape whose outside casts an inner one,+ // by the outline of a stroke along the shape twice as wide.+ auto shadow_shape = shape;+ if (command.spread_distance != 0) {+ SkPaint outline_paint;+ outline_paint.setStyle(SkPaint::kStroke_Style);+ outline_paint.setStrokeWidth(2 * AK::abs(command.spread_distance));+ outline_paint.setStrokeJoin(SkPaint::kMiter_Join);+ auto outline = skpathutils::FillPathWithPaint(shape, outline_paint);+ bool grows = command.inner ? command.spread_distance < 0 : command.spread_distance > 0;+ if (auto result = Op(shape, outline, grows ? SkPathOp::kUnion_SkPathOp : SkPathOp::kDifference_SkPathOp); result.has_value())+ shadow_shape = *result;+ }+ shadow_shape = shadow_shape.makeOffset(command.offset.x(), command.offset.y());++ if (command.inner) {+ // Everything outside the shape casts the inner shadow, so it is a rectangle reaching past the blur with the+ // shape cut out of it.+ auto margin = AK::abs(command.spread_distance) + AK::abs(command.offset.x()) + AK::abs(command.offset.y()) + command.blur_radius * 2 + 1;+ auto outside = SkPath::Rect(shape.getBounds().makeOutset(margin, margin));+ if (auto result = Op(outside, shadow_shape, SkPathOp::kDifference_SkPathOp); result.has_value())+ shadow_shape = *result;+ }++ auto& canvas = surface().canvas();+ canvas.save();+ canvas.clipPath(shape, command.inner ? SkClipOp::kIntersect : SkClipOp::kDifference, true);+ SkPaint paint;+ paint.setAntiAlias(true);+ paint.setColor(to_skia_color(command.color));+ if (command.blur_radius > 0)+ paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, command.blur_radius / 2));+ canvas.drawPath(shadow_shape, paint);+ canvas.restore();+}+void DisplayListPlayerSkia::play_command(PaintInnerBoxShadow const& command){auto outer_rect = to_skia_rrect(command.outer_shadow_rect, command.content_corner_radii);diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow-ref.htmlnew file mode 100644index 00000000000..19096d995b5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow-ref.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<style>+body {+ margin: 0;+}+svg {+ display: block;+ width: 240px;+ height: 250px;+}+</style>+<svg viewBox="0 0 240 250" xmlns="http://www.w3.org/2000/svg">+ <defs>+ <clipPath id="inner-clip">+ <rect x="10" y="10" width="190" height="190" />+ </clipPath>+ </defs>+ <!-- Outer shadow: 230x230 at (0,10) -->+ <rect x="0" y="10" width="230" height="230" fill="blue" />++ <!-- Background: 190x190 at (10,10) -->+ <rect x="10" y="10" width="190" height="190" fill="green" />++ <!-- Inset shadow: 10px stroke inside the 190x190 rect. Center at (15,15), size 180x180 -->+ <rect x="10" y="10" width="190" height="190" fill="none" stroke="purple" stroke-width="20" clip-path="url(#inner-clip)" />++ <!-- Border: 10px stroke centered on base path (5,5) 200x200 rect -->+ <rect x="5" y="5" width="200" height="200" fill="none" stroke="black" stroke-width="10" />+</svg>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur-ref.htmlnew file mode 100644index 00000000000..2f367dbe025--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur-ref.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<html>+<title>CSS Borders: border-shape with box-shadow reference</title>+<style>+ body {+ margin: 0;+ padding: 50px;+ }+ #target {+ width: 100px;+ height: 100px;+ background: green;+ /* Use border-radius as the canonical circle reference */+ border-radius: 50px;+ box-shadow: 0 0 10px 0 black;+ }+</style>+<body>+ <div id="target"></div>+</body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-ref.htmlnew file mode 100644index 00000000000..42a35e4c237--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-ref.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<style>+ body {+ margin: 0;+ }+ svg {+ position: absolute;+ top: 0;+ left: 0;+ width: 230px;+ height: 240px;+ overflow: visible;+ }+ .shadow {+ fill: purple;+ stroke: purple;+ stroke-width: 20px;+ transform: translate(10px, 20px);+ }+ .border {+ fill: green;+ stroke: black;+ stroke-width: 10px;+ }+</style>++<svg viewBox="0 0 230 240" xmlns="http://www.w3.org/2000/svg">+ <rect x="0" y="0" width="220" height="220" class="shadow" />+ <rect x="5" y="5" width="210" height="210" class="border" />+</svg>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow.htmlnew file mode 100644index 00000000000..eae89c349b9--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-borders-4/#border-shape">+<link rel="match" href="../../../../../expected/wpt-import/css/css-borders/border-shape/border-shape-combined-shadow-ref.html">+<style>+body {+ margin: 0;+}+#target {+ width: 190px;+ height: 190px;+ border-shape: xywh(0% 0% 100% 100%);+ position: relative;+ background: green;+ box-shadow: 10px 20px 0 10px blue, inset 0 0 0 10px purple;+ border: 10px solid black;+}+</style>+<div id="target">+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur.htmlnew file mode 100644index 00000000000..ff91388d10e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<html>+<title>CSS Borders: border-shape with box-shadow (blur > 0)</title>+<link rel="help" href="https://drafts.csswg.org/css-borders-4/#border-shape">+<link rel="match" href="../../../../../expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-blur-ref.html">+<meta name="fuzzy" content="maxDifference=0-32;totalPixels=0-500">+<meta name="assert" content="box-shadow blur on a circle border-shape should exactly match the blur on a border-radius circle.">+<style>+ body {+ margin: 0;+ padding: 50px;+ }+ #target {+ width: 100px;+ height: 100px;+ background: green;+ border-shape: circle(50px at 50% 50%);+ box-shadow: 0 0 10px 0 black;+ }+</style>+<body>+ <div id="target"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow.htmlnew file mode 100644index 00000000000..857f1cec33d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-borders/border-shape/border-shape-shadow.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-borders-4/#border-shape">+<link rel="match" href="../../../../../expected/wpt-import/css/css-borders/border-shape/border-shape-shadow-ref.html">+<meta name="fuzzy" content="maxDifference=0-80;totalPixels=0-600">+<style>+body {+ margin: 0;+}+#target {+ width: 200px;+ height: 200px;+ border-shape: xywh(0% 0% 100% 100%);+ position: relative;+ background: green;+ box-shadow: 10px 20px 0 10px purple;+ border: 10px solid black;+}+</style>+<div id="target">+</div>diff --git a/Tests/LibWeb/Screenshot/expected-macos/shaped-box-shadows.png b/Tests/LibWeb/Screenshot/expected-macos/shaped-box-shadows.pngnew file mode 100644index 00000000000..6d301ce27f0Binary files /dev/null and b/Tests/LibWeb/Screenshot/expected-macos/shaped-box-shadows.png differdiff --git a/Tests/LibWeb/Screenshot/expected/shaped-box-shadows.png b/Tests/LibWeb/Screenshot/expected/shaped-box-shadows.pngnew file mode 100644index 00000000000..fcf130c39afBinary files /dev/null and b/Tests/LibWeb/Screenshot/expected/shaped-box-shadows.png differdiff --git a/Tests/LibWeb/Screenshot/input/shaped-box-shadows.html b/Tests/LibWeb/Screenshot/input/shaped-box-shadows.htmlnew file mode 100644index 00000000000..5cafb4570eb--- /dev/null+++ b/Tests/LibWeb/Screenshot/input/shaped-box-shadows.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<style>+body { margin: 20px; background: white; display: flex; flex-wrap: wrap; gap: 40px; }+div { width: 120px; height: 80px; background: #fc6; }+.bevel { border-radius: 24px; corner-shape: bevel; box-shadow: 8px 8px 0 4px rgba(0,0,255,.5); }+.squircle { border-radius: 30px; corner-shape: squircle; box-shadow: 0 10px 20px rgba(0,0,0,.5); }+.scoop { border-radius: 24px; corner-shape: scoop; box-shadow: 0 0 0 6px green; }+.hollow { border-radius: 24px; corner-shape: bevel; background: none; border: 2px solid black; box-shadow: 10px 10px 10px red; }+.tip { --r:16px;--ap:50%;--ah:8px;--aw:8px; background: #0d0f12; border: 2px solid white; box-shadow: 0 1px 2px rgba(0,0,0,.2),0 3px 6px rgba(0,0,0,.2),0 9px 18px rgba(0,0,0,.2),0 27px 54px rgba(0,0,0,.2);+ border-shape: shape(from var(--r) 0,hline to calc(100% - var(--r)),curve to right var(--r) with right top,vline to calc(100% - (var(--r) + var(--ah))),curve to calc(100% - var(--r)) calc(100% - var(--ah)) with right calc(100% - var(--ah)),hline to calc(var(--ap) + var(--aw)),line by calc(var(--aw) * -1) var(--ah),line by calc(var(--aw) * -1) calc(var(--ah) * -1),hline to var(--r),curve to left calc(100% - (var(--r) + var(--ah))) with left calc(100% - var(--ah)),vline to var(--r),curve to var(--r) top with left top); }+.inset { border-radius: 24px; corner-shape: bevel; border: 4px solid #333; box-shadow: inset 6px 6px 8px 2px rgba(0,0,200,.6); }+</style>+<div class="bevel"></div><div class="squircle"></div><div class="scoop"></div><div class="hollow"></div><div class="tip"></div><div class="inset"></div>