mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Make DOMException serializable (#36535)
Follow the implementation of making DOMPoint and DOMPointReadOnly serializable in PR #35989 Testing: Passed a test previously expected to fail. Fixes: #36463 --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
parent
cc04caa8ce
commit
dacd951c9f
6 changed files with 138 additions and 12 deletions
|
@ -13,7 +13,7 @@ use std::cell::RefCell;
|
|||
use std::collections::{HashMap, VecDeque};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use base::id::{BlobId, DomPointId, MessagePortId};
|
||||
use base::id::{BlobId, DomExceptionId, DomPointId, MessagePortId};
|
||||
use log::warn;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use net_traits::filemanager_thread::RelativePos;
|
||||
|
@ -177,6 +177,8 @@ pub struct StructuredSerializedData {
|
|||
pub blobs: Option<HashMap<BlobId, BlobImpl>>,
|
||||
/// Serialized point objects.
|
||||
pub points: Option<HashMap<DomPointId, DomPoint>>,
|
||||
/// Serialized exception objects.
|
||||
pub exceptions: Option<HashMap<DomExceptionId, DomException>>,
|
||||
/// Transferred objects.
|
||||
pub ports: Option<HashMap<MessagePortId, MessagePortImpl>>,
|
||||
}
|
||||
|
@ -205,6 +207,8 @@ pub enum Serializable {
|
|||
DomPoint,
|
||||
/// The `DOMPointReadOnly` interface.
|
||||
DomPointReadOnly,
|
||||
/// The `DOMException` interface.
|
||||
DomException,
|
||||
}
|
||||
|
||||
impl Serializable {
|
||||
|
@ -215,6 +219,9 @@ impl Serializable {
|
|||
StructuredSerializedData::clone_all_of_type::<DomPoint>
|
||||
},
|
||||
Serializable::DomPoint => StructuredSerializedData::clone_all_of_type::<DomPoint>,
|
||||
Serializable::DomException => {
|
||||
StructuredSerializedData::clone_all_of_type::<DomException>
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +301,7 @@ pub struct PortMessageTask {
|
|||
|
||||
/// Messages for communication between the constellation and a global managing ports.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MessagePortMsg {
|
||||
/// Complete the transfer for a batch of ports.
|
||||
CompleteTransfer(HashMap<MessagePortId, VecDeque<PortMessageTask>>),
|
||||
|
@ -526,3 +534,30 @@ impl BroadcastClone for DomPoint {
|
|||
Some(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||
/// A serializable version of the DOMException interface.
|
||||
pub struct DomException {
|
||||
pub message: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl BroadcastClone for DomException {
|
||||
type Id = DomExceptionId;
|
||||
|
||||
fn source(
|
||||
data: &StructuredSerializedData,
|
||||
) -> &Option<std::collections::HashMap<Self::Id, Self>> {
|
||||
&data.exceptions
|
||||
}
|
||||
|
||||
fn destination(
|
||||
data: &mut StructuredSerializedData,
|
||||
) -> &mut Option<std::collections::HashMap<Self::Id, Self>> {
|
||||
&mut data.exceptions
|
||||
}
|
||||
|
||||
fn clone_for_broadcast(&self) -> Option<Self> {
|
||||
Some(self.clone())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue