make use of ScriptToConstellationChan

This commit is contained in:
Paul Rouget 2017-07-18 08:19:44 +02:00
parent 817de15735
commit d241389129
24 changed files with 285 additions and 280 deletions

View file

@ -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]

View file

@ -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 {

View file

@ -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);
}
}

View file

@ -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>) {
@ -2018,6 +1999,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)]
@ -2519,8 +2505,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
@ -2552,8 +2538,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());

View file

@ -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> {

View file

@ -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())
}

View file

@ -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 {

View file

@ -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,

View file

@ -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();

View file

@ -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()),

View file

@ -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,

View file

@ -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(())
}

View file

@ -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

View file

@ -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();

View file

@ -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>,

View file

@ -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,

View file

@ -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.");
}
}

View file

@ -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