Bug 1172897 - Rename Tab Actor to BrowsingContextActor

As part of [Bug 1172987](https://bugzilla.mozilla.org/show_bug.cgi?id=1172897) we renamed TabActor, as the actor does not represent tabs (as in a browser tab), it instead represents a browsing context as defined by the the [HTML standard](https://html.spec.whatwg.org/multipage/browsers.html#windows). In a later PR I will mirror the structure we have on devtools to have a targets folder, which contains all target types. At the moment it looks like servo only represents workers and browsing contexts.
This commit is contained in:
codehag 2018-09-23 16:13:39 +02:00
parent 196bec2b87
commit 86b78629c3
3 changed files with 34 additions and 34 deletions

View file

@ -4,7 +4,7 @@
//! Liberally derived from the [Firefox JS implementation] //! Liberally derived from the [Firefox JS implementation]
//! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js). //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js).
//! Connection point for remote devtools that wish to investigate a particular tab's contents. //! Connection point for remote devtools that wish to investigate a particular Browsing Context's contents.
//! Supports dynamic attaching and detaching which control notifications of navigation, etc. //! Supports dynamic attaching and detaching which control notifications of navigation, etc.
use actor::{Actor, ActorMessageStatus, ActorRegistry}; use actor::{Actor, ActorMessageStatus, ActorRegistry};
@ -15,21 +15,21 @@ use serde_json::{Map, Value};
use std::net::TcpStream; use std::net::TcpStream;
#[derive(Serialize)] #[derive(Serialize)]
struct TabTraits; struct BrowsingContextTraits;
#[derive(Serialize)] #[derive(Serialize)]
struct TabAttachedReply { struct BrowsingContextAttachedReply {
from: String, from: String,
#[serde(rename = "type")] #[serde(rename = "type")]
type_: String, type_: String,
threadActor: String, threadActor: String,
cacheDisabled: bool, cacheDisabled: bool,
javascriptEnabled: bool, javascriptEnabled: bool,
traits: TabTraits, traits: BrowsingContextTraits,
} }
#[derive(Serialize)] #[derive(Serialize)]
struct TabDetachedReply { struct BrowsingContextDetachedReply {
from: String, from: String,
#[serde(rename = "type")] #[serde(rename = "type")]
type_: String, type_: String,
@ -55,7 +55,7 @@ struct FrameMsg {
} }
#[derive(Serialize)] #[derive(Serialize)]
pub struct TabActorMsg { pub struct BrowsingContextActorMsg {
actor: String, actor: String,
title: String, title: String,
url: String, url: String,
@ -67,7 +67,7 @@ pub struct TabActorMsg {
performanceActor: String, performanceActor: String,
} }
pub struct TabActor { pub struct BrowsingContextActor {
pub name: String, pub name: String,
pub title: String, pub title: String,
pub url: String, pub url: String,
@ -79,7 +79,7 @@ pub struct TabActor {
pub thread: String, pub thread: String,
} }
impl Actor for TabActor { impl Actor for BrowsingContextActor {
fn name(&self) -> String { fn name(&self) -> String {
self.name.clone() self.name.clone()
} }
@ -107,16 +107,16 @@ impl Actor for TabActor {
ActorMessageStatus::Processed ActorMessageStatus::Processed
}, },
// https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs // https://docs.firefox-dev.tools/backend/protocol.html#listing-browser-tabs
// (see "To attach to a _tabActor_") // (see "To attach to a _targetActor_")
"attach" => { "attach" => {
let msg = TabAttachedReply { let msg = BrowsingContextAttachedReply {
from: self.name(), from: self.name(),
type_: "tabAttached".to_owned(), type_: "targetAttached".to_owned(),
threadActor: self.thread.clone(), threadActor: self.thread.clone(),
cacheDisabled: false, cacheDisabled: false,
javascriptEnabled: true, javascriptEnabled: true,
traits: TabTraits, traits: BrowsingContextTraits,
}; };
let console_actor = registry.find::<ConsoleActor>(&self.console); let console_actor = registry.find::<ConsoleActor>(&self.console);
console_actor console_actor
@ -134,7 +134,7 @@ impl Actor for TabActor {
//FIXME: The current implementation won't work for multiple connections. Need to ensure 105 //FIXME: The current implementation won't work for multiple connections. Need to ensure 105
// that the correct stream is removed. // that the correct stream is removed.
"detach" => { "detach" => {
let msg = TabDetachedReply { let msg = BrowsingContextDetachedReply {
from: self.name(), from: self.name(),
type_: "detached".to_owned(), type_: "detached".to_owned(),
}; };
@ -162,9 +162,9 @@ impl Actor for TabActor {
} }
} }
impl TabActor { impl BrowsingContextActor {
pub fn encodable(&self) -> TabActorMsg { pub fn encodable(&self) -> BrowsingContextActorMsg {
TabActorMsg { BrowsingContextActorMsg {
actor: self.name(), actor: self.name(),
title: self.title.clone(), title: self.title.clone(),
url: self.url.clone(), url: self.url.clone(),

View file

@ -5,10 +5,10 @@
/// Liberally derived from the [Firefox JS implementation] /// Liberally derived from the [Firefox JS implementation]
/// (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/root.js). /// (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/root.js).
/// Connection point for all new remote devtools interactions, providing lists of know actors /// Connection point for all new remote devtools interactions, providing lists of know actors
/// that perform more specific actions (tabs, addons, browser chrome, etc.) /// that perform more specific actions (targets, addons, browser chrome, etc.)
use actor::{Actor, ActorMessageStatus, ActorRegistry}; use actor::{Actor, ActorMessageStatus, ActorRegistry};
use actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg};
use actors::performance::PerformanceActor; use actors::performance::PerformanceActor;
use actors::tab::{TabActor, TabActorMsg};
use protocol::{ActorDescription, JsonPacketStream}; use protocol::{ActorDescription, JsonPacketStream};
use serde_json::{Map, Value}; use serde_json::{Map, Value};
use std::net::TcpStream; use std::net::TcpStream;
@ -34,7 +34,7 @@ enum AddonMsg {}
struct ListTabsReply { struct ListTabsReply {
from: String, from: String,
selected: u32, selected: u32,
tabs: Vec<TabActorMsg>, tabs: Vec<BrowsingContextActorMsg>,
} }
#[derive(Serialize)] #[derive(Serialize)]
@ -81,7 +81,7 @@ impl Actor for RootActor {
ActorMessageStatus::Processed ActorMessageStatus::Processed
}, },
//https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs // https://docs.firefox-dev.tools/backend/protocol.html#listing-browser-tabs
"listTabs" => { "listTabs" => {
let actor = ListTabsReply { let actor = ListTabsReply {
from: "root".to_owned(), from: "root".to_owned(),
@ -89,7 +89,7 @@ impl Actor for RootActor {
tabs: self tabs: self
.tabs .tabs
.iter() .iter()
.map(|tab| registry.find::<TabActor>(tab).encodable()) .map(|target| registry.find::<BrowsingContextActor>(target).encodable())
.collect(), .collect(),
}; };
stream.write_json_packet(&actor); stream.write_json_packet(&actor);

View file

@ -25,6 +25,7 @@ extern crate servo_channel;
extern crate time; extern crate time;
use actor::{Actor, ActorRegistry}; use actor::{Actor, ActorRegistry};
use actors::browsing_context::BrowsingContextActor;
use actors::console::ConsoleActor; use actors::console::ConsoleActor;
use actors::framerate::FramerateActor; use actors::framerate::FramerateActor;
use actors::inspector::InspectorActor; use actors::inspector::InspectorActor;
@ -32,7 +33,6 @@ use actors::network_event::{EventActor, NetworkEventActor, ResponseStartMsg};
use actors::performance::PerformanceActor; use actors::performance::PerformanceActor;
use actors::profiler::ProfilerActor; use actors::profiler::ProfilerActor;
use actors::root::RootActor; use actors::root::RootActor;
use actors::tab::TabActor;
use actors::thread::ThreadActor; use actors::thread::ThreadActor;
use actors::timeline::TimelineActor; use actors::timeline::TimelineActor;
use actors::worker::WorkerActor; use actors::worker::WorkerActor;
@ -55,6 +55,7 @@ use time::precise_time_ns;
mod actor; mod actor;
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/ /// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
mod actors { mod actors {
pub mod browsing_context;
pub mod console; pub mod console;
pub mod framerate; pub mod framerate;
pub mod inspector; pub mod inspector;
@ -64,7 +65,6 @@ mod actors {
pub mod performance; pub mod performance;
pub mod profiler; pub mod profiler;
pub mod root; pub mod root;
pub mod tab;
pub mod thread; pub mod thread;
pub mod timeline; pub mod timeline;
pub mod worker; pub mod worker;
@ -202,7 +202,7 @@ fn run_server(
// We need separate actor representations for each script global that exists; // We need separate actor representations for each script global that exists;
// clients can theoretically connect to multiple globals simultaneously. // clients can theoretically connect to multiple globals simultaneously.
// TODO: move this into the root or tab modules? // TODO: move this into the root or target modules?
fn handle_new_global( fn handle_new_global(
actors: Arc<Mutex<ActorRegistry>>, actors: Arc<Mutex<ActorRegistry>>,
ids: (PipelineId, Option<WorkerId>), ids: (PipelineId, Option<WorkerId>),
@ -215,8 +215,8 @@ fn run_server(
let (pipeline, worker_id) = ids; let (pipeline, worker_id) = ids;
//TODO: move all this actor creation into a constructor method on TabActor //TODO: move all this actor creation into a constructor method on BrowsingContextActor
let (tab, console, inspector, timeline, profiler, performance, thread) = { let (target, console, inspector, timeline, profiler, performance, thread) = {
let console = ConsoleActor { let console = ConsoleActor {
name: actors.new_name("console"), name: actors.new_name("console"),
script_chan: script_sender.clone(), script_chan: script_sender.clone(),
@ -240,8 +240,8 @@ fn run_server(
let thread = ThreadActor::new(actors.new_name("context")); let thread = ThreadActor::new(actors.new_name("context"));
let DevtoolsPageInfo { title, url } = page_info; let DevtoolsPageInfo { title, url } = page_info;
let tab = TabActor { let target = BrowsingContextActor {
name: actors.new_name("tab"), name: actors.new_name("target"),
title: String::from(title), title: String::from(title),
url: url.into_string(), url: url.into_string(),
console: console.name(), console: console.name(),
@ -253,10 +253,10 @@ fn run_server(
}; };
let root = actors.find_mut::<RootActor>("root"); let root = actors.find_mut::<RootActor>("root");
root.tabs.push(tab.name.clone()); root.tabs.push(target.name.clone());
( (
tab, target,
console, console,
inspector, inspector,
timeline, timeline,
@ -276,8 +276,8 @@ fn run_server(
actors.register(Box::new(worker)); actors.register(Box::new(worker));
} }
actor_pipelines.insert(pipeline, tab.name.clone()); actor_pipelines.insert(pipeline, target.name.clone());
actors.register(Box::new(tab)); actors.register(Box::new(target));
actors.register(Box::new(console)); actors.register(Box::new(console));
actors.register(Box::new(inspector)); actors.register(Box::new(inspector));
actors.register(Box::new(timeline)); actors.register(Box::new(timeline));
@ -342,7 +342,7 @@ fn run_server(
Some(actors.find::<WorkerActor>(actor_name).console.clone()) Some(actors.find::<WorkerActor>(actor_name).console.clone())
} else { } else {
let actor_name = (*actor_pipelines).get(&id)?; let actor_name = (*actor_pipelines).get(&id)?;
Some(actors.find::<TabActor>(actor_name).console.clone()) Some(actors.find::<BrowsingContextActor>(actor_name).console.clone())
} }
} }