Skip to content

Truly independent web browser

LibWeb: Keep the paint state of the layout arena plain

Aliaksandr Kalenike025b8446c78
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index fc131fbd240..2cc53f2b224 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -1265,7 +1265,7 @@ pub(crate) struct LayoutNodeArena {
memo_invalidations: super::memo_invalidations::MemoInvalidations,
pub(super) layout_trace: super::trace::TraceRecord,
pub(crate) paintable_rows: crate::painting::paintable_rows::PaintableRowStore,
- paint_state: RefCell<crate::painting::paint_state::PaintState>,
+ paint_state: crate::painting::paint_state::PaintState,
// Hit testing can measure overflow and invalidate painting state while querying this list.
// Reuse workspace allocations without making recording scratch part of the committed paint state.
pub(crate) scrollable_overflow: crate::painting::scrollable_overflow::ScrollableOverflowState,
@@ -1380,7 +1380,7 @@ impl LayoutNodeArena {
memo_invalidations: Default::default(),
layout_trace: super::trace::TraceRecord::default(),
paintable_rows: crate::painting::paintable_rows::PaintableRowStore::default(),
- paint_state: RefCell::new(crate::painting::paint_state::PaintState::default()),
+ paint_state: crate::painting::paint_state::PaintState::default(),
scrollable_overflow: Default::default(),
partial_relayout_boundary_roots: Default::default(),
nodes_with_layout_update_flags: Vec::new(),
@@ -1773,7 +1773,7 @@ impl LayoutNodeArena {
}
self.svg_paint_resources.forget_slot(id);
for highlight in crate::painting::selection::HighlightPseudoElement::ALL {
- let styles = self.paint_state.get_mut().highlight_pseudo_styles_mut(highlight);
+ let styles = self.paint_state.highlight_pseudo_styles_mut(highlight);
if styles.contains_key(&id) {
Arc::make_mut(styles).remove(&id);
}
@@ -2309,11 +2309,8 @@ impl LayoutNodeArena {
/// The scroll state reads the offsets the rows hold, so it is read again before it is published next whenever one
/// of them moves.
- fn note_scroll_offsets_moved(&self) {
- self.paint_state()
- .borrow_mut()
- .visual_context
- .needs_to_refresh_scroll_state = true;
+ fn note_scroll_offsets_moved(&mut self) {
+ self.paint_state_mut().visual_context.needs_to_refresh_scroll_state = true;
}
/// Record whether the node sits in the user agent shadow tree of the focused text control.
@@ -2625,7 +2622,7 @@ impl LayoutNodeArena {
/// Notes the visual contexts a style move with `damage`, an `FfiStyleInvalidationField` word, moves for `slot`'s
/// box, which the next recording builds again: those up to the level the word carries, and the nodes of the box's
/// stacking context where the move rebuilds it, as a z-index change does alone.
- pub(crate) fn note_style_visual_context_moves(&self, slot: NodeSlotId, damage: u32) {
+ pub(crate) fn note_style_visual_context_moves(&mut self, slot: NodeSlotId, damage: u32) {
use crate::css::style::bridge::FfiStyleInvalidationField;
use crate::painting::visual_context::dirty::VisualContextBoxDirtyKind;
let visual_contexts = (damage >> FfiStyleInvalidationField::VisualContextShift as u32)
@@ -4449,7 +4446,6 @@ impl LayoutNodeArena {
self.svg_paint_resources.address(),
self.image_map_areas().address(),
self.paint_state
- .borrow()
.visual_context
.tree
.as_ref()
@@ -5807,10 +5803,14 @@ impl LayoutNodeArena {
child_data.set_next_sibling(NodeSlotId::INVALID);
}
- pub(crate) fn paint_state(&self) -> &RefCell<crate::painting::paint_state::PaintState> {
+ pub(crate) fn paint_state(&self) -> &crate::painting::paint_state::PaintState {
&self.paint_state
}
+ pub(crate) fn paint_state_mut(&mut self) -> &mut crate::painting::paint_state::PaintState {
+ &mut self.paint_state
+ }
+
pub(crate) fn node_data_if_live(&self, id: NodeSlotId) -> Option<&NodeData> {
if !self.slot_is_live(id) {
return None;
@@ -7229,8 +7229,8 @@ mod tests {
let positioned = arena.allocate_for_test();
let anchor = arena.allocate_for_test();
let other_anchor = arena.allocate_for_test();
- let take_dirty_bits = |arena: &LayoutNodeArena| -> Option<BoxDirtyBits> {
- let mut paint_state = arena.paint_state().borrow_mut();
+ let take_dirty_bits = |arena: &mut LayoutNodeArena| -> Option<BoxDirtyBits> {
+ let paint_state = arena.paint_state_mut();
let bits = paint_state
.visual_context
.dirty_boxes
@@ -7240,25 +7240,25 @@ mod tests {
paint_state.visual_context.dirty_boxes.clear();
bits
};
- let notes_scroll_shift_change = |arena: &LayoutNodeArena| {
+ let notes_scroll_shift_change = |arena: &mut LayoutNodeArena| {
take_dirty_bits(arena)
.is_some_and(|bits| bits.contains(VisualContextBoxDirtyKind::DefaultScrollShiftInputsChanged))
};
arena.set_default_scroll_shift(positioned.slot, NodeSlotId::INVALID, false, false);
- assert!(!notes_scroll_shift_change(&arena));
+ assert!(!notes_scroll_shift_change(&mut arena));
arena.set_default_scroll_shift(positioned.slot, anchor.slot, true, false);
- assert!(notes_scroll_shift_change(&arena));
+ assert!(notes_scroll_shift_change(&mut arena));
arena.set_default_scroll_shift(positioned.slot, anchor.slot, true, false);
- assert!(!notes_scroll_shift_change(&arena));
+ assert!(!notes_scroll_shift_change(&mut arena));
arena.set_default_scroll_shift(positioned.slot, anchor.slot, true, true);
- assert!(notes_scroll_shift_change(&arena));
+ assert!(notes_scroll_shift_change(&mut arena));
arena.set_default_scroll_shift(positioned.slot, other_anchor.slot, true, true);
- assert!(notes_scroll_shift_change(&arena));
+ assert!(notes_scroll_shift_change(&mut arena));
arena.set_default_scroll_shift(positioned.slot, NodeSlotId::INVALID, false, false);
- assert!(notes_scroll_shift_change(&arena));
+ assert!(notes_scroll_shift_change(&mut arena));
let mut anchored_pairs = Vec::new();
arena.set_default_scroll_shift(positioned.slot, anchor.slot, false, true);
diff --git a/Libraries/LibWeb/Rust/src/layout/row_reads.rs b/Libraries/LibWeb/Rust/src/layout/row_reads.rs
index f253753ac23..4fe1b30d80d 100644
--- a/Libraries/LibWeb/Rust/src/layout/row_reads.rs
+++ b/Libraries/LibWeb/Rust/src/layout/row_reads.rs
@@ -260,7 +260,7 @@ impl LayoutNodeArena {
paintable,
bound,
image_maps: self.image_map_areas().snapshot(),
- visual_context_tree: self.paint_state().borrow().visual_context.tree.clone(),
+ visual_context_tree: self.paint_state().visual_context.tree.clone(),
version: self.rows_version(),
overflow_is_measured: self.scrollable_overflow_is_measured(),
text_awaiting_render: self.text_rows_awaiting_sync(),
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
index 1c8b9472bf8..126661b0024 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
@@ -3718,7 +3718,7 @@ impl<'a> TreeBuilderHost<'a> {
if let Some(element) = element
&& self.holds_highlight_style(element)
{
- crate::painting::selection::note_built_row_highlight_pseudo_styles(self.arena(), slot, element);
+ crate::painting::selection::note_built_row_highlight_pseudo_styles(self.arena_mut(), slot, element);
}
if self.arena().node_flags(slot) & NodeFlag::IsDocumentElement as u32 != 0 {
let viewport = self.arena().bound_viewport_row();
@@ -3765,7 +3765,7 @@ impl<'a> TreeBuilderHost<'a> {
&& self.holds_highlight_style(parent)
&& self.arena().bound_row(parent).is_invalid()
{
- crate::painting::selection::note_built_row_highlight_pseudo_styles(self.arena(), slot, parent);
+ crate::painting::selection::note_built_row_highlight_pseudo_styles(self.arena_mut(), slot, parent);
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi.rs b/Libraries/LibWeb/Rust/src/painting/ffi.rs
index beb2ecbae21..39061e9d45a 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi.rs
@@ -389,7 +389,7 @@ pub(super) fn apply_walk_assignments(
#[unsafe(no_mangle)]
pub extern "C" fn render_state_sticky_spatial_node_index(host: &DocumentHost, paintable: NodeSlotId) -> u32 {
read_arena(host, node_read(), paintable, |arena, paintable| {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
paint_state
.visual_context
.scroll_state
@@ -503,7 +503,7 @@ impl FfiPresentedRecording {
/// What the host reads of the last recording the document took in.
pub(crate) fn of_last_recording(arena: &LayoutNodeArena) -> Self {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
let recording = paint_state.last_recording.as_deref();
Self {
is_identical_to_published_recording: recording
@@ -1155,7 +1155,7 @@ pub extern "C" fn render_state_main_visual_context_tree_retain(
return tree;
}
read_arena(host, read, (), |arena, ()| {
- retain(arena.paint_state().borrow().visual_context.tree.as_ref())
+ retain(arena.paint_state().visual_context.tree.as_ref())
})
}
@@ -1165,7 +1165,7 @@ pub extern "C" fn render_state_has_visual_context_tree(
read: &crate::render_state::BegunRead,
) -> bool {
read_arena(host, read, (), |arena, ()| {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
paint_state.visual_context.tree.is_some()
})
}
@@ -1182,7 +1182,7 @@ pub extern "C" fn render_state_visual_context_tree_structural_epoch(
});
known.unwrap_or_else(|| {
read_arena(host, read, (), |arena, ()| {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
paint_state.visual_context.structural_epoch()
})
})
@@ -1194,7 +1194,7 @@ pub extern "C" fn render_state_visual_context_tree_has_visual_animations(
read: &crate::render_state::BegunRead,
) -> bool {
read_arena(host, read, (), |arena, ()| {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
paint_state
.visual_context
.tree
@@ -1226,7 +1226,7 @@ pub unsafe extern "C" fn render_state_background_color_animation_keyframe_colors
read,
(effect_node_index, context, push_keyframe_color),
|arena, (effect_node_index, context, push_keyframe_color)| {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
let Some(tree) = paint_state.visual_context.tree.as_deref() else {
return;
};
@@ -1279,7 +1279,7 @@ pub unsafe extern "C" fn compositor_animation_effect_build(
node_read(),
(layout_node, kind),
|arena, (layout_node, kind)| {
- let tree = arena.paint_state().borrow().visual_context.tree.clone();
+ let tree = arena.paint_state().visual_context.tree.clone();
arena.paintable_visual_animation_target_indices(layout_node, tree.as_deref(), kind)
},
)
@@ -1441,7 +1441,7 @@ mod tests {
let root = arena.allocate_for_test().slot;
arena.populate_paintable_row(root);
{
- let mut state = arena.paint_state().borrow_mut();
+ let state = arena.paint_state_mut();
state.root_background_source = Some(RootBackgroundSource {
root_layout_node: root,
..Default::default()
@@ -1488,7 +1488,7 @@ mod tests {
.contains(PaintDamage::SCROLL_METADATA)
);
assert!(
- arena.paint_state().borrow().visual_context.dirty_boxes.boxes[&viewport]
+ arena.paint_state().visual_context.dirty_boxes.boxes[&viewport]
.contains(VisualContextBoxDirtyKind::ScrollableOverflowFlipped)
);
}
@@ -1518,7 +1518,7 @@ mod tests {
has_scrollable_overflow: true,
};
arena.paintable_side_data_mut(root).overflow_measured_this_commit = true;
- arena.paint_state().borrow_mut().visual_context.dirty_boxes.clear();
+ arena.paint_state_mut().visual_context.dirty_boxes.clear();
let outcome = crate::painting::paint_passes::prepare_for_rendering(
&mut arena,
@@ -1536,12 +1536,12 @@ mod tests {
.outcome;
assert!(outcome.requires_visual_context_update);
assert!(
- arena.paint_state().borrow().visual_context.dirty_boxes.boxes[&root]
+ arena.paint_state().visual_context.dirty_boxes.boxes[&root]
.contains(VisualContextBoxDirtyKind::ScrollableOverflowFlipped)
);
// Recording reads the root's overflow while it holds the paint state.
- let _paint_state = arena.paint_state().borrow();
+ let _paint_state = arena.paint_state();
let canvas_rect = crate::painting::record::paint::background_resolution::root_background_canvas_rect(
&arena.paintable_rows(),
root,
diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
index f9eb32897c9..42e72a76fcb 100644
--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs
@@ -377,7 +377,7 @@ pub extern "C" fn render_state_publish_compositor_animations(
}
run_paint_pass(read, host, PassEffect::KeepsPaintPreparation, |arena| {
crate::painting::visual_context::publish_compositor_animations(
- &mut arena.paint_state().borrow_mut().visual_context,
+ &mut arena.paint_state_mut().visual_context,
animations,
)
})
@@ -545,9 +545,7 @@ pub unsafe extern "C" fn render_state_take_recording_trace(
let Some(pending) = host.recording().take_pending_recording_trace() else {
return false;
};
- let recording = read_arena(host, read, (), |arena, ()| {
- arena.paint_state().borrow().last_recording.clone()
- });
+ let recording = read_arena(host, read, (), |arena, ()| arena.paint_state().last_recording.clone());
let Some(recording) = recording else {
return false;
};
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
index f08f29f2e45..11a4a560ca3 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_changes.rs
@@ -142,7 +142,7 @@ impl PaintChange {
}
let selection =
super::selection::apply(&mut arena.paintable_rows_mut(), &entries, start_offset, end_offset);
- arena.paint_state().borrow_mut().selection = Some(Arc::new(selection));
+ arena.paint_state_mut().selection = Some(Arc::new(selection));
}
Self::ClearSelection { viewport } => {
if arena.paintable_row_is_populated(viewport) {
@@ -222,7 +222,7 @@ impl PaintChange {
Self::SvgPaintResourcesChanged => {
arena.svg_paint_resources_mut().note_changed();
}
- Self::SetRecordingTraceEnabled(enabled) => arena.paint_state().borrow_mut().trace_recordings = enabled,
+ Self::SetRecordingTraceEnabled(enabled) => arena.paint_state_mut().trace_recordings = enabled,
Self::TakeInRecording {
output,
hit_test_list_changed,
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
index d4bf474e493..03a5c102278 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_passes.rs
@@ -80,7 +80,7 @@ pub(crate) fn prepare_for_clock_tick(
// Recording reads overflow, and measuring it notes a flip in scrollability for the check below.
arena.measure_scrollable_overflow();
if arena.svg_paint_resources().needs_sync()
- || arena.paint_state().borrow().root_background_source
+ || arena.paint_state().root_background_source
!= Some(crate::layout::viewport_propagation::root_background_source(arena))
{
return Err(VisualContextsNeedHost(
@@ -88,7 +88,7 @@ pub(crate) fn prepare_for_clock_tick(
));
}
let (inputs, compositor_animations) = {
- let mut paint_state = arena.paint_state().borrow_mut();
+ let paint_state = arena.paint_state_mut();
let state = &mut paint_state.visual_context;
let (Some(inputs), Some(tree)) = (state.last_tree_inputs, state.tree.as_deref()) else {
return Err(VisualContextsNeedHost("no visual context tree"));
@@ -112,7 +112,7 @@ pub(crate) fn prepare_for_clock_tick(
// The boxes the compositor animations drive nodes of, as the tree before the update holds them, which a tree of a
// new structure gives other nodes.
let before = (!compositor_animations.is_empty()).then(|| {
- let tree = arena.paint_state().borrow().visual_context.tree.clone();
+ let tree = arena.paint_state().visual_context.tree.clone();
(
arena.visual_context_node_handles_snapshot(),
tree.expect("the tree is there"),
@@ -123,31 +123,35 @@ pub(crate) fn prepare_for_clock_tick(
if outcome.performed_full_build {
return Err(VisualContextsNeedHost("a full visual context tree build"));
}
- let paintable_rows = arena.paintable_rows();
- let mut paint_state = arena.paint_state().borrow_mut();
- let state = &mut paint_state.visual_context;
- let tree = state.tree.as_mut().expect("an incremental update keeps the tree");
- if !outcome.structural_epoch_changed {
- return Ok(Some(ClockTickVisualContexts {
- tree: tree.clone(),
- restructured_scroll_offsets: None,
- }));
- }
- // The update dropped the animations, which name nodes of the old structure: each goes on driving the nodes of its
- // box in the new one. An animation of a box that has no node of its kind any more drives nothing the frame shows,
- // as the tick gave the box a style of its own for what it animates.
- if let Some((handles_before, tree_before)) = before {
- let animations =
- carry_visual_animations_to_new_nodes(arena, &handles_before, &tree_before, tree, &compositor_animations)?;
- Arc::make_mut(tree).set_visual_animations(animations);
- }
- let tree = tree.clone();
- // The host refreshes its own copy of the scroll state still.
- let scroll_offsets = scroll_state_snapshot(&paintable_rows, state, inputs.device_pixels_per_css_pixel);
- Ok(Some(ClockTickVisualContexts {
- tree,
- restructured_scroll_offsets: Some(scroll_offsets),
- }))
+ arena.with_visual_context_state_lent(|arena, state| {
+ let tree = state.tree.as_mut().expect("an incremental update keeps the tree");
+ if !outcome.structural_epoch_changed {
+ return Ok(Some(ClockTickVisualContexts {
+ tree: tree.clone(),
+ restructured_scroll_offsets: None,
+ }));
+ }
+ // The update dropped the animations, which name nodes of the old structure: each goes on driving the nodes of its
+ // box in the new one. An animation of a box that has no node of its kind any more drives nothing the frame shows,
+ // as the tick gave the box a style of its own for what it animates.
+ if let Some((handles_before, tree_before)) = before {
+ let animations = carry_visual_animations_to_new_nodes(
+ arena,
+ &handles_before,
+ &tree_before,
+ tree,
+ &compositor_animations,
+ )?;
+ Arc::make_mut(tree).set_visual_animations(animations);
+ }
+ let tree = tree.clone();
+ // The host refreshes its own copy of the scroll state still.
+ let scroll_offsets = scroll_state_snapshot(&arena.paintable_rows(), state, inputs.device_pixels_per_css_pixel);
+ Ok(Some(ClockTickVisualContexts {
+ tree,
+ restructured_scroll_offsets: Some(scroll_offsets),
+ }))
+ })
}
/// The compositor animations `animations`, which drive nodes of `tree_before`, whose boxes `handles_before` held, driving
@@ -214,7 +218,7 @@ fn keep_nodes_compositor_animations_drive(arena: &mut LayoutNodeArena) {
use crate::layout::node_data::CompositorAnimationFrameKind;
use crate::painting::host::FfiVisualAnimationTargetKind;
let (dirty, animations) = {
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
let state = &paint_state.visual_context;
let Some(tree) = state.tree.as_deref().filter(|tree| tree.has_visual_animations()) else {
return;
@@ -282,7 +286,7 @@ impl PendingPreparation {
pub(crate) fn rendering_preparation_pending(arena: &LayoutNodeArena) -> Option<PendingPreparation> {
let root_background_source = crate::layout::viewport_propagation::root_background_source(arena);
let overflow = &arena.scrollable_overflow;
- let pending = arena.paint_state().borrow().root_background_source != Some(root_background_source)
+ let pending = arena.paint_state().root_background_source != Some(root_background_source)
|| overflow.full_layout_commit
|| overflow.measurement_awaits_preparation()
|| arena.scrollable_overflow_recalculation_is_scheduled()
@@ -318,18 +322,19 @@ pub(crate) fn prepare_for_rendering(
let flipped = std::mem::replace(&mut arena.scrollable_overflow.scrollability_changed, false);
let mut visual_context_values_changed = false;
if let Some(inputs) = sticky_inputs.filter(|_| changed && !flipped) {
- let rows = arena.paintable_rows();
- let mut state = arena.paint_state().borrow_mut();
- let state = &mut state.visual_context;
- if let Some(tree) = state.tree.as_mut() {
- visual_context_values_changed = crate::painting::visual_context::refresh::refresh_sticky_constraints(
- &rows,
- &state.scroll_state,
- tree,
- inputs,
- );
- }
- state.needs_to_refresh_scroll_state = true;
+ visual_context_values_changed = arena.with_visual_context_state_lent(|arena, state| {
+ let mut values_changed = false;
+ if let Some(tree) = state.tree.as_mut() {
+ values_changed = crate::painting::visual_context::refresh::refresh_sticky_constraints(
+ &arena.paintable_rows(),
+ &state.scroll_state,
+ tree,
+ inputs,
+ );
+ }
+ state.needs_to_refresh_scroll_state = true;
+ values_changed
+ });
}
RenderingPreparation {
outcome: FfiRenderingPreparationOutcome {
@@ -346,15 +351,14 @@ pub(crate) fn refresh_scroll_state(
device_pixels_per_css_pixel: f64,
) -> Option<Vec<FloatPoint>> {
arena.measure_scrollable_overflow();
- let paintable_rows = arena.paintable_rows();
- let mut paint_state = arena.paint_state().borrow_mut();
- let state = &mut paint_state.visual_context;
- if !state.needs_to_refresh_scroll_state {
- return None;
- }
- let snapshot = scroll_state_snapshot(&paintable_rows, state, device_pixels_per_css_pixel);
- state.needs_to_refresh_scroll_state = false;
- Some(snapshot)
+ arena.with_visual_context_state_lent(|arena, state| {
+ if !state.needs_to_refresh_scroll_state {
+ return None;
+ }
+ let snapshot = scroll_state_snapshot(&arena.paintable_rows(), state, device_pixels_per_css_pixel);
+ state.needs_to_refresh_scroll_state = false;
+ Some(snapshot)
+ })
}
/// The device scroll offsets of the nodes of `state`'s tree, refreshed from the rows where they may have moved.
@@ -374,8 +378,8 @@ fn scroll_state_snapshot(
snapshot
}
-pub(crate) fn update_visual_viewport_transform(arena: &LayoutNodeArena, inputs: &FfiVisualContextTreeInputs) {
- let mut paint_state = arena.paint_state().borrow_mut();
+pub(crate) fn update_visual_viewport_transform(arena: &mut LayoutNodeArena, inputs: &FfiVisualContextTreeInputs) {
+ let paint_state = arena.paint_state_mut();
if let Some(tree) = &mut paint_state.visual_context.tree {
std::sync::Arc::make_mut(tree).set_visual_viewport_transform(
crate::painting::visual_context::node_values::visual_viewport_transform_data(inputs),
@@ -392,7 +396,7 @@ pub(crate) fn update_accumulated_visual_contexts(
if !arena.paintable_row_is_populated(viewport) {
return FfiVisualContextUpdateOutcome::default();
}
- let mut state = std::mem::take(&mut arena.paint_state().borrow_mut().visual_context);
+ let mut state = std::mem::take(&mut arena.paint_state_mut().visual_context);
state.release_quarantined_slots_while_no_handle_is_retained();
let mut scope = state.dirty_boxes.scope;
@@ -445,7 +449,7 @@ pub(crate) fn update_accumulated_visual_contexts(
requires_display_list_recording: outcome.delta.requires_display_list_recording,
structural_epoch: state.structural_epoch(),
};
- arena.paint_state().borrow_mut().visual_context = state;
+ arena.paint_state_mut().visual_context = state;
return outcome;
}
IncrementalUpdateResult::NeedsFullBuild(fallback_scope) => {
@@ -457,7 +461,7 @@ pub(crate) fn update_accumulated_visual_contexts(
let outcome = fresh_visual_context_tree_build(arena, viewport, inputs, &mut state);
state.last_tree_inputs = Some(inputs);
- arena.paint_state().borrow_mut().visual_context = state;
+ arena.paint_state_mut().visual_context = state;
outcome
}
diff --git a/Libraries/LibWeb/Rust/src/painting/paint_state.rs b/Libraries/LibWeb/Rust/src/painting/paint_state.rs
index 5d0668ccefa..7918467333a 100644
--- a/Libraries/LibWeb/Rust/src/painting/paint_state.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paint_state.rs
@@ -84,7 +84,7 @@ impl crate::layout::LayoutNodeArena {
&mut self,
source: crate::painting::host::RootBackgroundSource,
) -> bool {
- let Some(previous) = self.paint_state().borrow_mut().root_background_source.replace(source) else {
+ let Some(previous) = self.paint_state_mut().root_background_source.replace(source) else {
return false;
};
if previous == source {
@@ -104,4 +104,16 @@ impl crate::layout::LayoutNodeArena {
}
true
}
+
+ /// Lends the visual context state out of the paint state to `update`, which reads the rest of the arena beside it:
+ /// refreshing the scroll state and the sticky constraints reads the rows while it writes the state.
+ pub(crate) fn with_visual_context_state_lent<T>(
+ &mut self,
+ update: impl FnOnce(&Self, &mut crate::painting::visual_context::VisualContextState) -> T,
+ ) -> T {
+ let mut state = std::mem::take(&mut self.paint_state_mut().visual_context);
+ let answer = update(self, &mut state);
+ self.paint_state_mut().visual_context = state;
+ answer
+ }
}
diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs b/Libraries/LibWeb/Rust/src/painting/paintable_build.rs
index c215b533e63..837649adc77 100644
--- a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paintable_build.rs
@@ -174,7 +174,7 @@ impl<'a> PaintableCommit<'a> {
self.arena_mut().push_paint_damage(node, PaintDamage::ALL_PRODUCERS);
}
if row_existed_before_this_commit && enclosing_line_root_changes.fragment_changed {
- self.arena()
+ self.arena_mut()
.note_visual_context_box_dirty(node, VisualContextBoxDirtyKind::InlineGeometryChanged);
}
}
@@ -192,12 +192,12 @@ impl<'a> PaintableCommit<'a> {
// A recommitted viewport row starts its paint state over: the scroll registry is
// dropped here and rebuilt by the next tree update, while the host resets its
// snapshot from the row reset notification.
- arena.paint_state().borrow_mut().visual_context.clear_scroll_state();
+ arena.paint_state_mut().visual_context.clear_scroll_state();
}
} else {
arena.populate_paintable_row(node);
if node_kind == NodeKind::Viewport {
- arena.paint_state().borrow_mut().reset_visual_context_state();
+ arena.paint_state_mut().reset_visual_context_state();
}
arena.note_visual_context_box_dirty(node, VisualContextBoxDirtyKind::NewRow);
}
@@ -348,11 +348,11 @@ impl<'a> PaintableCommit<'a> {
}
self.arena_mut().push_paint_damage(node, damage);
if !offset_unchanged {
- self.arena()
+ self.arena_mut()
.note_visual_context_box_dirty(node, VisualContextBoxDirtyKind::MovedWithDescendants);
}
if !fragment_content_unchanged {
- self.arena()
+ self.arena_mut()
.note_visual_context_box_dirty(node, VisualContextBoxDirtyKind::RecommittedInPlace);
}
if !fragment_content_unchanged || !self.arena().committed_side_data(node).overflow_valid_across_recommits {
@@ -458,7 +458,7 @@ impl<'a> PaintableCommit<'a> {
}
self.arena_mut()
.push_paint_damage(slot, PaintDamage::ALL_PRODUCERS | PaintDamage::MOVED);
- self.arena().note_visual_context_box_dirty(
+ self.arena_mut().note_visual_context_box_dirty(
slot,
if moved {
VisualContextBoxDirtyKind::MovedWithDescendants
diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
index 13fff907502..f0986255a2b 100644
--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs
@@ -905,8 +905,7 @@ impl LayoutNodeArena {
self.withdraw_stacking_context_state_of_reset_row(id, Some(record.stacking_context));
let former_paint_parent =
crate::painting::paint_order::paint_parent(&self.paintable_rows(), id).unwrap_or(NodeSlotId::INVALID);
- self.paint_state()
- .borrow_mut()
+ self.paint_state_mut()
.visual_context
.dirty_boxes
.note_removed(RemovedBoxBlocks {
@@ -916,11 +915,7 @@ impl LayoutNodeArena {
});
} else {
self.withdraw_stacking_context_state_of_reset_row(id, None);
- self.paint_state()
- .borrow_mut()
- .visual_context
- .dirty_boxes
- .forget_box(id);
+ self.paint_state_mut().visual_context.dirty_boxes.forget_box(id);
}
self.clear_absolute_rect_memo();
let store = &mut self.paintable_rows;
@@ -1135,20 +1130,18 @@ impl LayoutNodeArena {
std::mem::take(&mut self.paintable_rows.line_roots_needing_fragment_ownership)
}
- pub(crate) fn note_visual_context_box_dirty(&self, id: NodeSlotId, kind: VisualContextBoxDirtyKind) {
+ pub(crate) fn note_visual_context_box_dirty(&mut self, id: NodeSlotId, kind: VisualContextBoxDirtyKind) {
let pending_box_limit = self
.paintable_row_count()
.max(crate::painting::visual_context::dirty::MINIMUM_PENDING_DIRTY_BOX_LIMIT);
- self.paint_state()
- .borrow_mut()
+ self.paint_state_mut()
.visual_context
.dirty_boxes
.note_box(id, kind, pending_box_limit);
}
- pub(crate) fn request_full_visual_context_rebuild(&self, scope: VisualContextUpdateScope) {
- self.paint_state()
- .borrow_mut()
+ pub(crate) fn request_full_visual_context_rebuild(&mut self, scope: VisualContextUpdateScope) {
+ self.paint_state_mut()
.visual_context
.dirty_boxes
.request_full_rebuild(scope);
diff --git a/Libraries/LibWeb/Rust/src/painting/published_frame.rs b/Libraries/LibWeb/Rust/src/painting/published_frame.rs
index 5ce2c274acd..0fb565c7430 100644
--- a/Libraries/LibWeb/Rust/src/painting/published_frame.rs
+++ b/Libraries/LibWeb/Rust/src/painting/published_frame.rs
@@ -231,7 +231,7 @@ impl LayoutNodeArena {
PublishedFrame {
rows,
damage: self.paint_damage_for_frame(),
- paint_state: PublishedPaintState::new(&self.paint_state().borrow(), hit_test_item_capacity_hint),
+ paint_state: PublishedPaintState::new(self.paint_state(), hit_test_item_capacity_hint),
_style_records: self.with_style_store(|engine| engine.lease_style_records()),
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/publish.rs b/Libraries/LibWeb/Rust/src/painting/record/publish.rs
index 88a08f01444..67315826575 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/publish.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/publish.rs
@@ -386,7 +386,7 @@ pub(crate) fn take_in_recording(
if publishes_recording {
arena.clear_paint_damage_consumed_by_published_recording();
}
- let mut paint_state = arena.paint_state().borrow_mut();
+ let paint_state = arena.paint_state_mut();
if hit_test_list_changed {
paint_state.hit_test_list_generation += 1;
}
diff --git a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
index 9466dffbda2..0858815b09a 100644
--- a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
+++ b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
@@ -505,7 +505,6 @@ pub(crate) fn freeze_recording_frame(arena: &mut LayoutNodeArena, inputs: FrameI
if let Some(published_canvas_rect) = inputs.published_root_background_canvas_rect {
let root = arena
.paint_state()
- .borrow()
.root_background_source
.expect("a recording follows paint preparation")
.root_layout_node;
@@ -524,7 +523,7 @@ pub(crate) fn freeze_recording_frame(arena: &mut LayoutNodeArena, inputs: FrameI
// The recording reads the document as it is now: what the host writes after this goes to the next frame.
let frame = arena.freeze_frame(inputs.hit_test_item_capacity_hint);
let rows_version = arena.rows_version();
- let paint_state = arena.paint_state().borrow();
+ let paint_state = arena.paint_state();
Some(FrozenFrame {
frame,
rows_version,
diff --git a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
index ade139ebc53..e385f5b91e1 100644
--- a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
+++ b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
@@ -187,7 +187,7 @@ impl OverflowAssignment {
);
// The root background covers the viewport united with the root's overflow.
if layout_arena.node_kind_if_live(self.box_paintable) == Some(NodeKind::Viewport) {
- let root_background_source = layout_arena.paint_state().borrow().root_background_source;
+ let root_background_source = layout_arena.paint_state().root_background_source;
if let Some(source) = root_background_source {
layout_arena.push_paint_damage(source.root_layout_node, PaintDamage::DRAW_BACKGROUND);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/selection.rs b/Libraries/LibWeb/Rust/src/painting/selection.rs
index 94661843c1d..7998fc83afd 100644
--- a/Libraries/LibWeb/Rust/src/painting/selection.rs
+++ b/Libraries/LibWeb/Rust/src/painting/selection.rs
@@ -78,7 +78,7 @@ fn invalidate_text_node(layout_arena: &mut PaintableRowsMut<'_>, node: NodeSlotI
}
pub(crate) fn clear(layout_arena: &mut PaintableRowsMut<'_>) {
- let Some(previous) = layout_arena.paint_state().borrow_mut().selection.take() else {
+ let Some(previous) = layout_arena.paint_state_mut().selection.take() else {
return;
};
for node in previous.text_states.keys() {
@@ -176,7 +176,7 @@ impl SearchTextHighlights {
}
pub(crate) fn clear_search_text(layout_arena: &mut PaintableRowsMut<'_>) {
- let previous = std::mem::take(&mut layout_arena.paint_state().borrow_mut().search_text);
+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().search_text);
for node in previous.by_node.keys() {
invalidate_text_node(layout_arena, *node);
}
@@ -212,13 +212,13 @@ pub(crate) fn apply_search_text(
for touching in highlights.by_node.values_mut() {
touching.sort_by_key(|&(match_index, state)| matches[match_index as usize].offsets_in_node(state));
}
- let previous = std::mem::take(&mut layout_arena.paint_state().borrow_mut().search_text);
+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().search_text);
for node in previous.by_node.keys().chain(highlights.by_node.keys()) {
if previous.node_signature(*node) != highlights.node_signature(*node) {
invalidate_text_node(layout_arena, *node);
}
}
- layout_arena.paint_state().borrow_mut().search_text = Arc::new(highlights);
+ layout_arena.paint_state_mut().search_text = Arc::new(highlights);
}
#[derive(Debug, Default)]
@@ -228,7 +228,7 @@ pub(crate) struct SpellingErrorHighlights {
}
pub(crate) fn clear_spelling_errors(layout_arena: &mut PaintableRowsMut<'_>) {
- let previous = std::mem::take(&mut layout_arena.paint_state().borrow_mut().spelling_errors);
+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().spelling_errors);
for node in previous.by_node.keys() {
invalidate_text_node(layout_arena, *node);
}
@@ -248,13 +248,13 @@ pub(crate) fn apply_spelling_errors(layout_arena: &mut PaintableRowsMut<'_>, err
for runs in highlights.by_node.values_mut() {
runs.sort_unstable();
}
- let previous = std::mem::take(&mut layout_arena.paint_state().borrow_mut().spelling_errors);
+ let previous = std::mem::take(&mut layout_arena.paint_state_mut().spelling_errors);
for node in previous.by_node.keys().chain(highlights.by_node.keys()) {
if previous.by_node.get(node) != highlights.by_node.get(node) {
invalidate_text_node(layout_arena, *node);
}
}
- layout_arena.paint_state().borrow_mut().spelling_errors = Arc::new(highlights);
+ layout_arena.paint_state_mut().spelling_errors = Arc::new(highlights);
}
/// https://drafts.csswg.org/css-pseudo-4/#highlight-styling
@@ -392,7 +392,7 @@ fn highlight_pseudo_styles_of_records(
/// own rows, or, while it has no box, the rows of its text children, which then have no element
/// row above them to find it on.
pub(crate) fn sync_highlight_pseudo_styles(
- arena: &LayoutNodeArena,
+ arena: &mut LayoutNodeArena,
element: StyleNodeID,
style_records: HighlightStyleRecords,
) {
@@ -403,27 +403,33 @@ pub(crate) fn sync_highlight_pseudo_styles(
} else {
HighlightStyleAnswers::default()
};
- arena.with_style_store(|engine| {
- for text in engine
+ let text_rows: Vec<NodeSlotId> = arena.with_style_store(|engine| {
+ engine
.tree()
.dom_children(element)
.filter(|child| child.text_index().is_some())
- {
- let row = arena.bound_row(text);
- if !row.is_invalid() {
- set_highlight_pseudo_styles_of_rows(arena, arena.rows_sharing_dom_node_with(row), &text_rows_answers);
- }
- }
+ .map(|text| arena.bound_row(text))
+ .filter(|row| !row.is_invalid())
+ .collect()
});
+ for row in text_rows {
+ let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(row).collect();
+ set_highlight_pseudo_styles_of_rows(arena, &rows, &text_rows_answers);
+ }
if !element_row.is_invalid() {
- set_highlight_pseudo_styles_of_rows(arena, arena.rows_sharing_dom_node_with(element_row), &answers);
+ let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(element_row).collect();
+ set_highlight_pseudo_styles_of_rows(arena, &rows, &answers);
}
}
/// Gives a row the tree build made what the published highlight pseudo-element records of
/// `element` say highlighted text paints with: `element`'s own row, or a text row whose parent
/// element has no box.
-pub(crate) fn note_built_row_highlight_pseudo_styles(arena: &LayoutNodeArena, row: NodeSlotId, element: StyleNodeID) {
+pub(crate) fn note_built_row_highlight_pseudo_styles(
+ arena: &mut LayoutNodeArena,
+ row: NodeSlotId,
+ element: StyleNodeID,
+) {
let style_records = arena.with_style_store(|engine| {
HighlightPseudoElement::ALL.map(|highlight| {
engine
@@ -432,19 +438,19 @@ pub(crate) fn note_built_row_highlight_pseudo_styles(arena: &LayoutNodeArena, ro
})
});
let answers = highlight_pseudo_styles_of_records(arena, element, style_records);
- set_highlight_pseudo_styles_of_rows(arena, arena.rows_sharing_dom_node_with(row), &answers);
+ let rows: Vec<NodeSlotId> = arena.rows_sharing_dom_node_with(row).collect();
+ set_highlight_pseudo_styles_of_rows(arena, &rows, &answers);
}
fn set_highlight_pseudo_styles_of_rows(
- arena: &LayoutNodeArena,
- rows: impl Iterator<Item = NodeSlotId>,
+ arena: &mut LayoutNodeArena,
+ rows: &[NodeSlotId],
answers: &HighlightStyleAnswers,
) {
- let rows: Vec<NodeSlotId> = rows.collect();
- let mut paint_state = arena.paint_state().borrow_mut();
+ let paint_state = arena.paint_state_mut();
for (highlight, answer) in HighlightPseudoElement::ALL.into_iter().zip(answers) {
let styles = paint_state.highlight_pseudo_styles_mut(highlight);
- for &row in &rows {
+ for &row in rows {
match answer {
Some(answer) => {
Arc::make_mut(styles).insert(row, answer.clone());
diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rs
index afd44a985bf..11926831764 100644
--- a/Libraries/LibWeb/Rust/src/render_state.rs
+++ b/Libraries/LibWeb/Rust/src/render_state.rs
@@ -213,6 +213,14 @@ impl RenderState {
(unsafe { self.engine.get_mut() }, self.arena.arena())
}
+ /// The style engine to read, beside the layout arena to write.
+ pub(crate) fn engine_ref_and_arena_mut(
+ &mut self,
+ ) -> (&crate::css::style::StyleEngine, &mut crate::layout::LayoutNodeArena) {
+ // SAFETY: As for a change. The arena only links the engine, and its caller changes the engine through neither.
+ (unsafe { self.engine.get() }, self.arena.arena_mut())
+ }
+
/// The layout arena.
pub(crate) fn arena_mut(&mut self) -> &mut crate::layout::LayoutNodeArena {
self.arena.arena_mut()
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rs
index 21e88fbf51b..795b88abea6 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs
@@ -469,7 +469,7 @@ impl CommittedFrame {
&turn,
CommittedSample::Unrecorded {
visual_context_tree: sends_visual_context_tree
- .then(|| state.arena_mut().paint_state().borrow().visual_context.tree.clone())
+ .then(|| state.arena_mut().paint_state().visual_context.tree.clone())
.flatten(),
},
),
@@ -1442,7 +1442,7 @@ impl Lane {
}),
);
self.presented_compositor_animations.clear();
- if let Some(tree) = arena.paint_state().borrow().visual_context.tree.as_deref() {
+ if let Some(tree) = arena.paint_state().visual_context.tree.as_deref() {
self.presented_compositor_animations
.extend(self.presented_border_boxes.iter().map(|&(element, _)| {
let nodes = arena.box_animation_nodes(arena.bound_row(element));
@@ -1517,7 +1517,7 @@ fn freeze_tick_frame(
TickPresented::LeftToHost => return Err(Park("the host presents the frame")),
}
let viewport = arena.layout_root();
- if arena.paint_state().borrow().trace_recordings {
+ if arena.paint_state().trace_recordings {
return Err(Park("a trace reads the recording"));
}
let visual_contexts = prepare_for_clock_tick(arena, viewport)?;
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
index 06bc58362d6..047a61c3147 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs
@@ -878,18 +878,19 @@ pub(super) fn ended_compositor_animation_kinds(
/// Stops the compositor animations of the box of the element `transitions` restyle that drive what the host's
/// transitions the step ended animated, which the host published for them: the frames of the lane show the step's
/// style in their place.
-pub(super) fn stop_ended_compositor_animations(arena: &LayoutNodeArena, transitions: &HoverTransitions) {
+pub(super) fn stop_ended_compositor_animations(arena: &mut LayoutNodeArena, transitions: &HoverTransitions) {
let Some(ended) = ended_compositor_animation_kinds(transitions).filter(|ended| !ended.is_empty()) else {
return;
};
- stop_compositor_animations(arena, arena.bound_row(transitions.node), &ended);
+ let row = arena.bound_row(transitions.node);
+ stop_compositor_animations(arena, row, &ended);
}
/// Stops the compositor animations of the box of the element of `row`, a hover's row, that drive what the row moves: the
/// frames of the lane show the record it installs in their place.
pub(super) fn stop_compositor_animations_a_row_moves(
engine: &StyleEngine,
- arena: &LayoutNodeArena,
+ arena: &mut LayoutNodeArena,
row: &FfiStyleDelta,
) {
use crate::css::property_metadata::property_id as prop;
@@ -921,18 +922,19 @@ pub(super) fn stop_compositor_animations_a_row_moves(
kinds.push(kind);
}
}
- stop_compositor_animations(arena, arena.bound_row(node), &kinds);
+ let row = arena.bound_row(node);
+ stop_compositor_animations(arena, row, &kinds);
}
/// Stops the compositor animations of the box `row` of the `kinds`, which the host published: the frames of the lane
/// show what the lane gave the box in their place, which an animation the compositor runs on, or holds at its end
/// until the host publishes again, would hide.
-fn stop_compositor_animations(arena: &LayoutNodeArena, row: NodeSlotId, kinds: &[FfiVisualAnimationTargetKind]) {
+fn stop_compositor_animations(arena: &mut LayoutNodeArena, row: NodeSlotId, kinds: &[FfiVisualAnimationTargetKind]) {
if row.is_invalid() || kinds.is_empty() {
return;
}
let nodes = arena.box_animation_nodes(row);
- let mut paint_state = arena.paint_state().borrow_mut();
+ let paint_state = arena.paint_state_mut();
let Some(tree) = paint_state.visual_context.tree.as_mut() else {
return;
};
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
index 3ef5d9dd7ac..656f346adb5 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs
@@ -205,7 +205,7 @@ impl HoverPlan {
// pins only these rows' records, leaving unrelated records reclaimable. Frames with animation overlays
// use the regular lane above, and so do frames with a row that still names an overlay record no element
// is assigned, which the lease declines.
- let visual_context = state.arena.arena().paint_state().borrow().visual_context.clone();
+ let visual_context = state.arena.arena().paint_state().visual_context.clone();
if visual_context.tree.is_none() {
return;
}
@@ -965,7 +965,7 @@ impl Lane {
drop(work.resolve(arena));
// The boxes show what the rows moved in place of the compositor animations the host published for them.
if !settles_back {
- let (engine, arena) = state.engine_and_arena();
+ let (engine, arena) = state.engine_ref_and_arena_mut();
for install in installs.iter().filter(|install| !rebuilt(install.element.style_node)) {
super::effects::stop_compositor_animations_a_row_moves(engine, arena, &install.element);
}
@@ -982,7 +982,7 @@ impl Lane {
}
started_transitions = true;
made.started.push(transitions.node);
- super::effects::stop_ended_compositor_animations(state.arena.arena(), &transitions);
+ super::effects::stop_ended_compositor_animations(state.arena.arena_mut(), &transitions);
made.replaced.extend(self.start_transitions(transitions, timestamp));
}
let engine = state.engine_mut();
@@ -1195,7 +1195,6 @@ impl Lane {
let arena = state.arena.arena();
let tree = arena
.paint_state()
- .borrow()
.visual_context
.tree
.clone()
@@ -1210,9 +1209,7 @@ impl Lane {
..HitTestList::default()
};
list.build_spatial_indexes_if_needed();
- let paint_state = arena.paint_state().borrow();
- let scroll_offsets = self.scroll_offsets_on_screen(arena, &paint_state.visual_context, plan);
- drop(paint_state);
+ let scroll_offsets = self.scroll_offsets_on_screen(arena, &arena.paint_state().visual_context, plan);
let callbacks =
FfiHitTestQueryCallbacks::sealed(plan.device_pixels_per_css_pixel, &scroll_offsets, plan.chrome_metrics);
let pixel_ratio = plan.device_pixels_per_css_pixel as f32;