Skip to content

Truly independent web browser

LibCompositing+Compositor: Let group effects keep their content's spaces

Aliaksandr Kalenikb7b5a7899778
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers.rs b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
index b6104dfe6f4..da853eba03c 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
@@ -647,6 +647,17 @@ fn identity_of_composited_node(
PlacementNodeIdentity(hasher.finish())
}
+// A node of a space inside a composited node is named apart from the node of the same space and clips outside it.
+fn identity_of_node_inside_composited_node(
+ composited_node_identity: PlacementNodeIdentity,
+ identity_outside_composited_nodes: PlacementNodeIdentity,
+) -> PlacementNodeIdentity {
+ let mut hasher = foldhash::fast::FixedState::with_seed(0x696e_7369_6465_636e).build_hasher();
+ hasher.write_u64(composited_node_identity.0);
+ hasher.write_u64(identity_outside_composited_nodes.0);
+ PlacementNodeIdentity(hasher.finish())
+}
+
fn node_covers_viewport(nodes: &[PlacementNode], spaces: &[RasterSpace], node_index: PlacementNodeIndex) -> bool {
let mut node_on_way_out = Some(node_index);
while let Some(index) = node_on_way_out {
@@ -822,12 +833,32 @@ impl LayerStack {
layering_obstacles: LayeringObstacles,
) -> Self {
let mut nodes: Vec<PlacementNode> = Vec::with_capacity(plan.nodes.len());
+ let mut innermost_composited_node_around_by_node_index: Vec<Option<PlacementNodeIndex>> =
+ Vec::with_capacity(plan.nodes.len());
for node in plan.nodes {
+ let innermost_composited_node_around = node.parent_index.and_then(|parent_index| {
+ if nodes[parent_index.0].composited_effect.is_some() {
+ Some(parent_index)
+ } else {
+ innermost_composited_node_around_by_node_index[parent_index.0]
+ }
+ });
+ innermost_composited_node_around_by_node_index.push(innermost_composited_node_around);
let identity = match (node.composited_effect, node.parent_index) {
(Some(effect), Some(parent_index)) => {
identity_of_composited_node(nodes[parent_index.0].identity, effect)
}
- _ => identity_of_node(&spaces, node.raster_space_index, &node.composite_clips),
+ _ => {
+ let identity_outside_composited_nodes =
+ identity_of_node(&spaces, node.raster_space_index, &node.composite_clips);
+ match innermost_composited_node_around {
+ Some(composited_node_index) => identity_of_node_inside_composited_node(
+ nodes[composited_node_index.0].identity,
+ identity_outside_composited_nodes,
+ ),
+ None => identity_outside_composited_nodes,
+ }
+ }
};
nodes.push(PlacementNode {
identity,
@@ -1158,6 +1189,14 @@ impl LayerStack {
self.innermost_composited_band_around_layer(layer_index).is_some()
}
+ /// The effect the compositor composites the records of the band inside: that of the innermost node at or around the
+ /// band's node that it composites inside an effect, which may be a node of another space. A replay of the band's
+ /// records leaves it out, with the effects around it and the clips it is entered within.
+ pub fn innermost_composited_effect_at_or_around_band(&self, band_index: BandIndex) -> Option<EffectNodeIndex> {
+ let composited_band = self.innermost_composited_band_at_or_around_band[band_index.0]?;
+ self.nodes[self.bands[composited_band.0].placement_node_index.0].composited_effect
+ }
+
/// The bands the layer is in, innermost first, whose nodes the compositor composites inside their effects. A plan
/// nests no more of them than `MAXIMUM_NESTING_OF_COMPOSITED_EFFECTS`.
pub fn composited_bands_around_layer_innermost_first(
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
index 45b07aa0afd..3b8cee0f73d 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
@@ -40,6 +40,7 @@ use crate::display_list::tiles::{CellRange, reaches_too_many_cells_to_follow_one
use crate::visual_context::queries::{BackdropReader, NestingOfLiveEffects, backdrop_reader_by_reading_effect_index};
use crate::visual_context::{EffectNodeData, VisualContextTree};
use libgfx_rust::{FloatPoint, FloatRect, IntRect};
+use std::collections::HashMap;
use std::hash::Hash;
use std::sync::Arc;
@@ -144,6 +145,7 @@ pub enum WhyEffectIsComposited {
ItHoldsMedia(LiveContent),
TheCompositorAnimatesIt,
ItAppliesOverATransformTheCompositorAnimates,
+ ItHoldsContentOfSeveralSpaces,
}
impl std::fmt::Display for WhyEffectIsComposited {
@@ -163,6 +165,7 @@ impl std::fmt::Display for WhyEffectIsComposited {
WhyEffectIsComposited::ItAppliesOverATransformTheCompositorAnimates => {
"it applies over a transform the compositor animates"
}
+ WhyEffectIsComposited::ItHoldsContentOfSeveralSpaces => "it holds content of several spaces",
})
}
}
@@ -247,6 +250,9 @@ pub struct PlacedRunGroup {
pub paints_within_root_group: bool,
/// In the space's raster coordinates.
pub reach_read_by_records_blending_with_root_group: Reach<IntRect>,
+ /// The innermost effect around the group that holds content of several spaces, inside whose node the node of the
+ /// group goes.
+ pub inside_effect_holding_content_of_several_spaces: Option<EffectNodeIndex>,
}
/// The index of a placed effect in `ListPlacement::placed_effects`.
@@ -291,6 +297,10 @@ pub struct PlacedEffect {
/// None for an effect placed only as it reads the content of the root group, which the bands it can read are only
/// known of as the stack is cut into them.
pub why_composited_regardless_of_layer_content: Option<WhyEffectIsComposited>,
+ /// For an effect that holds content of several spaces, the space of its node: the lowest space holding all of that
+ /// content, whose raster coordinates `reach` is in. Each run group of its content goes into a node of its own
+ /// space inside that node, rather than all of them into one space where most of them would move.
+ pub space_of_node_holding_content_of_several_spaces: Option<RasterSpaceIndex>,
}
/// Live content that is a layer of its own, alone in its run.
@@ -501,6 +511,16 @@ struct ListBeingPlaced<'a> {
backdrop_reader_by_effect_index: Vec<Option<BackdropReader>>,
first_run_index_by_effect_index: Vec<usize>,
effects_in_paint_order_with_outer_before_inner: Vec<EffectNodeIndex>,
+ runs_reaching_outside: RunsReachingOutsideTheirContext,
+ /// Empty where no effect holds content of several spaces.
+ effect_holds_content_of_several_spaces_by_effect_index: Vec<bool>,
+}
+
+// Where the node of an effect that holds content of several spaces is, as `PlacedEffect` tells it.
+#[derive(Clone, Copy)]
+struct NodeOfEffectHoldingContentOfSeveralSpaces {
+ space: RasterSpaceIndex,
+ reach: IntRect,
}
// What placing the run groups of a list works out, which the phases after it read.
@@ -510,6 +530,8 @@ struct RunGroupsPlaced {
run_moves_within_space_by_run_index: Vec<bool>,
swept_reach_in_parent_space_by_space_index: Vec<Option<IntRect>>,
reach_by_effect_index_once_worked_out: std::cell::OnceCell<Vec<IntRect>>,
+ /// Empty where no effect holds content of several spaces.
+ node_by_effect_holding_content_of_several_spaces: Vec<Option<NodeOfEffectHoldingContentOfSeveralSpaces>>,
}
impl<'a> ListBeingPlaced<'a> {
@@ -574,7 +596,7 @@ impl<'a> ListBeingPlaced<'a> {
effects_in_paint_order_with_outer_before_inner
.extend(newly_reached_effects_inner_to_outer.into_iter().rev());
}
- Self {
+ let mut placing = Self {
tree,
list,
run_groups: list.run_groups(tree),
@@ -588,7 +610,123 @@ impl<'a> ListBeingPlaced<'a> {
backdrop_reader_by_effect_index: backdrop_reader_by_reading_effect_index(tree),
first_run_index_by_effect_index,
effects_in_paint_order_with_outer_before_inner,
+ runs_reaching_outside: RunsReachingOutsideTheirContext::new(list),
+ effect_holds_content_of_several_spaces_by_effect_index: Vec::new(),
+ };
+ placing.note_effects_holding_content_of_several_spaces();
+ placing
+ }
+
+ fn effect_holds_content_of_several_spaces(&self, effect: EffectNodeIndex) -> bool {
+ self.effect_holds_content_of_several_spaces_by_effect_index
+ .get(effect.0 as usize)
+ .copied()
+ .unwrap_or(false)
+ }
+
+ // A group effect placed whole is rastered in the lowest space holding all of its content, where content of the
+ // spaces inside that one moves as they scroll or stick, and is rastered anew for every frame they move in. So an
+ // effect whose content is in several spaces is composited around nodes of those spaces instead, where the
+ // compositor can composite it, which a group effect around it must be too. That leaves out an effect that reads
+ // what is below it or that content inside it reads, as what each reads is told in the space of its run group.
+ fn note_effects_holding_content_of_several_spaces(&mut self) {
+ let (tree, list) = (self.tree, self.list);
+ let holds_runs_of_kind = |marks_run: &dyn Fn(usize) -> bool| {
+ let mut marks = [effects_of_marked_runs(list, tree, marks_run)];
+ mark_effects_around_marked_effects(tree, &mut marks);
+ let [marked_by_effect_index] = marks;
+ marked_by_effect_index
+ };
+ let mut runs_holding_records_blending_with_what_is_below_them = vec![false; list.run_count()];
+ for record in &list.summary().destination_blending_records {
+ runs_holding_records_blending_with_what_is_below_them[record.run_index as usize] = true;
+ }
+ let holds_records_blending_with_what_is_below_them =
+ holds_runs_of_kind(&|run_index| runs_holding_records_blending_with_what_is_below_them[run_index]);
+ let holds_runs_sorted_by_depth =
+ holds_runs_of_kind(&|run_index| self.run_groups.run_is_sorted_by_depth(run_index));
+ let groups_runs = |effect: EffectNodeIndex| {
+ tree.effect_nodes[effect.0 as usize].data.pushes_layer() && tree.root_isolation_effect != Some(effect)
+ };
+ let mut may_hold_content_of_several_spaces = vec![false; tree.effect_nodes.len()];
+ tree.visit_effect_nodes_parents_first(|index| {
+ let effect = EffectNodeIndex(index as u32);
+ let node = &tree.effect_nodes[index];
+ let EffectNodeData::Effects(effects) = &node.data else {
+ return;
+ };
+ let every_group_effect_around_may = node.parent.is_none()
+ || !groups_runs(node.parent)
+ || may_hold_content_of_several_spaces[node.parent.0 as usize];
+ may_hold_content_of_several_spaces[index] = every_group_effect_around_may
+ && groups_runs(effect)
+ && effects.blend_mode == libgfx_rust::CompositingAndBlendingOperator::Normal
+ && effects.backdrop_filter.is_none()
+ && self.backdrop_reader_by_effect_index[index].is_none()
+ && !filter_may_spread_at_some_sample(tree, effect)
+ && self
+ .why_compositor_cannot_composite_effect_or_effects_around(effect)
+ .is_none()
+ && !holds_records_blending_with_what_is_below_them[index]
+ && !holds_runs_sorted_by_depth[index];
+ });
+ if !may_hold_content_of_several_spaces.contains(&true) {
+ return;
+ }
+
+ // Where an effect is composited around its content, the content can go into spaces deeper than the effect's.
+ self.tables
+ .note_effects_composited_around_content_of_several_spaces(may_hold_content_of_several_spaces.clone());
+ #[derive(Clone, Copy, PartialEq)]
+ enum SpacesOfRuns {
+ NoRun,
+ All(RasterSpaceIndex),
+ Several,
+ }
+ let spaces = self.tables.spaces();
+ let mut spaces_of_runs_by_effect_index = vec![SpacesOfRuns::NoRun; tree.effect_nodes.len()];
+ let mut holds_run_of_animated_space = vec![false; tree.effect_nodes.len()];
+ for run_index in 0..list.run_count() {
+ let run = list.run(run_index);
+ let mut effect = run.context.effect;
+ let space_of_run = self
+ .runs_reaching_outside
+ .deepest_space_of_run(tree, &self.tables, run_index, run);
+ let run_is_in_animated_space = is_animated_space(&spaces[space_of_run.0]);
+ while !effect.is_none() {
+ let spaces_of_runs = &mut spaces_of_runs_by_effect_index[effect.0 as usize];
+ *spaces_of_runs = match *spaces_of_runs {
+ SpacesOfRuns::NoRun => SpacesOfRuns::All(space_of_run),
+ SpacesOfRuns::All(space) if space == space_of_run => SpacesOfRuns::All(space),
+ _ => SpacesOfRuns::Several,
+ };
+ holds_run_of_animated_space[effect.0 as usize] |= run_is_in_animated_space;
+ effect = tree.effect_nodes[effect.0 as usize].parent;
+ }
+ }
+ let mut holds_content_of_several_spaces = vec![false; tree.effect_nodes.len()];
+ tree.visit_effect_nodes_parents_first(|index| {
+ let parent = tree.effect_nodes[index].parent;
+ let every_group_effect_around_does =
+ parent.is_none() || !groups_runs(parent) || holds_content_of_several_spaces[parent.0 as usize];
+ holds_content_of_several_spaces[index] = every_group_effect_around_does
+ && may_hold_content_of_several_spaces[index]
+ && spaces_of_runs_by_effect_index[index] == SpacesOfRuns::Several
+ && !holds_run_of_animated_space[index];
+ });
+ if !holds_content_of_several_spaces.contains(&true) {
+ self.tables
+ .note_effects_composited_around_content_of_several_spaces(Vec::new());
+ return;
}
+ self.tables
+ .note_effects_composited_around_content_of_several_spaces(holds_content_of_several_spaces.clone());
+ self.run_groups = Arc::new(RunGroups::new_leaving_runs_of_effects_ungrouped(
+ tree,
+ list.runs(),
+ &holds_content_of_several_spaces,
+ ));
+ self.effect_holds_content_of_several_spaces_by_effect_index = holds_content_of_several_spaces;
}
// The walk up from an effect stops at the root isolation effect, which holds no reason.
@@ -625,7 +763,28 @@ impl<'a> ListBeingPlaced<'a> {
runs.groups[self.run_groups.group_of_run(run_index).0].raster_space_index
}
+ fn node_of_effect_holding_content_of_several_spaces(
+ runs: &RunGroupsPlaced,
+ effect: EffectNodeIndex,
+ ) -> Option<NodeOfEffectHoldingContentOfSeveralSpaces> {
+ runs.node_by_effect_holding_content_of_several_spaces
+ .get(effect.0 as usize)
+ .copied()
+ .flatten()
+ }
+
+ // The space whose raster coordinates `reach_of_effect` is in.
+ fn space_of_effect(&self, runs: &RunGroupsPlaced, effect: EffectNodeIndex) -> RasterSpaceIndex {
+ match Self::node_of_effect_holding_content_of_several_spaces(runs, effect) {
+ Some(node) => node.space,
+ None => runs.groups[self.run_group_of_effect(effect).0].raster_space_index,
+ }
+ }
+
fn reach_of_effect(&self, runs: &RunGroupsPlaced, effect: EffectNodeIndex) -> IntRect {
+ if let Some(node) = Self::node_of_effect_holding_content_of_several_spaces(runs, effect) {
+ return node.reach;
+ }
let (tree, list) = (self.tree, self.list);
runs.reach_by_effect_index_once_worked_out.get_or_init(|| {
let mut reach_by_effect_index = vec![IntRect::default(); tree.effect_nodes.len()];
@@ -646,7 +805,9 @@ impl<'a> ListBeingPlaced<'a> {
fn place_run_groups(&self) -> (RunGroupsPlaced, Vec<(AnimatedNode, WhyAnimationHasNoLayer)>) {
let (tree, list, tables, run_groups) = (self.tree, self.list, &self.tables, &*self.run_groups);
let spaces = tables.spaces();
- let runs_reaching_outside = RunsReachingOutsideTheirContext::new(list);
+ let runs_reaching_outside = &self.runs_reaching_outside;
+ let innermost_effect_holding_content_of_several_spaces_at_or_around_by_effect_index =
+ self.innermost_effect_holding_content_of_several_spaces_at_or_around_by_effect_index();
let mut run_blends_with_root_group_by_run_index = vec![false; list.run_count()];
for record in &list.summary().destination_blending_records {
let effect = list.run(record.run_index as usize).context.effect;
@@ -777,6 +938,12 @@ impl<'a> ListBeingPlaced<'a> {
.is_or_is_inside(list.run(run_index as usize).context.effect, root_isolation_effect)
}),
};
+ let effect_of_first_run = list.run(first_run_index as usize).context.effect;
+ let inside_effect_holding_content_of_several_spaces =
+ innermost_effect_holding_content_of_several_spaces_at_or_around_by_effect_index
+ .get(effect_of_first_run.0 as usize)
+ .copied()
+ .filter(|effect| !effect.is_none());
PlacedRunGroup {
raster_space_index,
composite_clips,
@@ -784,19 +951,105 @@ impl<'a> ListBeingPlaced<'a> {
moves_within_space,
paints_within_root_group,
reach_read_by_records_blending_with_root_group,
+ inside_effect_holding_content_of_several_spaces,
}
});
}
+ let node_by_effect_holding_content_of_several_spaces = self
+ .place_nodes_of_effects_holding_content_of_several_spaces(&placed_run_groups, &reach_of_run_by_run_index);
let runs = RunGroupsPlaced {
groups: placed_run_groups,
reach_of_run_by_run_index,
run_moves_within_space_by_run_index,
swept_reach_in_parent_space_by_space_index,
reach_by_effect_index_once_worked_out: std::cell::OnceCell::new(),
+ node_by_effect_holding_content_of_several_spaces,
};
(runs, animations_without_layers)
}
+ // Per effect node, the innermost effect at or around it that holds content of several spaces, or none. Empty where
+ // no effect holds content of several spaces.
+ fn innermost_effect_holding_content_of_several_spaces_at_or_around_by_effect_index(&self) -> Vec<EffectNodeIndex> {
+ let tree = self.tree;
+ if self.effect_holds_content_of_several_spaces_by_effect_index.is_empty() {
+ return Vec::new();
+ }
+ let mut innermost_by_effect_index = vec![EffectNodeIndex::NONE; tree.effect_nodes.len()];
+ tree.visit_effect_nodes_parents_first(|index| {
+ let parent = tree.effect_nodes[index].parent;
+ innermost_by_effect_index[index] = if self.effect_holds_content_of_several_spaces_by_effect_index[index] {
+ EffectNodeIndex(index as u32)
+ } else if parent.is_none() {
+ EffectNodeIndex::NONE
+ } else {
+ innermost_by_effect_index[parent.0 as usize]
+ };
+ });
+ innermost_by_effect_index
+ }
+
+ // The node of each effect that holds content of several spaces is in the lowest space that holds the run groups of
+ // its content, and reaches where that content can show in that space, wherever the spaces inside it take it.
+ fn place_nodes_of_effects_holding_content_of_several_spaces(
+ &self,
+ placed_run_groups: &[PlacedRunGroup],
+ reach_of_run_by_run_index: &[IntRect],
+ ) -> Vec<Option<NodeOfEffectHoldingContentOfSeveralSpaces>> {
+ let (tree, list, tables) = (self.tree, self.list, &self.tables);
+ if self.effect_holds_content_of_several_spaces_by_effect_index.is_empty() {
+ return Vec::new();
+ }
+ let space_of_run =
+ |run_index: usize| placed_run_groups[self.run_groups.group_of_run(run_index).0].raster_space_index;
+ let mut space_by_effect_index: Vec<Option<RasterSpaceIndex>> = vec![None; tree.effect_nodes.len()];
+ for run_index in 0..list.run_count() {
+ let mut effect = list.run(run_index).context.effect;
+ while !effect.is_none() {
+ if self.effect_holds_content_of_several_spaces(effect) {
+ let space = &mut space_by_effect_index[effect.0 as usize];
+ *space = Some(match *space {
+ None => space_of_run(run_index),
+ Some(space) => lowest_common_ancestor_space(tables.spaces(), space, space_of_run(run_index)),
+ });
+ }
+ effect = tree.effect_nodes[effect.0 as usize].parent;
+ }
+ }
+ let mut reach_by_effect_index = vec![IntRect::default(); tree.effect_nodes.len()];
+ for (run_index, &reach_of_run) in reach_of_run_by_run_index.iter().enumerate() {
+ let run = list.run(run_index);
+ if run.ink_bounds.is_empty() {
+ continue;
+ }
+ let mut effect = run.context.effect;
+ while !effect.is_none() {
+ if let Some(space_of_node) = space_by_effect_index[effect.0 as usize] {
+ let reach_in_space_of_node = if space_of_run(run_index) == space_of_node {
+ reach_of_run
+ } else {
+ let geometry = &self.geometries[space_of_node.0];
+ let drawn_within = (!tables.context_moves_within_space(tree, run.context, space_of_node))
+ .then(|| run.ink_bounds.to_float());
+ geometry.part_of_extent_reached_by(geometry.reach_of_content(
+ &self.filters_and_clips,
+ drawn_within,
+ run.context,
+ ))
+ };
+ let reach = &mut reach_by_effect_index[effect.0 as usize];
+ *reach = reach.united(reach_in_space_of_node);
+ }
+ effect = tree.effect_nodes[effect.0 as usize].parent;
+ }
+ }
+ space_by_effect_index
+ .into_iter()
+ .zip(reach_by_effect_index)
+ .map(|(space, reach)| space.map(|space| NodeOfEffectHoldingContentOfSeveralSpaces { space, reach }))
+ .collect()
+ }
+
/// Where content of `space`, whose anchor the compositor animates, can show in the raster coordinates of the space
/// it is in wherever the animation takes it, or why the space holds none of it: content that a frame cannot
/// composite through the anchor's transform, or whose reach nothing bounds, which would cut every tile around it,
@@ -1076,6 +1329,13 @@ impl<'a> ListBeingPlaced<'a> {
why_by_effect_index: vec![None; tree.effect_nodes.len()],
composited_effects: Vec::new(),
};
+ // Every group effect around one of these holds content of several spaces too, and comes before it.
+ for &effect in &self.effects_in_paint_order_with_outer_before_inner {
+ if self.effect_holds_content_of_several_spaces(effect) {
+ why_composited_regardless_of_layer_content
+ .set(effect, WhyEffectIsComposited::ItHoldsContentOfSeveralSpaces);
+ }
+ }
for media in placed_media {
why_composited_regardless_of_layer_content.mark_effects_around_as_composited(
tree,
@@ -1202,7 +1462,7 @@ impl<'a> ListBeingPlaced<'a> {
}
if canvas_or_video_painted_before_can_show_under(
first_run_index,
- self.space_of_run(runs, first_run_index),
+ self.space_of_effect(runs, effect),
self.reach_of_effect(runs, effect),
) {
return Some(WhyAnimationHasNoLayer::ItCanShowOverAnEarlierCanvasOrVideo);
@@ -1318,6 +1578,9 @@ impl<'a> ListBeingPlaced<'a> {
let Some(backdrop_root) = self.backdrop_root_of_reader(reader) else {
continue;
};
+ if self.effect_holds_content_of_several_spaces(backdrop_root) {
+ continue;
+ }
let (backdrop_read_reach, reads_nothing_past_mirrored_edge) =
self.backdrop_read_reach(runs, reader, backdrop_reader);
if !reads_nothing_past_mirrored_edge {
@@ -1438,6 +1701,9 @@ impl<'a> ListBeingPlaced<'a> {
let backdrop_root = self.backdrop_root_of_reader(effect);
let why_composited = if !reads_nothing_past_mirrored_edge {
Some(WhyEffectIsComposited::ItsBackdropFilterReadsPastTheEdgeOfTheFrame)
+ } else if backdrop_root.is_some_and(|root| self.effect_holds_content_of_several_spaces(root)) {
+ // Its backdrop is in nodes of several spaces.
+ Some(WhyEffectIsComposited::ItReadsWhatItsOwnLayerDoesNotHold)
} else if let Some(backdrop_root) = backdrop_root {
let backdrop_read_tiles = match backdrop_read_reach {
Reach::Within(rect) => Reach::Within(CellRange::touched_by(rect).rect()),
@@ -1535,6 +1801,8 @@ impl<'a> ListBeingPlaced<'a> {
reach: self.reach_of_effect(runs, effect),
backdrop_read_reach: backdrop_read_reach_by_effect_index[effect.0 as usize],
why_composited_regardless_of_layer_content,
+ space_of_node_holding_content_of_several_spaces:
+ Self::node_of_effect_holding_content_of_several_spaces(runs, effect).map(|node| node.space),
});
}
(placed_effects, innermost_placed_effect_at_or_around_by_effect_index)
@@ -1578,10 +1846,17 @@ impl<'a> ListBeingPlaced<'a> {
}
let run_span = list.span_of_run(run_index);
let run_draws_nothing = list.run(run_index).ink_bounds.is_empty();
+ // The reach of an effect holding content of several spaces is in the space of its node.
let reach_of_run_in_stretch = match innermost_placed_effect {
_ if run_draws_nothing => IntRect::default(),
- Some(placed_effect_index) => placed_effects[placed_effect_index.0].reach,
- None => runs.reach_of_run_by_run_index[run_index],
+ Some(placed_effect_index)
+ if placed_effects[placed_effect_index.0]
+ .space_of_node_holding_content_of_several_spaces
+ .is_none() =>
+ {
+ placed_effects[placed_effect_index.0].reach
+ }
+ _ => runs.reach_of_run_by_run_index[run_index],
};
match record_stretches.last_mut() {
Some(last)
@@ -1678,6 +1953,7 @@ struct StackBeingBuilt<'a> {
/// Per placed effect, once decided, the node the compositor composites it in, if it composites it.
composited_node_once_decided_by_placed_effect: Vec<Option<Option<PlacementNodeIndex>>>,
composited_effects_around_node_by_node_index: Vec<usize>,
+ innermost_composited_node_around_by_node_index: Vec<Option<PlacementNodeIndex>>,
}
impl StackBeingBuilt<'_> {
@@ -1688,6 +1964,15 @@ impl StackBeingBuilt<'_> {
});
self.composited_effects_around_node_by_node_index
.push(composited_effects_around_parent + usize::from(node.composited_effect.is_some()));
+ let innermost_composited_node_around = parent_index.and_then(|parent_index| {
+ if self.nodes[parent_index.0].composited_effect.is_some() {
+ Some(parent_index)
+ } else {
+ self.innermost_composited_node_around_by_node_index[parent_index.0]
+ }
+ });
+ self.innermost_composited_node_around_by_node_index
+ .push(innermost_composited_node_around);
self.nodes.push(node);
self.children_of_node.push(Vec::new());
let node_index = PlacementNodeIndex(self.nodes.len() - 1);
@@ -1697,20 +1982,40 @@ impl StackBeingBuilt<'_> {
node_index
}
- fn find_or_add_node(
+ // The node of the space composited within the clips inside the composited node `container`, or outside every
+ // composited node where there is none, with the nodes of the spaces between them. The space of a container holds
+ // the space of each node inside it.
+ fn find_or_add_node_inside(
&mut self,
+ container: Option<PlacementNodeIndex>,
raster_space_index: RasterSpaceIndex,
composite_clips: &[CompositeClip],
) -> PlacementNodeIndex {
- if let Some(existing_node_index) = self.nodes.iter().position(|node| {
+ let space_of_container = container.map(|container| self.nodes[container.0].raster_space_index);
+ if let Some(container) = container
+ && space_of_container == Some(raster_space_index)
+ && self.nodes[container.0].composite_clips == composite_clips
+ {
+ return container;
+ }
+ if let Some(existing_node_index) = (0..self.nodes.len()).find(|&index| {
+ let node = &self.nodes[index];
node.raster_space_index == raster_space_index
&& node.composite_clips == composite_clips
&& node.composited_effect.is_none()
+ && self.innermost_composited_node_around_by_node_index[index] == container
}) {
return PlacementNodeIndex(existing_node_index);
}
let spaces = self.spaces;
- let (parent_index, reach_in_parent_node) = if raster_space_index == RasterSpaceIndex::VIEWPORT {
+ let (parent_index, reach_in_parent_node) = if space_of_container == Some(raster_space_index) {
+ // Composited within clips the container is not.
+ (container, Reach::Anywhere)
+ } else if raster_space_index == RasterSpaceIndex::VIEWPORT {
+ debug_assert!(
+ container.is_none(),
+ "the space of a container holds the spaces of the nodes inside it"
+ );
(None, Reach::Anywhere)
} else {
let parent_space = spaces[raster_space_index.0].parent_index;
@@ -1724,7 +2029,7 @@ impl StackBeingBuilt<'_> {
.copied()
.collect();
(
- Some(self.find_or_add_node(parent_space, &composite_clips_of_parent_node)),
+ Some(self.find_or_add_node_inside(container, parent_space, &composite_clips_of_parent_node)),
reach_in_parent_node,
)
};
@@ -1754,6 +2059,36 @@ impl StackBeingBuilt<'_> {
self.add_node(composited_node)
}
+ // The composited node of a placed effect that holds content of several spaces, in the node of its space inside the
+ // node of the one around it, if there is one. Each is added before the stack is cut into bands.
+ fn node_of_effect_holding_content_of_several_spaces(
+ &mut self,
+ placed_effect_index: PlacedEffectIndex,
+ ) -> Result<PlacementNodeIndex, WhyListIsOneLayer> {
+ if let Some(Some(node_index)) = self.composited_node_once_decided_by_placed_effect[placed_effect_index.0] {
+ return Ok(node_index);
+ }
+ let placed_effect = self.placement.placed_effects[placed_effect_index.0];
+ let space = placed_effect
+ .space_of_node_holding_content_of_several_spaces
+ .expect("the effect holds content of several spaces");
+ // Every placed effect around it holds content of several spaces too.
+ let container = match placed_effect.placed_effect_around_index {
+ Some(placed_effect_around_index) => {
+ Some(self.node_of_effect_holding_content_of_several_spaces(placed_effect_around_index)?)
+ }
+ None => None,
+ };
+ let parent_index = self.find_or_add_node_inside(container, space, &[]);
+ if self.composited_effects_around_node_by_node_index[parent_index.0] >= MAXIMUM_NESTING_OF_COMPOSITED_EFFECTS {
+ return Err(WhyListIsOneLayer::CompositedEffectsNestTooDeep);
+ }
+ let draw_and_read_reach = self.draw_and_read_reach_of_placed_effect(placed_effect_index);
+ let node_index = self.add_composited_node_inside(parent_index, placed_effect.effect, draw_and_read_reach);
+ self.composited_node_once_decided_by_placed_effect[placed_effect_index.0] = Some(Some(node_index));
+ Ok(node_index)
+ }
+
fn placed_effects_around_stretch_outermost_first(&self, stretch: &PlacedRecordStretch) -> Vec<PlacedEffectIndex> {
let mut placed_effects_around_stretch: Vec<PlacedEffectIndex> =
std::iter::successors(stretch.placed_effect_index, |&placed_effect_index| {
@@ -1795,6 +2130,10 @@ impl StackBeingBuilt<'_> {
for node_index in (0..self.nodes.len()).rev() {
let node = &mut self.nodes[node_index];
if node.composited_effect.is_some() {
+ if let Some(parent_index) = node.parent_index {
+ content_reach_by_node_index[parent_index.0] =
+ content_reach_by_node_index[parent_index.0].united(node.reach_in_parent_node);
+ }
continue;
}
if let Some(Some(swept_reach)) = swept_reach_in_parent_space_by_space_index.get(node.raster_space_index.0) {
@@ -1953,6 +2292,12 @@ impl StackBeingBuilt<'_> {
) -> Result<PlacementNodeIndex, WhyListIsOneLayer> {
let mut node_index = self.node_of_run_group[stretch.run_group_index.0];
for placed_effect_index in self.placed_effects_around_stretch_outermost_first(stretch) {
+ if self.placement.placed_effects[placed_effect_index.0]
+ .space_of_node_holding_content_of_several_spaces
+ .is_some()
+ {
+ continue;
+ }
let composited_node_index = match self.composited_node_once_decided_by_placed_effect[placed_effect_index.0]
{
Some(composited_node_index) => composited_node_index,
@@ -2222,13 +2567,32 @@ fn assemble_plan(
bands_being_built: Vec::new(),
composited_node_once_decided_by_placed_effect: vec![None; placement.placed_effects.len()],
composited_effects_around_node_by_node_index: Vec::new(),
+ innermost_composited_node_around_by_node_index: Vec::new(),
};
- stack_being_built.find_or_add_node(RasterSpaceIndex::VIEWPORT, &[]);
- stack_being_built.node_of_run_group = placement
- .run_groups
- .iter()
- .map(|run_group| stack_being_built.find_or_add_node(run_group.raster_space_index, &run_group.composite_clips))
- .collect();
+ stack_being_built.find_or_add_node_inside(None, RasterSpaceIndex::VIEWPORT, &[]);
+ let placed_effect_index_by_effect_holding_content_of_several_spaces: HashMap<EffectNodeIndex, PlacedEffectIndex> =
+ placement
+ .placed_effects
+ .iter()
+ .enumerate()
+ .filter(|(_, placed_effect)| placed_effect.space_of_node_holding_content_of_several_spaces.is_some())
+ .map(|(index, placed_effect)| (placed_effect.effect, PlacedEffectIndex(index)))
+ .collect();
+ let mut node_of_run_group = Vec::with_capacity(placement.run_groups.len());
+ for run_group in &placement.run_groups {
+ let container = match run_group.inside_effect_holding_content_of_several_spaces {
+ Some(effect) => Some(stack_being_built.node_of_effect_holding_content_of_several_spaces(
+ placed_effect_index_by_effect_holding_content_of_several_spaces[&effect],
+ )?),
+ None => None,
+ };
+ node_of_run_group.push(stack_being_built.find_or_add_node_inside(
+ container,
+ run_group.raster_space_index,
+ &run_group.composite_clips,
+ ));
+ }
+ stack_being_built.node_of_run_group = node_of_run_group;
stack_being_built.limit_reach_of_moving_space_nodes_to_content_swept_over_how_they_move(
&swept_reach_in_parent_space_by_space_index,
);
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning/placement_tables.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning/placement_tables.rs
index fae7ff5a73f..671f0edb7e0 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning/placement_tables.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning/placement_tables.rs
@@ -96,6 +96,10 @@ pub(super) struct PlacementTables {
deepest_space_and_backdrop_filter_read_rect_by_effect: Vec<Option<(RasterSpaceIndex, IntRect)>>,
animated_space_holding_every_run_of_effect: Vec<Option<RasterSpaceIndex>>,
refused_animated_spaces: RefCell<Vec<bool>>,
+ /// Per effect node, whether the compositor composites it around content it keeps in several spaces, so that it
+ /// neither keeps its content out of spaces deeper than its own nor moves that content within a space. Empty where
+ /// no effect is.
+ effect_is_composited_around_content_of_several_spaces_by_effect_index: Vec<bool>,
cached_composite_clips_of_contexts:
RefCell<HashMap<(ContextRef, RasterSpaceIndex), CompositeClipsOfContextInSpace>>,
}
@@ -197,10 +201,25 @@ impl PlacementTables {
deepest_space_and_backdrop_filter_read_rect_by_effect,
animated_space_holding_every_run_of_effect: Vec::new(),
refused_animated_spaces: RefCell::new(vec![false; spaces_len]),
+ effect_is_composited_around_content_of_several_spaces_by_effect_index: Vec::new(),
cached_composite_clips_of_contexts: RefCell::new(HashMap::new()),
}
}
+ /// Notes the effects the compositor composites around content it keeps in several spaces. Where content goes then
+ /// changes, so this forgets what was worked out of it.
+ pub fn note_effects_composited_around_content_of_several_spaces(&mut self, marks_by_effect_index: Vec<bool>) {
+ self.effect_is_composited_around_content_of_several_spaces_by_effect_index = marks_by_effect_index;
+ self.cached_composite_clips_of_contexts.borrow_mut().clear();
+ }
+
+ fn effect_is_composited_around_content_of_several_spaces(&self, effect: EffectNodeIndex) -> bool {
+ self.effect_is_composited_around_content_of_several_spaces_by_effect_index
+ .get(effect.0 as usize)
+ .copied()
+ .unwrap_or(false)
+ }
+
/// Notes, per effect node, the space whose anchor the compositor animates that holds every run of the list under
/// the effect, if one does: content of that space can be placed in it under such an effect although the effect
/// does not move with the space, as the compositor composites the effect around the space's rasters.
@@ -325,6 +344,10 @@ impl PlacementTables {
let mut effect = context.effect;
while !effect.is_none() {
let node = &tree.effect_nodes[effect.0 as usize];
+ if self.effect_is_composited_around_content_of_several_spaces(effect) {
+ effect = node.parent;
+ continue;
+ }
match self.placement_constraint_of_effects[effect.0 as usize] {
EffectPlacementConstraint::ConstrainsNothing => {}
constraint => {
@@ -445,7 +468,10 @@ impl PlacementTables {
let mut effect = context.effect;
while !effect.is_none() {
let node = &tree.effect_nodes[effect.0 as usize];
- if tree.root_isolation_effect != Some(effect) && moves_within_space(node.spatial) {
+ if tree.root_isolation_effect != Some(effect)
+ && !self.effect_is_composited_around_content_of_several_spaces(effect)
+ && moves_within_space(node.spatial)
+ {
return true;
}
effect = node.parent;
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
index 2375633f85a..d9e6b9e6a0c 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
@@ -625,16 +625,18 @@ fn check_nodes(
if node.parent_index.is_some_and(|parent_index| parent_index.0 >= index) {
return Err("a node is not after the node it is in");
}
- // A node that is not composited is in the node of the space its space is in, and a composited node is in a node
- // of its own space. So nodes nest no deeper than spaces, plus composited effects, which nest as the tree nests
- // them.
+ // A node that is not composited is in the node of the space its space is in, or in a composited node of its own
+ // space, composited within clips the composited node is not. A composited node is in a node of its own space.
+ // So nodes nest no deeper than twice the spaces, plus composited effects, which nest as the tree nests them.
let parent = node.parent_index.map(|parent_index| &nodes[parent_index.0]);
let is_in_node_a_plan_puts_it_in = match (node.composited_effect, parent) {
(None, None) => node.raster_space_index == RasterSpaceIndex::VIEWPORT,
(None, Some(parent)) => {
- node.raster_space_index != RasterSpaceIndex::VIEWPORT
- && parent.composited_effect.is_none()
- && parent.raster_space_index == spaces[node.raster_space_index.0].parent_index
+ (node.raster_space_index != RasterSpaceIndex::VIEWPORT
+ && parent.raster_space_index == spaces[node.raster_space_index.0].parent_index)
+ || (parent.composited_effect.is_some()
+ && parent.raster_space_index == node.raster_space_index
+ && parent.composite_clips != node.composite_clips)
}
(Some(_), Some(parent)) => parent.raster_space_index == node.raster_space_index,
(Some(_), None) => return Err("a composited node is in no other node"),
diff --git a/Libraries/LibCompositing/Rust/src/display_list/placement.rs b/Libraries/LibCompositing/Rust/src/display_list/placement.rs
index ea71f1d881c..8f86e62c956 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/placement.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/placement.rs
@@ -1178,8 +1178,13 @@ pub struct RunGroups {
group_is_sorted_by_depth: Vec<bool>,
}
-// By the tree's structure rather than effect values, so that groups stay put while an opacity animates.
-fn outermost_grouping_effects(tree: &VisualContextTree) -> Vec<EffectNodeIndex> {
+// By the tree's structure rather than effect values, so that groups stay put while an opacity animates. An effect that
+// `effect_leaves_its_runs_ungrouped_by_effect_index` marks groups nothing, which holds only where no effect around it
+// groups.
+fn outermost_grouping_effects(
+ tree: &VisualContextTree,
+ effect_leaves_its_runs_ungrouped_by_effect_index: &[bool],
+) -> Vec<EffectNodeIndex> {
let mut outermost_grouping_effect_of_effect = vec![EffectNodeIndex::NONE; tree.effect_nodes.len()];
tree.visit_effect_nodes_parents_first(|index| {
let node = &tree.effect_nodes[index];
@@ -1188,7 +1193,13 @@ fn outermost_grouping_effects(tree: &VisualContextTree) -> Vec<EffectNodeIndex>
} else {
outermost_grouping_effect_of_effect[node.parent.0 as usize]
};
- let is_grouping = node.data.pushes_layer() && tree.root_isolation_effect != Some(EffectNodeIndex(index as u32));
+ let leaves_its_runs_ungrouped = effect_leaves_its_runs_ungrouped_by_effect_index
+ .get(index)
+ .copied()
+ .unwrap_or(false);
+ let is_grouping = node.data.pushes_layer()
+ && tree.root_isolation_effect != Some(EffectNodeIndex(index as u32))
+ && !leaves_its_runs_ungrouped;
outermost_grouping_effect_of_effect[index] = if !outermost_of_parent.is_none() {
outermost_of_parent
} else if is_grouping {
@@ -1244,10 +1255,21 @@ impl RunGroups {
pub fn new<'a>(
tree: &VisualContextTree,
command_runs: impl IntoIterator<Item = &'a DisplayListCommandRun>,
+ ) -> Self {
+ Self::new_leaving_runs_of_effects_ungrouped(tree, command_runs, &[])
+ }
+
+ /// As `new`, but the runs of each effect that `effect_leaves_its_runs_ungrouped_by_effect_index` marks are grouped
+ /// only as the effects inside it group them. No effect around a marked effect may group its runs.
+ pub fn new_leaving_runs_of_effects_ungrouped<'a>(
+ tree: &VisualContextTree,
+ command_runs: impl IntoIterator<Item = &'a DisplayListCommandRun>,
+ effect_leaves_its_runs_ungrouped_by_effect_index: &[bool],
) -> Self {
let roots_of_contexts_sorting_planes_by_depth = tree.roots_of_contexts_sorting_planes_by_depth();
let mut sorting_context_of_run = Vec::new();
- let outermost_grouping_effects = outermost_grouping_effects(tree);
+ let outermost_grouping_effects =
+ outermost_grouping_effects(tree, effect_leaves_its_runs_ungrouped_by_effect_index);
let mut effect_chain_holds_mask = vec![false; tree.effect_nodes.len()];
tree.visit_effect_nodes_parents_first(|index| {
let node = &tree.effect_nodes[index];
diff --git a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
index 6e59c067b4e..22645522116 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
@@ -22,9 +22,7 @@ use super::effect_geometry::{
FiltersOfEffects, LARGEST_FILTER_READ_REACH_IN_DEVICE_PIXELS, backdrop_filter_read_reach,
filter_read_reach_in_device_pixels, nearest_effects_at_or_above_where, spreading_filter_of,
};
-use super::layers::{
- BandIndex, BarrierCutsOfCell, CutsOfCell, LayerContent, LayerIndex, LayerStack, PlacementNodeBand,
-};
+use super::layers::{BandIndex, BarrierCutsOfCell, CutsOfCell, LayerContent, LayerIndex, LayerStack};
use super::nested_records::for_each_command_including_nested;
use super::placement::{
ANTIALIASING_MARGIN_IN_DEVICE_PIXELS, FiltersAndClipsOfList, RasterSpaceGeometry, RunGroupIndex, RunGroups,
@@ -1783,7 +1781,7 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
return self.band_replaying_every_held_record_in_every_tile(&held_offset_ranges_by_chunk);
}
let held_chunks = self.held_chunks_with_their_placements(held_offset_ranges_by_chunk);
- let backdrop_reads = self.backdrop_reads_of_held_runs(stack, band, &held_chunks);
+ let backdrop_reads = self.backdrop_reads_of_held_runs(stack, band_index, &held_chunks);
let (runs_replayed_whole, masks_with_declared_content) =
self.runs_replayed_whole(&held_chunks, &backdrop_reads);
let held_runs_read_frame_state_hashed_for_the_list = held_chunks.iter().any(|held_chunk| {
@@ -1919,13 +1917,13 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
fn backdrop_reads_of_held_runs(
&self,
stack: &LayerStack,
- band: &PlacementNodeBand,
+ band_index: BandIndex,
held_chunks: &[ChunkHeldByBand],
) -> BackdropReadsOfBand {
let display_list = self.list.display_list;
let tree = self.list.tree;
- let effect_composited_around_band = stack.nodes[band.placement_node_index.0]
- .composited_effect
+ let effect_composited_around_band = stack
+ .innermost_composited_effect_at_or_around_band(band_index)
.unwrap_or(EffectNodeIndex::NONE);
let mut effect_was_visited = vec![false; tree.effect_nodes.len()];
let mut backdrop_reads_in_paint_order = Vec::new();
diff --git a/Services/Compositor/Rust/src/presenting/layers.rs b/Services/Compositor/Rust/src/presenting/layers.rs
index b487fb4c1e0..b5009da40ed 100644
--- a/Services/Compositor/Rust/src/presenting/layers.rs
+++ b/Services/Compositor/Rust/src/presenting/layers.rs
@@ -1692,7 +1692,7 @@ impl ContextPresenting {
record_spans,
clips_left_to_composite: (!geometry.clips_left_to_composite.is_empty())
.then_some(&geometry.clips_left_to_composite[..]),
- composited_effect: stack.nodes[layer.placement_node_index.0].composited_effect,
+ composited_effect: stack.innermost_composited_effect_at_or_around_band(layer.band_index),
allows_lcd_text,
frame_edge_backdrop_blurs_mirror_at: frame_rect_in_layer_space.map(IntRect::to_float),
raster_root: stack.spaces[raster_space_index.0].raster_root(),
diff --git a/Tests/LibWeb/Ref/expected/iframe-fixed-blend-in-isolated-group-over-scrolled-content-ref.html b/Tests/LibWeb/Ref/expected/iframe-fixed-blend-in-isolated-group-over-scrolled-content-ref.html
new file mode 100644
index 00000000000..1d55fb9931b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/iframe-fixed-blend-in-isolated-group-over-scrolled-content-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<style>
+ iframe { display: block; width: 200px; height: 150px; border: 0; }
+</style>
+<iframe></iframe>
+<script>
+ const iframe = document.querySelector("iframe");
+ iframe.srcdoc = `<!DOCTYPE html>
+ <style>
+ body { margin: 0; height: 1000px; background: white; }
+ main { position: relative; z-index: 1; height: 600px; background: navy; }
+ .stripe { position: absolute; left: 0; width: 200px; height: 30px; background: lime; }
+ #nav { position: absolute; left: 20px; top: 125px; width: 100px; height: 40px; background: orange; mix-blend-mode: difference; }
+ </style>
+ <main>
+ <div class="stripe" style="top: 120px"></div>
+ <div class="stripe" style="top: 160px"></div>
+ <div id="nav"></div>
+ </main>`;
+ const frame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ window.onload = async () => {
+ await frame();
+ await frame();
+ iframe.contentWindow.scrollTo(0, 115);
+ await frame();
+ await frame();
+ document.documentElement.classList.remove("reftest-wait");
+ };
+</script>
diff --git a/Tests/LibWeb/Ref/expected/iframe-opacity-group-holding-scrolled-nested-scroller-ref.html b/Tests/LibWeb/Ref/expected/iframe-opacity-group-holding-scrolled-nested-scroller-ref.html
new file mode 100644
index 00000000000..70e7be5751c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/iframe-opacity-group-holding-scrolled-nested-scroller-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+ iframe { display: block; width: 200px; height: 150px; border: 0; }
+</style>
+<iframe srcdoc="<!DOCTYPE html>
+ <style>
+ body { margin: 0; }
+ #card { opacity: 0.5; width: 160px; padding: 10px; background: navy; }
+ #nested { height: 100px; overflow: clip; background: white; }
+ .stripe { height: 40px; background: orange; }
+ </style>
+ <div id='card'>
+ <div id='nested'>
+ <div style='position: relative; top: -25px'>
+ <div class='stripe'></div>
+ <div style='height: 30px'></div>
+ <div class='stripe'></div>
+ </div>
+ </div>
+ </div>"></iframe>
diff --git a/Tests/LibWeb/Ref/input/iframe-fixed-blend-in-isolated-group-over-scrolled-content.html b/Tests/LibWeb/Ref/input/iframe-fixed-blend-in-isolated-group-over-scrolled-content.html
new file mode 100644
index 00000000000..604aa77a4e4
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/iframe-fixed-blend-in-isolated-group-over-scrolled-content.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<link rel="match" href="../expected/iframe-fixed-blend-in-isolated-group-over-scrolled-content-ref.html">
+<style>
+ iframe { display: block; width: 200px; height: 150px; border: 0; }
+</style>
+<iframe></iframe>
+<script>
+ const iframe = document.querySelector("iframe");
+ iframe.srcdoc = `<!DOCTYPE html>
+ <style>
+ body { margin: 0; height: 1000px; background: white; }
+ main { position: relative; z-index: 1; height: 600px; background: navy; }
+ .stripe { position: absolute; left: 0; width: 200px; height: 30px; background: lime; }
+ #nav { position: fixed; left: 20px; top: 10px; width: 100px; height: 40px; background: orange; mix-blend-mode: difference; }
+ </style>
+ <main>
+ <div class="stripe" style="top: 120px"></div>
+ <div class="stripe" style="top: 160px"></div>
+ <div id="nav"></div>
+ </main>`;
+ const frame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ window.onload = async () => {
+ await frame();
+ await frame();
+ // The fixed box stays over the stripes as the document under it scrolls, and blends with them alone.
+ iframe.contentWindow.scrollTo(0, 115);
+ await frame();
+ await frame();
+ if (window.internals)
+ internals.signalTestIsDone("PASS");
+ else
+ document.documentElement.classList.remove("reftest-wait");
+ };
+</script>
diff --git a/Tests/LibWeb/Ref/input/iframe-opacity-group-holding-scrolled-nested-scroller.html b/Tests/LibWeb/Ref/input/iframe-opacity-group-holding-scrolled-nested-scroller.html
new file mode 100644
index 00000000000..91255cfc2b7
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/iframe-opacity-group-holding-scrolled-nested-scroller.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<link rel="match" href="../expected/iframe-opacity-group-holding-scrolled-nested-scroller-ref.html">
+<meta name="fuzzy" content="maxDifference=0-1;totalPixels=0-30000">
+<style>
+ iframe { display: block; width: 200px; height: 150px; border: 0; }
+</style>
+<iframe></iframe>
+<script>
+ const iframe = document.querySelector("iframe");
+ iframe.srcdoc = `<!DOCTYPE html>
+ <style>
+ body { margin: 0; }
+ #card { opacity: 0.5; width: 160px; padding: 10px; background: navy; }
+ #nested { height: 100px; overflow: auto; scrollbar-width: none; background: white; }
+ .stripe { height: 40px; background: orange; }
+ </style>
+ <div id="card">
+ <div id="nested">
+ <div class="stripe"></div>
+ <div style="height: 30px"></div>
+ <div class="stripe"></div>
+ <div style="height: 200px"></div>
+ </div>
+ </div>`;
+ const frame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ window.onload = async () => {
+ await frame();
+ await frame();
+ // The scrolled content keeps a space of its own inside the translucent group.
+ iframe.contentDocument.getElementById("nested").scrollTop = 25;
+ await frame();
+ await frame();
+ if (window.internals)
+ internals.signalTestIsDone("PASS");
+ else
+ document.documentElement.classList.remove("reftest-wait");
+ };
+</script>
diff --git a/Tests/LibWeb/Text/expected/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.txt b/Tests/LibWeb/Text/expected/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.txt
new file mode 100644
index 00000000000..b3adfb50efd
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.txt
@@ -0,0 +1,7 @@
+Layers (for a window server that shows tiles and filters what is below layers):
+ [L0] base space=viewport held by the frame: it is under a layer the frame holds
+ [L2] painted space=document inside e1 held by the frame: it is under a layer the frame holds
+ [L4] painted space=viewport inside e2 inside e1 held by the frame: it is inside an effect the compositor composites
+ composited e1 space=viewport: it holds content of several spaces, can be composited by the window server
+ composited e2 space=viewport inside e1 reads=[0,7 63x26]: it reads what its own layer does not hold, composited by the compositor: it blends with what is below it
+
diff --git a/Tests/LibWeb/Text/expected/display_list/compositing-layers-opacity-group-holding-nested-scroller.txt b/Tests/LibWeb/Text/expected/display_list/compositing-layers-opacity-group-holding-nested-scroller.txt
new file mode 100644
index 00000000000..11326fb063b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/display_list/compositing-layers-opacity-group-holding-nested-scroller.txt
@@ -0,0 +1,8 @@
+Layers (for a window server that shows tiles and filters what is below layers):
+ [L0] base space=viewport
+ [L2] painted space=document inside e1
+ [L3] painted space=scroller@s2 in document inside e1 composited within [20,20 300x100] of document
+ [L4] painted space=document inside e1 above band 0 of scroller@s2 in document inside e1
+ composited e1 space=document: it holds content of several spaces, can be composited by the window server
+ no layer for vertical scroll bar: inside an effect that pushes a layer at replay
+
diff --git a/Tests/LibWeb/Text/input/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.html b/Tests/LibWeb/Text/input/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.html
new file mode 100644
index 00000000000..3edb5a2d0f9
--- /dev/null
+++ b/Tests/LibWeb/Text/input/display_list/compositing-layers-fixed-blend-in-isolated-group-over-scrolling-content.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ @font-face {
+ font-family: Ahem;
+ src: url("../../../Ref/data/fonts/Ahem.ttf");
+ }
+
+ body {
+ margin: 0;
+ height: 3000px;
+ font: 20px/40px Ahem;
+ }
+
+ main {
+ position: relative;
+ z-index: 1;
+ background: navy;
+ }
+
+ section {
+ height: 500px;
+ color: white;
+ }
+
+ #fixed-blending-nav {
+ position: fixed;
+ left: 0;
+ top: 0;
+ height: 40px;
+ color: orange;
+ mix-blend-mode: difference;
+ }
+</style>
+<main>
+ <section>Text of the first section</section>
+ <section>Text of the second section</section>
+ <div id="fixed-blending-nav">Nav</div>
+</main>
+<script>
+ promiseTest(async () => {
+ await document.fonts.ready;
+ println("Layers" + internals.dumpDisplayList().split("\nDisplayList:")[0].split("\nLayers")[1]);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/display_list/compositing-layers-opacity-group-holding-nested-scroller.html b/Tests/LibWeb/Text/input/display_list/compositing-layers-opacity-group-holding-nested-scroller.html
new file mode 100644
index 00000000000..2cd67c8b2b1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/display_list/compositing-layers-opacity-group-holding-nested-scroller.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body {
+ margin: 0;
+ height: 3000px;
+ }
+
+ #translucent-card {
+ opacity: 0.5;
+ width: 300px;
+ padding: 20px;
+ background: navy;
+ }
+
+ #nested-scroller {
+ height: 100px;
+ overflow: auto;
+ background: white;
+ }
+
+ #nested-scroller div {
+ height: 400px;
+ background: linear-gradient(orange, purple);
+ }
+</style>
+<div id="translucent-card">
+ <div id="nested-scroller"><div></div></div>
+</div>
+<script>
+ test(() => {
+ println("Layers" + internals.dumpDisplayList().split("\nDisplayList:")[0].split("\nLayers")[1]);
+ });
+</script>