Skip to content

Commit

Permalink
Add flag to send live updates to devtools.
Browse files Browse the repository at this point in the history
  • Loading branch information
srm09 authored and jdm committed Feb 5, 2015
1 parent 0beb070 commit 5345edf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/devtools/actors/tab.rs
Expand Up @@ -8,6 +8,7 @@

use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
use devtools_traits::WantsLiveNotifications;
use protocol::JsonPacketStream;

use serialize::json;
Expand Down Expand Up @@ -99,6 +100,7 @@ impl Actor for TabActor {
let console_actor = registry.find::<ConsoleActor>(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
}

Expand All @@ -112,6 +114,7 @@ impl Actor for TabActor {
let console_actor = registry.find::<ConsoleActor>(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
}

Expand Down
1 change: 1 addition & 0 deletions components/devtools_traits/lib.rs
Expand Up @@ -94,6 +94,7 @@ pub enum DevtoolScriptControlMsg {
GetChildren(PipelineId, String, Sender<Vec<NodeInfo>>),
GetLayout(PipelineId, String, Sender<(f32, f32)>),
ModifyAttribute(PipelineId, String, Vec<Modification>),
WantsLiveNotifications(PipelineId, bool),
}

/// Messages to instruct devtools server to update its state relating to a particular
Expand Down
5 changes: 5 additions & 0 deletions components/script/devtools.rs
Expand Up @@ -108,3 +108,8 @@ pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: S
}
}
}

pub fn handle_wants_live_notifications(page: &Rc<Page>, pipeline_id: PipelineId, send_notifications: bool) {
let page = get_page(&*page, pipeline_id);
page.devtools_wants_updates.set(send_notifications);
}
5 changes: 5 additions & 0 deletions components/script/page.rs
Expand Up @@ -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<Rect<Au>>,

/// A flag to indicate whether the developer tools have requested live updates of
/// page changes.
pub devtools_wants_updates: Cell<bool>,
}

pub struct PageIterator {
Expand Down Expand Up @@ -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),
}
}

Expand Down
4 changes: 3 additions & 1 deletion components/script/script_task.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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),
}
}

Expand Down

5 comments on commit 5345edf

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at jdm@5345edf

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jdm/servo/buffermessages = 5345edf into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jdm/servo/buffermessages = 5345edf merged ok, testing candidate = 0a2bde1

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 0a2bde1

Please sign in to comment.