mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Return real page titles and URLs for devtools tab choices.
Fixes #4167.
This commit is contained in:
parent
914f27263d
commit
a477893ab3
3 changed files with 37 additions and 15 deletions
|
@ -35,7 +35,7 @@ use actors::root::RootActor;
|
||||||
use actors::tab::TabActor;
|
use actors::tab::TabActor;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
|
|
||||||
use devtools_traits::{ServerExitMsg, DevtoolsControlMsg, NewGlobal, DevtoolScriptControlMsg};
|
use devtools_traits::{ServerExitMsg, DevtoolsControlMsg, NewGlobal, DevtoolScriptControlMsg, DevtoolsPageInfo};
|
||||||
use servo_msg::constellation_msg::PipelineId;
|
use servo_msg::constellation_msg::PipelineId;
|
||||||
use servo_util::task::spawn_named;
|
use servo_util::task::spawn_named;
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
||||||
fn handle_new_global(actors: Arc<Mutex<ActorRegistry>>,
|
fn handle_new_global(actors: Arc<Mutex<ActorRegistry>>,
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
sender: Sender<DevtoolScriptControlMsg>,
|
sender: Sender<DevtoolScriptControlMsg>,
|
||||||
actor_pipelines: &mut HashMap<PipelineId, String>) {
|
actor_pipelines: &mut HashMap<PipelineId, String>,
|
||||||
|
page_info: DevtoolsPageInfo) {
|
||||||
let mut actors = actors.lock();
|
let mut actors = actors.lock();
|
||||||
|
|
||||||
//TODO: move all this actor creation into a constructor method on TabActor
|
//TODO: move all this actor creation into a constructor method on TabActor
|
||||||
|
@ -146,11 +147,12 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
||||||
script_chan: sender,
|
script_chan: sender,
|
||||||
pipeline: pipeline,
|
pipeline: pipeline,
|
||||||
};
|
};
|
||||||
//TODO: send along the current page title and URL
|
|
||||||
|
let DevtoolsPageInfo { title, url } = page_info;
|
||||||
let tab = TabActor {
|
let tab = TabActor {
|
||||||
name: actors.new_name("tab"),
|
name: actors.new_name("tab"),
|
||||||
title: "".to_string(),
|
title: title,
|
||||||
url: "about:blank".to_string(),
|
url: url.serialize(),
|
||||||
console: console.name(),
|
console: console.name(),
|
||||||
inspector: inspector.name(),
|
inspector: inspector.name(),
|
||||||
};
|
};
|
||||||
|
@ -177,7 +179,7 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
|
||||||
Err(ref e) if e.kind == TimedOut => {
|
Err(ref e) if e.kind == TimedOut => {
|
||||||
match receiver.try_recv() {
|
match receiver.try_recv() {
|
||||||
Ok(ServerExitMsg) | Err(Disconnected) => break,
|
Ok(ServerExitMsg) | Err(Disconnected) => break,
|
||||||
Ok(NewGlobal(id, sender)) => handle_new_global(actors.clone(), id, sender, &mut actor_pipelines),
|
Ok(NewGlobal(id, sender, pageinfo)) => handle_new_global(actors.clone(), id, sender, &mut actor_pipelines, pageinfo),
|
||||||
Err(Empty) => acceptor.set_timeout(Some(POLL_TIMEOUT)),
|
Err(Empty) => acceptor.set_timeout(Some(POLL_TIMEOUT)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
extern crate "msg" as servo_msg;
|
extern crate "msg" as servo_msg;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
extern crate url;
|
||||||
|
extern crate "util" as servo_util;
|
||||||
|
|
||||||
/// This module contains shared types and messages for use by devtools/script.
|
/// This module contains shared types and messages for use by devtools/script.
|
||||||
/// The traits are here instead of in script so that the devtools crate can be
|
/// The traits are here instead of in script so that the devtools crate can be
|
||||||
|
@ -19,14 +21,23 @@ extern crate serialize;
|
||||||
|
|
||||||
use serialize::{Decodable, Decoder};
|
use serialize::{Decodable, Decoder};
|
||||||
use servo_msg::constellation_msg::PipelineId;
|
use servo_msg::constellation_msg::PipelineId;
|
||||||
|
use servo_util::str::DOMString;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
pub type DevtoolsControlChan = Sender<DevtoolsControlMsg>;
|
pub type DevtoolsControlChan = Sender<DevtoolsControlMsg>;
|
||||||
pub type DevtoolsControlPort = Receiver<DevtoolScriptControlMsg>;
|
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.
|
||||||
|
pub struct DevtoolsPageInfo {
|
||||||
|
pub title: DOMString,
|
||||||
|
pub url: Url
|
||||||
|
}
|
||||||
|
|
||||||
/// Messages to the instruct the devtools server to update its known actors/state
|
/// Messages to the instruct the devtools server to update its known actors/state
|
||||||
/// according to changes in the browser.
|
/// according to changes in the browser.
|
||||||
pub enum DevtoolsControlMsg {
|
pub enum DevtoolsControlMsg {
|
||||||
NewGlobal(PipelineId, Sender<DevtoolScriptControlMsg>),
|
NewGlobal(PipelineId, Sender<DevtoolScriptControlMsg>, DevtoolsPageInfo),
|
||||||
ServerExitMsg
|
ServerExitMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ use page::{Page, IterablePage, Frame};
|
||||||
use timers::TimerId;
|
use timers::TimerId;
|
||||||
use devtools;
|
use devtools;
|
||||||
|
|
||||||
use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, NewGlobal, GetRootNode};
|
use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, NewGlobal, GetRootNode, DevtoolsPageInfo};
|
||||||
use devtools_traits::{DevtoolScriptControlMsg, EvaluateJS, GetDocumentElement};
|
use devtools_traits::{DevtoolScriptControlMsg, EvaluateJS, GetDocumentElement};
|
||||||
use devtools_traits::{GetChildren, GetLayout, ModifyAttribute};
|
use devtools_traits::{GetChildren, GetLayout, ModifyAttribute};
|
||||||
use script_traits::{CompositorEvent, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent};
|
use script_traits::{CompositorEvent, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent};
|
||||||
|
@ -185,6 +185,7 @@ pub struct ScriptTask {
|
||||||
/// For receiving commands from an optional devtools server. Will be ignored if
|
/// For receiving commands from an optional devtools server. Will be ignored if
|
||||||
/// no such server exists.
|
/// no such server exists.
|
||||||
devtools_port: DevtoolsControlPort,
|
devtools_port: DevtoolsControlPort,
|
||||||
|
devtools_sender: Sender<DevtoolScriptControlMsg>,
|
||||||
|
|
||||||
/// The JavaScript runtime.
|
/// The JavaScript runtime.
|
||||||
js_runtime: js::rust::rt,
|
js_runtime: js::rust::rt,
|
||||||
|
@ -344,13 +345,7 @@ impl ScriptTask {
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
js_context.clone());
|
js_context.clone());
|
||||||
|
|
||||||
// Notify devtools that a new script global exists.
|
|
||||||
//FIXME: Move this into handle_load after we create a window instead.
|
|
||||||
let (devtools_sender, devtools_receiver) = channel();
|
let (devtools_sender, devtools_receiver) = channel();
|
||||||
devtools_chan.as_ref().map(|chan| {
|
|
||||||
chan.send(NewGlobal(id, devtools_sender.clone()));
|
|
||||||
});
|
|
||||||
|
|
||||||
ScriptTask {
|
ScriptTask {
|
||||||
page: DOMRefCell::new(Rc::new(page)),
|
page: DOMRefCell::new(Rc::new(page)),
|
||||||
|
|
||||||
|
@ -365,6 +360,7 @@ impl ScriptTask {
|
||||||
compositor: DOMRefCell::new(compositor),
|
compositor: DOMRefCell::new(compositor),
|
||||||
devtools_chan: devtools_chan,
|
devtools_chan: devtools_chan,
|
||||||
devtools_port: devtools_receiver,
|
devtools_port: devtools_receiver,
|
||||||
|
devtools_sender: devtools_sender,
|
||||||
|
|
||||||
js_runtime: js_runtime,
|
js_runtime: js_runtime,
|
||||||
js_context: DOMRefCell::new(Some(js_context)),
|
js_context: DOMRefCell::new(Some(js_context)),
|
||||||
|
@ -824,10 +820,23 @@ impl ScriptTask {
|
||||||
let wintarget: JSRef<EventTarget> = EventTargetCast::from_ref(*window);
|
let wintarget: JSRef<EventTarget> = EventTargetCast::from_ref(*window);
|
||||||
let _ = wintarget.dispatch_event_with_target(Some(doctarget), *event);
|
let _ = wintarget.dispatch_event_with_target(Some(doctarget), *event);
|
||||||
|
|
||||||
*page.fragment_name.borrow_mut() = final_url.fragment;
|
*page.fragment_name.borrow_mut() = final_url.fragment.clone();
|
||||||
|
|
||||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||||
chan.send(LoadCompleteMsg);
|
chan.send(LoadCompleteMsg);
|
||||||
|
|
||||||
|
// Notify devtools that a new script global exists.
|
||||||
|
match self.devtools_chan {
|
||||||
|
None => {}
|
||||||
|
Some(ref chan) => {
|
||||||
|
let page_info = DevtoolsPageInfo {
|
||||||
|
title: document.Title(),
|
||||||
|
url: final_url
|
||||||
|
};
|
||||||
|
chan.send(NewGlobal(pipeline_id, self.devtools_sender.clone(),
|
||||||
|
page_info));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_fragment_point(&self, pipeline_id: PipelineId, node: JSRef<Element>) {
|
fn scroll_fragment_point(&self, pipeline_id: PipelineId, node: JSRef<Element>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue