aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs41
1 files changed, 18 insertions, 23 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 7bfdf4e46d4..db047d7a793 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -34,9 +34,9 @@ use dom::storage::Storage;
use layout_interface::{ReflowGoal, ReflowQueryType, LayoutRPC, LayoutChan, Reflow, Msg};
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use page::Page;
-use script_task::{TimerSource, ScriptChan, ScriptPort, NonWorkerScriptChan};
-use script_task::ScriptMsg;
-use script_traits::ScriptControlChan;
+use script_task::{TimerSource, ScriptChan, ScriptPort, MainThreadScriptMsg};
+use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan};
+use script_traits::ConstellationControlMsg;
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
use webdriver_handlers::jsval_to_webdriver;
@@ -77,7 +77,7 @@ use std::mem as std_mem;
use std::rc::Rc;
use std::sync::Arc;
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
-use std::sync::mpsc::{channel, Receiver};
+use std::sync::mpsc::{channel, Receiver, Sender};
use time;
/// Current state of the window object
@@ -88,7 +88,7 @@ enum WindowState {
}
/// Extra information concerning the reason for reflowing.
-#[derive(Debug)]
+#[derive(Debug, HeapSizeOf)]
pub enum ReflowReason {
CachedPageNeededReflow,
RefreshTick,
@@ -110,9 +110,9 @@ pub enum ReflowReason {
pub struct Window {
eventtarget: EventTarget,
#[ignore_heap_size_of = "trait objects are hard"]
- script_chan: Box<ScriptChan+Send>,
+ script_chan: MainThreadScriptChan,
#[ignore_heap_size_of = "channels are hard"]
- control_chan: ScriptControlChan,
+ control_chan: Sender<ConstellationControlMsg>,
console: MutNullableHeap<JS<Console>>,
crypto: MutNullableHeap<JS<Crypto>>,
navigator: MutNullableHeap<JS<Navigator>>,
@@ -236,6 +236,11 @@ impl Window {
self.script_chan.clone()
}
+ pub fn main_thread_script_chan(&self) -> &Sender<MainThreadScriptMsg> {
+ let MainThreadScriptChan(ref sender) = self.script_chan;
+ sender
+ }
+
pub fn image_cache_chan(&self) -> ImageCacheChan {
self.image_cache_chan.clone()
}
@@ -261,11 +266,7 @@ impl Window {
pub fn new_script_pair(&self) -> (Box<ScriptChan+Send>, Box<ScriptPort+Send>) {
let (tx, rx) = channel();
- (box NonWorkerScriptChan(tx), box rx)
- }
-
- pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan {
- &self.control_chan
+ (box SendableMainThreadScriptChan(tx), box rx)
}
pub fn image_cache_task<'a>(&'a self) -> &'a ImageCacheTask {
@@ -374,7 +375,7 @@ impl<'a> WindowMethods for &'a Window {
// https://html.spec.whatwg.org/multipage/#dom-window-close
fn Close(self) {
- self.script_chan.send(ScriptMsg::ExitWindow(self.id.clone())).unwrap();
+ self.main_thread_script_chan().send(MainThreadScriptMsg::ExitWindow(self.id.clone())).unwrap();
}
// https://html.spec.whatwg.org/multipage/#dom-document-0
@@ -891,14 +892,8 @@ impl<'a> WindowHelpers for &'a Window {
/// Commence a new URL load which will either replace this window or scroll to a fragment.
fn load_url(self, url: Url) {
- match url.fragment {
- Some(fragment) => {
- self.script_chan.send(ScriptMsg::TriggerFragment(self.id, fragment)).unwrap();
- },
- None => {
- self.script_chan.send(ScriptMsg::Navigate(self.id, LoadData::new(url))).unwrap();
- }
- }
+ self.main_thread_script_chan().send(
+ MainThreadScriptMsg::Navigate(self.id, LoadData::new(url))).unwrap();
}
fn handle_fire_timer(self, timer_id: TimerId) {
@@ -1075,9 +1070,9 @@ impl<'a> WindowHelpers for &'a Window {
impl Window {
pub fn new(runtime: Rc<Runtime>,
page: Rc<Page>,
- script_chan: Box<ScriptChan+Send>,
+ script_chan: MainThreadScriptChan,
image_cache_chan: ImageCacheChan,
- control_chan: ScriptControlChan,
+ control_chan: Sender<ConstellationControlMsg>,
compositor: ScriptListener,
image_cache_task: ImageCacheTask,
resource_task: Arc<ResourceTask>,