diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/Cargo.toml | 3 | ||||
-rw-r--r-- | components/script/dom/bindings/trace.rs | 2 | ||||
-rw-r--r-- | components/script/dom/document.rs | 12 | ||||
-rw-r--r-- | components/script/dom/window.rs | 6 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 3 | ||||
-rw-r--r-- | components/script/lib.rs | 1 | ||||
-rw-r--r-- | components/script/script_task.rs | 38 |
7 files changed, 37 insertions, 28 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 8fc3d56fa9b..6aefc2903d7 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -55,6 +55,9 @@ features = ["query_encoding"] [dependencies.offscreen_gl_context] git = "https://github.com/ecoal95/rust-offscreen-rendering-context" +[dependencies.ipc-channel] +git = "https://github.com/pcwalton/ipc-channel" + [dependencies] log = "*" encoding = "0.2" diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index b64d46a212e..43e9814242e 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -328,7 +328,7 @@ impl<A,B> JSTraceable for fn(A) -> B { } } -impl JSTraceable for Box<ScriptListener+'static> { +impl JSTraceable for ScriptListener { #[inline] fn trace(&self, _: *mut JSTracer) { // Do nothing diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 83a9e5dedd4..7ddced8ef0d 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -251,8 +251,11 @@ pub trait DocumentHelpers<'a> { fn title_changed(self); fn send_title_to_compositor(self); fn dirty_all_nodes(self); - fn dispatch_key_event(self, key: Key, state: KeyState, - modifiers: KeyModifiers, compositor: &mut Box<ScriptListener+'static>); + fn dispatch_key_event(self, + key: Key, + state: KeyState, + modifiers: KeyModifiers, + compositor: &mut ScriptListener); fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>) -> Fallible<Root<Node>>; fn get_body_attribute(self, local_name: &Atom) -> DOMString; @@ -760,10 +763,11 @@ impl<'a> DocumentHelpers<'a> for &'a Document { } /// The entry point for all key processing for web content - fn dispatch_key_event(self, key: Key, + fn dispatch_key_event(self, + key: Key, state: KeyState, modifiers: KeyModifiers, - compositor: &mut Box<ScriptListener+'static>) { + compositor: &mut ScriptListener) { let window = self.window.root(); let focused = self.get_focused_element(); let body = self.GetBody(); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index b781d7e19a1..984a8d4fb01 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -105,7 +105,7 @@ pub struct Window { navigator: MutNullableHeap<JS<Navigator>>, image_cache_task: ImageCacheTask, image_cache_chan: ImageCacheChan, - compositor: DOMRefCell<Box<ScriptListener+'static>>, + compositor: DOMRefCell<ScriptListener>, browser_context: DOMRefCell<Option<BrowserContext>>, page: Rc<Page>, performance: MutNullableHeap<JS<Performance>>, @@ -241,7 +241,7 @@ impl Window { &self.image_cache_task } - pub fn compositor<'a>(&'a self) -> RefMut<'a, Box<ScriptListener+'static>> { + pub fn compositor<'a>(&'a self) -> RefMut<'a, ScriptListener> { self.compositor.borrow_mut() } @@ -964,7 +964,7 @@ impl Window { script_chan: Box<ScriptChan+Send>, image_cache_chan: ImageCacheChan, control_chan: ScriptControlChan, - compositor: Box<ScriptListener+'static>, + compositor: ScriptListener, image_cache_task: ImageCacheTask, resource_task: ResourceTask, storage_task: StorageTask, diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index b88f60c6b4e..7db08689279 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -10,6 +10,7 @@ use dom::node::LayoutData; use euclid::point::Point2D; use euclid::rect::Rect; +use ipc_channel::ipc::IpcSender; use libc::uintptr_t; use msg::compositor_msg::LayerId; use msg::constellation_msg::{PipelineExitType, WindowSizeData}; @@ -71,7 +72,7 @@ pub enum Msg { ExitNow(PipelineExitType), /// Get the last epoch counter for this layout task. - GetCurrentEpoch(Sender<Epoch>) + GetCurrentEpoch(IpcSender<Epoch>) } /// Synchronous messages that script can send to layout. diff --git a/components/script/lib.rs b/components/script/lib.rs index 15a1c4c5db5..66d184846f3 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -44,6 +44,7 @@ extern crate html5ever; extern crate encoding; extern crate fnv; extern crate hyper; +extern crate ipc_channel; extern crate js; extern crate libc; extern crate msg; diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 49f9ecdfa2d..693e89058ef 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -297,8 +297,9 @@ pub struct ScriptTask { /// For communicating load url messages to the constellation constellation_chan: ConstellationChan, + /// A handle to the compositor for communicating ready state messages. - compositor: DOMRefCell<Box<ScriptListener+'static>>, + compositor: DOMRefCell<ScriptListener>, /// The port on which we receive messages from the image cache image_cache_port: Receiver<ImageCacheResult>, @@ -374,29 +375,28 @@ impl ScriptTaskFactory for ScriptTask { box pair.sender() as Box<Any+Send> } - fn create<C>(_phantom: Option<&mut ScriptTask>, - id: PipelineId, - parent_info: Option<(PipelineId, SubpageId)>, - compositor: C, - layout_chan: &OpaqueScriptLayoutChannel, - control_chan: ScriptControlChan, - control_port: Receiver<ConstellationControlMsg>, - constellation_chan: ConstellationChan, - failure_msg: Failure, - resource_task: ResourceTask, - storage_task: StorageTask, - image_cache_task: ImageCacheTask, - devtools_chan: Option<DevtoolsControlChan>, - window_size: Option<WindowSizeData>, - load_data: LoadData) - where C: ScriptListener + Send + 'static { + fn create(_phantom: Option<&mut ScriptTask>, + id: PipelineId, + parent_info: Option<(PipelineId, SubpageId)>, + compositor: ScriptListener, + layout_chan: &OpaqueScriptLayoutChannel, + control_chan: ScriptControlChan, + control_port: Receiver<ConstellationControlMsg>, + constellation_chan: ConstellationChan, + failure_msg: Failure, + resource_task: ResourceTask, + storage_task: StorageTask, + image_cache_task: ImageCacheTask, + devtools_chan: Option<DevtoolsControlChan>, + window_size: Option<WindowSizeData>, + load_data: LoadData) { let ConstellationChan(const_chan) = constellation_chan.clone(); let (script_chan, script_port) = channel(); let layout_chan = LayoutChan(layout_chan.sender()); spawn_named_with_send_on_failure(format!("ScriptTask {:?}", id), task_state::SCRIPT, move || { let roots = RootCollection::new(); let _stack_roots_tls = StackRootTLS::new(&roots); - let script_task = ScriptTask::new(box compositor as Box<ScriptListener>, + let script_task = ScriptTask::new(compositor, script_port, NonWorkerScriptChan(script_chan), control_chan, @@ -464,7 +464,7 @@ impl ScriptTask { } /// Creates a new script task. - pub fn new(compositor: Box<ScriptListener+'static>, + pub fn new(compositor: ScriptListener, port: Receiver<ScriptMsg>, chan: NonWorkerScriptChan, control_chan: ScriptControlChan, |