Truly independent web browser
LibCompositing+LibWeb+Compositor: Send trees and scroll states typed
Aliaksandr Kalenik2f454d9d6368
diff --git a/Libraries/LibCompositing/Rust/src/ipc_types.rs b/Libraries/LibCompositing/Rust/src/ipc_types.rsindex 9cce7b811c9..8af8e0e06b3 100644--- a/Libraries/LibCompositing/Rust/src/ipc_types.rs+++ b/Libraries/LibCompositing/Rust/src/ipc_types.rs@@ -26,6 +26,8 @@ pub type Gfx_IntSize = libgfx_rust::IntSize;pub type Gfx_IntRect = libgfx_rust::IntRect;pub type Gfx_FloatRect = libgfx_rust::FloatRect;pub type Gfx_Color = libgfx_rust::Color;+pub type Compositing_VisualContextTree = Arc<VisualContextTree>;+pub type Compositing_ScrollStateSnapshot = crate::scrolling::ScrollStateSnapshot;impl Encode for CompositorContextId {fn encode(&self, encoder: &mut Encoder) -> Result<(), EncodeError> {@@ -169,7 +171,7 @@ impl NestedDisplayListResource {encoder.encode_size(self.storage.bytes().len())?;encoder.encode_size(self.storage.command_runs().len())?;encoder.append_bytes(&self.storage.packed());- encoder.encode(&self.tree.to_bytes())+ encoder.encode(&self.tree)}}@@ -249,7 +251,7 @@ impl Decode for Compositing_DisplayListResourceTransaction {packed_size(tape_size, run_count).ok_or(DecodeError::InvalidValue("Display list sizes overflow"))?;let packed = decoder.read_bytes(packed_size)?;let storage = receive_packed(packed, tape_size, run_count).map_err(DecodeError::InvalidValue)?;- let tree = Arc::new(VisualContextTree::from_bytes(&decoder.decode::<Vec<u8>>()?)?);+ let tree: Arc<VisualContextTree> = decoder.decode()?;if properties.compatible_visual_context_tree_structural_epoch != tree.structural_epoch {return Err(DecodeError::InvalidValue("Display list resource does not match its visual context tree",diff --git a/Libraries/LibCompositing/Rust/src/scrolling/scroll_state_snapshot.rs b/Libraries/LibCompositing/Rust/src/scrolling/scroll_state_snapshot.rsindex af7dc10cd6d..7d3847fd0a9 100644--- a/Libraries/LibCompositing/Rust/src/scrolling/scroll_state_snapshot.rs+++ b/Libraries/LibCompositing/Rust/src/scrolling/scroll_state_snapshot.rs@@ -86,28 +86,17 @@ impl ScrollStateSnapshot {}}- // The wire form, for C++ to carry to where Rust decodes it again.- pub fn to_encoded_bytes(&self) -> Vec<u8> {- let mut encoder = Encoder::new();- encoder.encode(self).expect("a scroll state snapshot encodes");- encoder.finish().0- }-- pub fn from_encoded_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {- let mut decoder = Decoder::new(bytes, []);- let snapshot = decoder.decode()?;- if !decoder.is_at_end() {- return Err(DecodeError::InvalidValue(- "bytes after an encoded scroll state snapshot",- ));- }- Ok(snapshot)- }-pub fn device_offsets(&self) -> &[FloatPoint] {&self.device_offsets}+ /// Whether this holds the offsets `other` holds, as the compositor receives them, which holds no zero offset.+ pub fn holds_the_offsets_of(&self, other: &Self) -> bool {+ let offset_at = |offsets: &[FloatPoint], index: usize| offsets.get(index).copied().unwrap_or_default();+ let count = self.device_offsets.len().max(other.device_offsets.len());+ (0..count).all(|index| offset_at(&self.device_offsets, index) == offset_at(&other.device_offsets, index))+ }+// The world transforms of the tree under these offsets, in the layout viewport's space, kept until either changes.pub fn world_transforms(&self, tree: &AccumulatedVisualContextTree) -> Arc<WorldTransforms> {self.world_transforms_cache.get_or_build(tree, &self.device_offsets)@@ -223,6 +212,16 @@ impl Decode for ScrollStateSnapshot {mod tests {use super::*;+ fn decoded(bytes: &[u8]) -> ScrollStateSnapshot {+ Decoder::new(bytes, []).decode().unwrap()+ }++ fn encoded(snapshot: &ScrollStateSnapshot) -> Vec<u8> {+ let mut encoder = Encoder::new();+ encoder.encode(snapshot).unwrap();+ encoder.finish().0+ }+// An index far above any real node count, but still inside the range the decoder accepts. Densifying it would// allocate (index + 1) * size_of::<FloatPoint>(), i.e. 512 MiB: the allocation the node-count bound exists to stop.const MALICIOUS_INDEX: u32 = 0x0400_0000;@@ -234,7 +233,7 @@ mod tests {encoder.encode(index).unwrap();encoder.encode(offset).unwrap();}- ScrollStateSnapshot::from_encoded_bytes(&encoder.finish().0).unwrap()+ decoded(&encoder.finish().0)}#[test]@@ -280,12 +279,27 @@ mod tests {assert!(snapshot.device_offsets().len() <= 4);}+ #[test]+ fn snapshots_that_differ_only_by_zero_offsets_hold_the_same_offsets() {+ let mut snapshot = ScrollStateSnapshot::default();+ snapshot.set_device_offset_for_index(SpatialNodeIndex(1), FloatPoint { x: 10.0, y: 20.0 });+ let mut with_trailing_zero = snapshot.clone();+ with_trailing_zero.set_device_offset_for_index(SpatialNodeIndex(5), FloatPoint::default());+ assert!(snapshot.holds_the_offsets_of(&with_trailing_zero));+ assert!(with_trailing_zero.holds_the_offsets_of(&snapshot));++ let mut scrolled = snapshot.clone();+ scrolled.set_device_offset_for_index(SpatialNodeIndex(5), FloatPoint { x: 0.0, y: 1.0 });+ assert!(!snapshot.holds_the_offsets_of(&scrolled));+ assert!(!scrolled.holds_the_offsets_of(&snapshot));+ }+#[test]fn wire_round_trip_preserves_scroll_offsets() {let mut snapshot = ScrollStateSnapshot::default();snapshot.set_device_offset_for_index(SpatialNodeIndex(3), FloatPoint { x: 10.0, y: 20.0 });- let mut decoded = ScrollStateSnapshot::from_encoded_bytes(&snapshot.to_encoded_bytes()).unwrap();+ let mut decoded = decoded(&encoded(&snapshot));decoded.set_node_count(8);assert_eq!(diff --git a/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs b/Libraries/LibCompositing/Rust/src/visual_context/serialize.rsindex b1f020bd04c..5881924b775 100644--- a/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs+++ b/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs@@ -1062,6 +1062,7 @@ impl Decode for VisualContextTree {}}+#[cfg(test)]impl VisualContextTree {pub fn to_bytes(&self) -> Vec<u8> {let mut encoder = Encoder::new();diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.cpp b/Libraries/LibWeb/Painting/DocumentPaintState.cppindex 1638056908c..ce3c0e4915f 100644--- a/Libraries/LibWeb/Painting/DocumentPaintState.cpp+++ b/Libraries/LibWeb/Painting/DocumentPaintState.cpp@@ -120,15 +120,6 @@ bool DocumentPaintState::translations_snap_to_device_pixels(DOM::Document const&return Layout::RustFFI::render_state_translations_snap_to_device_pixels(m_layout_node_arena->host(), read, box);}-ByteBuffer DocumentPaintState::encoded_scroll_state() const-{- ByteBuffer bytes;- Layout::RustFFI::render_state_encode_scroll_state(m_layout_node_arena->host(), &bytes, [](void* sink, u8 const* data, size_t size) {- MUST(static_cast<ByteBuffer*>(sink)->try_append(data, size));- });- return bytes;-}-void DocumentPaintState::reset_selection_states(Layout::BegunRead const& read, DOM::Document& document){Layout::RustFFI::render_state_clear_selection(m_layout_node_arena->host(), viewport_row_slot(read, document));diff --git a/Libraries/LibWeb/Painting/DocumentPaintState.h b/Libraries/LibWeb/Painting/DocumentPaintState.hindex 5dcc70dc8be..4496c6008fd 100644--- a/Libraries/LibWeb/Painting/DocumentPaintState.h+++ b/Libraries/LibWeb/Painting/DocumentPaintState.h@@ -43,7 +43,6 @@ public:// device pixels: no transform but identities lies above it in the visual context tree, brought up to date.bool translations_snap_to_device_pixels(DOM::Document const&, Compositing::RustFFI::NodeSlotId box) const;// Only the scroll logic of the compositor, which is Rust, decodes it.- ByteBuffer encoded_scroll_state() const;void did_update_visual_context_values();void update_visual_viewport_accumulated_visual_context(Layout::BegunRead const& read, DOM::Document&);diff --git a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rsindex 71283b9d7a3..2bd32cf32bd 100644--- a/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs+++ b/Libraries/LibWeb/Rust/src/painting/ffi/main_thread_entries.rs@@ -595,22 +595,6 @@ pub unsafe extern "C" fn render_state_stacking_context_structure_verification_re}}-/// Hands `append` the scroll state of `host`'s document as the scroll logic of the compositor reads it.-///-/// # Safety-///-/// `append` is called synchronously with `sink`, and must copy the bytes it keeps.-#[unsafe(no_mangle)]-pub unsafe extern "C" fn render_state_encode_scroll_state(- host: &crate::render_state::DocumentHost,- sink: *mut c_void,- append: unsafe extern "C" fn(*mut c_void, *const u8, usize),-) {- let bytes = host.scroll_state().to_encoded_bytes();- // SAFETY: The C++ sink copies the bytes synchronously.- unsafe { append(sink, bytes.as_ptr(), bytes.len()) };-}-/// # Safety////// `host` must be a live document host, on its document's thread; the callbacks in `publish` are calleddiff --git a/Libraries/LibWeb/Rust/src/painting/presentation.rs b/Libraries/LibWeb/Rust/src/painting/presentation.rsindex 580aca94bfd..7db65f5419c 100644--- a/Libraries/LibWeb/Rust/src/painting/presentation.rs+++ b/Libraries/LibWeb/Rust/src/painting/presentation.rs@@ -76,7 +76,7 @@ struct PresenterState {/// The generation of the last frame a rendering update committed that the presenter presented.last_committed_generation: u64,/// The scroll offsets the last frame the presenter presented sent the compositor.- last_presented_encoded_scroll_state: Vec<u8>,+ last_presented_scroll_state: Option<ScrollStateSnapshot>,/// What the display list of the last frame a rendering update committed draws, which the frames of a clock lane keep/// beside their own.committed_command_resources: DisplayListResources,@@ -167,8 +167,8 @@ pub(crate) struct Presentation {presenter: Arc<NavigablePresenter>,seal: Box<Seal>,/// Where the document's boxes were scrolled to as the frame was sealed, which seeds the offsets of the boxes new to- /// the compositor, as the scroll logic of the compositor reads it.- encoded_scroll_state: Vec<u8>,+ /// the compositor.+ scroll_state: ScrollStateSnapshot,/// The visual context tree the frames presented from the seal take to the compositor where a clock tick's update/// left one, or the render state's where a frame without a recording sends it. A frame with a recording goes with/// the tree it was recorded against otherwise.@@ -196,20 +196,20 @@ struct DisplayListUpdate {output: Arc<RecordingOutput>,properties: Compositing_DisplayListProperties,async_scrolling_metadata: Compositing_AsyncScrollingMetadata,- visual_context_tree: Vec<u8>,+ visual_context_tree: Arc<VisualContextTree>,resources: ResourceUpdate,- scroll_state: Vec<u8>,+ scroll_state: ScrollStateSnapshot,}struct VisualContextTreeUpdate {- visual_context_tree: Vec<u8>,+ visual_context_tree: Arc<VisualContextTree>,resources: ResourceUpdate,- scroll_state: Vec<u8>,+ scroll_state: ScrollStateSnapshot,keyboard_scroll_state: Compositing_KeyboardScrollState,}struct ScrollStateUpdate {- scroll_state: Vec<u8>,+ scroll_state: ScrollStateSnapshot,keyboard_scroll_state: Compositing_KeyboardScrollState,}@@ -275,10 +275,13 @@ impl PresenterState {seal.presented_by == FfiPresentedBy::Clock && seal.generation < self.last_committed_generation}- fn note_presented(&mut self, seal: &mut Seal, encoded_scroll_state: &[u8]) {- seal.presented_other_scroll_offsets = self.last_presented_encoded_scroll_state != encoded_scroll_state;+ fn note_presented(&mut self, seal: &mut Seal, scroll_state: &ScrollStateSnapshot) {+ seal.presented_other_scroll_offsets = !self+ .last_presented_scroll_state+ .as_ref()+ .is_some_and(|last| last.holds_the_offsets_of(scroll_state));if seal.presented_other_scroll_offsets {- self.last_presented_encoded_scroll_state = encoded_scroll_state.to_vec();+ self.last_presented_scroll_state = Some(scroll_state.clone());}if seal.presented_by == FfiPresentedBy::Commit {self.last_committed_generation = self.last_committed_generation.max(seal.generation);@@ -391,7 +394,7 @@ impl PresenterState {seal: &Seal,published: Option<Published>,visual_context_tree: &Arc<VisualContextTree>,- encoded_scroll_state: &[u8],+ scroll_state: &ScrollStateSnapshot,) -> CompositorFrame {// Keyboard eligibility belongs to this publication, not to the cached paint commands. Refresh it even if recording// was skipped or repeated the display list, and send it with the corresponding scroll state.@@ -438,9 +441,9 @@ impl PresenterState {frame.display_list_update = Some(DisplayListUpdate {properties: display_list_properties_of(&output),async_scrolling_metadata,- visual_context_tree: visual_context_tree.to_bytes(),+ visual_context_tree: visual_context_tree.clone(),resources: self.resource_update(kept),- scroll_state: encoded_scroll_state.to_vec(),+ scroll_state: scroll_state.clone(),output: output.clone(),});self.compositor_display_list = Some(CompositorDisplayList {@@ -471,14 +474,14 @@ impl PresenterState {.unwrap_or_default();let kept = self.kept_resources(seal, None, &command_resources, visual_context_tree);frame.visual_context_tree_update = Some(VisualContextTreeUpdate {- visual_context_tree: visual_context_tree.to_bytes(),+ visual_context_tree: visual_context_tree.clone(),resources: self.resource_update(kept),- scroll_state: encoded_scroll_state.to_vec(),+ scroll_state: scroll_state.clone(),keyboard_scroll_state,});} else {frame.scroll_state_update = Some(ScrollStateUpdate {- scroll_state: encoded_scroll_state.to_vec(),+ scroll_state: scroll_state.clone(),keyboard_scroll_state,});}@@ -534,7 +537,7 @@ impl Presentation {visual_context_tree_mismatches_for_testing: ffi.visual_context_tree_mismatches_for_testing,generation: ffi.generation,}),- encoded_scroll_state: scroll_state.to_encoded_bytes(),+ scroll_state: scroll_state.clone(),taken_visual_context_tree: None,}}@@ -580,7 +583,7 @@ impl Presentation {Some(Self {presenter: self.presenter.clone(),seal: Box::new(seal),- encoded_scroll_state: self.encoded_scroll_state.clone(),+ scroll_state: self.scroll_state.clone(),taken_visual_context_tree: None,})}@@ -597,7 +600,7 @@ impl Presentation {// was cut from a tree of its structure.let tree_is_restructured = restructured_scroll_offsets.is_some();if let Some(scroll_offsets) = restructured_scroll_offsets {- self.encoded_scroll_state = ScrollStateSnapshot::from_device_offsets(scroll_offsets).to_encoded_bytes();+ self.scroll_state = ScrollStateSnapshot::from_device_offsets(scroll_offsets);}if !tree_is_restructured && let Some(epoch) = self.seal.visual_context_tree_structural_epoch {assert_eq!(@@ -639,9 +642,9 @@ impl Presentation {.and_then(|display_list| display_list.output.visual_context_tree.clone())}).unwrap_or_else(|| Arc::new(VisualContextTree::create_identity()));- let mut frame = state.build_frame(&self.seal, None, &tree, &self.encoded_scroll_state);+ let mut frame = state.build_frame(&self.seal, None, &tree, &self.scroll_state);frame.scroll_requests = std::mem::take(&mut self.seal.scroll_requests);- state.note_presented(&mut self.seal, &self.encoded_scroll_state);+ state.note_presented(&mut self.seal, &self.scroll_state);presenting.post_frame(frame);}@@ -676,14 +679,14 @@ impl Presentation {replaces_paint_command_cache_source,}),&tree,- &self.encoded_scroll_state,+ &self.scroll_state,);if replaces_paint_command_cache_source {self.seal.paint_command_cache_source = Some(output.clone());}self.seal.published = Some(output.clone());frame.scroll_requests = std::mem::take(&mut self.seal.scroll_requests);- state.note_presented(&mut self.seal, &self.encoded_scroll_state);+ state.note_presented(&mut self.seal, &self.scroll_state);presenting.post_frame(frame);}}diff --git a/Libraries/LibWeb/Rust/src/painting/rasterize.rs b/Libraries/LibWeb/Rust/src/painting/rasterize.rsindex d6132326a81..2d7bd772017 100644--- a/Libraries/LibWeb/Rust/src/painting/rasterize.rs+++ b/Libraries/LibWeb/Rust/src/painting/rasterize.rs@@ -169,7 +169,7 @@ fn post_rasterization(surface_clear_color: None,root_group_color: libgfx_rust::Color::TRANSPARENT,},- visual_context_tree: tree.to_bytes(),+ visual_context_tree: tree,nested_display_lists: Compositing_DisplayListResourceTransaction {display_lists: resources.nested_display_listsdiff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipcindex 050879c6121..eb539cf922d 100644--- a/Services/Compositor/CompositorWebContentServer.ipc+++ b/Services/Compositor/CompositorWebContentServer.ipc@@ -41,12 +41,12 @@ endpoint CompositorWebContentServerdestroy_context(Web::CompositorContextId context_id) =|// The fonts and image frames that a display list or a visual context tree draws go ahead of it, in- // update_display_list_resources, and the resource transaction that comes with it holds none. WebContent's Rust sends- // the display lists, the trees and the scroll state.- [RustReceiver, RustSender] update_display_list(Web::CompositorContextId context_id, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, Optional<Compositing::AsyncScrollingMetadata> async_scrolling_metadata, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state) =|+ // update_display_list_resources, and the resource transaction that comes with it holds none. Only Rust sends and+ // receives the display lists, the visual context trees and the scroll state snapshots.+ [RustReceiver, RustSender] update_display_list(Web::CompositorContextId context_id, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, Optional<Compositing::AsyncScrollingMetadata> async_scrolling_metadata, Compositing::VisualContextTree visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, Compositing::ScrollStateSnapshot scroll_state) =|update_display_list_resources(Web::CompositorContextId context_id, Compositing::DisplayListResourceTransaction resource_transaction) =|- [RustReceiver, RustSender] update_visual_context_tree(Web::CompositorContextId context_id, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, ByteBuffer scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|- [RustReceiver, RustSender] update_scroll_state(Web::CompositorContextId context_id, ByteBuffer scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|+ [RustReceiver, RustSender] update_visual_context_tree(Web::CompositorContextId context_id, Compositing::VisualContextTree visual_context_tree, Compositing::DisplayListResourceTransaction resource_transaction, Compositing::ScrollStateSnapshot scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|+ [RustReceiver, RustSender] update_scroll_state(Web::CompositorContextId context_id, Compositing::ScrollStateSnapshot scroll_state, Compositing::KeyboardScrollState keyboard_scroll_state) =|// Hands WebContent a range of canvas IDs it may name its own 2D contexts with, so creating one needs no round trip.reserve_canvas_ids() => (Compositing::CanvasId first_canvas_id, u64 count)@@ -68,7 +68,7 @@ endpoint CompositorWebContentServer// a token that the next rasterize_display_list names, and with the display lists it nests, which come with it. The// compositor answers with did_rasterize_display_list().stage_rasterization(u64 token, Compositing::DisplayListResourceTransaction resources, Gfx::ShareableBitmap target_bitmap) =|- [RustReceiver, RustSender] rasterize_display_list(u64 token, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, ByteBuffer visual_context_tree, Compositing::DisplayListResourceTransaction nested_display_lists) =|+ [RustReceiver, RustSender] rasterize_display_list(u64 token, Core::AnonymousBuffer display_list_buffer, u64 tape_size, u64 run_count, Compositing::DisplayListProperties display_list_properties, Compositing::VisualContextTree visual_context_tree, Compositing::DisplayListResourceTransaction nested_display_lists) =|create_webgl_context(Compositing::WebGL::WebGLVersion webgl_version, Gfx::IntSize size, bool depth, bool stencil, bool antialias) => (bool success, Compositing::CanvasId canvas_id, Vector<String> supported_extensions)webgl_set_command_buffer(Compositing::CanvasId canvas_id, Core::AnonymousBuffer command_buffer) =|diff --git a/Services/Compositor/Rust/src/core/messages.rs b/Services/Compositor/Rust/src/core/messages.rsindex be48743a4d8..21de36d57af 100644--- a/Services/Compositor/Rust/src/core/messages.rs+++ b/Services/Compositor/Rust/src/core/messages.rs@@ -34,10 +34,9 @@ use libcompositing_rust::scrolling::async_scrolling_state::AsyncScrollOperationIuse libcompositing_rust::scrolling::{AccumulatedVisualContextTree, DisplayList};use libcompositing_rust::scrolling::{CompositorContextId, KeyEvent, KeyModifier, MouseButton, MouseEvent, MouseEventType, PendingAsyncScrollUpdates,- PinchEvent, ScrollRequest, ScrollStateSnapshot,+ PinchEvent, ScrollRequest,};use libcompositing_rust::time::MonotonicTime;-use libcompositing_rust::visual_context::VisualContextTree;use libgfx_rust::FloatPoint;use libipc_rust::Misbehavior;use std::io::Write;@@ -52,13 +51,6 @@ fn display_list_timing_enabled() -> bool {}const NESTED_DISPLAY_LISTS_THAT_NEST_THEMSELVES: &str = "WebContent published display lists that nest themselves";-const MALFORMED_VISUAL_CONTEXT_TREE: &str = "WebContent sent a visual context tree that does not decode";--fn decode_visual_context_tree(bytes: &[u8]) -> Result<std::sync::Arc<VisualContextTree>, Misbehavior> {- VisualContextTree::from_bytes(bytes)- .map(std::sync::Arc::new)- .map_err(|_| Misbehavior(MALFORMED_VISUAL_CONTEXT_TREE))-}const DISPLAY_LIST_WITH_UNUSABLE_SCROLLING_STATE: &str ="WebContent published a display list with scrolling state the compositor cannot use";@@ -248,13 +240,7 @@ impl MessagesFromWebContent<'_> {for display_list in transaction.display_lists {nested_display_lists.add(display_list);}- let tree = match decode_visual_context_tree(&message.visual_context_tree) {- Ok(tree) => tree,- Err(misbehavior) => {- raster.discard_staged_rasterization(client, token);- return Err(misbehavior);- }- };+ let tree = message.visual_context_tree;let properties = message.display_list_properties;if properties.compatible_visual_context_tree_structural_epoch != tree.structural_epoch|| !tree.display_list_references_only_live_nodes(storage.command_runs())@@ -314,7 +300,7 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {}};let adopt_time = started_at.elapsed();- let tree = decode_visual_context_tree(&message.visual_context_tree)?;+ let tree = message.visual_context_tree;if !self.context_is_owned_by_sender(message.context_id)? {return Ok(());}@@ -335,9 +321,7 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {);return Ok(());}- let Ok(scroll_state_snapshot) = ScrollStateSnapshot::from_encoded_bytes(&message.scroll_state) else {- return Err(Misbehavior(DISPLAY_LIST_WITH_UNUSABLE_SCROLLING_STATE));- };+ let scroll_state_snapshot = message.scroll_state;let display_list = DisplayList::new(storage,properties.id,@@ -373,15 +357,13 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {}fn update_visual_context_tree(&mut self, message: UpdateVisualContextTree) -> Result<(), Misbehavior> {- let unusable_scroll_state =- Misbehavior("WebContent published a visual context tree with a scroll state the compositor cannot use");- let Ok(scroll_state_snapshot) = ScrollStateSnapshot::from_encoded_bytes(&message.scroll_state) else {- return Err(unusable_scroll_state);- };+ let scroll_state_snapshot = message.scroll_state;if !scroll_state_snapshot.has_only_finite_offsets() {- return Err(unusable_scroll_state);+ return Err(Misbehavior(+ "WebContent published a visual context tree with a scroll state the compositor cannot use",+ ));}- let tree = decode_visual_context_tree(&message.visual_context_tree)?;+ let tree = message.visual_context_tree;if !self.context_is_owned_by_sender(message.context_id)? {return Ok(());}@@ -412,9 +394,7 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {}fn update_scroll_state(&mut self, message: UpdateScrollState) -> Result<(), Misbehavior> {- let Ok(scroll_state_snapshot) = ScrollStateSnapshot::from_encoded_bytes(&message.scroll_state) else {- return Err(Misbehavior("Invalid scroll state"));- };+ let scroll_state_snapshot = message.scroll_state;if !scroll_state_snapshot.has_only_finite_offsets() {return Err(Misbehavior("Invalid scroll state"));}