mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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
|
@ -21,8 +21,8 @@ use std::sync::Arc;
|
|||
use background_hang_monitor_api::BackgroundHangMonitorRegister;
|
||||
use base::cross_process_instant::CrossProcessInstant;
|
||||
use base::id::{
|
||||
BlobId, BrowsingContextId, HistoryStateId, MessagePortId, PipelineId, PipelineNamespaceId,
|
||||
WebViewId,
|
||||
BlobId, BrowsingContextId, DomPointId, HistoryStateId, MessagePortId, PipelineId,
|
||||
PipelineNamespaceId, WebViewId,
|
||||
};
|
||||
#[cfg(feature = "bluetooth")]
|
||||
use bluetooth_traits::BluetoothRequest;
|
||||
|
@ -64,7 +64,7 @@ pub use crate::script_msg::{
|
|||
DOMMessage, IFrameSizeMsg, Job, JobError, JobResult, JobResultValue, JobType, SWManagerMsg,
|
||||
SWManagerSenders, ScopeThings, ScriptMsg, ServiceWorkerMsg, TouchEventResult,
|
||||
};
|
||||
use crate::serializable::BlobImpl;
|
||||
use crate::serializable::{BlobImpl, DomPoint};
|
||||
use crate::transferable::MessagePortImpl;
|
||||
|
||||
/// The origin where a given load was initiated.
|
||||
|
@ -648,12 +648,14 @@ impl ScriptToConstellationChan {
|
|||
|
||||
/// A data-holder for serialized data and transferred objects.
|
||||
/// <https://html.spec.whatwg.org/multipage/#structuredserializewithtransfer>
|
||||
#[derive(Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||
#[derive(Debug, Default, Deserialize, MallocSizeOf, Serialize)]
|
||||
pub struct StructuredSerializedData {
|
||||
/// Data serialized by SpiderMonkey.
|
||||
pub serialized: Vec<u8>,
|
||||
/// Serialized in a structured callback,
|
||||
pub blobs: Option<HashMap<BlobId, BlobImpl>>,
|
||||
/// Serialized point objects.
|
||||
pub points: Option<HashMap<DomPointId, DomPoint>>,
|
||||
/// Transferred objects.
|
||||
pub ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
||||
}
|
||||
|
@ -678,12 +680,20 @@ where
|
|||
pub enum Serializable {
|
||||
/// The `Blob` interface.
|
||||
Blob,
|
||||
/// The `DOMPoint` interface.
|
||||
DomPoint,
|
||||
/// The `DOMPointReadOnly` interface.
|
||||
DomPointReadOnly,
|
||||
}
|
||||
|
||||
impl Serializable {
|
||||
fn clone_values(&self) -> fn(&StructuredSerializedData, &mut StructuredSerializedData) {
|
||||
match self {
|
||||
Serializable::Blob => StructuredSerializedData::clone_all_of_type::<BlobImpl>,
|
||||
Serializable::DomPointReadOnly => {
|
||||
StructuredSerializedData::clone_all_of_type::<DomPoint>
|
||||
},
|
||||
Serializable::DomPoint => StructuredSerializedData::clone_all_of_type::<DomPoint>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,9 +747,7 @@ impl StructuredSerializedData {
|
|||
|
||||
let mut cloned = StructuredSerializedData {
|
||||
serialized,
|
||||
blobs: None,
|
||||
// Ports cannot be broadcast.
|
||||
ports: None,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for serializable in Serializable::iter() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue