mirror of
https://github.com/servo/servo.git
synced 2025-09-10 06:58:21 +01:00
Add direct script to embedder channel (#39039)
This PR **removes** `ScriptToConstellationMessage::ForwardToEmbedder`, and replaces it with an explicit `ScriptToEmbedderChannel`. This new channel is based on `GenericCallback` and in single-process mode will directly send the message the to the embedder and wake it. In multi-process mode, the message is routed via the ROUTER, since waking is only possible from the same process currently. This means in multi-process mode there are likely no direct perf benefits, since we still need to hop the message over the ROUTER (instead of over the constellation). In single-process mode we can directly send the message to the embedder, which should provide a noticable latency improvement in all cases where script is blocked waiting on the embedder to reply. This does not change the way the embedder receives messages - the receiving end is unchanged. ## How was sending messages to the embedder working before? 1. Script wraps it's message to the embedder in `ScriptToConstellationMessage::ForwardToEmbedder` and sends it to constellation. 2. The [constellation event loop] receives the message in [handle_request] 3. If deserialization fails, [an error is logged and the message is ignored] 4. Since our message came from script, it is handle in [handle_request_from_script] 5. The message is logged with trace log level 6. If the pipeline is closed, [a warning is logged and the message ignored] 7. The wrapped `EmbedderMsg` [is forwarded to the embedder]. Sending the message also invokes `wake()` on the embedder eventloop waker. [constellation event loop]:2e1b2e7260/components/constellation/constellation.rs (L755)
[handle request]:2e1b2e7260/components/constellation/constellation.rs (L1182)
[an error is logged and the message is ignored]:2e1b2e7260/components/constellation/constellation.rs (L1252)
[handle_request_from_script]: https://github.com/servo/servo/blob/main/components/constellation/constellation.rs#L1590 [a warning is logged and the message ignored]:2e1b2e7260/components/constellation/constellation.rs (L1599)
[is forwarded to the embedder]:2e1b2e7260/components/constellation/constellation.rs (L1701)
Testing: Communication between Script and Embedder is extensive, so this should be covered by existing tests. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
97c8c83cbb
commit
f4dd2960b8
21 changed files with 120 additions and 113 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -7461,6 +7461,7 @@ dependencies = [
|
||||||
"euclid",
|
"euclid",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"keyboard-types",
|
"keyboard-types",
|
||||||
|
"log",
|
||||||
"malloc_size_of_derive",
|
"malloc_size_of_derive",
|
||||||
"media",
|
"media",
|
||||||
"net_traits",
|
"net_traits",
|
||||||
|
|
|
@ -134,8 +134,8 @@ use embedder_traits::{
|
||||||
AnimationState, CompositorHitTestResult, EmbedderMsg, EmbedderProxy, FocusId,
|
AnimationState, CompositorHitTestResult, EmbedderMsg, EmbedderProxy, FocusId,
|
||||||
FocusSequenceNumber, InputEvent, JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId,
|
FocusSequenceNumber, InputEvent, JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId,
|
||||||
KeyboardEvent, MediaSessionActionType, MediaSessionEvent, MediaSessionPlaybackState,
|
KeyboardEvent, MediaSessionActionType, MediaSessionEvent, MediaSessionPlaybackState,
|
||||||
MouseButton, MouseButtonAction, MouseButtonEvent, Theme, ViewportDetails, WebDriverCommandMsg,
|
MouseButton, MouseButtonAction, MouseButtonEvent, ScriptToEmbedderChan, Theme, ViewportDetails,
|
||||||
WebDriverCommandResponse, WebDriverLoadStatus, WebDriverScriptCommand,
|
WebDriverCommandMsg, WebDriverCommandResponse, WebDriverLoadStatus, WebDriverScriptCommand,
|
||||||
};
|
};
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use euclid::default::Size2D as UntypedSize2D;
|
use euclid::default::Size2D as UntypedSize2D;
|
||||||
|
@ -968,6 +968,10 @@ where
|
||||||
self.public_resource_threads.clone()
|
self.public_resource_threads.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let embedder_chan = self.embedder_proxy.sender.clone();
|
||||||
|
let eventloop_waker = self.embedder_proxy.event_loop_waker.clone();
|
||||||
|
let script_to_embedder_chan = ScriptToEmbedderChan::new(embedder_chan, eventloop_waker);
|
||||||
|
|
||||||
let result = Pipeline::spawn::<STF>(InitialPipelineState {
|
let result = Pipeline::spawn::<STF>(InitialPipelineState {
|
||||||
id: pipeline_id,
|
id: pipeline_id,
|
||||||
browsing_context_id,
|
browsing_context_id,
|
||||||
|
@ -978,6 +982,7 @@ where
|
||||||
sender: self.script_sender.clone(),
|
sender: self.script_sender.clone(),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
},
|
},
|
||||||
|
script_to_embedder_chan,
|
||||||
namespace_request_sender: self.namespace_ipc_sender.clone(),
|
namespace_request_sender: self.namespace_ipc_sender.clone(),
|
||||||
pipeline_namespace_id: self.next_pipeline_namespace_id(),
|
pipeline_namespace_id: self.next_pipeline_namespace_id(),
|
||||||
background_monitor_register: self.background_monitor_register.clone(),
|
background_monitor_register: self.background_monitor_register.clone(),
|
||||||
|
@ -1702,9 +1707,6 @@ where
|
||||||
self.broadcast_channels
|
self.broadcast_channels
|
||||||
.schedule_broadcast(router_id, message);
|
.schedule_broadcast(router_id, message);
|
||||||
},
|
},
|
||||||
ScriptToConstellationMessage::ForwardToEmbedder(embedder_msg) => {
|
|
||||||
self.embedder_proxy.send(embedder_msg);
|
|
||||||
},
|
|
||||||
ScriptToConstellationMessage::PipelineExited => {
|
ScriptToConstellationMessage::PipelineExited => {
|
||||||
self.handle_pipeline_exited(source_pipeline_id);
|
self.handle_pipeline_exited(source_pipeline_id);
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,7 +27,9 @@ use constellation_traits::{LoadData, SWManagerMsg, ScriptToConstellationChan};
|
||||||
use crossbeam_channel::{Sender, unbounded};
|
use crossbeam_channel::{Sender, unbounded};
|
||||||
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
||||||
use embedder_traits::user_content_manager::UserContentManager;
|
use embedder_traits::user_content_manager::UserContentManager;
|
||||||
use embedder_traits::{AnimationState, FocusSequenceNumber, Theme, ViewportDetails};
|
use embedder_traits::{
|
||||||
|
AnimationState, FocusSequenceNumber, ScriptToEmbedderChan, Theme, ViewportDetails,
|
||||||
|
};
|
||||||
use fonts::{SystemFontServiceProxy, SystemFontServiceProxySender};
|
use fonts::{SystemFontServiceProxy, SystemFontServiceProxySender};
|
||||||
use ipc_channel::Error;
|
use ipc_channel::Error;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
|
@ -131,6 +133,9 @@ pub struct InitialPipelineState {
|
||||||
/// A channel to the associated constellation.
|
/// A channel to the associated constellation.
|
||||||
pub script_to_constellation_chan: ScriptToConstellationChan,
|
pub script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
|
||||||
|
/// A channel to the embedder.
|
||||||
|
pub script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
|
|
||||||
/// A sender to request pipeline namespace ids.
|
/// A sender to request pipeline namespace ids.
|
||||||
pub namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
|
pub namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
|
||||||
|
|
||||||
|
@ -277,6 +282,7 @@ impl Pipeline {
|
||||||
parent_pipeline_id: state.parent_pipeline_id,
|
parent_pipeline_id: state.parent_pipeline_id,
|
||||||
opener: state.opener,
|
opener: state.opener,
|
||||||
script_to_constellation_chan: state.script_to_constellation_chan.clone(),
|
script_to_constellation_chan: state.script_to_constellation_chan.clone(),
|
||||||
|
script_to_embedder_chan: state.script_to_embedder_chan,
|
||||||
namespace_request_sender: state.namespace_request_sender,
|
namespace_request_sender: state.namespace_request_sender,
|
||||||
background_hang_monitor_to_constellation_chan: state
|
background_hang_monitor_to_constellation_chan: state
|
||||||
.background_hang_monitor_to_constellation_chan
|
.background_hang_monitor_to_constellation_chan
|
||||||
|
@ -476,6 +482,7 @@ pub struct UnprivilegedPipelineContent {
|
||||||
opener: Option<BrowsingContextId>,
|
opener: Option<BrowsingContextId>,
|
||||||
namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
|
namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
|
||||||
script_to_constellation_chan: ScriptToConstellationChan,
|
script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
|
background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
|
||||||
bhm_control_port: Option<IpcReceiver<BackgroundHangMonitorControlMsg>>,
|
bhm_control_port: Option<IpcReceiver<BackgroundHangMonitorControlMsg>>,
|
||||||
devtools_ipc_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
devtools_ipc_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
|
@ -530,6 +537,7 @@ impl UnprivilegedPipelineContent {
|
||||||
constellation_sender: self.script_chan.clone(),
|
constellation_sender: self.script_chan.clone(),
|
||||||
constellation_receiver: self.script_port,
|
constellation_receiver: self.script_port,
|
||||||
pipeline_to_constellation_sender: self.script_to_constellation_chan.clone(),
|
pipeline_to_constellation_sender: self.script_to_constellation_chan.clone(),
|
||||||
|
pipeline_to_embedder_sender: self.script_to_embedder_chan,
|
||||||
background_hang_monitor_register: background_hang_monitor_register.clone(),
|
background_hang_monitor_register: background_hang_monitor_register.clone(),
|
||||||
#[cfg(feature = "bluetooth")]
|
#[cfg(feature = "bluetooth")]
|
||||||
bluetooth_sender: self.bluetooth_thread,
|
bluetooth_sender: self.bluetooth_thread,
|
||||||
|
|
|
@ -110,8 +110,6 @@ mod from_compositor {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod from_script {
|
mod from_script {
|
||||||
use embedder_traits::LoadStatus;
|
|
||||||
|
|
||||||
use super::LogTarget;
|
use super::LogTarget;
|
||||||
|
|
||||||
macro_rules! target {
|
macro_rules! target {
|
||||||
|
@ -141,7 +139,6 @@ mod from_script {
|
||||||
target!("RemoveBroadcastChannelNameInRouter")
|
target!("RemoveBroadcastChannelNameInRouter")
|
||||||
},
|
},
|
||||||
Self::ScheduleBroadcast(..) => target!("ScheduleBroadcast"),
|
Self::ScheduleBroadcast(..) => target!("ScheduleBroadcast"),
|
||||||
Self::ForwardToEmbedder(msg) => msg.log_target(),
|
|
||||||
Self::BroadcastStorageEvent(..) => target!("BroadcastStorageEvent"),
|
Self::BroadcastStorageEvent(..) => target!("BroadcastStorageEvent"),
|
||||||
Self::ChangeRunningAnimationsState(..) => target!("ChangeRunningAnimationsState"),
|
Self::ChangeRunningAnimationsState(..) => target!("ChangeRunningAnimationsState"),
|
||||||
Self::CreateCanvasPaintThread(..) => target!("CreateCanvasPaintThread"),
|
Self::CreateCanvasPaintThread(..) => target!("CreateCanvasPaintThread"),
|
||||||
|
@ -188,72 +185,4 @@ mod from_script {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogTarget for embedder_traits::EmbedderMsg {
|
|
||||||
fn log_target(&self) -> &'static str {
|
|
||||||
macro_rules! target_variant {
|
|
||||||
($name:literal) => {
|
|
||||||
target!("ForwardToEmbedder(" $name ")")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
match self {
|
|
||||||
Self::Status(..) => target_variant!("Status"),
|
|
||||||
Self::ChangePageTitle(..) => target_variant!("ChangePageTitle"),
|
|
||||||
Self::MoveTo(..) => target_variant!("MoveTo"),
|
|
||||||
Self::ResizeTo(..) => target_variant!("ResizeTo"),
|
|
||||||
Self::ShowSimpleDialog(..) => target_variant!("ShowSimpleDialog"),
|
|
||||||
Self::RequestAuthentication(..) => target_variant!("RequestAuthentication"),
|
|
||||||
Self::ShowContextMenu(..) => target_variant!("ShowContextMenu"),
|
|
||||||
Self::AllowNavigationRequest(..) => target_variant!("AllowNavigationRequest"),
|
|
||||||
Self::AllowOpeningWebView(..) => target_variant!("AllowOpeningWebView"),
|
|
||||||
Self::WebViewClosed(..) => target_variant!("WebViewClosed"),
|
|
||||||
Self::WebViewFocused(..) => target_variant!("WebViewFocused"),
|
|
||||||
Self::WebViewBlurred => target_variant!("WebViewBlurred"),
|
|
||||||
Self::WebResourceRequested(..) => target_variant!("WebResourceRequested"),
|
|
||||||
Self::AllowUnload(..) => target_variant!("AllowUnload"),
|
|
||||||
Self::Keyboard(..) => target_variant!("Keyboard"),
|
|
||||||
Self::ClearClipboard(..) => target_variant!("ClearClipboard"),
|
|
||||||
Self::GetClipboardText(..) => target_variant!("GetClipboardText"),
|
|
||||||
Self::SetClipboardText(..) => target_variant!("SetClipboardText"),
|
|
||||||
Self::SetCursor(..) => target_variant!("SetCursor"),
|
|
||||||
Self::NewFavicon(..) => target_variant!("NewFavicon"),
|
|
||||||
Self::HistoryChanged(..) => target_variant!("HistoryChanged"),
|
|
||||||
Self::HistoryTraversalComplete(..) => target_variant!("HistoryTraversalComplete"),
|
|
||||||
Self::GetWindowRect(..) => target_variant!("GetWindowRect"),
|
|
||||||
Self::GetScreenMetrics(..) => target_variant!("GetScreenMetrics"),
|
|
||||||
Self::NotifyFullscreenStateChanged(..) => {
|
|
||||||
target_variant!("NotifyFullscreenStateChanged")
|
|
||||||
},
|
|
||||||
Self::NotifyLoadStatusChanged(_, LoadStatus::Started) => {
|
|
||||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::Started)")
|
|
||||||
},
|
|
||||||
Self::NotifyLoadStatusChanged(_, LoadStatus::HeadParsed) => {
|
|
||||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::HeadParsed)")
|
|
||||||
},
|
|
||||||
Self::NotifyLoadStatusChanged(_, LoadStatus::Complete) => {
|
|
||||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::Complete")
|
|
||||||
},
|
|
||||||
Self::Panic(..) => target_variant!("Panic"),
|
|
||||||
Self::GetSelectedBluetoothDevice(..) => {
|
|
||||||
target_variant!("GetSelectedBluetoothDevice")
|
|
||||||
},
|
|
||||||
Self::SelectFiles(..) => target_variant!("SelectFiles"),
|
|
||||||
Self::PromptPermission(..) => target_variant!("PromptPermission"),
|
|
||||||
Self::ShowIME(..) => target_variant!("ShowIME"),
|
|
||||||
Self::HideIME(..) => target_variant!("HideIME"),
|
|
||||||
Self::ReportProfile(..) => target_variant!("ReportProfile"),
|
|
||||||
Self::MediaSessionEvent(..) => target_variant!("MediaSessionEvent"),
|
|
||||||
Self::OnDevtoolsStarted(..) => target_variant!("OnDevtoolsStarted"),
|
|
||||||
Self::RequestDevtoolsConnection(..) => target_variant!("RequestDevtoolsConnection"),
|
|
||||||
Self::PlayGamepadHapticEffect(..) => target_variant!("PlayGamepadHapticEffect"),
|
|
||||||
Self::StopGamepadHapticEffect(..) => target_variant!("StopGamepadHapticEffect"),
|
|
||||||
Self::ShutdownComplete => target_variant!("ShutdownComplete"),
|
|
||||||
Self::ShowNotification(..) => target_variant!("ShowNotification"),
|
|
||||||
Self::ShowFormControl(..) => target_variant!("ShowFormControl"),
|
|
||||||
Self::FinishJavaScriptEvaluation(..) => {
|
|
||||||
target_variant!("FinishJavaScriptEvaluation")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use base::id::WebViewId;
|
use base::id::WebViewId;
|
||||||
use constellation_traits::{ScriptToConstellationChan, ScriptToConstellationMessage};
|
use embedder_traits::{EmbedderMsg, ScriptToEmbedderChan};
|
||||||
use embedder_traits::EmbedderMsg;
|
|
||||||
use ipc_channel::ipc::channel;
|
use ipc_channel::ipc::channel;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
|
|
||||||
|
@ -19,25 +18,21 @@ pub trait ClipboardProvider {
|
||||||
|
|
||||||
#[derive(MallocSizeOf)]
|
#[derive(MallocSizeOf)]
|
||||||
pub(crate) struct EmbedderClipboardProvider {
|
pub(crate) struct EmbedderClipboardProvider {
|
||||||
pub constellation_sender: ScriptToConstellationChan,
|
pub embedder_sender: ScriptToEmbedderChan,
|
||||||
pub webview_id: WebViewId,
|
pub webview_id: WebViewId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClipboardProvider for EmbedderClipboardProvider {
|
impl ClipboardProvider for EmbedderClipboardProvider {
|
||||||
fn get_text(&mut self) -> Result<String, String> {
|
fn get_text(&mut self) -> Result<String, String> {
|
||||||
let (tx, rx) = channel().unwrap();
|
let (tx, rx) = channel().unwrap();
|
||||||
self.constellation_sender
|
self.embedder_sender
|
||||||
.send(ScriptToConstellationMessage::ForwardToEmbedder(
|
.send(EmbedderMsg::GetClipboardText(self.webview_id, tx))
|
||||||
EmbedderMsg::GetClipboardText(self.webview_id, tx),
|
|
||||||
))
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
rx.recv().unwrap()
|
rx.recv().unwrap()
|
||||||
}
|
}
|
||||||
fn set_text(&mut self, s: String) {
|
fn set_text(&mut self, s: String) {
|
||||||
self.constellation_sender
|
self.embedder_sender
|
||||||
.send(ScriptToConstellationMessage::ForwardToEmbedder(
|
.send(EmbedderMsg::SetClipboardText(self.webview_id, s))
|
||||||
EmbedderMsg::SetClipboardText(self.webview_id, s),
|
|
||||||
))
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ use base::id::{Index, PipelineId, PipelineNamespaceId};
|
||||||
use constellation_traits::ScriptToConstellationChan;
|
use constellation_traits::ScriptToConstellationChan;
|
||||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, SourceInfo, WorkerId};
|
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, SourceInfo, WorkerId};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::JavaScriptEvaluationError;
|
|
||||||
use embedder_traits::resources::{self, Resource};
|
use embedder_traits::resources::{self, Resource};
|
||||||
|
use embedder_traits::{JavaScriptEvaluationError, ScriptToEmbedderChan};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::wrappers::JS_DefineDebuggerObject;
|
use js::rust::wrappers::JS_DefineDebuggerObject;
|
||||||
|
@ -66,6 +66,7 @@ impl DebuggerGlobalScope {
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
script_to_constellation_chan: ScriptToConstellationChan,
|
script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
resource_threads: ResourceThreads,
|
resource_threads: ResourceThreads,
|
||||||
#[cfg(feature = "webgpu")] gpu_id_hub: std::sync::Arc<IdentityHub>,
|
#[cfg(feature = "webgpu")] gpu_id_hub: std::sync::Arc<IdentityHub>,
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
|
@ -77,6 +78,7 @@ impl DebuggerGlobalScope {
|
||||||
mem_profiler_chan,
|
mem_profiler_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
script_to_constellation_chan,
|
script_to_constellation_chan,
|
||||||
|
script_to_embedder_chan,
|
||||||
resource_threads,
|
resource_threads,
|
||||||
MutableOrigin::new(ImmutableOrigin::new_opaque()),
|
MutableOrigin::new(ImmutableOrigin::new_opaque()),
|
||||||
ServoUrl::parse_with_base(None, "about:internal/debugger")
|
ServoUrl::parse_with_base(None, "about:internal/debugger")
|
||||||
|
|
|
@ -438,6 +438,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
init.mem_profiler_chan.clone(),
|
init.mem_profiler_chan.clone(),
|
||||||
init.time_profiler_chan.clone(),
|
init.time_profiler_chan.clone(),
|
||||||
init.script_to_constellation_chan.clone(),
|
init.script_to_constellation_chan.clone(),
|
||||||
|
init.script_to_embedder_chan.clone(),
|
||||||
init.resource_threads.clone(),
|
init.resource_threads.clone(),
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_id_hub.clone(),
|
gpu_id_hub.clone(),
|
||||||
|
|
|
@ -58,6 +58,7 @@ impl DissimilarOriginWindow {
|
||||||
global_to_clone_from.mem_profiler_chan().clone(),
|
global_to_clone_from.mem_profiler_chan().clone(),
|
||||||
global_to_clone_from.time_profiler_chan().clone(),
|
global_to_clone_from.time_profiler_chan().clone(),
|
||||||
global_to_clone_from.script_to_constellation_chan().clone(),
|
global_to_clone_from.script_to_constellation_chan().clone(),
|
||||||
|
global_to_clone_from.script_to_embedder_chan().clone(),
|
||||||
global_to_clone_from.resource_threads().clone(),
|
global_to_clone_from.resource_threads().clone(),
|
||||||
global_to_clone_from.origin().clone(),
|
global_to_clone_from.origin().clone(),
|
||||||
global_to_clone_from.creation_url().clone(),
|
global_to_clone_from.creation_url().clone(),
|
||||||
|
|
|
@ -1345,10 +1345,10 @@ impl DocumentEventHandler {
|
||||||
},
|
},
|
||||||
ClipboardEventType::Paste => {
|
ClipboardEventType::Paste => {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
self.window
|
self.window.send_to_embedder(EmbedderMsg::GetClipboardText(
|
||||||
.send_to_constellation(ScriptToConstellationMessage::ForwardToEmbedder(
|
self.window.webview_id(),
|
||||||
EmbedderMsg::GetClipboardText(self.window.webview_id(), sender),
|
sender,
|
||||||
));
|
));
|
||||||
let text_contents = receiver
|
let text_contents = receiver
|
||||||
.recv()
|
.recv()
|
||||||
.map(Result::unwrap_or_default)
|
.map(Result::unwrap_or_default)
|
||||||
|
|
|
@ -26,7 +26,7 @@ use content_security_policy::CspList;
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use devtools_traits::{PageError, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{PageError, ScriptToDevtoolsControlMsg};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::{EmbedderMsg, JavaScriptEvaluationError};
|
use embedder_traits::{EmbedderMsg, JavaScriptEvaluationError, ScriptToEmbedderChan};
|
||||||
use fonts::FontContext;
|
use fonts::FontContext;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
|
@ -254,6 +254,11 @@ pub(crate) struct GlobalScope {
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
script_to_constellation_chan: ScriptToConstellationChan,
|
script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
|
||||||
|
/// A handle for communicating messages to the Embedder.
|
||||||
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
|
#[no_trace]
|
||||||
|
script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#in-error-reporting-mode>
|
/// <https://html.spec.whatwg.org/multipage/#in-error-reporting-mode>
|
||||||
in_error_reporting_mode: Cell<bool>,
|
in_error_reporting_mode: Cell<bool>,
|
||||||
|
|
||||||
|
@ -741,6 +746,7 @@ impl GlobalScope {
|
||||||
mem_profiler_chan: profile_mem::ProfilerChan,
|
mem_profiler_chan: profile_mem::ProfilerChan,
|
||||||
time_profiler_chan: profile_time::ProfilerChan,
|
time_profiler_chan: profile_time::ProfilerChan,
|
||||||
script_to_constellation_chan: ScriptToConstellationChan,
|
script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
resource_threads: ResourceThreads,
|
resource_threads: ResourceThreads,
|
||||||
origin: MutableOrigin,
|
origin: MutableOrigin,
|
||||||
creation_url: ServoUrl,
|
creation_url: ServoUrl,
|
||||||
|
@ -770,6 +776,7 @@ impl GlobalScope {
|
||||||
mem_profiler_chan,
|
mem_profiler_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
script_to_constellation_chan,
|
script_to_constellation_chan,
|
||||||
|
script_to_embedder_chan,
|
||||||
in_error_reporting_mode: Default::default(),
|
in_error_reporting_mode: Default::default(),
|
||||||
resource_threads,
|
resource_threads,
|
||||||
timers: OnceCell::default(),
|
timers: OnceCell::default(),
|
||||||
|
@ -2477,8 +2484,12 @@ impl GlobalScope {
|
||||||
&self.script_to_constellation_chan
|
&self.script_to_constellation_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn script_to_embedder_chan(&self) -> &ScriptToEmbedderChan {
|
||||||
|
&self.script_to_embedder_chan
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) {
|
pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) {
|
||||||
self.send_to_constellation(ScriptToConstellationMessage::ForwardToEmbedder(msg));
|
self.script_to_embedder_chan().send(msg).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_to_constellation(&self, msg: ScriptToConstellationMessage) {
|
pub(crate) fn send_to_constellation(&self, msg: ScriptToConstellationMessage) {
|
||||||
|
|
|
@ -456,10 +456,10 @@ impl HTMLInputElement {
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
) -> HTMLInputElement {
|
) -> HTMLInputElement {
|
||||||
let constellation_sender = document
|
let embedder_sender = document
|
||||||
.window()
|
.window()
|
||||||
.as_global_scope()
|
.as_global_scope()
|
||||||
.script_to_constellation_chan()
|
.script_to_embedder_chan()
|
||||||
.clone();
|
.clone();
|
||||||
HTMLInputElement {
|
HTMLInputElement {
|
||||||
htmlelement: HTMLElement::new_inherited_with_state(
|
htmlelement: HTMLElement::new_inherited_with_state(
|
||||||
|
@ -478,7 +478,7 @@ impl HTMLInputElement {
|
||||||
Single,
|
Single,
|
||||||
DOMString::new(),
|
DOMString::new(),
|
||||||
EmbedderClipboardProvider {
|
EmbedderClipboardProvider {
|
||||||
constellation_sender,
|
embedder_sender,
|
||||||
webview_id: document.webview_id(),
|
webview_id: document.webview_id(),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -141,10 +141,10 @@ impl HTMLTextAreaElement {
|
||||||
prefix: Option<Prefix>,
|
prefix: Option<Prefix>,
|
||||||
document: &Document,
|
document: &Document,
|
||||||
) -> HTMLTextAreaElement {
|
) -> HTMLTextAreaElement {
|
||||||
let constellation_sender = document
|
let embedder_sender = document
|
||||||
.window()
|
.window()
|
||||||
.as_global_scope()
|
.as_global_scope()
|
||||||
.script_to_constellation_chan()
|
.script_to_embedder_chan()
|
||||||
.clone();
|
.clone();
|
||||||
HTMLTextAreaElement {
|
HTMLTextAreaElement {
|
||||||
htmlelement: HTMLElement::new_inherited_with_state(
|
htmlelement: HTMLElement::new_inherited_with_state(
|
||||||
|
@ -158,7 +158,7 @@ impl HTMLTextAreaElement {
|
||||||
Lines::Multiple,
|
Lines::Multiple,
|
||||||
DOMString::new(),
|
DOMString::new(),
|
||||||
EmbedderClipboardProvider {
|
EmbedderClipboardProvider {
|
||||||
constellation_sender,
|
embedder_sender,
|
||||||
webview_id: document.webview_id(),
|
webview_id: document.webview_id(),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -35,9 +35,9 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarker
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::user_content_manager::{UserContentManager, UserScript};
|
use embedder_traits::user_content_manager::{UserContentManager, UserScript};
|
||||||
use embedder_traits::{
|
use embedder_traits::{
|
||||||
AlertResponse, ConfirmResponse, EmbedderMsg, PromptResponse, SimpleDialog, Theme,
|
AlertResponse, ConfirmResponse, EmbedderMsg, PromptResponse, ScriptToEmbedderChan,
|
||||||
UntrustedNodeAddress, ViewportDetails, WebDriverJSError, WebDriverJSResult,
|
SimpleDialog, Theme, UntrustedNodeAddress, ViewportDetails, WebDriverJSError,
|
||||||
WebDriverLoadStatus,
|
WebDriverJSResult, WebDriverLoadStatus,
|
||||||
};
|
};
|
||||||
use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect, Size2D as UntypedSize2D};
|
use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect, Size2D as UntypedSize2D};
|
||||||
use euclid::{Point2D, Scale, Size2D, Vector2D};
|
use euclid::{Point2D, Scale, Size2D, Vector2D};
|
||||||
|
@ -2995,7 +2995,10 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) {
|
pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) {
|
||||||
self.send_to_constellation(ScriptToConstellationMessage::ForwardToEmbedder(msg));
|
self.as_global_scope()
|
||||||
|
.script_to_embedder_chan()
|
||||||
|
.send(msg)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_to_constellation(&self, msg: ScriptToConstellationMessage) {
|
pub(crate) fn send_to_constellation(&self, msg: ScriptToConstellationMessage) {
|
||||||
|
@ -3100,6 +3103,7 @@ impl Window {
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
constellation_chan: ScriptToConstellationChan,
|
constellation_chan: ScriptToConstellationChan,
|
||||||
|
embedder_chan: ScriptToEmbedderChan,
|
||||||
control_chan: GenericSender<ScriptThreadMessage>,
|
control_chan: GenericSender<ScriptThreadMessage>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
parent_info: Option<PipelineId>,
|
parent_info: Option<PipelineId>,
|
||||||
|
@ -3139,6 +3143,7 @@ impl Window {
|
||||||
mem_profiler_chan,
|
mem_profiler_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
|
embedder_chan,
|
||||||
resource_threads,
|
resource_threads,
|
||||||
origin,
|
origin,
|
||||||
creation_url,
|
creation_url,
|
||||||
|
|
|
@ -90,6 +90,7 @@ pub(crate) fn prepare_workerscope_init(
|
||||||
time_profiler_chan: global.time_profiler_chan().clone(),
|
time_profiler_chan: global.time_profiler_chan().clone(),
|
||||||
from_devtools_sender: devtools_sender,
|
from_devtools_sender: devtools_sender,
|
||||||
script_to_constellation_chan: global.script_to_constellation_chan().clone(),
|
script_to_constellation_chan: global.script_to_constellation_chan().clone(),
|
||||||
|
script_to_embedder_chan: global.script_to_embedder_chan().clone(),
|
||||||
worker_id: worker_id.unwrap_or_else(|| WorkerId(Uuid::new_v4())),
|
worker_id: worker_id.unwrap_or_else(|| WorkerId(Uuid::new_v4())),
|
||||||
pipeline_id: global.pipeline_id(),
|
pipeline_id: global.pipeline_id(),
|
||||||
origin: global.origin().immutable().clone(),
|
origin: global.origin().immutable().clone(),
|
||||||
|
@ -185,6 +186,7 @@ impl WorkerGlobalScope {
|
||||||
init.mem_profiler_chan,
|
init.mem_profiler_chan,
|
||||||
init.time_profiler_chan,
|
init.time_profiler_chan,
|
||||||
init.script_to_constellation_chan,
|
init.script_to_constellation_chan,
|
||||||
|
init.script_to_embedder_chan,
|
||||||
init.resource_threads,
|
init.resource_threads,
|
||||||
MutableOrigin::new(init.origin),
|
MutableOrigin::new(init.origin),
|
||||||
init.creation_url,
|
init.creation_url,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use constellation_traits::{ScriptToConstellationChan, ScriptToConstellationMessa
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use devtools_traits::ScriptToDevtoolsControlMsg;
|
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::JavaScriptEvaluationError;
|
use embedder_traits::{JavaScriptEvaluationError, ScriptToEmbedderChan};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use net_traits::ResourceThreads;
|
use net_traits::ResourceThreads;
|
||||||
|
@ -100,6 +100,7 @@ impl WorkletGlobalScope {
|
||||||
init.mem_profiler_chan.clone(),
|
init.mem_profiler_chan.clone(),
|
||||||
init.time_profiler_chan.clone(),
|
init.time_profiler_chan.clone(),
|
||||||
script_to_constellation_chan,
|
script_to_constellation_chan,
|
||||||
|
init.to_embedder_sender.clone(),
|
||||||
init.resource_threads.clone(),
|
init.resource_threads.clone(),
|
||||||
MutableOrigin::new(ImmutableOrigin::new_opaque()),
|
MutableOrigin::new(ImmutableOrigin::new_opaque()),
|
||||||
base_url.clone(),
|
base_url.clone(),
|
||||||
|
@ -198,6 +199,8 @@ pub(crate) struct WorkletGlobalScopeInit {
|
||||||
pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
/// Messages to send to constellation
|
/// Messages to send to constellation
|
||||||
pub(crate) to_constellation_sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
pub(crate) to_constellation_sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
|
/// Messages to send to the Embedder
|
||||||
|
pub(crate) to_embedder_sender: ScriptToEmbedderChan,
|
||||||
/// The image cache
|
/// The image cache
|
||||||
pub(crate) image_cache: Arc<dyn ImageCache>,
|
pub(crate) image_cache: Arc<dyn ImageCache>,
|
||||||
/// Identity manager for WebGPU resources
|
/// Identity manager for WebGPU resources
|
||||||
|
|
|
@ -16,6 +16,7 @@ use bluetooth_traits::BluetoothRequest;
|
||||||
use constellation_traits::ScriptToConstellationMessage;
|
use constellation_traits::ScriptToConstellationMessage;
|
||||||
use crossbeam_channel::{Receiver, SendError, Sender, select};
|
use crossbeam_channel::{Receiver, SendError, Sender, select};
|
||||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg};
|
||||||
|
use embedder_traits::ScriptToEmbedderChan;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use net_traits::FetchResponseMsg;
|
use net_traits::FetchResponseMsg;
|
||||||
use net_traits::image_cache::ImageCacheResponseMessage;
|
use net_traits::image_cache::ImageCacheResponseMessage;
|
||||||
|
@ -344,6 +345,10 @@ pub(crate) struct ScriptThreadSenders {
|
||||||
pub(crate) pipeline_to_constellation_sender:
|
pub(crate) pipeline_to_constellation_sender:
|
||||||
GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
|
|
||||||
|
/// A channel to send messages to the Embedder.
|
||||||
|
#[no_trace]
|
||||||
|
pub(crate) pipeline_to_embedder_sender: ScriptToEmbedderChan,
|
||||||
|
|
||||||
/// The shared [`IpcSender`] which is sent to the `ImageCache` when requesting an image. The
|
/// The shared [`IpcSender`] which is sent to the `ImageCache` when requesting an image. The
|
||||||
/// messages on this channel are routed to crossbeam [`Sender`] on the router thread, which
|
/// messages on this channel are routed to crossbeam [`Sender`] on the router thread, which
|
||||||
/// in turn sends messages to [`ScriptThreadReceivers::image_cache_receiver`].
|
/// in turn sends messages to [`ScriptThreadReceivers::image_cache_receiver`].
|
||||||
|
|
|
@ -781,6 +781,10 @@ impl ScriptThread {
|
||||||
.senders
|
.senders
|
||||||
.pipeline_to_constellation_sender
|
.pipeline_to_constellation_sender
|
||||||
.clone(),
|
.clone(),
|
||||||
|
to_embedder_sender: script_thread
|
||||||
|
.senders
|
||||||
|
.pipeline_to_embedder_sender
|
||||||
|
.clone(),
|
||||||
image_cache,
|
image_cache,
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_id_hub: script_thread.gpu_id_hub.clone(),
|
gpu_id_hub: script_thread.gpu_id_hub.clone(),
|
||||||
|
@ -941,6 +945,7 @@ impl ScriptThread {
|
||||||
bluetooth_sender: state.bluetooth_sender,
|
bluetooth_sender: state.bluetooth_sender,
|
||||||
constellation_sender: state.constellation_sender,
|
constellation_sender: state.constellation_sender,
|
||||||
pipeline_to_constellation_sender: state.pipeline_to_constellation_sender.sender.clone(),
|
pipeline_to_constellation_sender: state.pipeline_to_constellation_sender.sender.clone(),
|
||||||
|
pipeline_to_embedder_sender: state.pipeline_to_embedder_sender.clone(),
|
||||||
image_cache_sender: ipc_image_cache_sender,
|
image_cache_sender: ipc_image_cache_sender,
|
||||||
time_profiler_sender: state.time_profiler_sender,
|
time_profiler_sender: state.time_profiler_sender,
|
||||||
memory_profiler_sender: state.memory_profiler_sender,
|
memory_profiler_sender: state.memory_profiler_sender,
|
||||||
|
@ -966,6 +971,7 @@ impl ScriptThread {
|
||||||
senders.memory_profiler_sender.clone(),
|
senders.memory_profiler_sender.clone(),
|
||||||
senders.time_profiler_sender.clone(),
|
senders.time_profiler_sender.clone(),
|
||||||
script_to_constellation_chan,
|
script_to_constellation_chan,
|
||||||
|
senders.pipeline_to_embedder_sender.clone(),
|
||||||
state.resource_threads.clone(),
|
state.resource_threads.clone(),
|
||||||
#[cfg(feature = "webgpu")]
|
#[cfg(feature = "webgpu")]
|
||||||
gpu_id_hub.clone(),
|
gpu_id_hub.clone(),
|
||||||
|
@ -3312,6 +3318,7 @@ impl ScriptThread {
|
||||||
self.senders.time_profiler_sender.clone(),
|
self.senders.time_profiler_sender.clone(),
|
||||||
self.senders.devtools_server_sender.clone(),
|
self.senders.devtools_server_sender.clone(),
|
||||||
script_to_constellation_chan,
|
script_to_constellation_chan,
|
||||||
|
self.senders.pipeline_to_embedder_sender.clone(),
|
||||||
self.senders.constellation_sender.clone(),
|
self.senders.constellation_sender.clone(),
|
||||||
incomplete.pipeline_id,
|
incomplete.pipeline_id,
|
||||||
incomplete.parent_info,
|
incomplete.parent_info,
|
||||||
|
|
|
@ -17,9 +17,9 @@ use canvas_traits::canvas::{CanvasId, CanvasMsg};
|
||||||
use compositing_traits::CrossProcessCompositorApi;
|
use compositing_traits::CrossProcessCompositorApi;
|
||||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||||
use embedder_traits::{
|
use embedder_traits::{
|
||||||
AnimationState, EmbedderMsg, FocusSequenceNumber, JSValue, JavaScriptEvaluationError,
|
AnimationState, FocusSequenceNumber, JSValue, JavaScriptEvaluationError,
|
||||||
JavaScriptEvaluationId, MediaSessionEvent, Theme, TouchEventResult, ViewportDetails,
|
JavaScriptEvaluationId, MediaSessionEvent, ScriptToEmbedderChan, Theme, TouchEventResult,
|
||||||
WebDriverMessageId,
|
ViewportDetails, WebDriverMessageId,
|
||||||
};
|
};
|
||||||
use euclid::default::Size2D as UntypedSize2D;
|
use euclid::default::Size2D as UntypedSize2D;
|
||||||
use fonts_traits::SystemFontServiceProxySender;
|
use fonts_traits::SystemFontServiceProxySender;
|
||||||
|
@ -444,6 +444,8 @@ pub struct WorkerGlobalScopeInit {
|
||||||
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||||
/// Messages to send to constellation
|
/// Messages to send to constellation
|
||||||
pub script_to_constellation_chan: ScriptToConstellationChan,
|
pub script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
|
/// Messages to send to the Embedder
|
||||||
|
pub script_to_embedder_chan: ScriptToEmbedderChan,
|
||||||
/// The worker id
|
/// The worker id
|
||||||
pub worker_id: WorkerId,
|
pub worker_id: WorkerId,
|
||||||
/// The pipeline id
|
/// The pipeline id
|
||||||
|
@ -525,8 +527,6 @@ pub enum ScriptToConstellationMessage {
|
||||||
/// Broadcast a message to all same-origin broadcast channels,
|
/// Broadcast a message to all same-origin broadcast channels,
|
||||||
/// excluding the source of the broadcast.
|
/// excluding the source of the broadcast.
|
||||||
ScheduleBroadcast(BroadcastChannelRouterId, BroadcastChannelMsg),
|
ScheduleBroadcast(BroadcastChannelRouterId, BroadcastChannelMsg),
|
||||||
/// Forward a message to the embedder.
|
|
||||||
ForwardToEmbedder(EmbedderMsg),
|
|
||||||
/// Broadcast a storage event to every same-origin pipeline.
|
/// Broadcast a storage event to every same-origin pipeline.
|
||||||
/// The strings are key, old value and new value.
|
/// The strings are key, old value and new value.
|
||||||
BroadcastStorageEvent(
|
BroadcastStorageEvent(
|
||||||
|
|
|
@ -21,7 +21,7 @@ use std::ops::Range;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use base::generic_channel::GenericSender;
|
use base::generic_channel::{GenericCallback, GenericSender, SendResult};
|
||||||
use base::id::{PipelineId, WebViewId};
|
use base::id::{PipelineId, WebViewId};
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use euclid::{Point2D, Scale, Size2D};
|
use euclid::{Point2D, Scale, Size2D};
|
||||||
|
@ -1081,3 +1081,34 @@ pub struct RgbColor {
|
||||||
pub green: u8,
|
pub green: u8,
|
||||||
pub blue: u8,
|
pub blue: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A Script to Embedder Channel
|
||||||
|
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||||
|
pub struct ScriptToEmbedderChan(GenericCallback<EmbedderMsg>);
|
||||||
|
|
||||||
|
impl ScriptToEmbedderChan {
|
||||||
|
/// Create a new Channel allowing script to send messages to the Embedder
|
||||||
|
pub fn new(
|
||||||
|
embedder_chan: Sender<EmbedderMsg>,
|
||||||
|
waker: Box<dyn EventLoopWaker>,
|
||||||
|
) -> ScriptToEmbedderChan {
|
||||||
|
let embedder_callback = GenericCallback::new(move |embedder_msg| {
|
||||||
|
let msg = match embedder_msg {
|
||||||
|
Ok(embedder_msg) => embedder_msg,
|
||||||
|
Err(err) => {
|
||||||
|
log::warn!("Script to Embedder message error: {err}");
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let _ = embedder_chan.send(msg);
|
||||||
|
waker.wake();
|
||||||
|
})
|
||||||
|
.expect("Failed to create channel");
|
||||||
|
ScriptToEmbedderChan(embedder_callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send a message to and wake the Embedder
|
||||||
|
pub fn send(&self, msg: EmbedderMsg) -> SendResult {
|
||||||
|
self.0.send(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,3 +44,4 @@ stylo_traits = { workspace = true }
|
||||||
webgpu_traits = { workspace = true, optional = true }
|
webgpu_traits = { workspace = true, optional = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
webxr-api = { workspace = true, features = ["ipc"] }
|
webxr-api = { workspace = true, features = ["ipc"] }
|
||||||
|
log = "0.4.27"
|
||||||
|
|
|
@ -30,7 +30,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||||
use embedder_traits::user_content_manager::UserContentManager;
|
use embedder_traits::user_content_manager::UserContentManager;
|
||||||
use embedder_traits::{
|
use embedder_traits::{
|
||||||
CompositorHitTestResult, FocusSequenceNumber, InputEvent, JavaScriptEvaluationId,
|
CompositorHitTestResult, FocusSequenceNumber, InputEvent, JavaScriptEvaluationId,
|
||||||
MediaSessionActionType, Theme, ViewportDetails, WebDriverScriptCommand,
|
MediaSessionActionType, ScriptToEmbedderChan, Theme, ViewportDetails, WebDriverScriptCommand,
|
||||||
};
|
};
|
||||||
use euclid::{Rect, Scale, Size2D, UnknownUnit};
|
use euclid::{Rect, Scale, Size2D, UnknownUnit};
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
|
@ -321,6 +321,9 @@ pub struct InitialScriptState {
|
||||||
pub constellation_receiver: GenericReceiver<ScriptThreadMessage>,
|
pub constellation_receiver: GenericReceiver<ScriptThreadMessage>,
|
||||||
/// A channel on which messages can be sent to the constellation from script.
|
/// A channel on which messages can be sent to the constellation from script.
|
||||||
pub pipeline_to_constellation_sender: ScriptToConstellationChan,
|
pub pipeline_to_constellation_sender: ScriptToConstellationChan,
|
||||||
|
/// A channel which allows script to send messages directly to the Embedder
|
||||||
|
/// This will pump the embedder event loop.
|
||||||
|
pub pipeline_to_embedder_sender: ScriptToEmbedderChan,
|
||||||
/// A handle to register script-(and associated layout-)threads for hang monitoring.
|
/// A handle to register script-(and associated layout-)threads for hang monitoring.
|
||||||
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
||||||
/// A channel to the resource manager thread.
|
/// A channel to the resource manager thread.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue