servo: Merge #6745 - devtools: Convert the developer tools to run over IPC (from pcwalton:devtools-ipc); r=jdm

This was a large, invasive change.

r? @jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 4bc1db3fe85f2a1a04536f0f6045b53b1319f4bc
This commit is contained in:
Patrick Walton 2015-07-27 11:09:38 -06:00
parent 950b3b0868
commit 8325a09ce0
26 changed files with 295 additions and 141 deletions

View File

@ -16,7 +16,7 @@ use canvas::webgl_paint_task::WebGLPaintTask;
use canvas_traits::CanvasMsg;
use compositor_task::CompositorProxy;
use compositor_task::Msg as CompositorMsg;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg};
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlChan, DevtoolsControlMsg};
use euclid::point::Point2D;
use euclid::rect::{Rect, TypedRect};
use euclid::size::Size2D;
@ -518,7 +518,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.image_cache_task.exit();
self.resource_task.send(net_traits::ControlMsg::Exit).unwrap();
self.devtools_chan.as_ref().map(|chan| {
chan.send(DevtoolsControlMsg::ServerExitMsg).unwrap();
chan.send(DevtoolsControlMsg::FromChrome(
ChromeToDevtoolsControlMsg::ServerExitMsg)).unwrap();
});
self.storage_task.send(StorageTaskMsg::Exit).unwrap();
self.font_cache_task.exit();

View File

@ -8,13 +8,14 @@ use script_traits::{LayoutControlMsg, ScriptControlChan, ScriptTaskFactory};
use script_traits::{NewLayoutInfo, ConstellationControlMsg};
use compositor_task;
use devtools_traits::DevtoolsControlChan;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
use euclid::rect::{TypedRect};
use euclid::scale_factor::ScaleFactor;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::{PaintChan, PaintTask};
use gfx::font_cache_task::FontCacheTask;
use ipc_channel::ipc::{self, IpcReceiver};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use layers::geometry::DevicePixel;
use msg::compositor_msg::ScriptListener;
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
@ -102,6 +103,17 @@ impl Pipeline {
}
});
// Route messages coming from content to devtools as appropriate.
let script_to_devtools_chan = devtools_chan.as_ref().map(|devtools_chan| {
let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap();
let devtools_chan = (*devtools_chan).clone();
ROUTER.add_route(script_to_devtools_port.to_opaque(), box move |message| {
let message: ScriptToDevtoolsControlMsg = message.to().unwrap();
devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap()
});
script_to_devtools_chan
});
let (script_chan, script_port) = match script_chan {
Some(script_chan) => {
let (containing_pipeline_id, subpage_id) =
@ -143,7 +155,7 @@ impl Pipeline {
parent_info: parent_info,
constellation_chan: constellation_chan,
compositor_proxy: compositor_proxy,
devtools_chan: devtools_chan,
devtools_chan: script_to_devtools_chan,
image_cache_task: image_cache_task,
font_cache_task: font_cache_task,
resource_task: resource_task,
@ -272,7 +284,7 @@ pub struct PipelineContent {
parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan,
compositor_proxy: Box<CompositorProxy + Send + 'static>,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask,
resource_task: ResourceTask,

View File

@ -20,8 +20,17 @@ path = "../msg"
[dependencies.util]
path = "../util"
[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"
[dependencies.url]
version = "0.2"
features = [ "serde_serialization" ]
[dependencies]
log = "0.3"
time = "0.1"
rustc-serialize = "0.3"
url = "0.2"
serde = "0.4"
serde_macros = "0.4"

View File

@ -4,6 +4,7 @@
/// General actor system infrastructure.
use devtools_traits::PreciseTime;
use rustc_serialize::json;
use std::any::{Any, TypeId};
use std::collections::HashMap;
@ -13,7 +14,6 @@ use std::mem::{replace, transmute};
use std::net::TcpStream;
use std::raw::TraitObject;
use std::sync::{Arc, Mutex};
use time::PreciseTime;
/// A common trait for all devtools actors that encompasses an immutable name
/// and the ability to process messages that are directed to particular actors.

View File

@ -18,9 +18,10 @@ use msg::constellation_msg::PipelineId;
use std::collections::BTreeMap;
use core::cell::RefCell;
use ipc_channel::ipc::{self, IpcSender};
use rustc_serialize::json::{self, Json, ToJson};
use std::net::TcpStream;
use std::sync::mpsc::{channel, Sender};
use std::sync::mpsc::channel;
trait EncodableConsoleMessage {
fn encode(&self) -> json::EncodeResult<String>;
@ -81,7 +82,7 @@ struct EvaluateJSReply {
pub struct ConsoleActor {
pub name: String,
pub pipeline: PipelineId,
pub script_chan: Sender<DevtoolScriptControlMsg>,
pub script_chan: IpcSender<DevtoolScriptControlMsg>,
pub streams: RefCell<Vec<TcpStream>>,
}
@ -108,7 +109,7 @@ impl Actor for ConsoleActor {
s => println!("unrecognized message type requested: \"{}\"", s),
};
};
let (chan, port) = channel();
let (chan, port) = ipc::channel().unwrap();
self.script_chan.send(DevtoolScriptControlMsg::GetCachedMessages(
self.pipeline, message_types, chan)).unwrap();
let messages = try!(port.recv().map_err(|_| ())).into_iter().map(|message| {
@ -170,7 +171,7 @@ impl Actor for ConsoleActor {
"evaluateJS" => {
let input = msg.get(&"text".to_string()).unwrap().as_string().unwrap().to_string();
let (chan, port) = channel();
let (chan, port) = ipc::channel().unwrap();
self.script_chan.send(DevtoolScriptControlMsg::EvaluateJS(
self.pipeline, input.clone(), chan)).unwrap();

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use rustc_serialize::json;
use std::mem;
use std::net::TcpStream;
@ -12,12 +14,12 @@ use time::precise_time_ns;
use msg::constellation_msg::PipelineId;
use actor::{Actor, ActorRegistry};
use actors::timeline::HighResolutionStamp;
use devtools_traits::{DevtoolsControlMsg, DevtoolScriptControlMsg};
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, DevtoolScriptControlMsg};
pub struct FramerateActor {
name: String,
pipeline: PipelineId,
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>,
start_time: Option<u64>,
is_recording: Arc<Mutex<bool>>,
@ -43,7 +45,7 @@ impl FramerateActor {
/// return name of actor
pub fn create(registry: &ActorRegistry,
pipeline_id: PipelineId,
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>) -> String {
let actor_name = registry.new_name("framerate");
let mut actor = FramerateActor {
@ -86,12 +88,13 @@ impl FramerateActor {
fn get_closure(is_recording: Arc<Mutex<bool>>,
name: String,
pipeline: PipelineId,
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>)
-> Box<Fn(f64, ) + Send> {
let closure = move |now: f64| {
let msg = DevtoolsControlMsg::FramerateTick(name.clone(), now);
let msg = DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::FramerateTick(
name.clone(), now));
devtools_sender.send(msg).unwrap();
if !*is_recording.lock().unwrap() {
@ -103,7 +106,15 @@ impl FramerateActor {
pipeline.clone(),
script_sender.clone(),
devtools_sender.clone());
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(pipeline, closure);
let (request_animation_frame_sender, request_animation_frame_receiver) =
ipc::channel().unwrap();
ROUTER.add_route(request_animation_frame_receiver.to_opaque(), box move |message| {
let value: f64 = message.to().unwrap();
closure(value);
});
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(
pipeline,
request_animation_frame_sender);
script_sender.send(msg).unwrap();
};
Box::new(closure)
@ -114,7 +125,14 @@ impl FramerateActor {
self.pipeline.clone(),
self.script_sender.clone(),
self.devtools_sender.clone());
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, closure);
let (request_animation_frame_sender, request_animation_frame_receiver) =
ipc::channel().unwrap();
ROUTER.add_route(request_animation_frame_receiver.to_opaque(), box move |message| {
let value: f64 = message.to().unwrap();
closure(value);
});
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline,
request_animation_frame_sender);
self.script_sender.send(msg).unwrap();
}

View File

@ -12,19 +12,20 @@ use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
use actor::{Actor, ActorRegistry};
use protocol::JsonPacketStream;
use ipc_channel::ipc::{self, IpcSender};
use std::collections::BTreeMap;
use msg::constellation_msg::PipelineId;
use rustc_serialize::json::{self, Json, ToJson};
use std::cell::RefCell;
use std::net::TcpStream;
use std::sync::mpsc::{channel, Sender};
use std::sync::mpsc::channel;
pub struct InspectorActor {
pub name: String,
pub walker: RefCell<Option<String>>,
pub pageStyle: RefCell<Option<String>>,
pub highlighter: RefCell<Option<String>>,
pub script_chan: Sender<DevtoolScriptControlMsg>,
pub script_chan: IpcSender<DevtoolScriptControlMsg>,
pub pipeline: PipelineId,
}
@ -45,7 +46,7 @@ struct HighlighterActor {
pub struct NodeActor {
pub name: String,
script_chan: Sender<DevtoolScriptControlMsg>,
script_chan: IpcSender<DevtoolScriptControlMsg>,
pipeline: PipelineId,
}
@ -181,7 +182,7 @@ trait NodeInfoToProtocol {
fn encode(self,
actors: &ActorRegistry,
display: bool,
script_chan: Sender<DevtoolScriptControlMsg>,
script_chan: IpcSender<DevtoolScriptControlMsg>,
pipeline: PipelineId) -> NodeActorMsg;
}
@ -189,7 +190,7 @@ impl NodeInfoToProtocol for NodeInfo {
fn encode(self,
actors: &ActorRegistry,
display: bool,
script_chan: Sender<DevtoolScriptControlMsg>,
script_chan: IpcSender<DevtoolScriptControlMsg>,
pipeline: PipelineId) -> NodeActorMsg {
let actor_name = if !actors.script_actor_registered(self.uniqueId.clone()) {
let name = actors.new_name("node");
@ -242,7 +243,7 @@ impl NodeInfoToProtocol for NodeInfo {
struct WalkerActor {
name: String,
script_chan: Sender<DevtoolScriptControlMsg>,
script_chan: IpcSender<DevtoolScriptControlMsg>,
pipeline: PipelineId,
}
@ -290,7 +291,7 @@ impl Actor for WalkerActor {
}
"documentElement" => {
let (tx, rx) = channel();
let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetDocumentElement(self.pipeline, tx)).unwrap();
let doc_elem_info = rx.recv().unwrap();
let node = doc_elem_info.encode(registry, true, self.script_chan.clone(), self.pipeline);
@ -313,7 +314,7 @@ impl Actor for WalkerActor {
"children" => {
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
let (tx, rx) = channel();
let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetChildren(self.pipeline,
registry.actor_to_script(target.to_string()),
tx))
@ -350,7 +351,7 @@ struct PageStyleMsg {
struct PageStyleActor {
name: String,
script_chan: Sender<DevtoolScriptControlMsg>,
script_chan: IpcSender<DevtoolScriptControlMsg>,
pipeline: PipelineId,
}
@ -452,7 +453,7 @@ impl Actor for PageStyleActor {
//TODO: query script for box layout properties of node (msg.node)
"getLayout" => {
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
let (tx, rx) = channel();
let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetLayout(self.pipeline,
registry.actor_to_script(target.to_string()),
tx))
@ -514,7 +515,7 @@ impl Actor for InspectorActor {
registry.register_later(box walker);
}
let (tx, rx) = channel();
let (tx, rx) = ipc::channel().unwrap();
self.script_chan.send(GetRootNode(self.pipeline, tx)).unwrap();
let root_info = rx.recv().unwrap();

View File

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::PipelineId;
use rustc_serialize::{json, Encoder, Encodable};
use std::cell::RefCell;
@ -10,21 +11,20 @@ use std::mem;
use std::net::TcpStream;
use std::thread::sleep_ms;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver};
use time::PreciseTime;
use std::sync::mpsc::{channel, Sender};
use actor::{Actor, ActorRegistry};
use actors::memory::{MemoryActor, TimelineMemoryReply};
use actors::framerate::FramerateActor;
use devtools_traits::{DevtoolsControlMsg, DevtoolScriptControlMsg};
use devtools_traits::DevtoolScriptControlMsg::{SetTimelineMarkers, DropTimelineMarkers};
use devtools_traits::{TimelineMarker, TracingMetadata, TimelineMarkerType};
use devtools_traits::{PreciseTime, TimelineMarker, TracingMetadata, TimelineMarkerType};
use protocol::JsonPacketStream;
use util::task;
pub struct TimelineActor {
name: String,
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>,
marker_types: Vec<TimelineMarkerType>,
pipeline: PipelineId,
@ -126,7 +126,7 @@ static DEFAULT_TIMELINE_DATA_PULL_TIMEOUT: u32 = 200; //ms
impl TimelineActor {
pub fn new(name: String,
pipeline: PipelineId,
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>) -> TimelineActor {
let marker_types = vec!(TimelineMarkerType::Reflow,
@ -146,7 +146,7 @@ impl TimelineActor {
}
}
fn pull_timeline_data(&self, receiver: Receiver<TimelineMarker>, mut emitter: Emitter) {
fn pull_timeline_data(&self, receiver: IpcReceiver<TimelineMarker>, mut emitter: Emitter) {
let is_recording = self.is_recording.clone();
if !*is_recording.lock().unwrap() {
@ -240,8 +240,10 @@ impl Actor for TimelineActor {
"start" => {
**self.is_recording.lock().as_mut().unwrap() = true;
let (tx, rx) = channel::<TimelineMarker>();
self.script_sender.send(SetTimelineMarkers(self.pipeline, self.marker_types.clone(), tx)).unwrap();
let (tx, rx) = ipc::channel::<TimelineMarker>().unwrap();
self.script_sender.send(SetTimelineMarkers(self.pipeline,
self.marker_types.clone(),
tx)).unwrap();
*self.stream.borrow_mut() = stream.try_clone().ok();
@ -255,10 +257,11 @@ impl Actor for TimelineActor {
// init framerate actor
if let Some(with_ticks) = msg.get("withTicks") {
if let Some(true) = with_ticks.as_boolean() {
let framerate_actor = Some(FramerateActor::create(registry,
self.pipeline.clone(),
self.script_sender.clone(),
self.devtools_sender.clone()));
let framerate_actor = Some(FramerateActor::create(
registry,
self.pipeline.clone(),
self.script_sender.clone(),
self.devtools_sender.clone()));
*self.framerate_actor.borrow_mut() = framerate_actor;
}
}

View File

@ -12,9 +12,12 @@
#![feature(box_syntax)]
#![feature(core)]
#![feature(custom_derive)]
#![feature(get_type_id)]
#![feature(plugin)]
#![feature(raw)]
#![feature(reflect_marker)]
#![plugin(serde_macros)]
#![allow(non_snake_case)]
@ -24,6 +27,8 @@ extern crate log;
extern crate core;
extern crate devtools_traits;
extern crate rustc_serialize;
extern crate ipc_channel;
extern crate serde;
extern crate msg;
extern crate time;
extern crate util;
@ -41,11 +46,13 @@ use actors::timeline::TimelineActor;
use actors::worker::WorkerActor;
use protocol::JsonPacketStream;
use devtools_traits::{ConsoleMessage, DevtoolsControlMsg, NetworkEvent, LogLevel};
use devtools_traits::{DevtoolsPageInfo, DevtoolScriptControlMsg};
use devtools_traits::{ChromeToDevtoolsControlMsg, ConsoleMessage, DevtoolsControlMsg};
use devtools_traits::{DevtoolsPageInfo, DevtoolScriptControlMsg, LogLevel, NetworkEvent};
use devtools_traits::{ScriptToDevtoolsControlMsg};
use msg::constellation_msg::{PipelineId, WorkerId};
use util::task::spawn_named;
use ipc_channel::ipc::IpcSender;
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::HashMap;
@ -184,7 +191,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
// TODO: move this into the root or tab modules?
fn handle_new_global(actors: Arc<Mutex<ActorRegistry>>,
ids: (PipelineId, Option<WorkerId>),
script_sender: Sender<DevtoolScriptControlMsg>,
script_sender: IpcSender<DevtoolScriptControlMsg>,
devtools_sender: Sender<DevtoolsControlMsg>,
actor_pipelines: &mut HashMap<PipelineId, String>,
actor_workers: &mut HashMap<(PipelineId, WorkerId), String>,
@ -371,28 +378,34 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
// accept connections and process them, spawning a new task for each one
for stream in listener.incoming() {
// connection succeeded
sender_clone.send(DevtoolsControlMsg::AddClient(stream.unwrap())).unwrap();
sender_clone.send(DevtoolsControlMsg::FromChrome(
ChromeToDevtoolsControlMsg::AddClient(stream.unwrap()))).unwrap();
}
});
loop {
match receiver.recv() {
Ok(DevtoolsControlMsg::AddClient(stream)) => {
Ok(DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::AddClient(stream))) => {
let actors = actors.clone();
accepted_connections.push(stream.try_clone().unwrap());
spawn_named("DevtoolsClientHandler".to_owned(), move || {
handle_client(actors, stream.try_clone().unwrap())
})
}
Ok(DevtoolsControlMsg::FramerateTick(actor_name, tick)) =>
Ok(DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::FramerateTick(
actor_name, tick))) =>
handle_framerate_tick(actors.clone(), actor_name, tick),
Ok(DevtoolsControlMsg::NewGlobal(ids, script_sender, pageinfo)) =>
Ok(DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::NewGlobal(
ids, script_sender, pageinfo))) =>
handle_new_global(actors.clone(), ids, script_sender, sender.clone(), &mut actor_pipelines,
&mut actor_workers, pageinfo),
Ok(DevtoolsControlMsg::SendConsoleMessage(id, console_message)) =>
Ok(DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::SendConsoleMessage(
id,
console_message))) =>
handle_console_message(actors.clone(), id, console_message,
&actor_pipelines),
Ok(DevtoolsControlMsg::NetworkEventMessage(request_id, network_event)) => {
Ok(DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::NetworkEventMessage(
request_id, network_event))) => {
// copy the accepted_connections vector
let mut connections = Vec::<TcpStream>::new();
for stream in accepted_connections.iter() {
@ -403,7 +416,8 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
handle_network_event(actors.clone(), connections, &actor_pipelines, &mut actor_requests,
PipelineId(0), request_id, network_event);
},
Ok(DevtoolsControlMsg::ServerExitMsg) | Err(RecvError) => break
Ok(DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::ServerExitMsg)) |
Err(RecvError) => break
}
}
for connection in accepted_connections.iter_mut() {

View File

@ -17,8 +17,17 @@ path = "../msg"
[dependencies.util]
path = "../util"
[dependencies.url]
version = "0.2"
features = [ "serde_serialization" ]
[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"
[dependencies]
time = "0.1"
rustc-serialize = "0.3"
url = "0.2"
bitflags = "0.3"
serde = "0.4"
serde_macros = "0.4"

View File

@ -10,12 +10,16 @@
#![crate_type = "rlib"]
#![allow(non_snake_case)]
#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]
#[macro_use]
extern crate bitflags;
extern crate ipc_channel;
extern crate msg;
extern crate rustc_serialize;
extern crate serde;
extern crate url;
extern crate hyper;
extern crate util;
@ -29,15 +33,18 @@ use url::Url;
use hyper::header::Headers;
use hyper::http::RawStatus;
use hyper::method::Method;
use ipc_channel::ipc::IpcSender;
use time::Duration;
use std::net::TcpStream;
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc::{Receiver, Sender};
pub type DevtoolsControlChan = Sender<DevtoolsControlMsg>;
pub type DevtoolsControlPort = Receiver<DevtoolScriptControlMsg>;
// Information would be attached to NewGlobal to be received and show in devtools.
// Extend these fields if we need more information.
#[derive(Deserialize, Serialize)]
pub struct DevtoolsPageInfo {
pub title: DOMString,
pub url: Url
@ -46,16 +53,28 @@ pub struct DevtoolsPageInfo {
/// Messages to the instruct the devtools server to update its known actors/state
/// according to changes in the browser.
pub enum DevtoolsControlMsg {
FromChrome(ChromeToDevtoolsControlMsg),
FromScript(ScriptToDevtoolsControlMsg),
}
pub enum ChromeToDevtoolsControlMsg {
AddClient(TcpStream),
FramerateTick(String, f64),
NewGlobal((PipelineId, Option<WorkerId>), Sender<DevtoolScriptControlMsg>, DevtoolsPageInfo),
SendConsoleMessage(PipelineId, ConsoleMessage),
ServerExitMsg,
NetworkEventMessage(String, NetworkEvent),
}
#[derive(Deserialize, Serialize)]
pub enum ScriptToDevtoolsControlMsg {
NewGlobal((PipelineId, Option<WorkerId>),
IpcSender<DevtoolScriptControlMsg>,
DevtoolsPageInfo),
SendConsoleMessage(PipelineId, ConsoleMessage),
}
/// Serialized JS return values
/// TODO: generalize this beyond the EvaluateJS message?
#[derive(Deserialize, Serialize)]
pub enum EvaluateJSReply {
VoidValue,
NullValue,
@ -65,12 +84,14 @@ pub enum EvaluateJSReply {
ActorValue(String),
}
#[derive(Deserialize, Serialize)]
pub struct AttrInfo {
pub namespace: String,
pub name: String,
pub value: String,
}
#[derive(Deserialize, Serialize)]
pub struct NodeInfo {
pub uniqueId: String,
pub baseURI: String,
@ -92,7 +113,7 @@ pub struct NodeInfo {
pub incompleteValue: bool,
}
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Deserialize, Serialize)]
pub enum TracingMetadata {
Default,
IntervalStart,
@ -101,36 +122,38 @@ pub enum TracingMetadata {
EventBacktrace,
}
#[derive(Deserialize, Serialize)]
pub struct TimelineMarker {
pub name: String,
pub metadata: TracingMetadata,
pub time: time::PreciseTime,
pub time: PreciseTime,
pub stack: Option<Vec<()>>,
}
#[derive(PartialEq, Eq, Hash, Clone)]
#[derive(PartialEq, Eq, Hash, Clone, Deserialize, Serialize)]
pub enum TimelineMarkerType {
Reflow,
DOMEvent,
}
/// Messages to process in a particular script task, as instructed by a devtools client.
#[derive(Deserialize, Serialize)]
pub enum DevtoolScriptControlMsg {
EvaluateJS(PipelineId, String, Sender<EvaluateJSReply>),
GetRootNode(PipelineId, Sender<NodeInfo>),
GetDocumentElement(PipelineId, Sender<NodeInfo>),
GetChildren(PipelineId, String, Sender<Vec<NodeInfo>>),
GetLayout(PipelineId, String, Sender<(f32, f32)>),
GetCachedMessages(PipelineId, CachedConsoleMessageTypes, Sender<Vec<CachedConsoleMessage>>),
EvaluateJS(PipelineId, String, IpcSender<EvaluateJSReply>),
GetRootNode(PipelineId, IpcSender<NodeInfo>),
GetDocumentElement(PipelineId, IpcSender<NodeInfo>),
GetChildren(PipelineId, String, IpcSender<Vec<NodeInfo>>),
GetLayout(PipelineId, String, IpcSender<(f32, f32)>),
GetCachedMessages(PipelineId, CachedConsoleMessageTypes, IpcSender<Vec<CachedConsoleMessage>>),
ModifyAttribute(PipelineId, String, Vec<Modification>),
WantsLiveNotifications(PipelineId, bool),
SetTimelineMarkers(PipelineId, Vec<TimelineMarkerType>, Sender<TimelineMarker>),
SetTimelineMarkers(PipelineId, Vec<TimelineMarkerType>, IpcSender<TimelineMarker>),
DropTimelineMarkers(PipelineId, Vec<TimelineMarkerType>),
RequestAnimationFrame(PipelineId, Box<Fn(f64, ) + Send>),
RequestAnimationFrame(PipelineId, IpcSender<f64>),
}
#[derive(RustcEncodable)]
pub struct Modification{
#[derive(RustcEncodable, Deserialize, Serialize)]
pub struct Modification {
pub attributeName: String,
pub newValue: Option<String>,
}
@ -149,7 +172,7 @@ impl Decodable for Modification {
}
}
#[derive(Clone)]
#[derive(Clone, Deserialize, Serialize)]
pub enum LogLevel {
Log,
Debug,
@ -158,7 +181,7 @@ pub enum LogLevel {
Error,
}
#[derive(Clone)]
#[derive(Clone, Deserialize, Serialize)]
pub struct ConsoleMessage {
pub message: String,
pub logLevel: LogLevel,
@ -168,13 +191,14 @@ pub struct ConsoleMessage {
}
bitflags! {
#[derive(Deserialize, Serialize)]
flags CachedConsoleMessageTypes: u8 {
const PAGE_ERROR = 1 << 0,
const CONSOLE_API = 1 << 1,
}
}
#[derive(RustcEncodable)]
#[derive(RustcEncodable, Deserialize, Serialize)]
pub struct PageError {
pub _type: String,
pub errorMessage: String,
@ -191,7 +215,7 @@ pub struct PageError {
pub private: bool,
}
#[derive(RustcEncodable)]
#[derive(RustcEncodable, Deserialize, Serialize)]
pub struct ConsoleAPI {
pub _type: String,
pub level: String,
@ -203,6 +227,7 @@ pub struct ConsoleAPI {
pub arguments: Vec<String>,
}
#[derive(Deserialize, Serialize)]
pub enum CachedConsoleMessage {
PageError(PageError),
ConsoleAPI(ConsoleAPI),
@ -219,8 +244,28 @@ impl TimelineMarker {
TimelineMarker {
name: name,
metadata: metadata,
time: time::PreciseTime::now(),
time: PreciseTime::now(),
stack: None,
}
}
}
/// A replacement for `time::PreciseTime` that isn't opaque, so we can serialize it.
///
/// The reason why this doesn't go upstream is that `time` is slated to be part of Rust's standard
/// library, which definitely can't have any dependencies on `serde`. But `serde` can't implement
/// `Deserialize` and `Serialize` itself, because `time::PreciseTime` is opaque! A Catch-22. So I'm
/// duplicating the definition here.
#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct PreciseTime(u64);
impl PreciseTime {
pub fn now() -> PreciseTime {
PreciseTime(time::precise_time_ns())
}
pub fn to(&self, later: PreciseTime) -> Duration {
Duration::nanoseconds((later.0 - self.0) as i64)
}
}

View File

@ -4,7 +4,7 @@
use net_traits::{ControlMsg, CookieSource, LoadData, Metadata, LoadConsumer};
use net_traits::ProgressMsg::{Payload, Done};
use devtools_traits::{DevtoolsControlMsg, NetworkEvent};
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, NetworkEvent};
use mime_classifier::MIMEClassifier;
use resource_task::{start_sending_opt, start_sending_sniffed_opt};
use hsts::{HSTSList, secure_url};
@ -14,7 +14,8 @@ use std::collections::HashSet;
use file_loader;
use flate2::read::{DeflateDecoder, GzDecoder};
use hyper::client::Request;
use hyper::header::{AcceptEncoding, Accept, ContentLength, ContentType, Host, Location, qitem, Quality, QualityItem};
use hyper::header::{AcceptEncoding, Accept, ContentLength, ContentType, Host, Location, qitem};
use hyper::header::{Quality, QualityItem};
use hyper::Error as HttpError;
use hyper::method::Method;
use hyper::mime::{Mime, TopLevel, SubLevel};
@ -262,7 +263,9 @@ reason: \"certificate verify failed\" }]))";
load_data.method.clone(),
load_data.headers.clone(),
load_data.data.clone());
chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id.clone(), net_event)).unwrap();
chan.send(DevtoolsControlMsg::FromChrome(
ChromeToDevtoolsControlMsg::NetworkEventMessage(request_id.clone(),
net_event))).unwrap();
}
let mut response = match writer.send() {
@ -368,9 +371,13 @@ reason: \"certificate verify failed\" }]))";
// Send an HttpResponse message to devtools with the corresponding request_id
// TODO: Send this message only if load_data has a pipeline_id that is not None
if let Some(ref chan) = devtools_chan {
let net_event_response = NetworkEvent::HttpResponse(
metadata.headers.clone(), metadata.status.clone(), None);
chan.send(DevtoolsControlMsg::NetworkEventMessage(request_id, net_event_response)).unwrap();
let net_event_response =
NetworkEvent::HttpResponse(metadata.headers.clone(),
metadata.status.clone(),
None);
chan.send(DevtoolsControlMsg::FromChrome(
ChromeToDevtoolsControlMsg::NetworkEventMessage(request_id,
net_event_response))).unwrap();
}
match encoding_str {

View File

@ -16,12 +16,12 @@ use dom::node::{Node, NodeHelpers};
use dom::window::{WindowHelpers, ScriptHelpers};
use dom::document::DocumentHelpers;
use page::{IterablePage, Page};
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use script_task::{get_page, ScriptTask};
use js::jsapi::RootedValue;
use js::jsval::UndefinedValue;
use std::sync::mpsc::Sender;
use std::rc::Rc;
@ -29,7 +29,7 @@ pub fn handle_evaluate_js(
page: &Rc<Page>,
pipeline: PipelineId,
eval: String,
reply: Sender<EvaluateJSReply>
reply: IpcSender<EvaluateJSReply>
) {
let page = get_page(&*page, pipeline);
let window = page.window();
@ -58,7 +58,7 @@ pub fn handle_evaluate_js(
}).unwrap();
}
pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSender<NodeInfo>) {
let page = get_page(&*page, pipeline);
let document = page.document();
@ -66,7 +66,7 @@ pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender
reply.send(node.summarize()).unwrap();
}
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSender<NodeInfo>) {
let page = get_page(&*page, pipeline);
let document = page.document();
let document_element = document.r().GetDocumentElement().unwrap();
@ -89,7 +89,7 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
panic!("couldn't find node with unique id {}", node_id)
}
pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<Vec<NodeInfo>>) {
pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<Vec<NodeInfo>>) {
let parent = find_node_by_unique_id(&*page, pipeline, node_id);
let children = parent.r().children().map(|child| {
child.r().summarize()
@ -97,7 +97,7 @@ pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: Strin
reply.send(children).unwrap();
}
pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<(f32, f32)>) {
pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<(f32, f32)>) {
let node = find_node_by_unique_id(&*page, pipeline, node_id);
let elem = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
let rect = elem.GetBoundingClientRect();
@ -108,7 +108,7 @@ pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String,
pub fn handle_get_cached_messages(_pipeline_id: PipelineId,
message_types: CachedConsoleMessageTypes,
reply: Sender<Vec<CachedConsoleMessage>>) {
reply: IpcSender<Vec<CachedConsoleMessage>>) {
//TODO: check the messageTypes against a global Cache for console messages and page exceptions
let mut messages = Vec::new();
if message_types.contains(PAGE_ERROR) {
@ -174,7 +174,7 @@ pub fn handle_wants_live_notifications(page: &Rc<Page>, pipeline_id: PipelineId,
pub fn handle_set_timeline_markers(page: &Rc<Page>,
script_task: &ScriptTask,
marker_types: Vec<TimelineMarkerType>,
reply: Sender<TimelineMarker>) {
reply: IpcSender<TimelineMarker>) {
for marker_type in &marker_types {
match *marker_type {
TimelineMarkerType::Reflow => {
@ -204,8 +204,10 @@ pub fn handle_drop_timeline_markers(page: &Rc<Page>,
}
}
pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, callback: Box<Fn(f64, )>) {
pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, callback: IpcSender<f64>) {
let page = page.find(id).expect("There is no such page");
let doc = page.document();
doc.r().request_animation_frame(callback);
doc.r().request_animation_frame(box move |time| {
callback.send(time).unwrap()
});
}

View File

@ -14,13 +14,14 @@ use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::DocumentHelpers;
use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers};
use dom::window::{self, WindowHelpers};
use devtools_traits::DevtoolsControlChan;
use devtools_traits::ScriptToDevtoolsControlMsg;
use script_task::{ScriptChan, ScriptPort, ScriptMsg, ScriptTask};
use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
use net_traits::ResourceTask;
use profile_traits::mem;
use ipc_channel::ipc::IpcSender;
use js::{JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
use js::jsapi::{GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject};
@ -99,9 +100,9 @@ impl<'a> GlobalRef<'a> {
}
}
/// Get a `DevtoolsControlChan` to send messages to Devtools
/// Get an `IpcSender<ScriptToDevtoolsControlMsg>` to send messages to Devtools
/// task when available.
pub fn devtools_chan(&self) -> Option<DevtoolsControlChan> {
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
match *self {
GlobalRef::Window(window) => window.devtools_chan(),
GlobalRef::Worker(worker) => worker.devtools_chan(),

View File

@ -8,7 +8,7 @@ use dom::bindings::global::{GlobalRef, GlobalField};
use dom::bindings::js::Root;
use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::window::WindowHelpers;
use devtools_traits::{DevtoolsControlMsg, ConsoleMessage, LogLevel};
use devtools_traits::{ConsoleMessage, LogLevel, ScriptToDevtoolsControlMsg};
use util::str::DOMString;
// https://developer.mozilla.org/en-US/docs/Web/API/Console
@ -101,7 +101,7 @@ fn propagate_console_msg(console: &&Console, console_message: ConsoleMessage) {
GlobalRef::Window(window_ref) => {
let pipelineId = window_ref.pipeline();
console.global.root().r().as_window().devtools_chan().as_ref().map(|chan| {
chan.send(DevtoolsControlMsg::SendConsoleMessage(
chan.send(ScriptToDevtoolsControlMsg::SendConsoleMessage(
pipelineId, console_message.clone())).unwrap();
});
},

View File

@ -26,7 +26,7 @@ use script_task::StackRootTLS;
use msg::constellation_msg::{ConstellationChan, PipelineId};
use devtools_traits::DevtoolsControlChan;
use devtools_traits::ScriptToDevtoolsControlMsg;
use net_traits::{load_whole_resource, ResourceTask};
use profile_traits::mem::{self, Reporter, ReporterRequest};
@ -34,7 +34,7 @@ use util::task::spawn_named;
use util::task_state;
use util::task_state::{SCRIPT, IN_WORKER};
use ipc_channel::ipc;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::jsapi::{JSContext, RootedValue, HandleValue};
use js::jsapi::{JSAutoRequest, JSAutoCompartment};
@ -110,7 +110,7 @@ impl DedicatedWorkerGlobalScope {
fn new_inherited(worker_url: Url,
id: PipelineId,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
runtime: Rc<Runtime>,
resource_task: ResourceTask,
constellation_chan: ConstellationChan,
@ -133,7 +133,7 @@ impl DedicatedWorkerGlobalScope {
pub fn new(worker_url: Url,
id: PipelineId,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
runtime: Rc<Runtime>,
resource_task: ResourceTask,
constellation_chan: ConstellationChan,
@ -152,7 +152,7 @@ impl DedicatedWorkerGlobalScope {
pub fn run_worker_scope(worker_url: Url,
id: PipelineId,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
worker: TrustedWorkerAddress,
resource_task: ResourceTask,
constellation_chan: ConstellationChan,

View File

@ -38,7 +38,8 @@ use script_traits::ScriptControlChan;
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
use webdriver_handlers::jsval_to_webdriver;
use devtools_traits::{DevtoolsControlChan, TimelineMarker, TimelineMarkerType, TracingMetadata};
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
use devtools_traits::{TracingMetadata};
use msg::compositor_msg::ScriptListener;
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData, WorkerId};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
@ -68,7 +69,7 @@ use std::default::Default;
use std::ffi::CString;
use std::mem as std_mem;
use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::mpsc::{channel, Receiver};
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
use time;
@ -124,11 +125,11 @@ pub struct Window {
mem_profiler_chan: mem::ProfilerChan,
/// For providing instructions to an optional devtools server.
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// For sending timeline markers. Will be ignored if
/// no devtools server
devtools_markers: RefCell<HashSet<TimelineMarkerType>>,
devtools_marker_sender: RefCell<Option<Sender<TimelineMarker>>>,
devtools_marker_sender: RefCell<Option<IpcSender<TimelineMarker>>>,
/// A flag to indicate whether the developer tools have requested live updates of
/// page changes.
@ -547,7 +548,7 @@ pub trait WindowHelpers {
fn get_url(self) -> Url;
fn resource_task(self) -> ResourceTask;
fn mem_profiler_chan(self) -> mem::ProfilerChan;
fn devtools_chan(self) -> Option<DevtoolsControlChan>;
fn devtools_chan(self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>>;
fn layout_chan(self) -> LayoutChan;
fn constellation_chan(self) -> ConstellationChan;
fn windowproxy_handler(self) -> WindowProxyHandler;
@ -564,7 +565,9 @@ pub trait WindowHelpers {
fn freeze(self);
fn need_emit_timeline_marker(self, timeline_type: TimelineMarkerType) -> bool;
fn emit_timeline_marker(self, marker: TimelineMarker);
fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>);
fn set_devtools_timeline_marker(self,
marker: TimelineMarkerType,
reply: IpcSender<TimelineMarker>);
fn drop_devtools_timeline_markers(self);
fn set_webdriver_script_chan(self, chan: Option<IpcSender<WebDriverJSResult>>);
fn is_alive(self) -> bool;
@ -832,7 +835,7 @@ impl<'a> WindowHelpers for &'a Window {
self.mem_profiler_chan.clone()
}
fn devtools_chan(self) -> Option<DevtoolsControlChan> {
fn devtools_chan(self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
self.devtools_chan.clone()
}
@ -935,7 +938,9 @@ impl<'a> WindowHelpers for &'a Window {
sender.send(marker).unwrap();
}
fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>) {
fn set_devtools_timeline_marker(self,
marker: TimelineMarkerType,
reply: IpcSender<TimelineMarker>) {
*self.devtools_marker_sender.borrow_mut() = Some(reply);
self.devtools_markers.borrow_mut().insert(marker);
}
@ -978,7 +983,7 @@ impl Window {
resource_task: ResourceTask,
storage_task: StorageTask,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan,
layout_chan: LayoutChan,
id: PipelineId,

View File

@ -22,10 +22,11 @@ use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
use dom::messageevent::MessageEvent;
use script_task::{ScriptChan, ScriptMsg, Runnable};
use devtools_traits::{DevtoolsControlMsg, DevtoolsPageInfo};
use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg};
use util::str::DOMString;
use ipc_channel::ipc;
use js::jsapi::{JSContext, HandleValue, RootedValue};
use js::jsapi::{JSAutoRequest, JSAutoCompartment};
use js::jsval::UndefinedValue;
@ -78,16 +79,16 @@ impl Worker {
if let Some(ref chan) = global.devtools_chan() {
let pipeline_id = global.pipeline();
let (devtools_sender, _) = channel();
let (devtools_sender, _) = ipc::channel().unwrap();
let title = format!("Worker for {}", worker_url);
let page_info = DevtoolsPageInfo {
title: title,
url: worker_url.clone(),
};
let worker_id = global.get_next_worker_id();
chan.send(
DevtoolsControlMsg::NewGlobal((pipeline_id, Some(worker_id)), devtools_sender.clone(), page_info)
).unwrap();
chan.send(ScriptToDevtoolsControlMsg::NewGlobal((pipeline_id, Some(worker_id)),
devtools_sender.clone(),
page_info)).unwrap();
}
DedicatedWorkerGlobalScope::run_worker_scope(

View File

@ -20,13 +20,14 @@ use dom::window::{base64_atob, base64_btoa};
use script_task::{ScriptChan, TimerSource, ScriptPort, ScriptMsg};
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
use devtools_traits::DevtoolsControlChan;
use devtools_traits::ScriptToDevtoolsControlMsg;
use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
use profile_traits::mem;
use net_traits::{load_whole_resource, ResourceTask};
use util::str::DOMString;
use ipc_channel::ipc::IpcSender;
use js::jsapi::{JSContext, HandleValue};
use js::rust::Runtime;
use url::{Url, UrlParser};
@ -54,7 +55,7 @@ pub struct WorkerGlobalScope {
crypto: MutNullableHeap<JS<Crypto>>,
timers: TimerManager,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan,
}
@ -64,8 +65,9 @@ impl WorkerGlobalScope {
runtime: Rc<Runtime>,
resource_task: ResourceTask,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
constellation_chan: ConstellationChan) -> WorkerGlobalScope {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan)
-> WorkerGlobalScope {
WorkerGlobalScope {
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WorkerGlobalScope(type_id)),
next_worker_id: Cell::new(WorkerId(0)),
@ -87,7 +89,7 @@ impl WorkerGlobalScope {
self.mem_profiler_chan.clone()
}
pub fn devtools_chan(&self) -> Option<DevtoolsControlChan> {
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
self.devtools_chan.clone()
}

View File

@ -50,9 +50,9 @@ use timers::TimerId;
use devtools;
use webdriver_handlers;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, DevtoolsPageInfo};
use devtools_traits::{DevtoolsControlMsg, DevtoolScriptControlMsg};
use devtools_traits::{TimelineMarker, TimelineMarkerType, TracingMetadata};
use devtools_traits::{DevtoolsControlPort, DevtoolsPageInfo, DevtoolScriptControlMsg};
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
use devtools_traits::{TracingMetadata};
use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent};
use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent};
use script_traits::CompositorEvent::{ResizeEvent, ClickEvent};
@ -79,7 +79,7 @@ use util::task_state;
use euclid::Rect;
use euclid::point::Point2D;
use hyper::header::{LastModified, Headers};
use ipc_channel::ipc;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::glue::CollectServoSizes;
use js::jsapi::{JS_SetWrapObjectCallbacks, JS_AddExtraGCRootsTracer, DisableIncrementalGC};
@ -320,15 +320,15 @@ pub struct ScriptTask {
mem_profiler_chan: mem::ProfilerChan,
/// For providing instructions to an optional devtools server.
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// For receiving commands from an optional devtools server. Will be ignored if
/// no such server exists.
devtools_port: DevtoolsControlPort,
devtools_sender: Sender<DevtoolScriptControlMsg>,
devtools_sender: IpcSender<DevtoolScriptControlMsg>,
/// For sending timeline markers. Will be ignored if
/// no devtools server
devtools_markers: RefCell<HashSet<TimelineMarkerType>>,
devtools_marker_sender: RefCell<Option<Sender<TimelineMarker>>>,
devtools_marker_sender: RefCell<Option<IpcSender<TimelineMarker>>>,
/// The JavaScript runtime.
js_runtime: Rc<Runtime>,
@ -400,7 +400,7 @@ impl ScriptTaskFactory for ScriptTask {
storage_task: StorageTask,
image_cache_task: ImageCacheTask,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
window_size: Option<WindowSizeData>,
load_data: LoadData) {
let ConstellationChan(const_chan) = constellation_chan.clone();
@ -507,7 +507,7 @@ impl ScriptTask {
storage_task: StorageTask,
image_cache_task: ImageCacheTask,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>)
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>)
-> ScriptTask {
let runtime = ScriptTask::new_rt_and_cx();
@ -516,7 +516,9 @@ impl ScriptTask {
&WRAP_CALLBACKS);
}
let (devtools_sender, devtools_receiver) = channel();
// Ask the router to proxy IPC messages from the devtools to us.
let (ipc_devtools_sender, ipc_devtools_receiver) = ipc::channel().unwrap();
let devtools_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_devtools_receiver);
// Ask the router to proxy IPC messages from the image cache task to us.
let (ipc_image_cache_channel, ipc_image_cache_port) = ipc::channel().unwrap();
@ -543,8 +545,8 @@ impl ScriptTask {
mem_profiler_chan: mem_profiler_chan,
devtools_chan: devtools_chan,
devtools_port: devtools_receiver,
devtools_sender: devtools_sender,
devtools_port: devtools_port,
devtools_sender: ipc_devtools_sender,
devtools_markers: RefCell::new(HashSet::new()),
devtools_marker_sender: RefCell::new(None),
@ -1435,9 +1437,10 @@ impl ScriptTask {
title: title,
url: url,
};
chan.send(DevtoolsControlMsg::NewGlobal(ids,
self.devtools_sender.clone(),
page_info)).unwrap();
chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
ids,
self.devtools_sender.clone(),
page_info)).unwrap();
}
}
}
@ -1637,7 +1640,9 @@ impl ScriptTask {
sender.send(marker).unwrap();
}
pub fn set_devtools_timeline_marker(&self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>) {
pub fn set_devtools_timeline_marker(&self,
marker: TimelineMarkerType,
reply: IpcSender<TimelineMarker>) {
*self.devtools_marker_sender.borrow_mut() = Some(reply);
self.devtools_markers.borrow_mut().insert(marker);
}

View File

@ -21,7 +21,7 @@ extern crate serde;
extern crate util;
extern crate url;
use devtools_traits::DevtoolsControlChan;
use devtools_traits::ScriptToDevtoolsControlMsg;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void;
use msg::compositor_msg::{Epoch, LayerId};
@ -35,7 +35,7 @@ use net_traits::image_cache_task::ImageCacheTask;
use net_traits::storage_task::StorageTask;
use profile_traits::mem;
use std::any::Any;
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc::{Receiver, Sender};
use url::Url;
use util::geometry::Au;
@ -193,7 +193,7 @@ pub trait ScriptTaskFactory {
storage_task: StorageTask,
image_cache_task: ImageCacheTask,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<DevtoolsControlChan>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
window_size: Option<WindowSizeData>,
load_data: LoadData);
/// Create a script -> layout channel (`Sender`, `Receiver` pair).

View File

@ -249,9 +249,12 @@ version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@ -263,8 +266,11 @@ version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",

View File

@ -10,13 +10,13 @@ use std::ascii::AsciiExt;
use string_cache::Atom;
use url::{Url, UrlParser};
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum Source {
Url(UrlSource),
Local(Atom),
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct UrlSource {
pub url: Url,
pub format_hints: Vec<String>,

View File

@ -1701,7 +1701,7 @@ pub mod longhands {
}
pub mod computed_value {
use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[derive(PartialEq, Eq, Copy, Clone, Hash, Deserialize, Serialize)]
pub enum T {
% for weight in range(100, 901, 100):
Weight${weight} = ${weight},

View File

@ -248,9 +248,12 @@ version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@ -262,8 +265,11 @@ version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",

View File

@ -225,9 +225,12 @@ version = "0.0.1"
dependencies = [
"devtools_traits 0.0.1",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@ -239,8 +242,11 @@ version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)",
"msg 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",