diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-03-26 21:35:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 01:35:02 +0000 |
commit | 53a2e61fecd42d4d35b7ff5479095cf86e12c1ae (patch) | |
tree | be8a4e29a1662d4b308666fcac280bd322bc0855 /components/shared/script/serializable.rs | |
parent | 1df1ba58d6a2fe5807a2770d4c118af79c2d5fab (diff) | |
download | servo-53a2e61fecd42d4d35b7ff5479095cf86e12c1ae.tar.gz servo-53a2e61fecd42d4d35b7ff5479095cf86e12c1ae.zip |
Make DOMPoint and DOMPointReadOnly serializable (#35989)
* script: Make DOMPointReadOnly serializable.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Make DOMPoint serializable.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Shrink worker script event.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Update components/script/dom/dompoint.rs
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
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()) + } +} |