aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared
diff options
context:
space:
mode:
Diffstat (limited to 'components/shared')
-rw-r--r--components/shared/constellation/from_script_message.rs16
-rw-r--r--components/shared/constellation/lib.rs19
-rw-r--r--components/shared/constellation/structured_data/transferable.rs7
3 files changed, 32 insertions, 10 deletions
diff --git a/components/shared/constellation/from_script_message.rs b/components/shared/constellation/from_script_message.rs
index 625d642033e..ddc9f788617 100644
--- a/components/shared/constellation/from_script_message.rs
+++ b/components/shared/constellation/from_script_message.rs
@@ -4,7 +4,7 @@
//! Messages send from the ScriptThread to the Constellation.
-use std::collections::{HashMap, VecDeque};
+use std::collections::HashMap;
use std::fmt;
use base::Epoch;
@@ -35,7 +35,9 @@ use webgpu_traits::{WebGPU, WebGPUAdapterResponse};
use webrender_api::ImageKey;
use crate::structured_data::{BroadcastMsg, StructuredSerializedData};
-use crate::{LogEntry, MessagePortMsg, PortMessageTask, TraversalDirection, WindowSizeType};
+use crate::{
+ LogEntry, MessagePortMsg, PortMessageTask, PortTransferInfo, TraversalDirection, WindowSizeType,
+};
/// A Script to Constellation channel.
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -470,7 +472,7 @@ pub enum ScriptToConstellationMessage {
/* The ids of ports transferred successfully */
Vec<MessagePortId>,
/* The ids, and buffers, of ports whose transfer failed */
- HashMap<MessagePortId, VecDeque<PortMessageTask>>,
+ HashMap<MessagePortId, PortTransferInfo>,
),
/// A new message-port was created or transferred, with corresponding control-sender.
NewMessagePort(MessagePortRouterId, MessagePortId),
@@ -482,10 +484,14 @@ pub enum ScriptToConstellationMessage {
RerouteMessagePort(MessagePortId, PortMessageTask),
/// A message-port was shipped, let the entangled port know.
MessagePortShipped(MessagePortId),
- /// A message-port has been discarded by script.
- RemoveMessagePort(MessagePortId),
/// Entangle two message-ports.
EntanglePorts(MessagePortId, MessagePortId),
+ /// Disentangle two message-ports.
+ /// The first is the initiator, the second the other port,
+ /// unless the message is sent to complete a disentanglement,
+ /// in which case the first one is the other port,
+ /// and the second is none.
+ DisentanglePorts(MessagePortId, Option<MessagePortId>),
/// A global has started managing broadcast-channels.
NewBroadcastChannelRouter(
BroadcastChannelRouterId,
diff --git a/components/shared/constellation/lib.rs b/components/shared/constellation/lib.rs
index b3d4fe525a1..559bc2dd2d1 100644
--- a/components/shared/constellation/lib.rs
+++ b/components/shared/constellation/lib.rs
@@ -157,18 +157,29 @@ pub struct PortMessageTask {
pub data: StructuredSerializedData,
}
+/// The information needed by a global to process the transfer of a port.
+#[derive(Debug, Deserialize, MallocSizeOf, Serialize)]
+pub struct PortTransferInfo {
+ /// <https://html.spec.whatwg.org/multipage/#port-message-queue>
+ pub port_message_queue: VecDeque<PortMessageTask>,
+ /// A boolean indicating whether the port has been disentangled while in transfer,
+ /// if so, the disentanglement should be completed along with the transfer.
+ /// <https://html.spec.whatwg.org/multipage/#disentangle>
+ pub disentangled: bool,
+}
+
/// 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>>),
+ CompleteTransfer(HashMap<MessagePortId, PortTransferInfo>),
/// Complete the transfer of a single port,
/// whose transfer was pending because it had been requested
/// while a previous failed transfer was being rolled-back.
- CompletePendingTransfer(MessagePortId, VecDeque<PortMessageTask>),
- /// Remove a port, the entangled one doesn't exists anymore.
- RemoveMessagePort(MessagePortId),
+ CompletePendingTransfer(MessagePortId, PortTransferInfo),
+ /// <https://html.spec.whatwg.org/multipage/#disentangle>
+ CompleteDisentanglement(MessagePortId),
/// Handle a new port-message-task.
NewTask(MessagePortId, PortMessageTask),
}
diff --git a/components/shared/constellation/structured_data/transferable.rs b/components/shared/constellation/structured_data/transferable.rs
index cd6388f5f34..7e4fe0e6d2d 100644
--- a/components/shared/constellation/structured_data/transferable.rs
+++ b/components/shared/constellation/structured_data/transferable.rs
@@ -77,7 +77,12 @@ impl MessagePortImpl {
self.entangled_port
}
- /// Entanged this port with another.
+ /// <https://html.spec.whatwg.org/multipage/#disentangle>
+ pub fn disentangle(&mut self) -> Option<MessagePortId> {
+ self.entangled_port.take()
+ }
+
+ /// <https://html.spec.whatwg.org/multipage/#entangle>
pub fn entangle(&mut self, other_id: MessagePortId) {
self.entangled_port = Some(other_id);
}