Skip to content

Truly independent web browser

LibWeb+LibCompositing+Compositor: Draw canvas shadows from every source

Andreas Klingfcd521e5f4b1
diff --git a/Libraries/LibCompositing/Rust/src/display_list/canvas_2d.rs b/Libraries/LibCompositing/Rust/src/display_list/canvas_2d.rs
index b224a9ef4ef..83d9600dc0a 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/canvas_2d.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/canvas_2d.rs
@@ -52,13 +52,14 @@ pub enum Paint<'a> {
},
}
-/// How a draw composites: the serialized filter graph of the context if it has one, the global alpha, and the
-/// compositing and blending operator.
+/// How a draw composites: the serialized filter graph of the context if it has one, the global alpha, the
+/// compositing and blending operator, and the shadow that the draw casts if it casts one.
#[derive(Clone, Copy, Debug)]
pub struct Compositing<'a> {
pub filter: Option<&'a [u8]>,
pub global_alpha: f32,
pub compositing_and_blending_operator: CompositingAndBlendingOperator,
+ pub shadow: Option<Canvas2DShadow>,
}
impl Default for Compositing<'_> {
@@ -67,6 +68,7 @@ impl Default for Compositing<'_> {
filter: None,
global_alpha: 1.0,
compositing_and_blending_operator: CompositingAndBlendingOperator::SourceOver,
+ shadow: None,
}
}
}
@@ -190,6 +192,8 @@ impl InlineData {
has_filter: compositing.filter.is_some(),
global_alpha: compositing.global_alpha,
compositing_and_blending_operator: compositing.compositing_and_blending_operator,
+ has_shadow: compositing.shadow.is_some(),
+ shadow: compositing.shadow.unwrap_or_default(),
}
}
@@ -222,34 +226,19 @@ impl TapeWriter {
}
/// `path` is a serialized Gfx::Path.
- pub fn fill_path(
- &mut self,
- path: &[u8],
- paint: &Paint,
- winding_rule: WindingRule,
- blur_radius: f32,
- compositing: &Compositing,
- ) {
+ pub fn fill_path(&mut self, path: &[u8], paint: &Paint, winding_rule: WindingRule, compositing: &Compositing) {
let mut inline_data = InlineData::new::<Canvas2DFillPath>();
let command = Canvas2DFillPath {
path_data: inline_data.append_path(path),
paint: inline_data.append_paint(paint),
winding_rule,
- blur_radius,
compositing: inline_data.append_compositing(compositing),
};
self.append(&command, &inline_data);
}
/// `path` is a serialized Gfx::Path.
- pub fn stroke_path(
- &mut self,
- path: &[u8],
- paint: &Paint,
- stroke: &Stroke,
- blur_radius: f32,
- compositing: &Compositing,
- ) {
+ pub fn stroke_path(&mut self, path: &[u8], paint: &Paint, stroke: &Stroke, compositing: &Compositing) {
let mut inline_data = InlineData::new::<Canvas2DStrokePath>();
let command = Canvas2DStrokePath {
path_data: inline_data.append_path(path),
@@ -260,7 +249,6 @@ impl TapeWriter {
miter_limit: stroke.miter_limit,
dash_array: inline_data.append_objects(stroke.dash_array),
dash_offset: stroke.dash_offset,
- blur_radius,
compositing: inline_data.append_compositing(compositing),
};
self.append(&command, &inline_data);
@@ -454,11 +442,11 @@ mod tests {
&path,
&linear_gradient(&colors, &positions),
WindingRule::EvenOdd,
- 0.0,
&Compositing {
filter: Some(&filter),
global_alpha: 0.5,
compositing_and_blending_operator: CompositingAndBlendingOperator::Multiply,
+ shadow: None,
},
);
assert_eq!(validate_canvas_2d_tape(writer.bytes()), Ok(()));
@@ -576,7 +564,6 @@ mod tests {
dash_array: &[1.0, 2.0],
dash_offset: 0.5,
},
- 3.0,
&Compositing::default(),
);
assert_eq!(validate_canvas_2d_tape(writer.bytes()), Ok(()));
@@ -586,7 +573,6 @@ mod tests {
assert_eq!(command.paint.pattern_repetition, Canvas2DPatternRepetition::RepeatY);
assert_eq!(command.paint.pattern_transform.get().unwrap().values[4], 3.0);
assert_eq!(command.dash_array.size, 8);
- assert_eq!(command.blur_radius, 3.0);
}
#[test]
@@ -638,7 +624,6 @@ mod tests {
&[1],
&Paint::Color(Color(0xff00_0000)),
WindingRule::Nonzero,
- 0.0,
&Compositing {
global_alpha,
..Compositing::default()
diff --git a/Libraries/LibCompositing/Rust/src/display_list/canvas_2d_recorder.rs b/Libraries/LibCompositing/Rust/src/display_list/canvas_2d_recorder.rs
index 4b7d1cb60f6..c6d7d0f696c 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/canvas_2d_recorder.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/canvas_2d_recorder.rs
@@ -132,27 +132,13 @@ impl<T: Transport> Recorder<T> {
}
/// `path` is a serialized Gfx::Path.
- pub fn fill_path(
- &mut self,
- path: &[u8],
- paint: &Paint,
- winding_rule: WindingRule,
- blur_radius: f32,
- compositing: &Compositing,
- ) {
- self.record(|tape| tape.fill_path(path, paint, winding_rule, blur_radius, compositing));
+ pub fn fill_path(&mut self, path: &[u8], paint: &Paint, winding_rule: WindingRule, compositing: &Compositing) {
+ self.record(|tape| tape.fill_path(path, paint, winding_rule, compositing));
}
/// `path` is a serialized Gfx::Path.
- pub fn stroke_path(
- &mut self,
- path: &[u8],
- paint: &Paint,
- stroke: &Stroke,
- blur_radius: f32,
- compositing: &Compositing,
- ) {
- self.record(|tape| tape.stroke_path(path, paint, stroke, blur_radius, compositing));
+ pub fn stroke_path(&mut self, path: &[u8], paint: &Paint, stroke: &Stroke, compositing: &Compositing) {
+ self.record(|tape| tape.stroke_path(path, paint, stroke, compositing));
}
pub fn draw_glyph_run(
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
index 17f88988920..c02e51a26dc 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
@@ -1815,8 +1815,26 @@ ffi_bytes_fields!(Canvas2DPaint {
pattern_transform
});
+/// The shadow that a 2D canvas draw casts, with its offset and blur in the coordinates of the canvas, which the
+/// current transformation matrix does not affect.
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+#[repr(C)]
+pub struct Canvas2DShadow {
+ pub color: Color,
+ pub offset_x: f32,
+ pub offset_y: f32,
+ pub blur: f32,
+}
+ffi_bytes_fields!(Canvas2DShadow {
+ color,
+ offset_x,
+ offset_y,
+ blur
+});
+
/// How a 2D canvas draw composites onto the canvas: through the serialized filter graph of the context, if it has one,
-/// with the global alpha of the context, and with its compositing and blending operator.
+/// with the global alpha of the context, with its compositing and blending operator, and with the shadow that it
+/// casts, if it casts one.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[repr(C)]
pub struct Canvas2DCompositing {
@@ -1824,30 +1842,30 @@ pub struct Canvas2DCompositing {
pub has_filter: bool,
pub global_alpha: f32,
pub compositing_and_blending_operator: CompositingAndBlendingOperator,
+ pub has_shadow: bool,
+ pub shadow: Canvas2DShadow,
}
ffi_bytes_fields!(Canvas2DCompositing {
filter,
has_filter,
global_alpha,
- compositing_and_blending_operator
+ compositing_and_blending_operator,
+ has_shadow,
+ shadow
});
-// A path fill. A solid color fill with a blur radius is a shadow, which is blurred and drawn without the filter and the
-// global alpha.
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
pub struct Canvas2DFillPath {
pub path_data: DisplayListDataSpan,
pub paint: Canvas2DPaint,
pub winding_rule: WindingRule,
- pub blur_radius: f32,
pub compositing: Canvas2DCompositing,
}
ffi_bytes_fields!(Canvas2DFillPath {
path_data,
paint,
winding_rule,
- blur_radius,
compositing
});
@@ -1866,7 +1884,6 @@ pub struct Canvas2DStrokePath {
pub miter_limit: f32,
pub dash_array: DisplayListDataSpan,
pub dash_offset: f32,
- pub blur_radius: f32,
pub compositing: Canvas2DCompositing,
}
ffi_bytes_fields!(Canvas2DStrokePath {
@@ -1878,7 +1895,6 @@ ffi_bytes_fields!(Canvas2DStrokePath {
miter_limit,
dash_array,
dash_offset,
- blur_radius,
compositing
});
diff --git a/Libraries/LibCompositing/Rust/src/display_list/validate.rs b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
index cd61355ea26..d182c25fd22 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/validate.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
@@ -287,7 +287,17 @@ fn validate_canvas_2d_compositing(payload: Payload, offset: usize) -> Result<(),
}
payload.enum_at::<CompositingAndBlendingOperator>(
offset + offset_of!(Canvas2DCompositing, compositing_and_blending_operator),
- )
+ )?;
+ payload.bool_at(offset + offset_of!(Canvas2DCompositing, has_shadow))?;
+ let shadow_offset = offset + offset_of!(Canvas2DCompositing, shadow);
+ let shadow_offset_x = payload.f32_at(shadow_offset + offset_of!(Canvas2DShadow, offset_x));
+ let shadow_offset_y = payload.f32_at(shadow_offset + offset_of!(Canvas2DShadow, offset_y));
+ let shadow_blur = payload.f32_at(shadow_offset + offset_of!(Canvas2DShadow, blur));
+ if !shadow_offset_x.is_finite() || !shadow_offset_y.is_finite() || !(shadow_blur.is_finite() && shadow_blur >= 0.0)
+ {
+ return Err("Canvas 2D stream command has a shadow with an offset or blur that is not finite or is negative");
+ }
+ Ok(())
}
fn command_struct_size(command_type: DisplayListCommandType) -> usize {
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
index b838f5b614d..d1ff90f9593 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs
@@ -15,7 +15,7 @@ use core::ptr::NonNull;
use ak::Utf16String;
use libcompositing_rust::display_list::canvas_2d::{Compositing, Paint, Stroke};
use libcompositing_rust::display_list::canvas_2d_recorder::{AlphaType, ColorSpace, Recorder};
-use libcompositing_rust::display_list::commands::CanvasId;
+use libcompositing_rust::display_list::commands::{Canvas2DShadow, CanvasId};
use libgfx_rust::path::Path;
use libgfx_rust::{AffineTransform, Color, CompositingAndBlendingOperator, FloatRect, IntRect, IntSize, WindingRule};
use libjs_rust::api::{ForeignCellSlot, Gc, Realm, Trace, Visitor, Vm};
@@ -715,44 +715,31 @@ impl ContextState {
filter: state.filter.as_deref(),
global_alpha: state.global_alpha,
compositing_and_blending_operator: state.current_compositing_and_blending_operator,
+ shadow: Self::shadow_of(state),
}
}
- /// A shadow is drawn through the filter with its operator, but without the global alpha, which its color holds.
- fn shadow_compositing(state: &DrawingState) -> Compositing<'_> {
- Compositing {
- filter: state.filter.as_deref(),
- global_alpha: 1.0,
- compositing_and_blending_operator: state.current_compositing_and_blending_operator,
- }
- }
-
- /// The color and the transformation matrix of the shadow of a draw, unless the draw casts none.
- fn shadow_of(state: &DrawingState) -> Option<(Color, AffineTransform)> {
+ /// The shadow of a draw, unless the draw casts none, https://html.spec.whatwg.org/multipage/canvas.html#shadows
+ fn shadow_of(state: &DrawingState) -> Option<Canvas2DShadow> {
+ // NB: A draw with the copy operator replaces the whole bitmap with its source, which would replace its shadow.
if state.current_compositing_and_blending_operator == CompositingAndBlendingOperator::Copy {
return None;
}
- if state.shadow_blur == 0.0 && state.shadow_offset_x == 0.0 && state.shadow_offset_y == 0.0 {
+
+ // Shadows are only drawn if the opacity component of the alpha component of the shadow color is nonzero and
+ // either the shadowBlur is nonzero, or the shadowOffsetX is nonzero, or the shadowOffsetY is nonzero.
+ if state.shadow_color.alpha() == 0 {
return None;
}
- let mut alpha = state.global_alpha * (f32::from(state.shadow_color.alpha()) / 255.0);
- if let Some(fill_style_color) = state.fill_style.as_color()
- && fill_style_color.alpha() > 0
- {
- alpha = (f32::from(fill_style_color.alpha()) / 255.0) * state.global_alpha;
- }
- if alpha == 0.0 {
+ if state.shadow_blur == 0.0 && state.shadow_offset_x == 0.0 && state.shadow_offset_y == 0.0 {
return None;
}
- let transform = multiply_transforms(
- translated(
- AffineTransform::identity(),
- state.shadow_offset_x,
- state.shadow_offset_y,
- ),
- state.transform,
- );
- Some((state.shadow_color.in_color_space.with_opacity(alpha), transform))
+ Some(Canvas2DShadow {
+ color: state.shadow_color.in_color_space,
+ offset_x: state.shadow_offset_x,
+ offset_y: state.shadow_offset_y,
+ blur: state.shadow_blur,
+ })
}
/// https://html.spec.whatwg.org/multipage/canvas.html#drawing-model
@@ -775,36 +762,11 @@ impl ContextState {
}
let path_bytes = path.serialize_to_bytes();
- self.paint_shadow_for_fill_internal(&path_bytes, winding_rule);
-
{
let state = self.drawing_state();
self.record(|recorder| {
let paint = paint_of(recorder, &state.fill_style, self.context_attributes.color_space);
- recorder.fill_path(&path_bytes, &paint, winding_rule, 0.0, &Self::compositing(&state));
- });
- }
- self.did_draw();
- }
-
- /// `path_bytes` is a serialized Gfx::Path. The caller has readied the recorder.
- fn paint_shadow_for_fill_internal(&self, path_bytes: &[u8], winding_rule: WindingRule) {
- {
- let state = self.drawing_state();
- let Some((shadow_color, transform)) = Self::shadow_of(&state) else {
- return;
- };
- self.record(|recorder| {
- recorder.save();
- recorder.set_transform(transform);
- recorder.fill_path(
- path_bytes,
- &Paint::Color(shadow_color),
- winding_rule,
- state.shadow_blur,
- &Self::shadow_compositing(&state),
- );
- recorder.restore();
+ recorder.fill_path(&path_bytes, &paint, winding_rule, &Self::compositing(&state));
});
}
self.did_draw();
@@ -823,7 +785,6 @@ impl ContextState {
let dash_array = self.drawing_state().dash_array();
let path_bytes = path.serialize_to_bytes();
- self.paint_shadow_for_stroke_internal(&path_bytes, &dash_array);
{
let state = self.drawing_state();
@@ -837,38 +798,7 @@ impl ContextState {
};
self.record(|recorder| {
let paint = paint_of(recorder, &state.stroke_style, self.context_attributes.color_space);
- recorder.stroke_path(&path_bytes, &paint, &stroke, 0.0, &Self::compositing(&state));
- });
- }
- self.did_draw();
- }
-
- /// `path_bytes` is a serialized Gfx::Path. The caller has readied the recorder.
- fn paint_shadow_for_stroke_internal(&self, path_bytes: &[u8], dash_array: &[f32]) {
- {
- let state = self.drawing_state();
- let Some((shadow_color, transform)) = Self::shadow_of(&state) else {
- return;
- };
- let stroke = Stroke {
- thickness: state.line_width,
- cap_style: state.cap_style(),
- join_style: state.join_style(),
- miter_limit: state.miter_limit,
- dash_array,
- dash_offset: state.line_dash_offset,
- };
- self.record(|recorder| {
- recorder.save();
- recorder.set_transform(transform);
- recorder.stroke_path(
- path_bytes,
- &Paint::Color(shadow_color),
- &stroke,
- state.shadow_blur,
- &Self::shadow_compositing(&state),
- );
- recorder.restore();
+ recorder.stroke_path(&path_bytes, &paint, &stroke, &Self::compositing(&state));
});
}
self.did_draw();
diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/drawing_state.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/drawing_state.rs
index 604d6b184d0..9dbbcbac10f 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/drawing_state.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/drawing_state.rs
@@ -67,13 +67,6 @@ impl FillOrStrokeStyle {
pub(crate) fn is_not_origin_clean(self) -> bool {
matches!(self, Self::Pattern(pattern) if pattern.is_not_origin_clean())
}
-
- pub(crate) fn as_color(self) -> Option<CanvasColor> {
- match self {
- Self::Color(color) => Some(color),
- Self::Gradient(_) | Self::Pattern(_) => None,
- }
- }
}
// SAFETY: Visits the gradient or the pattern, the cells that a style holds.
diff --git a/Services/Compositor/Canvas2DCommandPlayer.cpp b/Services/Compositor/Canvas2DCommandPlayer.cpp
index 1e8bf0940a3..450e3d06ade 100644
--- a/Services/Compositor/Canvas2DCommandPlayer.cpp
+++ b/Services/Compositor/Canvas2DCommandPlayer.cpp
@@ -95,6 +95,18 @@ sk_sp<SkImageFilter> Canvas2DCommandPlayer::image_filter_from(Canvas2DCompositin
});
}
+static Optional<Gfx::CanvasShadow> shadow_from(Canvas2DCompositing const& compositing)
+{
+ if (!compositing.has_shadow)
+ return {};
+ return Gfx::CanvasShadow {
+ .color = compositing.shadow.color,
+ .offset_x = compositing.shadow.offset_x,
+ .offset_y = compositing.shadow.offset_y,
+ .blur = compositing.shadow.blur,
+ };
+}
+
RefPtr<Gfx::PaintStyle> Canvas2DCommandPlayer::paint_style_from(Canvas2DPaint const& paint) const
{
auto with_color_stops = [&](auto paint_style) -> NonnullRefPtr<Gfx::PaintStyle> {
@@ -138,31 +150,20 @@ RefPtr<Gfx::PaintStyle> Canvas2DCommandPlayer::paint_style_from(Canvas2DPaint co
void Canvas2DCommandPlayer::play_command(Canvas2DFillPath const& command)
{
auto path = path_from(command.path_data);
- // Shadows are recorded as blurred solid-color fills; everything else goes through the general paint-style overload.
- if (command.blur_radius > 0 && command.paint.kind == Canvas2DPaintKind::Color) {
- m_painter->fill_path(path, command.paint.color, command.winding_rule, command.blur_radius, command.compositing.compositing_and_blending_operator);
- return;
- }
-
auto paint_style = paint_style_from(command.paint);
if (!paint_style)
return;
- m_painter->fill_path(path, *paint_style, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, command.winding_rule);
+ m_painter->fill_path(path, *paint_style, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, command.winding_rule, shadow_from(command.compositing));
}
void Canvas2DCommandPlayer::play_command(Canvas2DStrokePath const& command)
{
auto path = path_from(command.path_data);
auto dash_array = inline_objects<float>(inline_data(command.dash_array));
- if (command.blur_radius > 0 && command.paint.kind == Canvas2DPaintKind::Color) {
- m_painter->stroke_path(path, command.paint.color, command.thickness, command.blur_radius, command.compositing.compositing_and_blending_operator, command.cap_style, command.join_style, command.miter_limit, dash_array, command.dash_offset);
- return;
- }
-
auto paint_style = paint_style_from(command.paint);
if (!paint_style)
return;
- m_painter->stroke_path(path, *paint_style, image_filter_from(command.compositing), command.thickness, command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, command.cap_style, command.join_style, command.miter_limit, dash_array, command.dash_offset);
+ m_painter->stroke_path(path, *paint_style, image_filter_from(command.compositing), command.thickness, command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, command.cap_style, command.join_style, command.miter_limit, dash_array, command.dash_offset, shadow_from(command.compositing));
}
void Canvas2DCommandPlayer::play_command(Canvas2DDrawGlyphRun const& command)
@@ -183,7 +184,7 @@ void Canvas2DCommandPlayer::play_command(Canvas2DDrawGlyphRun const& command)
glyphs.ensure_capacity(tape_glyphs.size());
for (auto const& glyph : tape_glyphs)
glyphs.unchecked_append({ .position = glyph.position, .glyph_id = glyph.glyph_id });
- m_painter->draw_glyph_run(*font, sk_font.release_value(), glyphs, command.translation, *paint_style, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator);
+ m_painter->draw_glyph_run(*font, sk_font.release_value(), glyphs, command.translation, *paint_style, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, shadow_from(command.compositing));
}
void Canvas2DCommandPlayer::play_command(Canvas2DClearRect const& command)
@@ -196,7 +197,7 @@ void Canvas2DCommandPlayer::play_command(Canvas2DDrawImageFrame const& command)
auto const* frame = m_resolvers.image_frame(command.frame_id.value());
if (!frame)
return;
- m_painter->draw_bitmap(command.dst_rect, *frame, command.src_rect, command.scaling_mode, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator);
+ m_painter->draw_bitmap(command.dst_rect, *frame, command.src_rect, command.scaling_mode, image_filter_from(command.compositing), command.compositing.global_alpha, command.compositing.compositing_and_blending_operator, shadow_from(command.compositing));
}
void Canvas2DCommandPlayer::play_command(Canvas2DDrawCanvas const& command)
@@ -226,7 +227,7 @@ void Canvas2DCommandPlayer::play_command(Canvas2DDrawVideoFrame const& command)
void Canvas2DCommandPlayer::draw_image(SkImage const& image, Gfx::FloatRect const& dst_rect, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, Canvas2DCompositing const& compositing)
{
- m_painter->draw_image(image, dst_rect, src_rect, scaling_mode, image_filter_from(compositing), compositing.global_alpha, compositing.compositing_and_blending_operator);
+ m_painter->draw_image(image, dst_rect, src_rect, scaling_mode, image_filter_from(compositing), compositing.global_alpha, compositing.compositing_and_blending_operator, shadow_from(compositing));
}
void Canvas2DCommandPlayer::play_command(Canvas2DSetTransform const& command)
diff --git a/Services/Compositor/PainterSkia.cpp b/Services/Compositor/PainterSkia.cpp
index 37a93c1b655..69ca0e6a930 100644
--- a/Services/Compositor/PainterSkia.cpp
+++ b/Services/Compositor/PainterSkia.cpp
@@ -24,9 +24,9 @@
#include <core/SkPath.h>
#include <core/SkPathBuilder.h>
#include <core/SkSurface.h>
-#include <effects/SkBlurMaskFilter.h>
#include <effects/SkDashPathEffect.h>
#include <effects/SkGradient.h>
+#include <effects/SkImageFilters.h>
namespace Gfx {
@@ -178,12 +178,36 @@ static bool affects_pixels_not_covered_by_source(CompositingAndBlendingOperator
CompositingAndBlendingOperator::DestinationATop);
}
-// NB: A Skia blend mode only touches the pixels that a draw covers. For the operators that also affect uncovered
-// pixels, the source is drawn into a transparent layer, which is then composited onto all of the destination
-// inside the clip.
+// https://html.spec.whatwg.org/multipage/canvas.html#drawing-model
template<typename Callback>
-static void draw_with_compositing_and_blending_operator(SkCanvas& canvas, SkPaint& paint, CompositingAndBlendingOperator compositing_and_blending_operator, Callback draw)
+static void draw_with_compositing(SkCanvas& canvas, SkPaint& paint, CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const& shadow, Callback draw)
{
+ // 5. When shadows are drawn, render the shadow from image B, using the current shadow styles, creating image C.
+ // 6. When shadows are drawn, composite C within the clipping region over the current output bitmap using the
+ // current compositing and blending operator.
+ // NB: The current transformation matrix does not affect the offset and the blur of a shadow, so the source is
+ // drawn into a layer whose filter makes the shadow in the coordinates of the canvas. The paint carries the
+ // global alpha and the filter of the context, so the layer holds image B.
+ if (shadow.has_value()) {
+ auto matrix = canvas.getTotalMatrix();
+ canvas.save();
+ canvas.resetMatrix();
+ auto sigma = shadow->blur / 2;
+ SkPaint shadow_layer_paint;
+ shadow_layer_paint.setImageFilter(SkImageFilters::DropShadowOnly(shadow->offset_x, shadow->offset_y, sigma, sigma, to_skia_color4f(shadow->color), sk_ref_sp(canvas.imageInfo().colorSpace()), nullptr));
+ shadow_layer_paint.setBlender(to_skia_blender(compositing_and_blending_operator));
+ canvas.saveLayer(nullptr, &shadow_layer_paint);
+ canvas.setMatrix(matrix);
+ draw(canvas, paint);
+ canvas.restore();
+ canvas.restore();
+ }
+
+ // 7. Composite B within the clipping region over the current output bitmap using the current compositing and
+ // blending operator.
+ // NB: A Skia blend mode only touches the pixels that a draw covers. For the operators that also affect uncovered
+ // pixels, the source is drawn into a transparent layer, which is then composited onto all of the destination
+ // inside the clip.
if (!affects_pixels_not_covered_by_source(compositing_and_blending_operator)) {
paint.setBlender(to_skia_blender(compositing_and_blending_operator));
draw(canvas, paint);
@@ -292,21 +316,21 @@ void PainterSkia::fill_rect(Gfx::FloatRect const& rect, Color color)
canvas.drawRect(to_skia_rect(rect), paint);
}
-void PainterSkia::draw_bitmap(Gfx::FloatRect const& dst_rect, Gfx::DecodedImageFrame const& source, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
+void PainterSkia::draw_bitmap(Gfx::FloatRect const& dst_rect, Gfx::DecodedImageFrame const& source, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const& shadow)
{
auto sk_image = sk_image_for_decoded_image_frame(source);
if (!sk_image)
return;
- draw_image(*sk_image, dst_rect, src_rect, scaling_mode, move(image_filter), global_alpha, compositing_and_blending_operator);
+ draw_image(*sk_image, dst_rect, src_rect, scaling_mode, move(image_filter), global_alpha, compositing_and_blending_operator, shadow);
}
-void PainterSkia::draw_image(SkImage const& image, Gfx::FloatRect const& dst_rect, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
+void PainterSkia::draw_image(SkImage const& image, Gfx::FloatRect const& dst_rect, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const& shadow)
{
SkPaint paint;
paint.setImageFilter(move(image_filter));
paint.setAlpha(static_cast<u8>(global_alpha * 255));
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
+ draw_with_compositing(m_painting_surface->canvas(), paint, compositing_and_blending_operator, shadow, [&](SkCanvas& canvas, SkPaint const& paint) {
canvas.drawImageRect(
&image,
to_skia_rect(src_rect),
@@ -328,29 +352,7 @@ void PainterSkia::set_transform(Gfx::AffineTransform const& transform)
canvas.setMatrix(matrix);
}
-void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::Color color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle cap_style, Gfx::Path::JoinStyle join_style, float miter_limit, Vector<float> const& dash_array, float dash_offset)
-{
- // Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
- if (thickness <= 0)
- return;
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, blur_radius / 2));
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(thickness);
- set_color(paint, color, color_space());
- paint.setStrokeCap(to_skia_cap(cap_style));
- paint.setStrokeJoin(to_skia_join(join_style));
- paint.setStrokeMiter(miter_limit);
- paint.setPathEffect(SkDashPathEffect::Make({ dash_array.data(), dash_array.size() }, dash_offset));
- auto sk_path = prune_path_for_stroking(to_skia_path(path));
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
- canvas.drawPath(sk_path, paint);
- });
-}
-
-void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, sk_sp<SkImageFilter> image_filter, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const& cap_style, Gfx::Path::JoinStyle const& join_style, float miter_limit, Vector<float> const& dash_array, float dash_offset)
+void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, sk_sp<SkImageFilter> image_filter, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const& cap_style, Gfx::Path::JoinStyle const& join_style, float miter_limit, Vector<float> const& dash_array, float dash_offset, Optional<CanvasShadow> const& shadow)
{
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
if (thickness <= 0)
@@ -367,25 +369,12 @@ void PainterSkia::stroke_path(Gfx::Path const& path, Gfx::PaintStyle const& pain
paint.setStrokeJoin(to_skia_join(join_style));
paint.setStrokeMiter(miter_limit);
paint.setPathEffect(SkDashPathEffect::Make({ dash_array.data(), dash_array.size() }, dash_offset));
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
- canvas.drawPath(sk_path, paint);
- });
-}
-
-void PainterSkia::fill_path(Gfx::Path const& path, Gfx::Color color, Gfx::WindingRule winding_rule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
-{
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, blur_radius / 2));
- set_color(paint, color, color_space());
- auto sk_path = to_skia_path(path);
- sk_path.setFillType(to_skia_path_fill_type(winding_rule));
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
+ draw_with_compositing(m_painting_surface->canvas(), paint, compositing_and_blending_operator, shadow, [&](SkCanvas& canvas, SkPaint const& paint) {
canvas.drawPath(sk_path, paint);
});
}
-void PainterSkia::fill_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule winding_rule)
+void PainterSkia::fill_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_style, sk_sp<SkImageFilter> image_filter, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule winding_rule, Optional<CanvasShadow> const& shadow)
{
auto sk_path = to_skia_path(path);
sk_path.setFillType(to_skia_path_fill_type(winding_rule));
@@ -393,12 +382,12 @@ void PainterSkia::fill_path(Gfx::Path const& path, Gfx::PaintStyle const& paint_
paint.setAntiAlias(true);
float alpha = paint.getAlphaf();
paint.setAlphaf(alpha * global_alpha);
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
+ draw_with_compositing(m_painting_surface->canvas(), paint, compositing_and_blending_operator, shadow, [&](SkCanvas& canvas, SkPaint const& paint) {
canvas.drawPath(sk_path, paint);
});
}
-void PainterSkia::draw_glyph_run(Font const& font, SkFont sk_font, ReadonlySpan<CanvasGlyph> glyphs, FloatPoint translation, PaintStyle const& style, sk_sp<SkImageFilter> image_filter, float global_alpha, CompositingAndBlendingOperator compositing_and_blending_operator)
+void PainterSkia::draw_glyph_run(Font const& font, SkFont sk_font, ReadonlySpan<CanvasGlyph> glyphs, FloatPoint translation, PaintStyle const& style, sk_sp<SkImageFilter> image_filter, float global_alpha, CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const& shadow)
{
if (glyphs.is_empty() || font.is_invisible())
return;
@@ -424,7 +413,7 @@ void PainterSkia::draw_glyph_run(Font const& font, SkFont sk_font, ReadonlySpan<
// NB: Not drawTextBlob(). Skia caches a drawn SkTextBlob once per subpixel origin, and finds a cached entry by
// scanning every entry of that blob. Canvas text is often redrawn at moving fractional positions, which
// piles up thousands of entries per blob and makes each draw scan all of them.
- draw_with_compositing_and_blending_operator(m_painting_surface->canvas(), paint, compositing_and_blending_operator, [&](SkCanvas& canvas, SkPaint const& paint) {
+ draw_with_compositing(m_painting_surface->canvas(), paint, compositing_and_blending_operator, shadow, [&](SkCanvas& canvas, SkPaint const& paint) {
canvas.drawGlyphs({ glyph_ids.data(), glyph_ids.size() }, { glyph_positions.data(), glyph_positions.size() }, to_skia_point(translation), sk_font, paint);
});
}
diff --git a/Services/Compositor/PainterSkia.h b/Services/Compositor/PainterSkia.h
index 393b4a407b6..c8ed7d191f2 100644
--- a/Services/Compositor/PainterSkia.h
+++ b/Services/Compositor/PainterSkia.h
@@ -10,6 +10,7 @@
#include <AK/Optional.h>
#include <AK/Span.h>
#include <Compositor/PaintingSurface.h>
+#include <LibGfx/Color.h>
#include <LibGfx/CompositingAndBlendingOperator.h>
#include <LibGfx/Forward.h>
#include <LibGfx/PaintStyle.h>
@@ -27,6 +28,14 @@ class sk_sp;
namespace Gfx {
+// The shadow that a canvas draw casts, with its offset and blur in the coordinates of the canvas.
+struct CanvasShadow {
+ Color color;
+ float offset_x { 0 };
+ float offset_y { 0 };
+ float blur { 0 };
+};
+
struct CanvasGlyph {
FloatPoint position;
u32 glyph_id { 0 };
@@ -41,13 +50,11 @@ public:
void clear_rect(Gfx::FloatRect const&, Color);
void fill_rect(Gfx::FloatRect const&, Color);
- void draw_bitmap(Gfx::FloatRect const& dst_rect, Gfx::DecodedImageFrame const& source, Gfx::IntRect const& src_rect, Gfx::ScalingMode, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator);
- void draw_image(SkImage const&, Gfx::FloatRect const& dst_rect, Gfx::IntRect const& src_rect, Gfx::ScalingMode, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator);
- void stroke_path(Gfx::Path const&, Gfx::Color, float thickness, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle, Gfx::Path::JoinStyle, float miter_limit, Vector<float> const& dash_array, float dash_offset);
- void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, sk_sp<SkImageFilter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&, float miter_limit, Vector<float> const&, float dash_offset);
- void fill_path(Gfx::Path const&, Gfx::Color, Gfx::WindingRule, float blur_radius, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator);
- void fill_path(Gfx::Path const&, Gfx::PaintStyle const&, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule);
- void draw_glyph_run(Font const&, SkFont, ReadonlySpan<CanvasGlyph>, FloatPoint translation, PaintStyle const&, sk_sp<SkImageFilter>, float global_alpha, CompositingAndBlendingOperator);
+ void draw_bitmap(Gfx::FloatRect const& dst_rect, Gfx::DecodedImageFrame const& source, Gfx::IntRect const& src_rect, Gfx::ScalingMode, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const&);
+ void draw_image(SkImage const&, Gfx::FloatRect const& dst_rect, Gfx::IntRect const& src_rect, Gfx::ScalingMode, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Optional<CanvasShadow> const&);
+ void stroke_path(Gfx::Path const&, Gfx::PaintStyle const&, sk_sp<SkImageFilter>, float thickness, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::Path::CapStyle const&, Gfx::Path::JoinStyle const&, float miter_limit, Vector<float> const&, float dash_offset, Optional<CanvasShadow> const&);
+ void fill_path(Gfx::Path const&, Gfx::PaintStyle const&, sk_sp<SkImageFilter>, float global_alpha, Gfx::CompositingAndBlendingOperator compositing_and_blending_operator, Gfx::WindingRule, Optional<CanvasShadow> const&);
+ void draw_glyph_run(Font const&, SkFont, ReadonlySpan<CanvasGlyph>, FloatPoint translation, PaintStyle const&, sk_sp<SkImageFilter>, float global_alpha, CompositingAndBlendingOperator, Optional<CanvasShadow> const&);
void set_transform(Gfx::AffineTransform const&);
void save();
void restore();
diff --git a/Tests/LibWeb/Screenshot/expected/canvas-shadow.png b/Tests/LibWeb/Screenshot/expected/canvas-shadow.png
index b3bbd3ca598..afa805711e4 100644
Binary files a/Tests/LibWeb/Screenshot/expected/canvas-shadow.png and b/Tests/LibWeb/Screenshot/expected/canvas-shadow.png differ
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.alpha.txt
index 82e71264eef..2035c17e9a6 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.basic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.basic.txt
index e9508657796..22c8b29577c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.basic.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.basic.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.transparent.2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.transparent.2.txt
index f09350ed1d7..e7d8fec8c76 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.transparent.2.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.canvas.transparent.2.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.gradient.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.gradient.alpha.txt
index d03e06f2d1e..c08f1d11a7f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.gradient.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.gradient.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.alpha.txt
index 1e95d55d9cd..317faab3cf4 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.basic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.basic.txt
index 6ccd769ef7f..17b4da43ac3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.basic.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.basic.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.scale.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.scale.txt
index 786143e747c..4f21a64efdb 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.scale.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.scale.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for scaled images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for scaled images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.transparent.2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.transparent.2.txt
index cad48e8cdbe..f31ebfb4236 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.transparent.2.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.image.transparent.2.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of images
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.alpha.txt
index f993a56dd80..5354c8f7b7c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.transparent.1.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.transparent.1.txt
index 891b6a43736..a9beb5859a8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.transparent.1.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/shadows/2d.shadow.pattern.transparent.1.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent fill patterns
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.txt
index 82e71264eef..2035c17e9a6 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.worker.txt
index 82e71264eef..2035c17e9a6 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.alpha.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.txt
index e9508657796..22c8b29577c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.worker.txt
index e9508657796..22c8b29577c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.basic.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.txt
index f09350ed1d7..e7d8fec8c76 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.worker.txt
index f09350ed1d7..e7d8fec8c76 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.canvas.transparent.2.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of canvases
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.txt
index d03e06f2d1e..c08f1d11a7f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.worker.txt
index d03e06f2d1e..c08f1d11a7f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.gradient.alpha.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent gradient fills
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.txt
index 1e95d55d9cd..317faab3cf4 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.worker.txt
index 1e95d55d9cd..317faab3cf4 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.alpha.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.txt
index 6ccd769ef7f..17b4da43ac3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.worker.txt
index 6ccd769ef7f..17b4da43ac3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.basic.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn for images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn for images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.txt
index 786143e747c..4f21a64efdb 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for scaled images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for scaled images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.worker.txt
index 786143e747c..4f21a64efdb 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.scale.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for scaled images
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for scaled images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.txt
index cad48e8cdbe..f31ebfb4236 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of images
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.worker.txt
index cad48e8cdbe..f31ebfb4236 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.image.transparent.2.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent parts of images
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent parts of images
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.txt
index f993a56dd80..5354c8f7b7c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.worker.txt
index f993a56dd80..5354c8f7b7c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.alpha.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are drawn correctly for partially-transparent fill patterns
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.txt
index 891b6a43736..a9beb5859a8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent fill patterns
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.worker.txt
index 891b6a43736..a9beb5859a8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/shadows/2d.shadow.pattern.transparent.1.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Shadows are not drawn for transparent fill patterns
\ No newline at end of file
+1 Pass
+Pass Shadows are not drawn for transparent fill patterns
\ No newline at end of file