Truly independent web browser
LibCompositing: Replay a selection of record spans
Aliaksandr Kalenikd99d37dcdc2a
diff --git a/Libraries/LibCompositing/Rust/build.rs b/Libraries/LibCompositing/Rust/build.rsindex 67551eface7..ad5db3d3d6c 100644--- a/Libraries/LibCompositing/Rust/build.rs+++ b/Libraries/LibCompositing/Rust/build.rs@@ -407,6 +407,8 @@ fn main() -> Result<(), Box<dyn Error>> {"FfiCompositorAnimationPublishOutcome","FfiVisualAnimationSummary","FfiDisplayListReplayCallbacks",+ "RecordSpan",+ "FfiReplaySelection","FfiDisplayList","FfiEasingDescriptor","FfiEasingKind",diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rsindex 810261297ff..7fa864a3098 100644--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs@@ -16,6 +16,7 @@ use crate::display_list::effect_clip_plan::EffectClipPlan;use crate::display_list::effect_geometry::{EffectGeometry, Extent, compute_effect_geometry};use crate::display_list::ffi_bytes::FfiBytes;use crate::display_list::nested_records::span_bytes;+use crate::host::RecordSpan;use crate::visual_context::queries::TreeCullingScratch;use crate::visual_context::{ClipNodeData, ContextRef, EffectNodeData, SpatialData, VisualContextTree, WorldTransforms, device_offset_for_index,@@ -238,6 +239,12 @@ fn return_replay_scratch_storage(mut storage: ReplayScratchStorage) {});}+#[derive(Clone, Copy, Default)]+pub struct ReplaySelection<'a> {+ pub record_spans: Option<&'a [RecordSpan]>,+ pub skip_root_isolation_layer: bool,+}+#[derive(Clone, Copy, PartialEq, Eq)]enum SwitchResult {Switched,@@ -251,6 +258,7 @@ struct ReplayDriver<'a, Painter: ReplayPainter> {scroll_offsets: &'a [FloatPoint],effect_clips: &'a EffectClipPlan,root_group_color: Color,+ selection: ReplaySelection<'a>,painter: &'a mut Painter,// Spatial nodes never touch the canvas save stack: any node's space is entered absolutely with a single// set_matrix(), so only clips and effects do.@@ -348,6 +356,11 @@ fn int_rect_enclosing(rect: FloatRect) -> Option<IntRect> {}impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {+ fn effect_layer_is_pushed(&self, effect: EffectNodeIndex) -> bool {+ self.tree.effect_pushes_layer_at_replay(effect)+ && !(self.selection.skip_root_isolation_layer && self.tree.root_isolation_effect == Some(effect))+ }+fn ensure_ctm_space(&mut self, spatial: SpatialNodeIndex) {let space = self.world.draw_space[spatial.0 as usize];if self.current_ctm_space == Some(space) {@@ -558,7 +571,7 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {let node = &tree.effect_nodes[effect.0 as usize];match &node.data {EffectNodeData::Effects(_) => {- if tree.effect_pushes_layer_at_replay(effect) {+ if self.effect_layer_is_pushed(effect) {self.painter.pop();self.current_ctm_space = None;}@@ -642,7 +655,7 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {}match &node.data {EffectNodeData::Effects(effects) => {- if tree.effect_pushes_layer_at_replay(effect) {+ if self.effect_layer_is_pushed(effect) {self.ensure_ctm_space(node.spatial);let content_bounds = self.layer_content_bounds(effect, node.spatial);let mut layer = replay_layer_of(effects, effect, content_bounds);@@ -680,6 +693,28 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {// A run enters its context once. Skipping a run with nothing to draw before entering its// context spares the pushes.fn execute_run(&mut self, run_index: usize) {+ let run = self.command_runs[run_index];+ self.execute_run_records(run_index, run.offset, run.offset + run.size);+ }++ fn execute_record_span(&mut self, span: RecordSpan) {+ let first_run = self+ .command_runs+ .partition_point(|run| run.offset + run.size <= span.begin_offset);+ for run_index in first_run..self.command_runs.len() {+ let run = self.command_runs[run_index];+ if run.offset >= span.end_offset {+ break;+ }+ self.execute_run_records(+ run_index,+ run.offset.max(span.begin_offset),+ (run.offset + run.size).min(span.end_offset),+ );+ }+ }++ fn execute_run_records(&mut self, run_index: usize, begin_offset: u32, end_offset: u32) {let run = self.command_runs[run_index];if self.world.backface_culled[run.context.spatial.0 as usize] {return;@@ -697,7 +732,7 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {if self.painter.would_be_fully_clipped_by_painter(run.ink_bounds) {return;}- let records = &self.tape[run.offset as usize..(run.offset + run.size) as usize];+ let records = &self.tape[begin_offset as usize..end_offset as usize];let world = &self.world;let clip_space_matrix = |space: SpatialNodeIndex| world.draw_matrix_if_known(space);self.painter@@ -706,7 +741,12 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {fn execute(&mut self) {let tree = self.tree;- if !self.tree_has_sorting_contexts {+ if let Some(record_spans) = self.selection.record_spans {+ debug_assert!(!self.tree_has_sorting_contexts);+ for span in record_spans {+ self.execute_record_span(*span);+ }+ } else if !self.tree_has_sorting_contexts {for run_index in 0..self.command_runs.len() {self.execute_run(run_index);}@@ -776,6 +816,7 @@ impl<Painter: ReplayPainter> ReplayDriver<'_, Painter> {}}+#[allow(clippy::too_many_arguments)]pub fn replay_display_list(tree: &VisualContextTree,tape: &[u8],@@ -783,6 +824,7 @@ pub fn replay_display_list(effect_clips: &EffectClipPlan,root_group_color: Color,scroll_offsets: &[FloatPoint],+ selection: ReplaySelection<'_>,painter: &mut impl ReplayPainter,) {let replay_base_matrix = painter.canvas_matrix();@@ -795,6 +837,7 @@ pub fn replay_display_list(scroll_offsets,effect_clips,root_group_color,+ selection,painter,world: scratch.world,culling: scratch.culling,@@ -946,6 +989,7 @@ mod tests {fully_clipped_x: i32,layer_content_bounds: Vec<Option<FloatRect>>,backdrop_base_colors: Vec<Color>,+ run_record_sizes: Vec<usize>,}impl RecordingPainter {@@ -956,6 +1000,7 @@ mod tests {fully_clipped_x: i32::MIN,layer_content_bounds: Vec::new(),backdrop_base_colors: Vec::new(),+ run_record_sizes: Vec::new(),}}}@@ -1004,11 +1049,12 @@ mod tests {fn execute_run(&mut self,run_index: usize,- _records: &[u8],+ records: &[u8],_scroll_offsets: &[FloatPoint],_clip_space_matrix: &dyn Fn(SpatialNodeIndex) -> Option<FloatMatrix4x4>,) {self.events.push(PainterEvent::Run(run_index));+ self.run_record_sizes.push(records.len());}}@@ -1106,10 +1152,145 @@ mod tests {&EffectClipPlan::new(tree, runs).unwrap(),Color::TRANSPARENT,&[],+ ReplaySelection::default(),painter,);}+ fn replay_selection(+ tree: &VisualContextTree,+ runs: &mut [DisplayListCommandRun],+ run_size: u32,+ selection: ReplaySelection<'_>,+ ) -> RecordingPainter {+ for (index, run) in runs.iter_mut().enumerate() {+ run.offset = index as u32 * run_size;+ run.size = run_size;+ }+ let tape = vec![0u8; runs.len() * run_size as usize];+ let mut painter = RecordingPainter::new();+ replay_display_list(+ tree,+ &tape,+ runs,+ &EffectClipPlan::new(tree, runs).unwrap(),+ Color::TRANSPARENT,+ &[],+ selection,+ &mut painter,+ );+ painter+ .events+ .retain(|event| !matches!(event, PainterEvent::SetMatrix(_)));+ painter+ }++ #[test]+ fn a_span_replay_plays_only_its_runs_and_enters_their_contexts_from_what_it_played() {+ let mut tree = identity_tree();+ let rect = FloatRect::new(0.0, 0.0, 100.0, 100.0);+ let clip = root_clip(&mut tree, rect);+ let layer = effect_under(&mut tree, effects(0.5), EffectNodeIndex::NONE, ClipNodeIndex::NONE);+ let clipped = ContextRef {+ clip,+ ..ContextRef::default()+ };+ let in_layer = ContextRef {+ effect: layer,+ ..ContextRef::default()+ };+ let mut runs =+ [clipped, in_layer, clipped].map(|context| run(VISUAL_VIEWPORT_NODE_INDEX, context, visible_bounds()));+ let spans = [+ RecordSpan {+ begin_offset: 0,+ end_offset: 8,+ },+ RecordSpan {+ begin_offset: 16,+ end_offset: 24,+ },+ ];+ let painter = replay_selection(+ &tree,+ &mut runs,+ 8,+ ReplaySelection {+ record_spans: Some(&spans),+ skip_root_isolation_layer: false,+ },+ );+ assert_eq!(+ painter.events,+ vec![+ PainterEvent::PushClip(rect),+ PainterEvent::Run(0),+ PainterEvent::Run(2),+ PainterEvent::Pop,+ ]+ );+ }++ #[test]+ fn a_span_replay_plays_the_records_of_a_run_inside_the_span() {+ let mut runs = [ClipNodeIndex::NONE, ClipNodeIndex::NONE]+ .map(|_| run(VISUAL_VIEWPORT_NODE_INDEX, ContextRef::default(), visible_bounds()));+ runs[1].context.effect = EffectNodeIndex(0);+ let mut tree = identity_tree();+ effect_under(&mut tree, effects(1.0), EffectNodeIndex::NONE, ClipNodeIndex::NONE);+ let spans = [RecordSpan {+ begin_offset: 8,+ end_offset: 24,+ }];+ let painter = replay_selection(+ &tree,+ &mut runs,+ 16,+ ReplaySelection {+ record_spans: Some(&spans),+ skip_root_isolation_layer: false,+ },+ );+ assert_eq!(painter.events, vec![PainterEvent::Run(0), PainterEvent::Run(1)]);+ assert_eq!(painter.run_record_sizes, vec![8, 8]);+ }++ #[test]+ fn a_replay_that_skips_the_root_isolation_layer_pushes_only_the_layers_inside_it() {+ let mut tree = identity_tree();+ let root = effect_under(&mut tree, effects(1.0), EffectNodeIndex::NONE, ClipNodeIndex::NONE);+ tree.root_isolation_effect = Some(root);+ let layer = effect_under(&mut tree, effects(0.5), root, ClipNodeIndex::NONE);+ let mut runs = [root, layer].map(|effect| {+ run(+ VISUAL_VIEWPORT_NODE_INDEX,+ ContextRef {+ effect,+ ..ContextRef::default()+ },+ visible_bounds(),+ )+ });+ let painter = replay_selection(+ &tree,+ &mut runs,+ 8,+ ReplaySelection {+ record_spans: None,+ skip_root_isolation_layer: true,+ },+ );+ assert_eq!(+ painter.events,+ vec![+ PainterEvent::Run(0),+ PainterEvent::PushLayer(0.5),+ PainterEvent::Run(1),+ PainterEvent::Pop,+ ]+ );+ }+#[test]fn an_inline_clip_in_a_space_of_its_own_is_pushed_under_the_matrix_of_that_space() {let clip_space = SpatialNodeIndex(7);@@ -1880,6 +2061,7 @@ mod tests {&EffectClipPlan::new(&tree, &runs).unwrap(),white,&[],+ ReplaySelection::default(),&mut painter,);assert_eq!(painter.backdrop_base_colors, vec![white, Color::TRANSPARENT]);@@ -2006,6 +2188,7 @@ mod tests {&EffectClipPlan::new(&tree, &runs).unwrap(),Color::TRANSPARENT,&scroll_offsets,+ ReplaySelection::default(),&mut painter,);assert_eq!(diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rsindex dc29ef2a8cf..72e3f60e102 100644--- a/Libraries/LibCompositing/Rust/src/ffi.rs+++ b/Libraries/LibCompositing/Rust/src/ffi.rs@@ -59,6 +59,7 @@ pub unsafe fn replay_display_list_storage(storage: *const c_void,root_group_color: libgfx_rust::Color,scroll_offsets: &[FloatPoint],+ selection: crate::display_list::replay::ReplaySelection<'_>,callbacks: *const crate::host::FfiDisplayListReplayCallbacks,) {// SAFETY: The caller guarantees a live handle for the duration of the call.@@ -72,6 +73,7 @@ pub unsafe fn replay_display_list_storage(storage.effect_clip_plan(tree),root_group_color,scroll_offsets,+ selection,&mut painter,);}@@ -109,7 +111,16 @@ pub unsafe extern "C" fn display_list_replay(callbacks: *const crate::host::FfiDisplayListReplayCallbacks,) {// SAFETY: The caller guarantees live handles and callbacks for the duration of the call.- unsafe { replay_display_list_storage(tree_from_handle(tree), storage, root_group_color, &[], callbacks) };+ unsafe {+ replay_display_list_storage(+ tree_from_handle(tree),+ storage,+ root_group_color,+ &[],+ Default::default(),+ callbacks,+ );+ };}/// Plays a stream of records that a command nests, outside of any run, with nothing scrolled.diff --git a/Libraries/LibCompositing/Rust/src/host/replay.rs b/Libraries/LibCompositing/Rust/src/host/replay.rsindex 2cc2c5de538..849ba243b98 100644--- a/Libraries/LibCompositing/Rust/src/host/replay.rs+++ b/Libraries/LibCompositing/Rust/src/host/replay.rs@@ -5,12 +5,44 @@*/use crate::display_list::commands::{DisplayListCommandType, EffectNodeIndex, ReplayClip, ReplayLayer, ReplayMask};-use crate::display_list::replay::ReplayPainter;+use crate::display_list::replay::{ReplayPainter, ReplaySelection};use libgfx_rust::path::Path;use libgfx_rust::path::ffi::PathGeometryData;use libgfx_rust::{AffineTransform, FloatMatrix4x4, FloatVector3, IntRect, WindingRule};use std::ffi::c_void;+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+#[repr(C)]+pub struct RecordSpan {+ pub begin_offset: u32,+ pub end_offset: u32,+}++#[derive(Clone, Copy)]+#[repr(C)]+pub struct FfiReplaySelection {+ pub record_spans: *const RecordSpan,+ pub record_span_count: usize,+ pub replays_only_record_spans: bool,+ pub skip_root_isolation_layer: bool,+}++impl FfiReplaySelection {+ /// # Safety+ ///+ /// When the selection replays only record spans, `record_spans` must point at `record_span_count` spans that stay+ /// live for the returned lifetime.+ pub unsafe fn as_selection<'a>(&self) -> ReplaySelection<'a> {+ ReplaySelection {+ // SAFETY: The caller guarantees the spans are live.+ record_spans: self+ .replays_only_record_spans+ .then(|| unsafe { ak::slice_from_raw_parts(self.record_spans, self.record_span_count) }),+ skip_root_isolation_layer: self.skip_root_isolation_layer,+ }+ }+}+#[derive(Clone, Copy)]#[repr(C)]pub struct FfiDisplayListReplayCallbacks {diff --git a/Services/Compositor/DisplayListPlayer.cpp b/Services/Compositor/DisplayListPlayer.cppindex 1d9988f8a5a..5d70e88f19e 100644--- a/Services/Compositor/DisplayListPlayer.cpp+++ b/Services/Compositor/DisplayListPlayer.cpp@@ -20,9 +20,12 @@ void DisplayListPlayer::execute(DisplayListResourceStorage const& resource_storage,FrameInputs const* frame_inputs,RefPtr<Gfx::PaintingSurface> surface,- OwnedCanvasSurfaces const* canvas_surfaces)+ OwnedCanvasSurfaces const* canvas_surfaces,+ ReplaySelection const& selection){VERIFY(display_list.compatible_visual_context_tree_structural_epoch() == visual_context_tree.structural_epoch());+ VERIFY(frame_inputs || !selection.replays_only_record_spans);+ TemporaryChange replay_selection_change { m_replay_selection, selection };m_surface = surface;m_active_display_list = &display_list;m_active_visual_context_tree = &visual_context_tree;@@ -136,7 +139,7 @@ void DisplayListPlayer::execute_impl(DisplayList const& display_list, FrameInputauto callbacks = ReplayCallbacks::for_player(*this);if (frame_inputs) {VERIFY(frame_inputs->visual_context_tree().rust_handle() == visual_context_tree.rust_handle());- frame_inputs->replay(display_list, callbacks);+ frame_inputs->replay(display_list, callbacks, exchange(m_replay_selection, replaying_everything()));} else {display_list.replay(visual_context_tree, callbacks);}diff --git a/Services/Compositor/DisplayListPlayer.h b/Services/Compositor/DisplayListPlayer.hindex 9d5e3935433..74a501ce39f 100644--- a/Services/Compositor/DisplayListPlayer.h+++ b/Services/Compositor/DisplayListPlayer.h@@ -26,7 +26,7 @@ public:virtual ~DisplayListPlayer() = default;// The frame inputs say where the frame presents what scrolls. Without them, nothing is scrolled.- void execute(Compositing::DisplayList const&, Compositing::AccumulatedVisualContextTree const&, Compositing::DisplayListResourceStorage const&, FrameInputs const*, RefPtr<Gfx::PaintingSurface>, OwnedCanvasSurfaces const* = nullptr);+ void execute(Compositing::DisplayList const&, Compositing::AccumulatedVisualContextTree const&, Compositing::DisplayListResourceStorage const&, FrameInputs const*, RefPtr<Gfx::PaintingSurface>, OwnedCanvasSurfaces const* = nullptr, ReplaySelection const& = replaying_everything());virtual void flush(Gfx::PaintingSurface&) = 0;protected:@@ -88,6 +88,7 @@ private:RefPtr<Gfx::PaintingSurface> m_surface;ReadonlyBytes m_current_command_payload;FrameInputs const* m_active_frame_inputs { nullptr };+ ReplaySelection m_replay_selection { replaying_everything() };HashMap<u32, ReadonlyBytes> m_declared_mask_contents;};diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cppindex 0e070f105ff..e40e6e7a26c 100644--- a/Services/Compositor/DisplayListPlayerSkia.cpp+++ b/Services/Compositor/DisplayListPlayerSkia.cpp@@ -70,11 +70,13 @@ void DisplayListPlayerSkia::execute(FrameInputs const* frame_inputs,RefPtr<Gfx::PaintingSurface> surface,OwnedCanvasSurfaces const* canvas_surfaces,- CompositedContextResolver const* composited_context_resolver)+ CompositedContextResolver const* composited_context_resolver,+ ReplaySelection const& selection){TemporaryChange composited_context_resolver_change { m_composited_context_resolver, composited_context_resolver };TemporaryChange scrollbars_of_frame_change { m_scrollbars_of_frame, frame_inputs ? frame_inputs->scrollbars() : ReadonlySpan<ScrollbarOfFrame> {} };- raster_cache.drop_clip_paths_not_used_since_last_frame();+ if (!selection.replays_only_record_spans)+ raster_cache.drop_clip_paths_not_used_since_last_frame();TemporaryChange raster_cache_change { m_raster_cache, &raster_cache };DisplayListPlayer::execute(display_list,@@ -82,7 +84,8 @@ void DisplayListPlayerSkia::execute(resource_storage,frame_inputs,move(surface),- canvas_surfaces);+ canvas_surfaces,+ selection);}static SkRRect to_skia_rrect(auto const& rect, Gfx::CornerRadii const& corner_radii)diff --git a/Services/Compositor/DisplayListPlayerSkia.h b/Services/Compositor/DisplayListPlayerSkia.hindex 9e371f42770..aa6d79efdb7 100644--- a/Services/Compositor/DisplayListPlayerSkia.h+++ b/Services/Compositor/DisplayListPlayerSkia.h@@ -51,7 +51,8 @@ public:FrameInputs const*,RefPtr<Gfx::PaintingSurface>,OwnedCanvasSurfaces const*,- CompositedContextResolver const*);+ CompositedContextResolver const*,+ ReplaySelection const& = replaying_everything());void flush(Gfx::PaintingSurface&) override;void flush_async(Gfx::PaintingSurface&, Function<void()>&&);diff --git a/Services/Compositor/FrameInputs.cpp b/Services/Compositor/FrameInputs.cppindex cdde3efdf0c..d22a1b8bf8d 100644--- a/Services/Compositor/FrameInputs.cpp+++ b/Services/Compositor/FrameInputs.cpp@@ -51,10 +51,10 @@ ReadonlySpan<ScrollbarOfFrame> FrameInputs::scrollbars() constreturn { scrollbars, count };}-void FrameInputs::replay(Compositing::DisplayList const& display_list, Compositing::RustFFI::FfiDisplayListReplayCallbacks const& callbacks) const+void FrameInputs::replay(Compositing::DisplayList const& display_list, Compositing::RustFFI::FfiDisplayListReplayCallbacks const& callbacks, ReplaySelection const& selection) const{VERIFY(display_list.compatible_visual_context_tree_structural_epoch() == m_visual_context_tree.structural_epoch());- RustFFI::compositor_frame_inputs_replay(m_frame_inputs, display_list.rust_handle(), display_list.root_group_color(), &callbacks);+ RustFFI::compositor_frame_inputs_replay(m_frame_inputs, display_list.rust_handle(), display_list.root_group_color(), &selection, &callbacks);}void FrameInputs::replay_records(ReadonlyBytes records, Compositing::RustFFI::FfiDisplayListReplayCallbacks const& callbacks) constdiff --git a/Services/Compositor/FrameInputs.h b/Services/Compositor/FrameInputs.hindex 75ac1fcae10..627f44b6b66 100644--- a/Services/Compositor/FrameInputs.h+++ b/Services/Compositor/FrameInputs.h@@ -30,6 +30,17 @@ struct PresentedScrollbar {};using ScrollbarOfFrame = RustFFI::ScrollbarOfFrame;+using ReplaySelection = Compositing::RustFFI::FfiReplaySelection;++constexpr ReplaySelection replaying_everything()+{+ return { nullptr, 0, false, false };+}++inline ReplaySelection replaying_only(ReadonlySpan<Compositing::RustFFI::RecordSpan> record_spans, bool skip_root_isolation_layer = false)+{+ return { record_spans.data(), record_spans.size(), true, skip_root_isolation_layer };+}// A scroll offset outside the scroll range moves the thumb past an end of its track, where it is cut short instead.inline Gfx::IntRect thumb_rect_kept_inside_track(Gfx::IntRect thumb_rect, Gfx::IntRect const& track_rect, bool vertical)@@ -87,7 +98,7 @@ public:ReadonlySpan<ScrollbarOfFrame> scrollbars() const;// Replays the list through a player's callbacks as the frame shows it.- void replay(Compositing::DisplayList const&, Compositing::RustFFI::FfiDisplayListReplayCallbacks const&) const;+ void replay(Compositing::DisplayList const&, Compositing::RustFFI::FfiDisplayListReplayCallbacks const&, ReplaySelection const& = replaying_everything()) const;// Replays a stream of records that a command of the list being replayed nests.void replay_records(ReadonlyBytes records, Compositing::RustFFI::FfiDisplayListReplayCallbacks const&) const;diff --git a/Services/Compositor/Rust/build.rs b/Services/Compositor/Rust/build.rsindex e5159aae401..908941904d0 100644--- a/Services/Compositor/Rust/build.rs+++ b/Services/Compositor/Rust/build.rs@@ -34,6 +34,8 @@ fn main() -> Result<(), Box<dyn Error>> {"FfiDisplayListReplayCallbacks","Compositing::RustFFI::FfiDisplayListReplayCallbacks",),+ ("FfiReplaySelection", "Compositing::RustFFI::FfiReplaySelection"),+ ("RecordSpan", "Compositing::RustFFI::RecordSpan"),("CanvasId", "Compositing::CanvasId"),("VideoSinkResourceId", "Compositing::VideoSinkResourceId"),("ImageFrameResourceId", "Compositing::ImageFrameResourceId"),diff --git a/Services/Compositor/Rust/src/ffi.rs b/Services/Compositor/Rust/src/ffi.rsindex 733d8d0aadd..423d130cbf6 100644--- a/Services/Compositor/Rust/src/ffi.rs+++ b/Services/Compositor/Rust/src/ffi.rs@@ -22,7 +22,7 @@ use libcompositing_rust::display_list::storage::storage_from_handle;use libcompositing_rust::ffi::{FfiDisplayList, replay_display_list_storage, replay_nested_records, tree_sharing_handle,};-use libcompositing_rust::host::FfiDisplayListReplayCallbacks;+use libcompositing_rust::host::{FfiDisplayListReplayCallbacks, FfiReplaySelection};use libcompositing_rust::ipc_types::{Compositing_ContextVisibility as ContextVisibility, compositor_presentation_server, compositor_web_content_server,};@@ -335,22 +335,25 @@ pub extern "C" fn compositor_frame_inputs_scrollbars(////// # Safety///-/// `display_list_storage` must be a live storage handle of the list the context holds, and `callbacks` must be live.-/// The painter callbacks run synchronously and may re-enter a replay.+/// `display_list_storage` must be a live storage handle of the list the context holds, `selection` must hold live+/// spans when it selects any, and `callbacks` must be live. The painter callbacks run synchronously and may re-enter a+/// replay.#[unsafe(no_mangle)]pub unsafe extern "C" fn compositor_frame_inputs_replay(frame_inputs: &FrameInputs,display_list_storage: *const c_void,root_group_color: Color,+ selection: &FfiReplaySelection,callbacks: *const FfiDisplayListReplayCallbacks,) {- // SAFETY: The caller lends a live storage handle and live callbacks.+ // SAFETY: The caller lends a live storage handle, live spans and live callbacks.unsafe {replay_display_list_storage(frame_inputs.visual_context_tree.as_arc(),display_list_storage,root_group_color,frame_inputs.presented_scroll_state_snapshot.device_offsets(),+ selection.as_selection(),callbacks,);}