mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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>
This commit is contained in:
parent
1df1ba58d6
commit
53a2e61fec
13 changed files with 224 additions and 45 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue