From 5345edf51e54b270f0542aa1bde479b89c7938b7 Mon Sep 17 00:00:00 2001 From: Sagar Muchhal Date: Thu, 5 Feb 2015 19:19:38 +0000 Subject: [PATCH] Add flag to send live updates to devtools. --- components/devtools/actors/tab.rs | 3 +++ components/devtools_traits/lib.rs | 1 + components/script/devtools.rs | 5 +++++ components/script/page.rs | 5 +++++ components/script/script_task.rs | 4 +++- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs index 69450cd4b327..062ec02af11f 100644 --- a/components/devtools/actors/tab.rs +++ b/components/devtools/actors/tab.rs @@ -8,6 +8,7 @@ use actor::{Actor, ActorRegistry}; use actors::console::ConsoleActor; +use devtools_traits::WantsLiveNotifications; use protocol::JsonPacketStream; use serialize::json; @@ -99,6 +100,7 @@ impl Actor for TabActor { let console_actor = registry.find::(self.console.as_slice()); console_actor.streams.borrow_mut().push(stream.clone()); stream.write_json_packet(&msg); + console_actor.script_chan.send(WantsLiveNotifications(console_actor.pipeline, true)); true } @@ -112,6 +114,7 @@ impl Actor for TabActor { let console_actor = registry.find::(self.console.as_slice()); console_actor.streams.borrow_mut().pop(); stream.write_json_packet(&msg); + console_actor.script_chan.send(WantsLiveNotifications(console_actor.pipeline, false)); true } diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index a3534f586462..cb54831d852b 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -94,6 +94,7 @@ pub enum DevtoolScriptControlMsg { GetChildren(PipelineId, String, Sender>), GetLayout(PipelineId, String, Sender<(f32, f32)>), ModifyAttribute(PipelineId, String, Vec), + WantsLiveNotifications(PipelineId, bool), } /// Messages to instruct devtools server to update its state relating to a particular diff --git a/components/script/devtools.rs b/components/script/devtools.rs index c7a81ff67a60..6c29223af633 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -108,3 +108,8 @@ pub fn handle_modify_attribute(page: &Rc, pipeline: PipelineId, node_id: S } } } + +pub fn handle_wants_live_notifications(page: &Rc, pipeline_id: PipelineId, send_notifications: bool) { + let page = get_page(&*page, pipeline_id); + page.devtools_wants_updates.set(send_notifications); +} diff --git a/components/script/page.rs b/components/script/page.rs index 65f61490afd7..a7a24608b4e4 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -96,6 +96,10 @@ pub struct Page { /// An enlarged rectangle around the page contents visible in the viewport, used /// to prevent creating display list items for content that is far away from the viewport. pub page_clip_rect: Cell>, + + /// A flag to indicate whether the developer tools have requested live updates of + /// page changes. + pub devtools_wants_updates: Cell, } pub struct PageIterator { @@ -161,6 +165,7 @@ impl Page { constellation_chan: constellation_chan, children: DOMRefCell::new(vec!()), page_clip_rect: Cell::new(MAX_RECT), + devtools_wants_updates: Cell::new(false), } } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 287b6c61adf2..002939934f53 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -41,7 +41,7 @@ use devtools; use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, NewGlobal, GetRootNode, DevtoolsPageInfo}; use devtools_traits::{DevtoolScriptControlMsg, EvaluateJS, GetDocumentElement}; -use devtools_traits::{GetChildren, GetLayout, ModifyAttribute}; +use devtools_traits::{GetChildren, GetLayout, ModifyAttribute, WantsLiveNotifications}; use script_traits::CompositorEvent; use script_traits::CompositorEvent::{ResizeEvent, ReflowEvent, ClickEvent}; use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent}; @@ -637,6 +637,8 @@ impl ScriptTask { devtools::handle_get_layout(&*self.page.borrow(), id, node_id, reply), ModifyAttribute(id, node_id, modifications) => devtools::handle_modify_attribute(&*self.page.borrow(), id, node_id, modifications), + WantsLiveNotifications(pipeline_id, to_send) => + devtools::handle_wants_live_notifications(&*self.page.borrow(), pipeline_id, to_send), } }