aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs65
1 files changed, 35 insertions, 30 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index e87938bfa1e..1bcc6140a3a 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -87,7 +87,7 @@ use script_runtime::{ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
use script_traits::{CompositorEvent, ConstellationControlMsg};
use script_traits::{DocumentActivity, DiscardBrowsingContext, EventResult};
use script_traits::{InitialScriptState, LayoutMsg, LoadData, MouseButton, MouseEventType, MozBrowserEvent};
-use script_traits::{NewLayoutInfo, ScriptMsg as ConstellationMsg, UpdatePipelineIdReason};
+use script_traits::{NewLayoutInfo, ScriptToConstellationChan, ScriptMsg, UpdatePipelineIdReason};
use script_traits::{ScriptThreadFactory, TimerEvent, TimerSchedulerMsg, TimerSource};
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
@@ -462,7 +462,7 @@ pub struct ScriptThread {
control_port: Receiver<ConstellationControlMsg>,
/// For communicating load url messages to the constellation
- constellation_chan: IpcSender<ConstellationMsg>,
+ script_sender: IpcSender<(PipelineId, ScriptMsg)>,
/// A sender for new layout threads to communicate to the constellation.
layout_to_constellation_chan: IpcSender<LayoutMsg>,
@@ -733,12 +733,12 @@ impl ScriptThread {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.worklet_thread_pool.borrow_mut().get_or_insert_with(|| {
let init = WorkletGlobalScopeInit {
- script_sender: script_thread.chan.0.clone(),
+ to_script_thread_sender: script_thread.chan.0.clone(),
resource_threads: script_thread.resource_threads.clone(),
mem_profiler_chan: script_thread.mem_profiler_chan.clone(),
time_profiler_chan: script_thread.time_profiler_chan.clone(),
devtools_chan: script_thread.devtools_chan.clone(),
- constellation_chan: script_thread.constellation_chan.clone(),
+ to_constellation_sender: script_thread.script_sender.clone(),
scheduler_chan: script_thread.scheduler_chan.clone(),
image_cache: script_thread.image_cache.clone(),
};
@@ -844,7 +844,7 @@ impl ScriptThread {
control_chan: state.control_chan,
control_port: control_port,
- constellation_chan: state.constellation_chan,
+ script_sender: state.script_to_constellation_chan.sender.clone(),
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
@@ -1532,7 +1532,7 @@ impl ScriptThread {
fn handle_visibility_change_msg(&self, id: PipelineId, visible: bool) {
// Separate message sent since parent script thread could be different (Iframe of different
// domain)
- self.constellation_chan.send(ConstellationMsg::VisibilityChangeComplete(id, visible)).unwrap();
+ self.script_sender.send((id, ScriptMsg::VisibilityChangeComplete(visible))).unwrap();
let window = self.documents.borrow().find_window(id);
match window {
@@ -1632,13 +1632,13 @@ impl ScriptThread {
/// constellation to shut down the pipeline, which will clean everything up
/// normally. If we do exit, we will tear down the DOM nodes, possibly at a point
/// where layout is still accessing them.
- fn handle_exit_window_msg(&self, _: PipelineId) {
+ fn handle_exit_window_msg(&self, id: PipelineId) {
debug!("script thread handling exit window msg");
// TODO(tkuehn): currently there is only one window,
// so this can afford to be naive and just shut down the
// constellation. In the future it'll need to be smarter.
- self.constellation_chan.send(ConstellationMsg::Exit).unwrap();
+ self.script_sender.send((id, ScriptMsg::Exit)).unwrap();
}
/// We have received notification that the response associated with a load has completed.
@@ -1690,7 +1690,7 @@ impl ScriptThread {
let script_url = maybe_registration.get_installed().get_script_url();
let scope_things = ServiceWorkerRegistration::create_scope_things(window.upcast(), script_url);
- let _ = self.constellation_chan.send(ConstellationMsg::RegisterServiceWorker(scope_things, scope.clone()));
+ let _ = self.script_sender.send((pipeline_id, ScriptMsg::RegisterServiceWorker(scope_things, scope.clone())));
}
pub fn dispatch_job_queue(&self, job_handler: Box<AsyncJobHandler>) {
@@ -1707,7 +1707,7 @@ impl ScriptThread {
Some(document) => document,
None => return warn!("Message sent to closed pipeline {}.", pipeline_id),
};
- document.send_title_to_compositor();
+ document.send_title_to_constellation();
}
/// Handles a request to exit a pipeline and shut down layout.
@@ -1747,7 +1747,7 @@ impl ScriptThread {
debug!("shutting down layout for page {}", id);
let _ = response_port.recv();
chan.send(message::Msg::ExitNow).ok();
- self.constellation_chan.send(ConstellationMsg::PipelineExited(id)).ok();
+ self.script_sender.send((id, ScriptMsg::PipelineExited)).ok();
debug!("Exited pipeline {}.", id);
}
@@ -1872,15 +1872,15 @@ impl ScriptThread {
fn ask_constellation_for_browsing_context_id(&self, pipeline_id: PipelineId) -> Option<BrowsingContextId> {
let (result_sender, result_receiver) = ipc::channel().unwrap();
- let msg = ConstellationMsg::GetBrowsingContextId(pipeline_id, result_sender);
- self.constellation_chan.send(msg).expect("Failed to send to constellation.");
+ let msg = ScriptMsg::GetBrowsingContextId(pipeline_id, result_sender);
+ self.script_sender.send((pipeline_id, msg)).expect("Failed to send to constellation.");
result_receiver.recv().expect("Failed to get frame id from constellation.")
}
fn ask_constellation_for_parent_info(&self, pipeline_id: PipelineId) -> Option<(PipelineId, FrameType)> {
let (result_sender, result_receiver) = ipc::channel().unwrap();
- let msg = ConstellationMsg::GetParentInfo(pipeline_id, result_sender);
- self.constellation_chan.send(msg).expect("Failed to send to constellation.");
+ let msg = ScriptMsg::GetParentInfo(pipeline_id, result_sender);
+ self.script_sender.send((pipeline_id, msg)).expect("Failed to send to constellation.");
result_receiver.recv().expect("Failed to get frame id from constellation.")
}
@@ -1965,8 +1965,8 @@ impl ScriptThread {
.unwrap();
// update the pipeline url
- self.constellation_chan
- .send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone()))
+ self.script_sender
+ .send((incomplete.pipeline_id, ScriptMsg::SetFinalUrl(final_url.clone())))
.unwrap();
}
debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id);
@@ -1986,6 +1986,11 @@ impl ScriptThread {
MutableOrigin::new(final_url.origin())
};
+ let script_to_constellation_chan = ScriptToConstellationChan {
+ sender: self.script_sender.clone(),
+ pipeline_id: incomplete.pipeline_id,
+ };
+
// Create the window and document objects.
let window = Window::new(self.js_runtime.clone(),
MainThreadScriptChan(sender.clone()),
@@ -2001,7 +2006,7 @@ impl ScriptThread {
self.mem_profiler_chan.clone(),
self.time_profiler_chan.clone(),
self.devtools_chan.clone(),
- self.constellation_chan.clone(),
+ script_to_constellation_chan,
self.control_chan.clone(),
self.scheduler_chan.clone(),
ipc_timer_event_chan,
@@ -2071,8 +2076,8 @@ impl ScriptThread {
window.init_document(&document);
- self.constellation_chan
- .send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id))
+ self.script_sender
+ .send((incomplete.pipeline_id, ScriptMsg::ActivateDocument))
.unwrap();
// Notify devtools that a new script global exists.
@@ -2199,8 +2204,8 @@ impl ScriptThread {
url.join(&value).map(|url| url.to_string()).ok()
});
- let event = ConstellationMsg::NodeStatus(status);
- self.constellation_chan.send(event).unwrap();
+ let event = ScriptMsg::NodeStatus(status);
+ self.script_sender.send((pipeline_id, event)).unwrap();
state_already_changed = true;
}
@@ -2213,8 +2218,8 @@ impl ScriptThread {
.inclusive_ancestors()
.filter_map(Root::downcast::<HTMLAnchorElement>)
.next() {
- let event = ConstellationMsg::NodeStatus(None);
- self.constellation_chan.send(event).unwrap();
+ let event = ScriptMsg::NodeStatus(None);
+ self.script_sender.send((pipeline_id, event)).unwrap();
}
}
}
@@ -2229,8 +2234,8 @@ impl ScriptThread {
} else {
EventResult::DefaultPrevented
};
- let message = ConstellationMsg::TouchEventProcessed(result);
- self.constellation_chan.send(message).unwrap();
+ let message = ScriptMsg::TouchEventProcessed(result);
+ self.script_sender.send((pipeline_id, message)).unwrap();
}
_ => {
// TODO: Calling preventDefault on a touchup event should prevent clicks.
@@ -2251,7 +2256,7 @@ impl ScriptThread {
Some(document) => document,
None => return warn!("Message sent to closed pipeline {}.", pipeline_id),
};
- document.dispatch_key_event(ch, key, state, modifiers, &self.constellation_chan);
+ document.dispatch_key_event(ch, key, state, modifiers);
}
}
}
@@ -2299,8 +2304,8 @@ impl ScriptThread {
}
}
None => {
- self.constellation_chan
- .send(ConstellationMsg::LoadUrl(parent_pipeline_id, load_data, replace))
+ self.script_sender
+ .send((parent_pipeline_id, ScriptMsg::LoadUrl(load_data, replace)))
.unwrap();
}
}
@@ -2360,7 +2365,7 @@ impl ScriptThread {
let context = ParserContext::new(id, load_data.url);
self.incomplete_parser_contexts.borrow_mut().push((id, context));
- self.constellation_chan.send(ConstellationMsg::InitiateNavigateRequest(req_init, id)).unwrap();
+ self.script_sender.send((id, ScriptMsg::InitiateNavigateRequest(req_init))).unwrap();
self.incomplete_loads.borrow_mut().push(incomplete);
}