Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Script to embedder communication #20706

Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -732,6 +732,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
layout_to_constellation_chan: self.layout_sender.clone(),
scheduler_chan: self.scheduler_chan.clone(),
compositor_proxy: self.compositor_proxy.clone(),
embedder_proxy: self.embedder_proxy.clone(),
devtools_chan: self.devtools_chan.clone(),
bluetooth_thread: self.bluetooth_thread.clone(),
swmanager_thread: self.swmanager_sender.clone(),
@@ -5,7 +5,7 @@
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use compositing::CompositionPipeline;
use compositing::CompositorProxy;
use compositing::compositor_thread::{CompositorProxy, EmbedderProxy};
use compositing::compositor_thread::Msg as CompositorMsg;
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
use euclid::{TypedSize2D, TypedScale};
@@ -127,6 +127,9 @@ pub struct InitialPipelineState {

/// A channel to schedule timer events.
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,

/// A channel to the embedder.
pub embedder_proxy: EmbedderProxy,

/// A channel to the compositor.
pub compositor_proxy: CompositorProxy,
@@ -257,6 +260,7 @@ impl Pipeline {
browsing_context_id: state.browsing_context_id,
top_level_browsing_context_id: state.top_level_browsing_context_id,
parent_info: state.parent_info,
embedder_proxy: state.embedder_proxy,
script_to_constellation_chan: state.script_to_constellation_chan.clone(),
scheduler_chan: state.scheduler_chan,
devtools_chan: script_to_devtools_chan,
@@ -447,6 +451,7 @@ pub struct UnprivilegedPipelineContent {
top_level_browsing_context_id: TopLevelBrowsingContextId,
browsing_context_id: BrowsingContextId,
parent_info: Option<PipelineId>,
embedder_proxy: EmbedderProxy,
script_to_constellation_chan: ScriptToConstellationChan,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
@@ -493,6 +498,7 @@ impl UnprivilegedPipelineContent {
parent_info: self.parent_info,
control_chan: self.script_chan.clone(),
control_port: self.script_port,
embedder_proxy: self.embedder_proxy,
script_to_constellation_chan: self.script_to_constellation_chan.clone(),
layout_to_constellation_chan: self.layout_to_constellation_chan.clone(),
scheduler_chan: self.scheduler_chan,
@@ -41,7 +41,8 @@ use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
use profile_traits::{mem, time};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
use script_thread::{MainThreadScriptChan, ScriptThread};
use script_traits::{MsDuration, ScriptToConstellationChan, TimerEvent};
use script_traits::{MsDuration, TimerEvent};
use script_traits::{ScriptToConstellationChan, ScriptToEmbedderChan};
use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource};
use servo_url::{MutableOrigin, ServoUrl};
use std::cell::Cell;
@@ -97,7 +98,11 @@ pub struct GlobalScope {
/// For sending messages to the time profiler.
#[ignore_malloc_size_of = "channels are hard"]
time_profiler_chan: time::ProfilerChan,


/// A handle for communicating messages to the embedder.
#[ignore_malloc_size_of = "channels are hard"]
script_to_embedder_chan: ScriptToEmbedderChan,

/// A handle for communicating messages to the constellation thread.
#[ignore_malloc_size_of = "channels are hard"]
script_to_constellation_chan: ScriptToConstellationChan,
@@ -137,6 +142,7 @@ impl GlobalScope {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan,
time_profiler_chan: time::ProfilerChan,
script_to_embedder_chan: ScriptToEmbedderChan,
script_to_constellation_chan: ScriptToConstellationChan,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
resource_threads: ResourceThreads,
@@ -154,6 +160,7 @@ impl GlobalScope {
devtools_chan,
mem_profiler_chan,
time_profiler_chan,
script_to_embedder_chan,
script_to_constellation_chan,
scheduler_chan: scheduler_chan.clone(),
in_error_reporting_mode: Default::default(),
@@ -269,7 +276,12 @@ impl GlobalScope {
pub fn time_profiler_chan(&self) -> &time::ProfilerChan {
&self.time_profiler_chan
}


/// Get a sender to the constellation thread.
pub fn script_to_embedder_chan(&self) -> &ScriptToEmbedderChan {
&self.script_to_embedder_chan
}

/// Get a sender to the constellation thread.
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan {
&self.script_to_constellation_chan
@@ -76,7 +76,8 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventC
use script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg};
use script_thread::{ScriptThread, SendableMainThreadScriptChan};
use script_traits::{ConstellationControlMsg, DocumentState, LoadData};
use script_traits::{ScriptToConstellationChan, ScriptMsg, ScrollState, TimerEvent, TimerEventId};
use script_traits::{ScriptToConstellationChan, ScriptToEmbedderChan};
use script_traits::{ScriptMsg, ScrollState, TimerEvent, TimerEventId};
use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use selectors::attr::CaseSensitivity;
@@ -1762,6 +1763,7 @@ impl Window {
mem_profiler_chan: MemProfilerChan,
time_profiler_chan: TimeProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
embedder_chan: ScriptToEmbedderChan,
constellation_chan: ScriptToConstellationChan,
control_chan: IpcSender<ConstellationControlMsg>,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
@@ -1793,6 +1795,7 @@ impl Window {
devtools_chan,
mem_profiler_chan,
time_profiler_chan,
embedder_chan,
constellation_chan,
scheduler_chan,
resource_threads,
@@ -21,6 +21,7 @@ extern crate itertools;

use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use compositing::compositor_thread::{EmbedderMsg, EmbedderProxy};
use devtools;
use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo};
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
@@ -93,7 +94,8 @@ use script_traits::{DiscardBrowsingContext, DocumentActivity, EventResult};
use script_traits::{InitialScriptState, JsEvalResult, LayoutMsg, LoadData};
use script_traits::{MouseButton, MouseEventType, NewLayoutInfo};
use script_traits::{ProgressiveWebMetricType, Painter, ScriptMsg, ScriptThreadFactory};
use script_traits::{ScriptToConstellationChan, TimerEvent, TimerSchedulerMsg};
use script_traits::{ScriptToConstellationChan, ScriptToEmbedderChan};
use script_traits::{TimerEvent, TimerSchedulerMsg};
use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress};
use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent, TouchEvent};
@@ -848,6 +850,7 @@ impl ScriptThread {

control_chan: state.control_chan,
control_port: control_port,
embedder_proxy: state.embedder_proxy,
script_sender: state.script_to_constellation_chan.sender.clone(),
time_profiler_chan: state.time_profiler_chan.clone(),
mem_profiler_chan: state.mem_profiler_chan,
@@ -2099,6 +2102,11 @@ impl ScriptThread {
sender: self.script_sender.clone(),
pipeline_id: incomplete.pipeline_id,
};

let script_to_embedder_chan = ScriptToEmbedderChan {
sender: self.embedder_proxy.clone(),
top_level_browsing_context_id: incomplete.top_level_browsing_context_id,
};

// Create the window and document objects.
let window = Window::new(
@@ -2117,6 +2125,7 @@ impl ScriptThread {
self.mem_profiler_chan.clone(),
self.time_profiler_chan.clone(),
self.devtools_chan.clone(),
script_to_embedder_chan,
script_to_constellation_chan,
self.control_chan.clone(),
self.scheduler_chan.clone(),
@@ -11,6 +11,7 @@

extern crate bluetooth_traits;
extern crate canvas_traits;
extern crate compositing;
extern crate cookie as cookie_rs;
extern crate devtools_traits;
extern crate euclid;
@@ -40,6 +41,7 @@ pub mod webdriver_msg;

use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use compositing::compositor_thread::{EmbedderMsg, EmbedderProxy};
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
use euclid::{Length, Point2D, Vector2D, Rect, TypedSize2D, TypedScale};
use gfx_traits::Epoch;
@@ -521,6 +523,8 @@ pub struct InitialScriptState {
pub control_chan: IpcSender<ConstellationControlMsg>,
/// A port on which messages sent by the constellation to script can be received.
pub control_port: IpcReceiver<ConstellationControlMsg>,
/// A channel to the embedder.
pub embedder_proxy: EmbedderProxy,
/// A channel on which messages can be sent to the constellation from script.
pub script_to_constellation_chan: ScriptToConstellationChan,
/// A sender for the layout thread to communicate to the constellation.
@@ -807,3 +811,19 @@ impl ScriptToConstellationChan {
self.sender.send((self.pipeline_id, msg))
}
}

/// A Script to Embedder channel.
#[derive(Clone, Deserialize, Serialize)]
pub struct ScriptToEmbedderChan {

This comment has been minimized.

Copy link
@gterzian

gterzian Apr 28, 2018

Author Member

This is not necessary, since top_level_browsing_context_id would available directly at the point where could be used to send an EmbedderMsg...

/// Sender for communicating with constellation thread.
pub proxy: EmbedderProxy,
/// The top level ancestor browsing context.
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
}

impl ScriptToEmbedderChan {
/// Send ScriptMsg and attach the pipeline_id to the message.
pub fn send(&self, msg: EmbedderMsg) {
self.proxy.send((self.top_level_browsing_context_id, msg))
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.