diff options
Diffstat (limited to 'components/shared/script/serializable.rs')
-rw-r--r-- | components/shared/script/serializable.rs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/components/shared/script/serializable.rs b/components/shared/script/serializable.rs index 8e9f9f5b3da..5d89c622bee 100644 --- a/components/shared/script/serializable.rs +++ b/components/shared/script/serializable.rs @@ -11,7 +11,7 @@ use std::cell::RefCell; use std::path::PathBuf; -use base::id::BlobId; +use base::id::{BlobId, DomPointId}; use malloc_size_of_derive::MallocSizeOf; use net_traits::filemanager_thread::RelativePos; use serde::{Deserialize, Serialize}; @@ -182,3 +182,36 @@ impl BlobImpl { &mut self.blob_data } } + +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] +/// A serializable version of the DOMPoint/DOMPointReadOnly interface. +pub struct DomPoint { + /// The x coordinate. + pub x: f64, + /// The y coordinate. + pub y: f64, + /// The z coordinate. + pub z: f64, + /// The w coordinate. + pub w: f64, +} + +impl crate::BroadcastClone for DomPoint { + type Id = DomPointId; + + fn source( + data: &crate::StructuredSerializedData, + ) -> &Option<std::collections::HashMap<Self::Id, Self>> { + &data.points + } + + fn destination( + data: &mut crate::StructuredSerializedData, + ) -> &mut Option<std::collections::HashMap<Self::Id, Self>> { + &mut data.points + } + + fn clone_for_broadcast(&self) -> Option<Self> { + Some(self.clone()) + } +} |