mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #17425 - paulrouget:attach-pipeline-2, r=asajeffrey
cleanup embedder/compositor/constellation/script messages Fix: #17226 #17200 #17201 This is work in progress. Some tests still fail. I'd like to get early feedback as it's a pretty large PR. There is nothing fundamentally new. Basically, I added TopLevelBrowsingContrextId to the relevant messages between the embedder, the compositor and the constellation, and enforced the PipelineId to be attached to each ScriptMsg (see #17201). I unaliased all the ScriptMsg. It was getting difficult to understand the nature of the message as ScriptMsg was used aliased CompositorMsg sometimes (CompositorMsg is an actually type of message already). I renamed constellation_chan to script_to_constellation_chan, again, for clarification. This cleanup code is necessary for #15934 and for tabs support. /cc @asajeffrey can I ask you to look at this? No need for a formal review, I need feedback at this stage. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17425) <!-- Reviewable:end -->
This commit is contained in:
commit
74558990b2
33 changed files with 625 additions and 517 deletions
|
@ -2,8 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use ipc_channel::ipc::channel;
|
||||
use script_traits::{ScriptToConstellationChan, ScriptMsg};
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
pub trait ClipboardProvider {
|
||||
|
@ -13,14 +13,14 @@ pub trait ClipboardProvider {
|
|||
fn set_clipboard_contents(&mut self, String);
|
||||
}
|
||||
|
||||
impl ClipboardProvider for IpcSender<ConstellationMsg> {
|
||||
impl ClipboardProvider for ScriptToConstellationChan {
|
||||
fn clipboard_contents(&mut self) -> String {
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
self.send(ConstellationMsg::GetClipboardContents(tx)).unwrap();
|
||||
let (tx, rx) = channel().unwrap();
|
||||
self.send(ScriptMsg::GetClipboardContents(tx)).unwrap();
|
||||
rx.recv().unwrap()
|
||||
}
|
||||
fn set_clipboard_contents(&mut self, s: String) {
|
||||
self.send(ConstellationMsg::SetClipboardContents(s)).unwrap();
|
||||
self.send(ScriptMsg::SetClipboardContents(s)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
|||
use script_layout_interface::OpaqueStyleAndLayoutData;
|
||||
use script_layout_interface::reporter::CSSErrorReporter;
|
||||
use script_layout_interface::rpc::LayoutRPC;
|
||||
use script_traits::{DocumentActivity, TimerEventId, TimerSource, TouchpadPressurePhase};
|
||||
use script_traits::{DocumentActivity, ScriptToConstellationChan, TimerEventId, TimerSource, TouchpadPressurePhase};
|
||||
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||
use script_traits::DrawAPaintImageResult;
|
||||
use selectors::matching::ElementSelectorFlags;
|
||||
|
@ -400,6 +400,7 @@ unsafe_no_jsmanaged_fields!(WebGLTextureId);
|
|||
unsafe_no_jsmanaged_fields!(WebGLVertexArrayId);
|
||||
unsafe_no_jsmanaged_fields!(MediaList);
|
||||
unsafe_no_jsmanaged_fields!(WebVRGamepadHand);
|
||||
unsafe_no_jsmanaged_fields!(ScriptToConstellationChan);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -42,7 +42,7 @@ use net_traits::image_cache::ImageResponse;
|
|||
use net_traits::image_cache::ImageState;
|
||||
use net_traits::image_cache::UsePlaceholder;
|
||||
use num_traits::ToPrimitive;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptMsg;
|
||||
use servo_url::ServoUrl;
|
||||
use std::{cmp, fmt, mem};
|
||||
use std::cell::Cell;
|
||||
|
@ -130,9 +130,9 @@ impl CanvasRenderingContext2D {
|
|||
-> CanvasRenderingContext2D {
|
||||
debug!("Creating new canvas rendering context.");
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||
debug!("Asking constellation to create new canvas thread.");
|
||||
constellation_chan.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap();
|
||||
script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, sender)).unwrap();
|
||||
let ipc_renderer = receiver.recv().unwrap();
|
||||
debug!("Done.");
|
||||
CanvasRenderingContext2D {
|
||||
|
|
|
@ -17,7 +17,7 @@ use ipc_channel::ipc;
|
|||
use js::jsapi::{JSContext, HandleValue};
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptMsg;
|
||||
use servo_url::ImmutableOrigin;
|
||||
use servo_url::MutableOrigin;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -54,7 +54,7 @@ impl DissimilarOriginWindow {
|
|||
global_to_clone_from.devtools_chan().cloned(),
|
||||
global_to_clone_from.mem_profiler_chan().clone(),
|
||||
global_to_clone_from.time_profiler_chan().clone(),
|
||||
global_to_clone_from.constellation_chan().clone(),
|
||||
global_to_clone_from.script_to_constellation_chan().clone(),
|
||||
global_to_clone_from.scheduler_chan().clone(),
|
||||
global_to_clone_from.resource_threads().clone(),
|
||||
timer_event_chan,
|
||||
|
@ -184,9 +184,9 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
|||
|
||||
impl DissimilarOriginWindow {
|
||||
pub fn post_message(&self, origin: Option<ImmutableOrigin>, data: StructuredCloneData) {
|
||||
let msg = ConstellationMsg::PostMessage(self.window_proxy.browsing_context_id(),
|
||||
let msg = ScriptMsg::PostMessage(self.window_proxy.browsing_context_id(),
|
||||
origin,
|
||||
data.move_to_arraybuffer());
|
||||
let _ = self.upcast::<GlobalScope>().constellation_chan().send(msg);
|
||||
let _ = self.upcast::<GlobalScope>().script_to_constellation_chan().send(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
|||
use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
|
||||
use script_traits::{AnimationState, CompositorEvent, DocumentActivity};
|
||||
use script_traits::{MouseButton, MouseEventType, MozBrowserEvent};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
|
||||
use script_traits::{MsDuration, ScriptMsg, TouchpadPressurePhase};
|
||||
use script_traits::{TouchEventType, TouchId};
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use servo_arc::Arc;
|
||||
|
@ -795,9 +795,7 @@ impl Document {
|
|||
// Update the focus state for all elements in the focus chain.
|
||||
// https://html.spec.whatwg.org/multipage/#focus-chain
|
||||
if focus_type == FocusType::Element {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::Focus(global_scope.pipeline_id());
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
self.send_to_constellation(ScriptMsg::Focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -808,19 +806,14 @@ impl Document {
|
|||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
|
||||
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(String::from(self.Title())));
|
||||
|
||||
self.send_title_to_compositor();
|
||||
self.send_title_to_constellation();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends this document's title to the compositor.
|
||||
pub fn send_title_to_compositor(&self) {
|
||||
let window = self.window();
|
||||
let global_scope = window.upcast::<GlobalScope>();
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::SetTitle(global_scope.pipeline_id(),
|
||||
Some(String::from(self.Title()))))
|
||||
.unwrap();
|
||||
/// Sends this document's title to the constellation.
|
||||
pub fn send_title_to_constellation(&self) {
|
||||
let title = Some(String::from(self.Title()));
|
||||
self.send_to_constellation(ScriptMsg::SetTitle(title));
|
||||
}
|
||||
|
||||
pub fn dirty_all_nodes(&self) {
|
||||
|
@ -872,8 +865,8 @@ impl Document {
|
|||
let child_point = client_point - child_origin;
|
||||
|
||||
let event = CompositorEvent::MouseButtonEvent(mouse_event_type, button, child_point);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1029,8 +1022,8 @@ impl Document {
|
|||
let event = CompositorEvent::TouchpadPressureEvent(child_point,
|
||||
pressure,
|
||||
phase_now);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1131,8 +1124,8 @@ impl Document {
|
|||
let child_point = client_point - child_origin;
|
||||
|
||||
let event = CompositorEvent::MouseMoveEvent(Some(child_point));
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1238,8 +1231,8 @@ impl Document {
|
|||
let child_point = point - child_origin;
|
||||
|
||||
let event = CompositorEvent::TouchEvent(event_type, touch_id, child_point);
|
||||
let event = ConstellationMsg::ForwardEvent(pipeline_id, event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ForwardEvent(pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
return TouchEventResult::Forwarded;
|
||||
}
|
||||
|
@ -1330,8 +1323,7 @@ impl Document {
|
|||
ch: Option<char>,
|
||||
key: Key,
|
||||
state: KeyState,
|
||||
modifiers: KeyModifiers,
|
||||
constellation: &IpcSender<ConstellationMsg>) {
|
||||
modifiers: KeyModifiers) {
|
||||
let focused = self.get_focused_element();
|
||||
let body = self.GetBody();
|
||||
|
||||
|
@ -1407,7 +1399,8 @@ impl Document {
|
|||
}
|
||||
|
||||
if cancel_state == EventDefault::Allowed {
|
||||
constellation.send(ConstellationMsg::SendKeyEvent(ch, key, state, modifiers)).unwrap();
|
||||
let msg = ScriptMsg::SendKeyEvent(ch, key, state, modifiers);
|
||||
self.send_to_constellation(msg);
|
||||
|
||||
// This behavior is unspecced
|
||||
// We are supposed to dispatch synthetic click activation for Space and/or Return,
|
||||
|
@ -1525,11 +1518,8 @@ impl Document {
|
|||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
if PREFS.is_mozbrowser_enabled() {
|
||||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
||||
let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
|
||||
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
||||
top_level_browsing_context_id,
|
||||
event);
|
||||
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::MozBrowserEvent(parent_pipeline_id, event);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1559,11 +1549,8 @@ impl Document {
|
|||
// This reduces CPU usage by avoiding needless thread wakeups in the common case of
|
||||
// repeated rAF.
|
||||
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
||||
global_scope.pipeline_id(),
|
||||
AnimationState::AnimationCallbacksPresent);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::AnimationCallbacksPresent);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
ident
|
||||
|
@ -1629,11 +1616,8 @@ impl Document {
|
|||
(!was_faking_animation_frames && self.is_faking_animation_frames()) {
|
||||
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
||||
&mut *animation_frame_list);
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(
|
||||
global_scope.pipeline_id(),
|
||||
AnimationState::NoAnimationCallbacksPresent);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::NoAnimationCallbacksPresent);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
// Update the counter of spurious animation frames.
|
||||
|
@ -1896,10 +1880,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn notify_constellation_load(&self) {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let pipeline_id = global_scope.pipeline_id();
|
||||
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
|
||||
global_scope.constellation_chan().send(load_event).unwrap();
|
||||
self.send_to_constellation(ScriptMsg::LoadComplete);
|
||||
}
|
||||
|
||||
pub fn set_current_parser(&self, script: Option<&ServoParser>) {
|
||||
|
@ -2024,6 +2005,11 @@ impl Document {
|
|||
|
||||
registry.lookup_definition(local_name, is)
|
||||
}
|
||||
|
||||
fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
global_scope.script_to_constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, HeapSizeOf)]
|
||||
|
@ -2525,8 +2511,8 @@ impl Document {
|
|||
let window = self.window();
|
||||
// Step 6
|
||||
if !error {
|
||||
let event = ConstellationMsg::SetFullscreenState(true);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetFullscreenState(true);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
|
||||
// Step 7
|
||||
|
@ -2558,8 +2544,8 @@ impl Document {
|
|||
|
||||
let window = self.window();
|
||||
// Step 8
|
||||
let event = ConstellationMsg::SetFullscreenState(false);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetFullscreenState(false);
|
||||
self.send_to_constellation(event);
|
||||
|
||||
// Step 9
|
||||
let trusted_element = Trusted::new(element.r());
|
||||
|
|
|
@ -37,7 +37,7 @@ use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
|||
use profile_traits::{mem, time};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
|
||||
use script_traits::{MsDuration, ScriptToConstellationChan, TimerEvent};
|
||||
use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource};
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
use std::cell::Cell;
|
||||
|
@ -80,7 +80,7 @@ pub struct GlobalScope {
|
|||
|
||||
/// A handle for communicating messages to the constellation thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
constellation_chan: IpcSender<ConstellationMsg>,
|
||||
script_to_constellation_chan: ScriptToConstellationChan,
|
||||
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
|
@ -104,7 +104,7 @@ impl GlobalScope {
|
|||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
time_profiler_chan: time::ProfilerChan,
|
||||
constellation_chan: IpcSender<ConstellationMsg>,
|
||||
script_to_constellation_chan: ScriptToConstellationChan,
|
||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
resource_threads: ResourceThreads,
|
||||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
|
@ -120,7 +120,7 @@ impl GlobalScope {
|
|||
devtools_chan: devtools_chan,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
constellation_chan: constellation_chan,
|
||||
script_to_constellation_chan: script_to_constellation_chan,
|
||||
scheduler_chan: scheduler_chan.clone(),
|
||||
in_error_reporting_mode: Default::default(),
|
||||
resource_threads: resource_threads,
|
||||
|
@ -231,8 +231,8 @@ impl GlobalScope {
|
|||
}
|
||||
|
||||
/// Get a sender to the constellation thread.
|
||||
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
|
||||
&self.constellation_chan
|
||||
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan {
|
||||
&self.script_to_constellation_chan
|
||||
}
|
||||
|
||||
pub fn scheduler_chan(&self) -> &IpcSender<TimerSchedulerMsg> {
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::window::Window;
|
|||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc;
|
||||
use msg::constellation_msg::TraversalDirection;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptMsg;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-history-interface
|
||||
#[dom_struct]
|
||||
|
@ -44,9 +44,8 @@ impl History {
|
|||
if !self.window.Document().is_fully_active() {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
|
||||
let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
|
||||
let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
|
||||
let msg = ScriptMsg::TraverseHistory(direction);
|
||||
let _ = self.window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +56,9 @@ impl HistoryMethods for History {
|
|||
if !self.window.Document().is_fully_active() {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
|
||||
let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length.");
|
||||
let msg = ConstellationMsg::JointSessionHistoryLength(top_level_browsing_context_id, sender);
|
||||
let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
|
||||
let msg = ScriptMsg::JointSessionHistoryLength(sender);
|
||||
let _ = self.window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg);
|
||||
Ok(recv.recv().unwrap())
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use dom::node::{Node, document_from_node, window_from_node};
|
|||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptMsg;
|
||||
use servo_url::ServoUrl;
|
||||
use style::attr::AttrValue;
|
||||
use time;
|
||||
|
@ -138,8 +138,8 @@ impl VirtualMethods for HTMLBodyElement {
|
|||
let window = window_from_node(self);
|
||||
let document = window.Document();
|
||||
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
||||
let event = ConstellationMsg::HeadParsed;
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::HeadParsed;
|
||||
window.upcast::<GlobalScope>().script_to_constellation_chan().send(event).unwrap();
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
|
||||
|
|
|
@ -45,7 +45,7 @@ use net_traits::response::HttpsState;
|
|||
use script_layout_interface::message::ReflowQueryType;
|
||||
use script_thread::{ScriptThread, Runnable};
|
||||
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, LoadData, UpdatePipelineIdReason};
|
||||
use script_traits::{MozBrowserEvent, NewLayoutInfo, ScriptMsg as ConstellationMsg};
|
||||
use script_traits::{MozBrowserEvent, NewLayoutInfo, ScriptMsg};
|
||||
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::prefs::PREFS;
|
||||
|
@ -170,8 +170,8 @@ impl HTMLIFrameElement {
|
|||
let (pipeline_sender, pipeline_receiver) = ipc::channel().unwrap();
|
||||
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::ScriptNewIFrame(load_info, pipeline_sender))
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::ScriptNewIFrame(load_info, pipeline_sender))
|
||||
.unwrap();
|
||||
|
||||
let new_layout_info = NewLayoutInfo {
|
||||
|
@ -197,8 +197,8 @@ impl HTMLIFrameElement {
|
|||
sandbox: sandboxed,
|
||||
};
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::ScriptLoadedURLInIFrame(load_info))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -349,11 +349,9 @@ impl HTMLIFrameElement {
|
|||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
if let Some(pipeline_id) = self.pipeline_id.get() {
|
||||
let window = window_from_node(self);
|
||||
let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
let msg = ScriptMsg::SetVisible(visible);
|
||||
let window = window_from_node(self);
|
||||
window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#iframe-load-event-steps steps 1-4
|
||||
|
@ -540,10 +538,10 @@ unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
|
|||
|
||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> ErrorResult {
|
||||
if iframe.Mozbrowser() {
|
||||
if let Some(top_level_browsing_context_id) = iframe.top_level_browsing_context_id() {
|
||||
if let Some(_) = iframe.top_level_browsing_context_id() {
|
||||
let window = window_from_node(iframe);
|
||||
let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||
let msg = ScriptMsg::TraverseHistory(direction);
|
||||
window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg).unwrap();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
@ -795,8 +793,8 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
};
|
||||
debug!("Unbinding frame {}.", browsing_context_id);
|
||||
|
||||
let msg = ConstellationMsg::RemoveIFrame(browsing_context_id, sender);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||
let msg = ScriptMsg::RemoveIFrame(browsing_context_id, sender);
|
||||
window.upcast::<GlobalScope>().script_to_constellation_chan().send(msg).unwrap();
|
||||
let exited_pipeline_ids = receiver.recv().unwrap();
|
||||
|
||||
// The spec for discarding is synchronous,
|
||||
|
|
|
@ -38,13 +38,13 @@ use dom::validitystate::ValidationFlags;
|
|||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::ipc::channel;
|
||||
use mime_guess;
|
||||
use net_traits::{CoreResourceMsg, IpcSend};
|
||||
use net_traits::blob_url_store::get_blob_origin;
|
||||
use net_traits::filemanager_thread::{FileManagerThreadMsg, FilterPattern};
|
||||
use script_layout_interface::rpc::TextIndexResponse;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptToConstellationChan;
|
||||
use servo_atoms::Atom;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
|
@ -94,7 +94,7 @@ pub struct HTMLInputElement {
|
|||
maxlength: Cell<i32>,
|
||||
minlength: Cell<i32>,
|
||||
#[ignore_heap_size_of = "#7193"]
|
||||
textinput: DOMRefCell<TextInput<IpcSender<ConstellationMsg>>>,
|
||||
textinput: DOMRefCell<TextInput<ScriptToConstellationChan>>,
|
||||
activation_state: DOMRefCell<InputActivationState>,
|
||||
// https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag
|
||||
value_dirty: Cell<bool>,
|
||||
|
@ -136,7 +136,7 @@ static DEFAULT_MIN_LENGTH: i32 = -1;
|
|||
|
||||
impl HTMLInputElement {
|
||||
fn new_inherited(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> HTMLInputElement {
|
||||
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
|
||||
let chan = document.window().upcast::<GlobalScope>().script_to_constellation_chan().clone();
|
||||
HTMLInputElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
||||
|
@ -814,7 +814,7 @@ impl HTMLInputElement {
|
|||
if self.Multiple() {
|
||||
let opt_test_paths = opt_test_paths.map(|paths| paths.iter().map(|p| p.to_string()).collect());
|
||||
|
||||
let (chan, recv) = ipc::channel().expect("Error initializing channel");
|
||||
let (chan, recv) = channel().expect("Error initializing channel");
|
||||
let msg = FileManagerThreadMsg::SelectFiles(filter, chan, origin, opt_test_paths);
|
||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg)).unwrap();
|
||||
|
||||
|
@ -838,7 +838,7 @@ impl HTMLInputElement {
|
|||
None => None,
|
||||
};
|
||||
|
||||
let (chan, recv) = ipc::channel().expect("Error initializing channel");
|
||||
let (chan, recv) = channel().expect("Error initializing channel");
|
||||
let msg = FileManagerThreadMsg::SelectFile(filter, chan, origin, opt_test_path);
|
||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg)).unwrap();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ use dom_struct::dom_struct;
|
|||
use html5ever::{LocalName, Prefix};
|
||||
use net_traits::ReferrerPolicy;
|
||||
use script_layout_interface::message::Msg;
|
||||
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
|
||||
use script_traits::{MozBrowserEvent, ScriptMsg};
|
||||
use servo_arc::Arc;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -309,8 +309,8 @@ impl HTMLLinkElement {
|
|||
let document = document_from_node(self);
|
||||
match document.base_url().join(href) {
|
||||
Ok(url) => {
|
||||
let event = ConstellationMsg::NewFavicon(url.clone());
|
||||
document.window().upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::NewFavicon(url.clone());
|
||||
document.window().upcast::<GlobalScope>().script_to_constellation_chan().send(event).unwrap();
|
||||
|
||||
let mozbrowser_event = match *sizes {
|
||||
Some(ref sizes) => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), sizes.to_owned()),
|
||||
|
|
|
@ -27,8 +27,7 @@ use dom::validation::Validatable;
|
|||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptToConstellationChan;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use std::ops::Range;
|
||||
|
@ -40,7 +39,7 @@ use textinput::{KeyReaction, Lines, SelectionDirection, TextInput};
|
|||
pub struct HTMLTextAreaElement {
|
||||
htmlelement: HTMLElement,
|
||||
#[ignore_heap_size_of = "#7193"]
|
||||
textinput: DOMRefCell<TextInput<IpcSender<ConstellationMsg>>>,
|
||||
textinput: DOMRefCell<TextInput<ScriptToConstellationChan>>,
|
||||
placeholder: DOMRefCell<DOMString>,
|
||||
// https://html.spec.whatwg.org/multipage/#concept-textarea-dirty
|
||||
value_changed: Cell<bool>,
|
||||
|
@ -109,7 +108,7 @@ impl HTMLTextAreaElement {
|
|||
fn new_inherited(local_name: LocalName,
|
||||
prefix: Option<Prefix>,
|
||||
document: &Document) -> HTMLTextAreaElement {
|
||||
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
|
||||
let chan = document.window().upcast::<GlobalScope>().script_to_constellation_chan().clone();
|
||||
HTMLTextAreaElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE,
|
||||
|
|
|
@ -93,7 +93,7 @@ impl ServiceWorkerMethods for ServiceWorker {
|
|||
let msg_vec = DOMMessage(data.move_to_arraybuffer());
|
||||
let _ =
|
||||
self.global()
|
||||
.constellation_chan()
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::ForwardDOMMessage(msg_vec, self.scope_url.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -151,11 +151,10 @@ impl Storage {
|
|||
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
|
||||
fn broadcast_change_notification(&self, key: Option<String>, old_value: Option<String>,
|
||||
new_value: Option<String>) {
|
||||
let pipeline_id = self.global().pipeline_id();
|
||||
let storage = self.storage_type;
|
||||
let url = self.get_url();
|
||||
let msg = ScriptMsg::BroadcastStorageEvent(pipeline_id, storage, url, key, old_value, new_value);
|
||||
self.global().constellation_chan().send(msg).unwrap();
|
||||
let msg = ScriptMsg::BroadcastStorageEvent(storage, url, key, old_value, new_value);
|
||||
self.global().script_to_constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
|
||||
|
|
|
@ -50,7 +50,7 @@ use js::typedarray::{TypedArray, TypedArrayElement, Float32, Int32};
|
|||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache::ImageResponse;
|
||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::ScriptMsg;
|
||||
use servo_config::prefs::PREFS;
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
|
@ -172,8 +172,8 @@ impl WebGLRenderingContext {
|
|||
}
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = window.upcast::<GlobalScope>().constellation_chan();
|
||||
constellation_chan.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender))
|
||||
let script_to_constellation_chan = window.upcast::<GlobalScope>().script_to_constellation_chan();
|
||||
script_to_constellation_chan.send(ScriptMsg::CreateWebGLPaintThread(size, attrs, sender))
|
||||
.unwrap();
|
||||
let result = receiver.recv().unwrap();
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventC
|
|||
use script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg, Runnable};
|
||||
use script_thread::{RunnableWrapper, ScriptThread, SendableMainThreadScriptChan};
|
||||
use script_traits::{ConstellationControlMsg, DocumentState, LoadData, MozBrowserEvent};
|
||||
use script_traits::{ScriptMsg as ConstellationMsg, ScrollState, TimerEvent, TimerEventId};
|
||||
use script_traits::{ScriptToConstellationChan, ScriptMsg, ScrollState, TimerEvent, TimerEventId};
|
||||
use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use selectors::attr::CaseSensitivity;
|
||||
|
@ -515,11 +515,7 @@ impl WindowMethods for Window {
|
|||
}
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
global_scope
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::Alert(global_scope.pipeline_id(), s.to_string(), sender))
|
||||
.unwrap();
|
||||
self.send_to_constellation(ScriptMsg::Alert(s.to_string(), sender));
|
||||
|
||||
let should_display_alert_dialog = receiver.recv().unwrap();
|
||||
if should_display_alert_dialog {
|
||||
|
@ -918,10 +914,7 @@ impl WindowMethods for Window {
|
|||
// Step 1
|
||||
//TODO determine if this operation is allowed
|
||||
let size = Size2D::new(x.to_u32().unwrap_or(1), y.to_u32().unwrap_or(1));
|
||||
self.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::ResizeTo(size))
|
||||
.unwrap()
|
||||
self.send_to_constellation(ScriptMsg::ResizeTo(size));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-resizeby
|
||||
|
@ -936,10 +929,7 @@ impl WindowMethods for Window {
|
|||
// Step 1
|
||||
//TODO determine if this operation is allowed
|
||||
let point = Point2D::new(x, y);
|
||||
self.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::MoveTo(point))
|
||||
.unwrap()
|
||||
self.send_to_constellation(ScriptMsg::MoveTo(point));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-moveby
|
||||
|
@ -1159,9 +1149,8 @@ impl Window {
|
|||
scroll_offset: Vector2D::new(-x, -y),
|
||||
})).unwrap();
|
||||
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
let message = ConstellationMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
|
||||
global_scope.constellation_chan().send(message).unwrap();
|
||||
let message = ScriptMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
|
||||
self.send_to_constellation(message);
|
||||
}
|
||||
|
||||
pub fn update_viewport_for_scroll(&self, x: f32, y: f32) {
|
||||
|
@ -1172,10 +1161,7 @@ impl Window {
|
|||
|
||||
pub fn client_window(&self) -> (Size2D<u32>, Point2D<i32>) {
|
||||
let (send, recv) = ipc::channel::<(Size2D<u32>, Point2D<i32>)>().unwrap();
|
||||
self.upcast::<GlobalScope>()
|
||||
.constellation_chan()
|
||||
.send(ConstellationMsg::GetClientWindow(send))
|
||||
.unwrap();
|
||||
self.send_to_constellation(ScriptMsg::GetClientWindow(send));
|
||||
recv.recv().unwrap_or((Size2D::zero(), Point2D::zero()))
|
||||
}
|
||||
|
||||
|
@ -1371,9 +1357,8 @@ impl Window {
|
|||
|
||||
let pending_images = self.pending_layout_images.borrow().is_empty();
|
||||
if ready_state == DocumentReadyState::Complete && !reftest_wait && pending_images {
|
||||
let global_scope = self.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::SetDocumentState(global_scope.pipeline_id(), DocumentState::Idle);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
let event = ScriptMsg::SetDocumentState(DocumentState::Idle);
|
||||
self.send_to_constellation(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1779,6 +1764,13 @@ impl Window {
|
|||
self.navigation_start.set(now);
|
||||
self.navigation_start_precise.set(time::precise_time_ns() as f64);
|
||||
}
|
||||
|
||||
fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
self.upcast::<GlobalScope>()
|
||||
.script_to_constellation_chan()
|
||||
.send(msg)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -1797,7 +1789,7 @@ impl Window {
|
|||
mem_profiler_chan: MemProfilerChan,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
constellation_chan: IpcSender<ConstellationMsg>,
|
||||
constellation_chan: ScriptToConstellationChan,
|
||||
control_chan: IpcSender<ConstellationControlMsg>,
|
||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn prepare_workerscope_init(global: &GlobalScope,
|
|||
to_devtools_sender: global.devtools_chan().cloned(),
|
||||
time_profiler_chan: global.time_profiler_chan().clone(),
|
||||
from_devtools_sender: devtools_sender,
|
||||
constellation_chan: global.constellation_chan().clone(),
|
||||
script_to_constellation_chan: global.script_to_constellation_chan().clone(),
|
||||
scheduler_chan: global.scheduler_chan().clone(),
|
||||
worker_id: global.get_next_worker_id(),
|
||||
pipeline_id: global.pipeline_id(),
|
||||
|
@ -107,7 +107,7 @@ impl WorkerGlobalScope {
|
|||
init.to_devtools_sender,
|
||||
init.mem_profiler_chan,
|
||||
init.time_profiler_chan,
|
||||
init.constellation_chan,
|
||||
init.script_to_constellation_chan,
|
||||
init.scheduler_chan,
|
||||
init.resource_threads,
|
||||
timer_event_chan,
|
||||
|
|
|
@ -609,7 +609,7 @@ impl WorkletThread {
|
|||
if old_counter == 1 {
|
||||
debug!("Resolving promise.");
|
||||
let msg = MainThreadScriptMsg::WorkletLoaded(pipeline_id);
|
||||
self.global_init.script_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
self.global_init.to_script_thread_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
self.run_in_script_thread(promise.resolve_runnable(()));
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ impl WorkletThread {
|
|||
{
|
||||
let msg = CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::WorkletEvent, box runnable);
|
||||
let msg = MainThreadScriptMsg::Common(msg);
|
||||
self.global_init.script_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
self.global_init.to_script_thread_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ use script_thread::MainThreadScriptMsg;
|
|||
use script_thread::Runnable;
|
||||
use script_thread::ScriptThread;
|
||||
use script_traits::ScriptMsg;
|
||||
use script_traits::ScriptToConstellationChan;
|
||||
use script_traits::TimerSchedulerMsg;
|
||||
use servo_url::ImmutableOrigin;
|
||||
use servo_url::MutableOrigin;
|
||||
|
@ -49,7 +50,7 @@ pub struct WorkletGlobalScope {
|
|||
microtask_queue: MicrotaskQueue,
|
||||
/// Sender back to the script thread
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
script_sender: Sender<MainThreadScriptMsg>,
|
||||
to_script_thread_sender: Sender<MainThreadScriptMsg>,
|
||||
/// Worklet task executor
|
||||
executor: WorkletExecutor,
|
||||
}
|
||||
|
@ -63,19 +64,23 @@ impl WorkletGlobalScope {
|
|||
-> WorkletGlobalScope {
|
||||
// Any timer events fired on this global are ignored.
|
||||
let (timer_event_chan, _) = ipc::channel().unwrap();
|
||||
let script_to_constellation_chan = ScriptToConstellationChan {
|
||||
sender: init.to_constellation_sender.clone(),
|
||||
pipeline_id: pipeline_id,
|
||||
};
|
||||
WorkletGlobalScope {
|
||||
globalscope: GlobalScope::new_inherited(pipeline_id,
|
||||
init.devtools_chan.clone(),
|
||||
init.mem_profiler_chan.clone(),
|
||||
init.time_profiler_chan.clone(),
|
||||
init.constellation_chan.clone(),
|
||||
script_to_constellation_chan,
|
||||
init.scheduler_chan.clone(),
|
||||
init.resource_threads.clone(),
|
||||
timer_event_chan,
|
||||
MutableOrigin::new(ImmutableOrigin::new_opaque())),
|
||||
base_url: base_url,
|
||||
microtask_queue: MicrotaskQueue::default(),
|
||||
script_sender: init.script_sender.clone(),
|
||||
to_script_thread_sender: init.to_script_thread_sender.clone(),
|
||||
executor: executor,
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +103,7 @@ impl WorkletGlobalScope {
|
|||
{
|
||||
let msg = CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::WorkletEvent, box runnable);
|
||||
let msg = MainThreadScriptMsg::Common(msg);
|
||||
self.script_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
self.to_script_thread_sender.send(msg).expect("Worklet thread outlived script thread.");
|
||||
}
|
||||
|
||||
/// Send a message to layout.
|
||||
|
@ -156,7 +161,7 @@ impl WorkletGlobalScope {
|
|||
#[derive(Clone)]
|
||||
pub struct WorkletGlobalScopeInit {
|
||||
/// Channel to the main script thread
|
||||
pub script_sender: Sender<MainThreadScriptMsg>,
|
||||
pub to_script_thread_sender: Sender<MainThreadScriptMsg>,
|
||||
/// Channel to a resource thread
|
||||
pub resource_threads: ResourceThreads,
|
||||
/// Channel to the memory profiler
|
||||
|
@ -166,7 +171,7 @@ pub struct WorkletGlobalScopeInit {
|
|||
/// Channel to devtools
|
||||
pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
/// Messages to send to constellation
|
||||
pub constellation_chan: IpcSender<ScriptMsg>,
|
||||
pub to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
|
||||
/// Message to send to the scheduler
|
||||
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
/// The image cache
|
||||
|
|
|
@ -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(),
|
||||
};
|
||||
|
@ -855,7 +855,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,
|
||||
|
||||
|
@ -1543,7 +1543,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 {
|
||||
|
@ -1643,13 +1643,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.
|
||||
|
@ -1701,7 +1701,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>) {
|
||||
|
@ -1718,7 +1718,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.
|
||||
|
@ -1758,7 +1758,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);
|
||||
}
|
||||
|
@ -1883,15 +1883,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.")
|
||||
}
|
||||
|
||||
|
@ -1976,8 +1976,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);
|
||||
|
@ -1997,6 +1997,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()),
|
||||
|
@ -2012,7 +2017,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,
|
||||
|
@ -2082,8 +2087,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.
|
||||
|
@ -2210,8 +2215,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;
|
||||
}
|
||||
|
@ -2224,8 +2229,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2240,8 +2245,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.
|
||||
|
@ -2262,7 +2267,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2310,8 +2315,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();
|
||||
}
|
||||
}
|
||||
|
@ -2371,7 +2376,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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue