Skip to content

Truly independent web browser

LibWeb+LibCompositing+Compositor: Read root backdrops over the canvas

Shannon Booth5cfc0e1c5e47
diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.cpp b/Libraries/LibCompositing/DisplayList/DisplayList.cpp
index 2c2269dc572..7403a0c8bc5 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayList.cpp
+++ b/Libraries/LibCompositing/DisplayList/DisplayList.cpp
@@ -21,11 +21,12 @@ static u64 next_id()
return s_next_id.fetch_add(1, AK::MemoryOrder::memory_order_relaxed);
}
-DisplayList::DisplayList(u64 compatible_visual_context_tree_structural_epoch, u64 id, void const* storage, Optional<Gfx::Color> surface_clear_color, Optional<AsyncScrollingMetadata> async_scrolling_metadata)
+DisplayList::DisplayList(u64 compatible_visual_context_tree_structural_epoch, u64 id, void const* storage, Optional<Gfx::Color> surface_clear_color, Gfx::Color root_group_color, Optional<AsyncScrollingMetadata> async_scrolling_metadata)
: m_compatible_visual_context_tree_structural_epoch(compatible_visual_context_tree_structural_epoch)
, m_id(id)
, m_storage(storage)
, m_surface_clear_color(surface_clear_color)
+ , m_root_group_color(root_group_color)
, m_async_scrolling_metadata(move(async_scrolling_metadata))
{
VERIFY(m_storage);
@@ -38,13 +39,13 @@ DisplayList::~DisplayList()
NonnullRefPtr<DisplayList> DisplayList::create(AccumulatedVisualContextTree const& visual_context_tree)
{
- return adopt_ref(*new DisplayList(visual_context_tree.structural_epoch(), next_id(), RustFFI::display_list_storage_create_empty(), {}, {}));
+ return adopt_ref(*new DisplayList(visual_context_tree.structural_epoch(), next_id(), RustFFI::display_list_storage_create_empty(), {}, Gfx::Color::Transparent, {}));
}
NonnullRefPtr<DisplayList> DisplayList::adopt_rust_command_storage(AccumulatedVisualContextTree const& visual_context_tree, void const* recorded)
{
VERIFY(recorded);
- return adopt_ref(*new DisplayList(visual_context_tree.structural_epoch(), next_id(), RustFFI::display_list_storage_adopt_recorded(recorded), {}, {}));
+ return adopt_ref(*new DisplayList(visual_context_tree.structural_epoch(), next_id(), RustFFI::display_list_storage_adopt_recorded(recorded), {}, Gfx::Color::Transparent, {}));
}
NonnullRefPtr<DisplayList> DisplayList::share_rust_command_storage(AccumulatedVisualContextTree const& visual_context_tree, void const* recorded)
@@ -55,7 +56,7 @@ NonnullRefPtr<DisplayList> DisplayList::share_rust_command_storage(AccumulatedVi
NonnullRefPtr<DisplayList> DisplayList::adopt_received_storage(Properties properties, void const* storage)
{
- return adopt_ref(*new DisplayList(properties.compatible_visual_context_tree_structural_epoch, properties.id, storage, properties.surface_clear_color, move(properties.async_scrolling_metadata)));
+ return adopt_ref(*new DisplayList(properties.compatible_visual_context_tree_structural_epoch, properties.id, storage, properties.surface_clear_color, properties.root_group_color, move(properties.async_scrolling_metadata)));
}
// Copies a tape and run table that came from another process into Rust memory through `fill`, then checks them and
@@ -113,7 +114,7 @@ void DisplayList::replay(AccumulatedVisualContextTree const& visual_context_tree
{
VERIFY(m_compatible_visual_context_tree_structural_epoch == visual_context_tree.structural_epoch());
auto scroll_offsets = scroll_state.device_offsets();
- RustFFI::display_list_replay(visual_context_tree.rust_handle(), m_storage, scroll_offsets.data(), scroll_offsets.size(), &callbacks);
+ RustFFI::display_list_replay(visual_context_tree.rust_handle(), m_storage, m_root_group_color, scroll_offsets.data(), scroll_offsets.size(), &callbacks);
}
void DisplayList::replay_records(ReadonlyBytes records, ScrollStateSnapshot const& scroll_state, RustFFI::FfiDisplayListReplayCallbacks const& callbacks)
@@ -164,6 +165,7 @@ DisplayList::Properties DisplayList::properties() const
.id = m_id,
.compatible_visual_context_tree_structural_epoch = m_compatible_visual_context_tree_structural_epoch,
.surface_clear_color = m_surface_clear_color,
+ .root_group_color = m_root_group_color,
.async_scrolling_metadata = m_async_scrolling_metadata,
};
}
@@ -216,6 +218,7 @@ ErrorOr<void> encode(Encoder& encoder, Compositing::DisplayList::Properties cons
TRY(encoder.encode(properties.id));
TRY(encoder.encode(properties.compatible_visual_context_tree_structural_epoch));
TRY(encoder.encode(properties.surface_clear_color));
+ TRY(encoder.encode(properties.root_group_color));
TRY(encoder.encode(properties.async_scrolling_metadata));
return {};
}
@@ -227,6 +230,7 @@ ErrorOr<Compositing::DisplayList::Properties> decode(Decoder& decoder)
.id = TRY(decoder.decode<u64>()),
.compatible_visual_context_tree_structural_epoch = TRY(decoder.decode<u64>()),
.surface_clear_color = TRY(decoder.decode<Optional<Gfx::Color>>()),
+ .root_group_color = TRY(decoder.decode<Gfx::Color>()),
.async_scrolling_metadata = TRY(decoder.decode<Optional<Compositing::DisplayList::AsyncScrollingMetadata>>()),
};
}
diff --git a/Libraries/LibCompositing/DisplayList/DisplayList.h b/Libraries/LibCompositing/DisplayList/DisplayList.h
index 65ced79050a..04fefc20544 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayList.h
+++ b/Libraries/LibCompositing/DisplayList/DisplayList.h
@@ -57,6 +57,7 @@ public:
u64 id { 0 };
u64 compatible_visual_context_tree_structural_epoch { 0 };
Optional<Gfx::Color> surface_clear_color;
+ Gfx::Color root_group_color { Gfx::Color::Transparent };
Optional<AsyncScrollingMetadata> async_scrolling_metadata;
};
@@ -89,6 +90,8 @@ public:
void set_surface_clear_color(Gfx::Color color) { m_surface_clear_color = color; }
Optional<Gfx::Color> surface_clear_color() const { return m_surface_clear_color; }
+ void set_root_group_color(Gfx::Color color) { m_root_group_color = color; }
+ Gfx::Color root_group_color() const { return m_root_group_color; }
void set_async_scrolling_metadata(AsyncScrollingMetadata metadata) { m_async_scrolling_metadata = metadata; }
Optional<AsyncScrollingMetadata> const& async_scrolling_metadata() const { return m_async_scrolling_metadata; }
@@ -118,13 +121,14 @@ private:
// Takes over the storage of a tape that came from another process and passed its checks.
static NonnullRefPtr<DisplayList> adopt_received_storage(Properties, void const* storage);
- DisplayList(u64 compatible_visual_context_tree_structural_epoch, u64 id, void const* storage, Optional<Gfx::Color> surface_clear_color, Optional<AsyncScrollingMetadata>);
+ DisplayList(u64 compatible_visual_context_tree_structural_epoch, u64 id, void const* storage, Optional<Gfx::Color> surface_clear_color, Gfx::Color root_group_color, Optional<AsyncScrollingMetadata>);
u64 m_compatible_visual_context_tree_structural_epoch { 0 };
u64 m_id { 0 };
// One strong reference to the Rust storage, which owns the tape.
void const* m_storage { nullptr };
Optional<Gfx::Color> m_surface_clear_color;
+ Gfx::Color m_root_group_color { Gfx::Color::Transparent };
Optional<AsyncScrollingMetadata> m_async_scrolling_metadata;
template<typename T>
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
index 279b4ade9b5..601c8dff32c 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
@@ -263,6 +263,8 @@ pub struct ReplayLayer {
pub backdrop_filter_bytes_size: usize,
pub backdrop_region: IntRect,
pub backdrop_corner_radii: CornerRadii,
+ /// The color the backdrop is read over, transparent unless the parent layer is the root isolation layer.
+ pub backdrop_base_color: Color,
pub effect: EffectNodeIndex,
/// Bounds of everything replay draws into the layer, in the effect's space, when known.
pub content_bounds: OptionalFloatRect,
diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
index 419e8ead04b..c12cb602d07 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
@@ -21,7 +21,7 @@ use crate::visual_context::{
};
use libgfx_rust::path::Path;
use libgfx_rust::{
- AffineTransform, CornerRadii, FloatMatrix4x4, FloatPoint, FloatRect, FloatVector3, IntRect, WindingRule,
+ AffineTransform, Color, CornerRadii, FloatMatrix4x4, FloatPoint, FloatRect, FloatVector3, IntRect, WindingRule,
enclosing_int_rect, translation_matrix,
};
use std::cell::RefCell;
@@ -190,6 +190,7 @@ struct ReplayDriver<'a, Painter: ReplayPainter> {
command_runs: &'a [DisplayListCommandRun],
scroll_offsets: &'a [FloatPoint],
effect_clips: &'a EffectClipPlan,
+ root_group_color: Color,
painter: &'a mut Painter,
palette: ReplayPaletteStorage,
culling: TreeCullingScratch,
@@ -246,6 +247,7 @@ fn replay_layer_of(
backdrop_filter_bytes_size,
backdrop_region,
backdrop_corner_radii,
+ backdrop_base_color: Color::TRANSPARENT,
effect,
content_bounds: OptionalFloatRect::from(content_bounds),
}
@@ -467,13 +469,38 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {
};
match &tree.effect_nodes[effect.0 as usize].data {
EffectNodeData::Effects(effects) if backdrop_is_drawn_by_masks(tree, effect) => {
- Some(replay_layer_of(effects, effect, None))
+ let mut layer = replay_layer_of(effects, effect, None);
+ layer.backdrop_base_color = self.backdrop_base_color(mask_effect);
+ Some(layer)
}
_ => None,
}
})
}
+ // https://drafts.fxtf.org/filter-effects-2/#BackdropRoot
+ // The root element group is a backdrop root, yet engines read the canvas surface below it into the backdrop, see
+ // https://github.com/w3c/fxtf-drafts/issues/557. Skia reads a backdrop from the parent layer only, so a layer
+ // whose nearest enclosing effect is the root isolation effect reads its backdrop over the color the canvas holds
+ // outside every layer. Any other effect is a backdrop root, even one that pushes no layer, such as will-change.
+ fn backdrop_base_color(&self, layer_effect: EffectNodeIndex) -> Color {
+ let tree = self.tree;
+ let mut enclosing_effect = tree.effect_nodes[layer_effect.0 as usize].parent;
+ while !enclosing_effect.is_none()
+ && matches!(
+ tree.effect_nodes[enclosing_effect.0 as usize].data,
+ EffectNodeData::BackgroundColorAnimation
+ )
+ {
+ enclosing_effect = tree.effect_nodes[enclosing_effect.0 as usize].parent;
+ }
+ if tree.root_isolation_effect == Some(enclosing_effect) {
+ self.root_group_color
+ } else {
+ Color::TRANSPARENT
+ }
+ }
+
// Merge the clip and effect chains from leaf to root. Each effect goes immediately
// inside its output clip; reversing once produces the canvas stack in linear time.
fn build_target(&mut self, context: ContextRef) {
@@ -637,6 +664,8 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {
layer.backdrop_filter_bytes_size = 0;
layer.opacity = 1.0;
layer.blend_mode = libgfx_rust::CompositingAndBlendingOperator::Normal;
+ } else if effects.backdrop_filter.is_some() {
+ layer.backdrop_base_color = self.backdrop_base_color(effect);
}
self.painter.push_layer(&layer);
}
@@ -759,6 +788,7 @@ pub fn replay_display_list(
tape: &[u8],
command_runs: &[DisplayListCommandRun],
effect_clips: &EffectClipPlan,
+ root_group_color: Color,
scroll_offsets: &[FloatPoint],
painter: &mut impl ReplayPainter,
) {
@@ -771,6 +801,7 @@ pub fn replay_display_list(
command_runs,
scroll_offsets,
effect_clips,
+ root_group_color,
painter,
palette: scratch.palette,
culling: scratch.culling,
@@ -928,6 +959,7 @@ mod tests {
base_matrix: FloatMatrix4x4,
fully_clipped_x: i32,
layer_content_bounds: Vec<Option<FloatRect>>,
+ backdrop_base_colors: Vec<Color>,
}
impl RecordingPainter {
@@ -937,6 +969,7 @@ mod tests {
base_matrix: translation_matrix(100.0, 200.0, 0.0),
fully_clipped_x: i32::MIN,
layer_content_bounds: Vec::new(),
+ backdrop_base_colors: Vec::new(),
}
}
}
@@ -960,6 +993,9 @@ mod tests {
fn push_layer(&mut self, layer: &ReplayLayer) {
self.events.push(PainterEvent::PushLayer(layer.opacity));
self.layer_content_bounds.push(layer.content_bounds.get());
+ if layer.backdrop_filter_bytes_size != 0 {
+ self.backdrop_base_colors.push(layer.backdrop_base_color);
+ }
}
fn push_mask(&mut self, mask: &ReplayMask, _backdrop: Option<&ReplayLayer>) {
self.events.push(PainterEvent::PushMask(mask.rect));
@@ -1070,7 +1106,15 @@ mod tests {
}
fn replay(tree: &VisualContextTree, runs: &[DisplayListCommandRun], painter: &mut RecordingPainter) {
- replay_display_list(tree, &[], runs, &EffectClipPlan::new(tree, runs).unwrap(), &[], painter);
+ replay_display_list(
+ tree,
+ &[],
+ runs,
+ &EffectClipPlan::new(tree, runs).unwrap(),
+ Color::TRANSPARENT,
+ &[],
+ painter,
+ );
}
#[test]
@@ -1697,6 +1741,52 @@ mod tests {
assert_eq!(layer.backdrop_region, IntRect::default());
}
+ #[test]
+ fn only_a_backdrop_whose_backdrop_root_is_the_root_isolation_effect_reads_the_root_group_color() {
+ let mut tree = identity_tree();
+ let root = effect_under(&mut tree, effects(1.0), EffectNodeIndex::NONE, ClipNodeIndex::NONE);
+ tree.root_isolation_effect = Some(root);
+ // will-change: opacity keeps an effects node that pushes no layer, which is a backdrop root nonetheless.
+ let will_change = effect_under(&mut tree, effects(1.0), root, ClipNodeIndex::NONE);
+ let backdrop = || {
+ EffectNodeData::Effects(EffectsData {
+ isolation: false,
+ opacity: 1.0,
+ blend_mode: CompositingAndBlendingOperator::Normal,
+ filter: None,
+ backdrop_filter: Some(BackdropFilterData {
+ filter: std::sync::Arc::new(vec![1]),
+ region: visible_bounds(),
+ corner_radii: CornerRadii::default(),
+ }),
+ })
+ };
+ let in_root = effect_under(&mut tree, backdrop(), root, ClipNodeIndex::NONE);
+ let in_will_change = effect_under(&mut tree, backdrop(), will_change, ClipNodeIndex::NONE);
+ let runs = [in_root, in_will_change].map(|effect| {
+ run(
+ VISUAL_VIEWPORT_NODE_INDEX,
+ ContextRef {
+ effect,
+ ..ContextRef::default()
+ },
+ visible_bounds(),
+ )
+ });
+ let white = Color::from_rgb(255, 255, 255);
+ let mut painter = RecordingPainter::new();
+ replay_display_list(
+ &tree,
+ &[],
+ &runs,
+ &EffectClipPlan::new(&tree, &runs).unwrap(),
+ white,
+ &[],
+ &mut painter,
+ );
+ assert_eq!(painter.backdrop_base_colors, vec![white, Color::TRANSPARENT]);
+ }
+
// A background-color animation marker is an effect without canvas state: entering or leaving
// it neither pushes nor invalidates the matrix.
#[test]
@@ -1817,6 +1907,7 @@ mod tests {
&[],
&runs,
&EffectClipPlan::new(&tree, &runs).unwrap(),
+ Color::TRANSPARENT,
&scroll_offsets,
&mut painter,
);
diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rs
index d50bd611f1a..d68675cf4df 100644
--- a/Libraries/LibCompositing/Rust/src/ffi.rs
+++ b/Libraries/LibCompositing/Rust/src/ffi.rs
@@ -146,6 +146,7 @@ pub unsafe extern "C" fn display_list_animated_content_may_affect_viewport(
pub unsafe extern "C" fn display_list_replay(
tree: *const c_void,
storage: *const c_void,
+ root_group_color: libgfx_rust::Color,
scroll_offsets: *const libgfx_rust::FloatPoint,
scroll_offsets_len: usize,
callbacks: *const crate::host::FfiDisplayListReplayCallbacks,
@@ -165,6 +166,7 @@ pub unsafe extern "C" fn display_list_replay(
storage.bytes(),
storage.command_runs(),
storage.effect_clip_plan(tree),
+ root_group_color,
scroll_offsets,
&mut painter,
);
diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
index 65d34d2b247..02a7297a544 100644
--- a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
@@ -734,6 +734,7 @@ NonnullRefPtr<Compositing::DisplayList> display_list_of_published_recording(Disp
auto display_list = Compositing::DisplayList::share_rust_command_storage(recording.visual_context_tree, presented.display_list);
if (recording.surface_clear_color.has_value())
display_list->set_surface_clear_color(*recording.surface_clear_color);
+ display_list->set_root_group_color(presented.root_group_color);
stamp_async_scrolling_metadata(*display_list);
return display_list;
}
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
index cb348f72602..7ca0bfc6c33 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
@@ -333,7 +333,7 @@ impl DisplayListRecorder {
self.ambient_inline_clips.truncate(enclosing_scope_clip_count);
}
- fn resolve_color(&mut self, color: Color, force_dark_role: ForceDarkRole) -> Color {
+ pub fn resolve_color(&mut self, color: Color, force_dark_role: ForceDarkRole) -> Color {
let backdrop = self.contrast_backdrop;
match &mut self.force_dark {
Some(resolver) => resolver.resolve_against_backdrop(color, force_dark_role, backdrop),
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index 2db598d21dd..cca4611ffa6 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -472,6 +472,8 @@ pub struct FfiPresentedRecording {
/// The recorded display list, which the document's last recording holds until the next
/// recording replaces it. The host takes a reference of its own to keep it longer.
pub display_list: *const c_void,
+ /// The color the canvas holds below the recording's layers.
+ pub root_group_color: libgfx_rust::Color,
}
impl FfiPresentedRecording {
@@ -482,6 +484,7 @@ impl FfiPresentedRecording {
is_identical_to_published_recording: output.is_identical_to_published_recording,
has_blocking_wheel_event_listeners: output.has_blocking_wheel_event_listeners,
display_list: std::sync::Arc::as_ptr(&output.display_list).cast(),
+ root_group_color: output.root_group_color,
}
}
@@ -497,6 +500,7 @@ impl FfiPresentedRecording {
display_list: recording.map_or(std::ptr::null(), |recording| {
std::sync::Arc::as_ptr(&recording.display_list).cast()
}),
+ root_group_color: recording.map_or(libgfx_rust::Color::TRANSPARENT, |recording| recording.root_group_color),
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
index e229fef75db..8bfff95c871 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
@@ -54,6 +54,7 @@ pub struct RecordingOutput {
pub(crate) root_background_canvas_rect: CssPixelRect,
// The bytes before the viewport's scope: the canvas, recorded outside the tree.
pub(crate) prologue_bytes: u32,
+ pub root_group_color: libgfx_rust::Color,
pub hit_test_list: HitTestList,
pub display_list: Arc<RecordedDisplayList>,
pub has_blocking_wheel_event_listeners: bool,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/producers.rs b/Libraries/LibWeb/Rust/src/painting/record/producers.rs
index 2ce36af7ca6..cbddc71bd57 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/producers.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/producers.rs
@@ -23,6 +23,7 @@ use crate::painting::paintable_data::PaintableFlag;
use crate::painting::record::damage::PaintDamage;
use crate::painting::record::svg_resources::MaskLayerSet;
use crate::painting::scroll_snap;
+use libgfx_rust::Color;
use smallvec::SmallVec;
use std::ops::Range;
@@ -59,12 +60,17 @@ fn hit_phase(kind: ProducerKind) -> Option<PaintPhase> {
}
impl<O: Observer> PaintRecorder<'_, O> {
- pub(crate) fn record_canvas(&mut self) {
+ pub(crate) fn record_canvas(&mut self) -> Color {
+ let mut root_group_color = Color::TRANSPARENT;
self.trace_paint(Operation::Named(None, "canvas"), |this| {
let inputs = this.inputs;
+ let canvas_color = this
+ .recorder
+ .resolve_color(inputs.uncaptured.canvas_color, ForceDarkRole::Background);
if let Some(rect) = inputs.canvas_fill_rect {
this.recorder
.fill_rect(rect, inputs.uncaptured.canvas_color, ForceDarkRole::Background);
+ root_group_color = canvas_color;
}
// .. in the case of embedded documents typically rendered over a transparent canvas
// (such as provided via an HTML iframe element), if the used color scheme of the element
@@ -77,13 +83,19 @@ impl<O: Observer> PaintRecorder<'_, O> {
inputs.uncaptured.canvas_color,
ForceDarkRole::Background,
);
+ root_group_color = canvas_color;
}
this.recorder.fill_rect(
inputs.bitmap_rect,
inputs.uncaptured.background_color,
ForceDarkRole::Background,
);
+ root_group_color = root_group_color.blend(
+ this.recorder
+ .resolve_color(inputs.uncaptured.background_color, ForceDarkRole::Background),
+ );
});
+ root_group_color
}
// https://drafts.csswg.org/css-transforms-1/#transform-function-lists
diff --git a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
index 5e0e8946642..1aaefb0751f 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
@@ -125,7 +125,7 @@ fn record_display_list_impl<O: Observer>(
recorder
.observer
.observe(|log| log.damage = Some(source.frame().damage().summary()));
- recorder.record_canvas();
+ let root_group_color = recorder.record_canvas();
let prologue_bytes = u32::try_from(recorder.recorder.byte_size()).expect("display list exceeds u32");
let has_inspector_overlays = inputs.inspector_highlight.is_some()
|| inputs.grid_overlays.is_some()
@@ -180,6 +180,7 @@ fn record_display_list_impl<O: Observer>(
frame_inputs,
root_background_canvas_rect,
prologue_bytes,
+ root_group_color,
hit_test_list,
display_list,
has_blocking_wheel_event_listeners: recorder.blocking_wheel_event_region_count > 0,
diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cpp
index f36dc7a8901..e604007ca54 100644
--- a/Services/Compositor/DisplayListPlayerSkia.cpp
+++ b/Services/Compositor/DisplayListPlayerSkia.cpp
@@ -1560,6 +1560,10 @@ sk_sp<SkImageFilter> DisplayListPlayerSkia::backdrop_image_filter(ReplayLayer co
ReadonlyBytes filter_bytes { layer.backdrop_filter_bytes, layer.backdrop_filter_bytes_size };
return raster_cache().backdrop_image_filter(active_visual_context_tree().structural_epoch(), layer, limited_to_region, [&] {
auto image_filter = image_filter_from_bytes(filter_bytes);
+ if (layer.backdrop_base_color.alpha() != 0) {
+ auto base = SkImageFilters::Shader(SkShaders::Color(to_skia_color(layer.backdrop_base_color)));
+ image_filter = SkImageFilters::Compose(move(image_filter), SkImageFilters::Blend(SkBlendMode::kSrcOver, move(base), nullptr));
+ }
if (limited_to_region) {
auto region = to_skia_rect(layer.backdrop_region);
image_filter = SkImageFilters::Crop(region, SkTileMode::kDecal, move(image_filter));
diff --git a/Services/Compositor/DisplayListRasterCache.cpp b/Services/Compositor/DisplayListRasterCache.cpp
index 2948ebce231..ddce7953542 100644
--- a/Services/Compositor/DisplayListRasterCache.cpp
+++ b/Services/Compositor/DisplayListRasterCache.cpp
@@ -45,6 +45,7 @@ struct DisplayListRasterCache::LayerImageFilterCache {
ByteBuffer filter_bytes;
Gfx::IntRect region;
Gfx::CornerRadii corner_radii;
+ Gfx::Color base_color;
bool limited_to_region { false };
sk_sp<SkImageFilter> image_filter;
};
@@ -211,10 +212,11 @@ sk_sp<SkImageFilter> DisplayListRasterCache::backdrop_image_filter(u64 tree_stru
&& cached->filter_bytes.bytes() == filter_bytes
&& cached->region == layer.backdrop_region
&& cached->corner_radii == layer.backdrop_corner_radii
+ && cached->base_color == layer.backdrop_base_color
&& cached->limited_to_region == limited_to_region)
return cached->image_filter;
auto image_filter = create();
- entries.set(layer.effect.value(), LayerImageFilterCache::BackdropEntry { MUST(ByteBuffer::copy(filter_bytes)), layer.backdrop_region, layer.backdrop_corner_radii, limited_to_region, image_filter });
+ entries.set(layer.effect.value(), LayerImageFilterCache::BackdropEntry { MUST(ByteBuffer::copy(filter_bytes)), layer.backdrop_region, layer.backdrop_corner_radii, layer.backdrop_base_color, limited_to_region, image_filter });
return image_filter;
}
diff --git a/Tests/LibWeb/Ref/expected/backdrop-filter-will-change-is-a-backdrop-root-ref.html b/Tests/LibWeb/Ref/expected/backdrop-filter-will-change-is-a-backdrop-root-ref.html
new file mode 100644
index 00000000000..15700a5b335
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/backdrop-filter-will-change-is-a-backdrop-root-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ div {
+ position: absolute;
+ top: 0;
+ width: 100px;
+ height: 100px;
+ background: black;
+ }
+</style>
+<div></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-basic-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-basic-ref.html
new file mode 100644
index 00000000000..71e42e5ca7c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-basic-ref.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Basic operation of filter</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+
+<div>
+ <p>Expected: A green box and an overlapping black box, with a magenta<br>
+ overlapping region.</p>
+</div>
+<div class="colorbox"></div>
+<div class="box2outside"></div>
+<div class="box2inside"></div>
+
+<style>
+.colorbox {
+ position: absolute;
+ background: green;
+ width: 100px;
+ height: 100px;
+ left: 10px;
+ top: 100px;
+}
+.box2outside {
+ background: black;
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: 60px;
+ top: 150px;
+}
+.box2inside {
+ background: #ff7fff;
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ left: 60px;
+ top: 150px;
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom-ref.html
new file mode 100644
index 00000000000..82609f76332
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom-ref.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+
+<div id='rect1'></div>
+<div id='rect2'></div>
+
+<style>
+body {
+ zoom: 5;
+}
+div {
+ width: 100px;
+ height: 20px;
+ background-color: black;
+ border: 2px dashed green;
+}
+#rect1 {
+ border-radius: 20px / 5px;
+}
+#rect2 {
+ position: relative;
+ top:5px;
+ border-radius: 4px;
+}
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-non-isolation-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-non-isolation-ref.html
new file mode 100644
index 00000000000..229d6b4faad
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-non-isolation-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Isolation</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+
+<div>
+ <p>Expected: Two green boxes overlapped by a yellow box. The overlapped region<br>
+ of BOTH green boxes should be inverted (pink).</p>
+</div>
+<div class="box green"></div>
+<div class="box green" style="left: 130px;"></div>
+<div class="box yellow" style="width:160px;height:160px;top:140px;left:40px;"></div>
+<div class="box orange" style="width:70px;height:70px;top:140px;left:40px;"></div>
+<div class="box orange" style="width:70px;height:70px;top:140px;left:130px;"></div>
+
+<style>
+.box {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top:110px;
+ left:10px;
+}
+.green { background: green; }
+.yellow { background: #880; }
+.orange { background: #ffc377; }
+
+</style>
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-filter-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-filter-ref.html
new file mode 100644
index 00000000000..aa421fd9820
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-filter-ref.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Only filter objects painted before</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+
+<p>Expected: A green box with an overlapping purple box.<br>
+The overlapping portion of the boxes should be bright magenta.<br>
+
+<div class="container">
+ <div class="orangebox"></div>
+ <div class="bluebox blur-bd"></div>
+ <div class="invert"></div>
+</div>
+
+
+<style>
+div {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+}
+.container {
+ width:200px;
+ height:200px;
+ top: 50px;
+ position:absolute;
+}
+.blur-bd {
+ backdrop-filter: blur(10px);
+}
+.orangebox {
+ left: 10px;
+ top: 50px;
+ background: green;
+}
+.bluebox {
+ left: 60px;
+ top: 110px;
+ background: #00ff0055;
+}
+.invert {
+ left: 60px;
+ top: 110px;
+ background: transparent;
+ backdrop-filter: invert(1);
+}
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large-ref.html
new file mode 100644
index 00000000000..6d627fccf94
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Correctly apply masks/clips to backdrop-filter content</title>
+<link rel="author" href="mailto:[email protected]">
+
+<div></div>
+
+<style>
+body {
+ overflow: hidden;
+}
+div {
+ position: absolute;
+ top: 100px;
+ left: 50px;
+ width: 2000px;
+ height: 2000px;
+ background: black;
+ clip-path: circle(1000px at center);
+}
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-ref.html
new file mode 100644
index 00000000000..427376ee93b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Correctly apply masks/clips to backdrop-filter content</title>
+<link rel="author" href="mailto:[email protected]">
+
+<div></div>
+
+<svg>
+ <clipPath id="heart" clipPathUnits="objectBoundingBox">
+ <path d="M0.5,1
+ C 0.5,1,0,0.7,0,0.3
+ A 0.25,0.25,1,1,1,0.5,0.3
+ A 0.25,0.25,1,1,1,1,0.3
+ C 1,0.7,0.5,1,0.5,1 Z" />
+ </clipPath>
+</svg>
+
+<style>
+div {
+ position: absolute;
+ top: 100px;
+ left: 50px;
+ width: 200px;
+ height: 200px;
+ background: black;
+ clip-path: url(#heart);
+}
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-scale-transform-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-scale-transform-ref.html
new file mode 100644
index 00000000000..d7faa0e97a1
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-scale-transform-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+ #container {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ transform: scale(1.1);
+ }
+
+ #backdropfilter {
+ background: black;
+ position: relative;
+ width: 100%;
+ height: 100%;
+ }
+</style>
+<div id=container>
+ <div id=backdropfilter></div>
+</div>
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-transform-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-transform-ref.html
new file mode 100644
index 00000000000..1af8776cf0d
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filter-transform-ref.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<div class="filterbox">
+</div>
+<div class="colorbox">
+ <div class="invert"></div>
+</div>
+
+<style>
+div {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: 100px;
+ top: 100px;
+}
+.colorbox {
+ background: green;
+ overflow: clip;
+}
+.filterbox {
+ top: 140px;
+ background: black;
+ transform: rotate(30deg);
+ border-radius: 10px;
+}
+.invert {
+ top: 40px;
+ left: 0;
+ background: rgb(255, 127, 255);
+ transform: rotate(30deg);
+ border-radius: 10px;
+}
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-brightness-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-brightness-ref.html
new file mode 100644
index 00000000000..999894eb81f
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-brightness-ref.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Brightness</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: blue;
+ filter: brightness(50%);
+ }
+ .filt {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ background: white;
+ filter: brightness(50%);
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 125px;
+ left: 125px;
+ background: green;
+ }
+</style>
+<p>You should see a dark blue rectangle with a green box. Neither black nor blue.</p>
+<div class="filt"></div>
+<div class="square"></div>
+<div class="greenbox"></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-contrast-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-contrast-ref.html
new file mode 100644
index 00000000000..01b38f7b337
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-contrast-ref.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Contrast</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: black;
+ filter: contrast(50%);
+ }
+ .filt {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ background: white;
+ filter: contrast(50%);
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 125px;
+ left: 125px;
+ background: green;
+ }
+</style>
+<p>You should see a gray rectangle with a green box. Neither black nor white.</p>
+<div class="filt"></div>
+<div class="square"></div>
+<div class="greenbox"></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-invert-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-invert-ref.html
new file mode 100644
index 00000000000..61f285608bf
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-invert-ref.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Invert</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: black;
+ filter: invert(50%);
+ }
+ .filt {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ background: white;
+ filter: invert(50%);
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 125px;
+ left: 125px;
+ background: green;
+ }
+</style>
+<p>You should see a gray rectangle with a green box. Neither black nor white.</p>
+<div class="filt"></div>
+<div class="square"></div>
+<div class="greenbox"></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-sepia-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-sepia-ref.html
new file mode 100644
index 00000000000..eae10fe65c1
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/backdrop-filters-sepia-ref.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Sepia</title>
+<link rel="author" href="mailto:[email protected]">
+
+
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: blue;
+ filter: sepia(50%);
+ }
+ .filt {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ background: white;
+ filter: sepia(50%);
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 125px;
+ left: 125px;
+ background: green;
+ }
+</style>
+<p>You should see a dark blue rectangle with a green box.</p>
+<div class="filt"></div>
+<div class="square"></div>
+<div class="greenbox"></div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-clip-rect-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-clip-rect-2-ref.html
new file mode 100644
index 00000000000..f12e88515fe
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-clip-rect-2-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="author" href="mailto:[email protected]">
+<style>
+.box {
+ display: inline-block;
+ box-sizing: border-box;
+ width: 100px;
+ height: 100px;
+ border-radius: 10px 20px 30px 40px;
+ border-width: 10px;
+}
+.no-bf > .box {
+ background: black;
+}
+</style>
+<div>
+ <p>Expected: Same size rounded black boxes.</p>
+</div>
+
+<div class="no-bf">
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+</div>
+<div class="no-bf">
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-plus-will-change-opacity-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-plus-will-change-opacity-ref.html
new file mode 100644
index 00000000000..56c6243809b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/backdrop-filter-plus-will-change-opacity-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<p>Expected: A black box.</p>
+<div id="blackbox"></div>
+<style>
+ #blackbox {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ }
+</style>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/repaint-added-backdrop-filter-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/repaint-added-backdrop-filter-ref.html
new file mode 100644
index 00000000000..caaa3061eda
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/filter-effects/reference/repaint-added-backdrop-filter-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<p>Expected: A black box.</p>
+<div id="filter"></div>
+<style>
+ #filter {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ }
+</style>
diff --git a/Tests/LibWeb/Ref/input/backdrop-filter-will-change-is-a-backdrop-root.html b/Tests/LibWeb/Ref/input/backdrop-filter-will-change-is-a-backdrop-root.html
new file mode 100644
index 00000000000..62fc3c9dad6
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/backdrop-filter-will-change-is-a-backdrop-root.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<link rel="match" href="../expected/backdrop-filter-will-change-is-a-backdrop-root-ref.html">
+<style>
+ div {
+ position: absolute;
+ top: 0;
+ width: 100px;
+ height: 100px;
+ }
+ #will-change {
+ left: 150px;
+ will-change: opacity;
+ }
+ .invert {
+ backdrop-filter: invert(1);
+ }
+</style>
+<div class="invert"></div>
+<div id="will-change"><div class="invert"></div></div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-basic.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-basic.html
new file mode 100644
index 00000000000..7bd8faf829d
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-basic.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Basic operation of filter</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-basic-ref.html">
+
+<div>
+ <p>Expected: A green box and an overlapping black box, with a magenta<br>
+ overlapping region.</p>
+</div>
+<div class="colorbox">
+ <div class="filterbox"></div>
+</div>
+
+<style>
+.colorbox {
+ position: absolute;
+ background: green;
+ width: 100px;
+ height: 100px;
+ left: 10px;
+ top: 100px;
+}
+.filterbox {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: 50px;
+ top: 50px;
+ backdrop-filter: invert(1);
+ opacity: 1.0;
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom.html
new file mode 100644
index 00000000000..f757a1b469d
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name=fuzzy content="maxDifference=0-200; totalPixels=0-2000">
+<title>Backdrop filter clipping radius with zoom</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-clip-radius-zoom-ref.html">
+
+<!--You should see two completely filled black rectangles with rounded corners.-->
+
+<div id='rect1'></div>
+<div id='rect2'></div>
+
+<style>
+body {
+ zoom: 5;
+}
+div {
+ width: 100px;
+ height: 20px;
+ backdrop-filter: invert(1);
+ border: 2px dashed green;
+}
+#rect1 {
+ border-radius: 20px / 5px;
+}
+#rect2 {
+ position: relative;
+ top:5px;
+ border-radius: 4px;
+}
+</style>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-rect-2.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-rect-2.html
new file mode 100644
index 00000000000..0b1ecb6b38b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-clip-rect-2.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Clip the filter at border box of element</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/reference/backdrop-filter-clip-rect-2-ref.html">
+<meta name="fuzzy" content="maxDifference=0-80; totalPixels=0-1000" />
+<style>
+.box {
+ display: inline-block;
+ box-sizing: border-box;
+ width: 100px;
+ height: 100px;
+ border-radius: 10px 20px 30px 40px;
+ border-width: 10px;
+}
+.no-bf > .box {
+ background: black;
+}
+.bf > .box {
+ border-color: transparent;
+ backdrop-filter: invert(1);
+}
+</style>
+<div>
+ <p>Expected: Same size rounded black boxes.</p>
+</div>
+
+<div class="no-bf">
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+</div>
+<div class="bf">
+ <div class="box" style="border-style:none"></div>
+ <div class="box" style="border-style:solid"></div>
+ <div class="box" style="border-style:dotted"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-fixed.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-fixed.html
new file mode 100644
index 00000000000..985d3070b08
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-fixed.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: fixed position should not cause a backdrop root.</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-non-isolation-ref.html">
+
+<div>
+ <p>Expected: Two green boxes overlapped by a yellow box. The overlapped region<br>
+ of BOTH green boxes should be inverted (pink).</p>
+</div>
+<div class="box outside">
+ <div class="box stacking-context">
+ <div class="box filter">
+ </div>
+ </div>
+</div>
+
+<style>
+.box {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+}
+.outside {
+ top: 110px;
+ left: 10px;
+}
+.stacking-context {
+ position: fixed;
+ top: 110px;
+ left: 130px;
+}
+.filter {
+ width: 160px;
+ height: 160px;
+ top: 30px;
+ left: -90px;
+ backdrop-filter: invert(1);
+ background: #ff08;
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-isolate.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-isolate.html
new file mode 100644
index 00000000000..229f976d96d
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-isolation-isolate.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: isolation isolate should not cause a backdrop root.</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-non-isolation-ref.html">
+
+<div>
+ <p>Expected: Two green boxes overlapped by a yellow box. The overlapped region<br>
+ of BOTH green boxes should be inverted (pink).</p>
+</div>
+<div class="box outside">
+ <div class="box stacking-context">
+ <div class="box filter">
+ </div>
+ </div>
+</div>
+
+<style>
+.box {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: green;
+}
+.outside {
+ top: 110px;
+ left: 10px;
+}
+.stacking-context {
+ isolation: isolate;
+ top: 0px;
+ left: 120px;
+}
+.filter {
+ width: 160px;
+ height: 160px;
+ top: 30px;
+ left: -90px;
+ backdrop-filter: invert(1);
+ background: #ff08;
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-filter.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-filter.html
new file mode 100644
index 00000000000..f6ebeda0953
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-filter.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Correctly apply filters to backdrop-filter content</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-plus-filter-ref.html">
+<meta name="fuzzy" content="maxDifference=0-1;totalPixels=0-16000">
+
+<p>Expected: A green box with an overlapping purple box.<br>
+The overlapping portion of the boxes should be bright magenta.<br>
+
+<div class="container">
+ <div class="orangebox"></div>
+ <div class="bluebox blur blur-bd"></div>
+</div>
+
+
+<style>
+div {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+}
+.container {
+ width:200px;
+ height:200px;
+ top: 50px;
+ position:absolute;
+}
+.blur {
+ filter: invert(1);
+}
+.blur-bd {
+ backdrop-filter: blur(10px);
+}
+.orangebox {
+ left: 10px;
+ top: 50px;
+ background: green;
+}
+.bluebox {
+ left: 60px;
+ top: 110px;
+ background: #00ff0055;
+}
+</style>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large.html
new file mode 100644
index 00000000000..d48207b863c
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name=fuzzy content="maxDifference=0-100;totalPixels=0-2000">
+<title>backdrop-filter: Correctly apply masks/clips to backdrop-filter content</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-large-ref.html">
+
+<!--Expected: A large black circle.-->
+
+<div></div>
+
+<style>
+body {
+ overflow: hidden;
+}
+div {
+ position: absolute;
+ top: 100px;
+ left: 50px;
+ width: 2000px;
+ height: 2000px;
+ backdrop-filter: invert(1);
+ clip-path: circle(1000px at center);
+}
+</style>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask.html
new file mode 100644
index 00000000000..91c80f9c376
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-mask.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name=fuzzy content="maxDifference=0-200;totalPixels=0-1000">
+<title>backdrop-filter: Correctly apply masks/clips to backdrop-filter content</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-plus-mask-ref.html">
+
+<!--Expected: A black heart.-->
+
+<div></div>
+
+<svg>
+ <clipPath id="heart" clipPathUnits="objectBoundingBox">
+ <path d="M0.5,1
+ C 0.5,1,0,0.7,0,0.3
+ A 0.25,0.25,1,1,1,0.5,0.3
+ A 0.25,0.25,1,1,1,1,0.3
+ C 1,0.7,0.5,1,0.5,1 Z" />
+ </clipPath>
+</svg>
+
+<style>
+body {
+ overflow: hidden;
+}
+div {
+ position: absolute;
+ top: 100px;
+ left: 50px;
+ width: 200px;
+ height: 200px;
+ backdrop-filter: invert(1);
+ clip-path: url(#heart);
+}
+</style>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-will-change-opacity.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-will-change-opacity.html
new file mode 100644
index 00000000000..e1c47a5b0dd
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-plus-will-change-opacity.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>backdrop-filter: Correctly apply backdrop-filter with will-change opacity</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/reference/backdrop-filter-plus-will-change-opacity-ref.html">
+
+<p>Expected: A black box.</p>
+
+<div id="filter"></div>
+
+<style>
+ #filter {
+ width: 100px;
+ height: 100px;
+ backdrop-filter: invert(1);
+ will-change: opacity;
+ }
+</style>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-scale-transform.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-scale-transform.html
new file mode 100644
index 00000000000..e7fca5f3a03
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-scale-transform.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-scale-transform-ref.html">
+<style>
+ #container {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ transform: scale(1.1);
+ }
+
+ #backdropfilter {
+ backdrop-filter: invert(100%);
+ position: relative;
+ width: 100%;
+ height: 100%;
+ }
+</style>
+<div id=container>
+ <div id=backdropfilter></div>
+</div>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-svg-foreignObject.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-svg-foreignObject.html
new file mode 100644
index 00000000000..5db25582a91
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-svg-foreignObject.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<title>backdrop-filter: on SVG foreignObject</title>
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-basic-ref.html">
+
+<div>
+ <p>Expected: A green box and an overlapping black box, with a magenta<br>
+ overlapping region.</p>
+</div>
+<div class="colorbox">
+ <svg>
+ <foreignObject class="filterbox"></foreignObject>
+ </svg>
+</div>
+
+<style>
+.colorbox {
+ position: absolute;
+ background: green;
+ width: 100px;
+ height: 100px;
+ left: 10px;
+ top: 100px;
+}
+svg {
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ left: 50px;
+ top: 50px;
+}
+.filterbox {
+ width: 100px;
+ height: 100px;
+ backdrop-filter: invert(1);
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-transform.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-transform.html
new file mode 100644
index 00000000000..861aa46a392
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filter-transform.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name=fuzzy content="maxDifference=0-200; totalPixels=0-2000">
+<title>backdrop-filter: backdrop-filter plus transform should be applied correctly</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filter-transform-ref.html">
+
+<!--Expected: A green box with an overlapping rotated box that inverts content behind it. -->
+
+<div class="colorbox"></div>
+<div class="filterbox"></div>
+
+<style>
+div {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: 100px;
+ top: 100px;
+}
+.colorbox {
+ background: green;
+}
+.filterbox {
+ top: 140px;
+ backdrop-filter: invert(1);
+ transform: rotate(30deg);
+ border-radius: 10px;
+}
+</style>
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-brightness.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-brightness.html
new file mode 100644
index 00000000000..4b0e16291e0
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-brightness.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Brightness</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filters-brightness-ref.html">
+<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-37500">
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: blue;
+ }
+ .filt {
+ backdrop-filter: brightness(50%);
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 75px;
+ left: 75px;
+ background: green;
+ }
+</style>
+<p>You should see a dark blue rectangle with a green box. Neither black nor blue.</p>
+<div class="square"></div>
+<div class="filt">
+ <div class="greenbox"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-contrast.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-contrast.html
new file mode 100644
index 00000000000..b2ac56a4f9f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-contrast.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Contrast</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filters-contrast-ref.html">
+<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-7500" />
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: black;
+ }
+ .filt {
+ backdrop-filter: contrast(50%);
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 75px;
+ left: 75px;
+ background: green;
+ }
+</style>
+<p>You should see a gray rectangle with a green box. Neither black nor white.</p>
+<div class="square"></div>
+<div class="filt">
+ <div class="greenbox"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-invert.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-invert.html
new file mode 100644
index 00000000000..ceaf8284bc9
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-invert.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Invert</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filters-invert-ref.html">
+<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-37500" />
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: black;
+ }
+ .filt {
+ backdrop-filter: invert(50%);
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 75px;
+ left: 75px;
+ background: green;
+ }
+</style>
+<p>You should see a gray rectangle with a green box. Neither black nor white.</p>
+<div class="square"></div>
+<div class="filt">
+ <div class="greenbox"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-sepia.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-sepia.html
new file mode 100644
index 00000000000..0e5903e723e
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/backdrop-filters-sepia.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<title>CSS Backdrop Filters Animation: Sepia</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/backdrop-filters-sepia-ref.html">
+<style>
+ .square {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 100px;
+ background: blue;
+ }
+ .filt {
+ backdrop-filter: sepia(50%);
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 50px;
+ left: 50px;
+ }
+ .greenbox {
+ position: absolute;
+ width: 50px;
+ height: 50px;
+ top: 75px;
+ left: 75px;
+ background: green;
+ }
+</style>
+<p>You should see a dark blue rectangle with a green box.</p>
+<div class="square"></div>
+<div class="filt">
+ <div class="greenbox"></div>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/repaint-added-backdrop-filter.html b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/repaint-added-backdrop-filter.html
new file mode 100644
index 00000000000..731eabd179b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/filter-effects/repaint-added-backdrop-filter.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<meta charset="utf-8">
+<title>backdrop-filter: Correctly repaint added backdrop-filter</title>
+<link rel="author" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
+<link rel="match" href="../../../../expected/wpt-import/css/filter-effects/reference/repaint-added-backdrop-filter-ref.html">
+<script src="../../common/reftest-wait.js"></script>
+
+<p>Expected: A black box.</p>
+
+<div id="filter"></div>
+
+<style>
+ #filter {
+ width: 100px;
+ height: 100px;
+ backdrop-filter: none;
+ will-change: opacity;
+ }
+</style>
+
+<script>
+ function doTest() {
+ requestAnimationFrame(function() {
+ requestAnimationFrame(function() {
+ document.getElementById('filter').style.backdropFilter = 'invert(1)';
+ takeScreenshot();
+ });
+ });
+ }
+ window.addEventListener('load', doTest, false);
+</script>