mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
devtools: Use webview_id
as browser_id
(#35956)
* use `webview_id` as `browser_id` Signed-off-by: atbrakhi <atbrakhi@igalia.com> * use correct webview id Signed-off-by: atbrakhi <atbrakhi@igalia.com> * fmt Signed-off-by: atbrakhi <atbrakhi@igalia.com> * review fix Signed-off-by: atbrakhi <atbrakhi@igalia.com> --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
4acaa08cf5
commit
2362e4c134
7 changed files with 43 additions and 17 deletions
|
@ -10,7 +10,7 @@ use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
use base::id::{BrowsingContextId, PipelineId};
|
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||||
use devtools_traits::DevtoolScriptControlMsg::{self, GetCssDatabase, WantsLiveNotifications};
|
use devtools_traits::DevtoolScriptControlMsg::{self, GetCssDatabase, WantsLiveNotifications};
|
||||||
use devtools_traits::{DevtoolsPageInfo, NavigationState};
|
use devtools_traits::{DevtoolsPageInfo, NavigationState};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
|
@ -84,6 +84,9 @@ pub struct BrowsingContextActorMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
title: String,
|
title: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
/// This correspond to webview_id
|
||||||
|
#[serde(rename = "browserId")]
|
||||||
|
browser_id: u32,
|
||||||
#[serde(rename = "outerWindowID")]
|
#[serde(rename = "outerWindowID")]
|
||||||
outer_window_id: u32,
|
outer_window_id: u32,
|
||||||
#[serde(rename = "browsingContextID")]
|
#[serde(rename = "browsingContextID")]
|
||||||
|
@ -121,6 +124,8 @@ pub(crate) struct BrowsingContextActor {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub title: RefCell<String>,
|
pub title: RefCell<String>,
|
||||||
pub url: RefCell<String>,
|
pub url: RefCell<String>,
|
||||||
|
/// This correspond to webview_id
|
||||||
|
pub browser_id: WebViewId,
|
||||||
pub active_pipeline: Cell<PipelineId>,
|
pub active_pipeline: Cell<PipelineId>,
|
||||||
pub browsing_context_id: BrowsingContextId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
pub accessibility: String,
|
pub accessibility: String,
|
||||||
|
@ -173,6 +178,7 @@ impl Actor for BrowsingContextActor {
|
||||||
impl BrowsingContextActor {
|
impl BrowsingContextActor {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
console: String,
|
console: String,
|
||||||
|
browser_id: WebViewId,
|
||||||
browsing_context_id: BrowsingContextId,
|
browsing_context_id: BrowsingContextId,
|
||||||
page_info: DevtoolsPageInfo,
|
page_info: DevtoolsPageInfo,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
|
@ -225,6 +231,7 @@ impl BrowsingContextActor {
|
||||||
title: RefCell::new(title),
|
title: RefCell::new(title),
|
||||||
url: RefCell::new(url.into_string()),
|
url: RefCell::new(url.into_string()),
|
||||||
active_pipeline: Cell::new(pipeline_id),
|
active_pipeline: Cell::new(pipeline_id),
|
||||||
|
browser_id,
|
||||||
browsing_context_id,
|
browsing_context_id,
|
||||||
accessibility: accessibility.name(),
|
accessibility: accessibility.name(),
|
||||||
console,
|
console,
|
||||||
|
@ -263,6 +270,7 @@ impl BrowsingContextActor {
|
||||||
},
|
},
|
||||||
title: self.title.borrow().clone(),
|
title: self.title.borrow().clone(),
|
||||||
url: self.url.borrow().clone(),
|
url: self.url.borrow().clone(),
|
||||||
|
browser_id: self.browser_id.0.index.0.get(),
|
||||||
//FIXME: shouldn't ignore pipeline namespace field
|
//FIXME: shouldn't ignore pipeline namespace field
|
||||||
browsing_context_id: self.browsing_context_id.index.0.get(),
|
browsing_context_id: self.browsing_context_id.index.0.get(),
|
||||||
//FIXME: shouldn't ignore pipeline namespace field
|
//FIXME: shouldn't ignore pipeline namespace field
|
||||||
|
|
|
@ -310,6 +310,6 @@ impl RootActor {
|
||||||
.find::<TabDescriptorActor>(target)
|
.find::<TabDescriptorActor>(target)
|
||||||
.encodable(registry, true)
|
.encodable(registry, true)
|
||||||
})
|
})
|
||||||
.find(|tab| tab.id() == browser_id)
|
.find(|tab| tab.browser_id() == browser_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ use crate::protocol::JsonPacketStream;
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct TabDescriptorActorMsg {
|
pub struct TabDescriptorActorMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
|
/// This correspond to webview_id
|
||||||
|
#[serde(rename = "browserId")]
|
||||||
browser_id: u32,
|
browser_id: u32,
|
||||||
#[serde(rename = "browsingContextID")]
|
#[serde(rename = "browsingContextID")]
|
||||||
browsing_context_id: u32,
|
browsing_context_id: u32,
|
||||||
|
@ -38,7 +40,7 @@ pub struct TabDescriptorActorMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TabDescriptorActorMsg {
|
impl TabDescriptorActorMsg {
|
||||||
pub fn id(&self) -> u32 {
|
pub fn browser_id(&self) -> u32 {
|
||||||
self.browser_id
|
self.browser_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,16 +142,16 @@ impl TabDescriptorActor {
|
||||||
|
|
||||||
pub fn encodable(&self, registry: &ActorRegistry, selected: bool) -> TabDescriptorActorMsg {
|
pub fn encodable(&self, registry: &ActorRegistry, selected: bool) -> TabDescriptorActorMsg {
|
||||||
let ctx_actor = registry.find::<BrowsingContextActor>(&self.browsing_context_actor);
|
let ctx_actor = registry.find::<BrowsingContextActor>(&self.browsing_context_actor);
|
||||||
let browser_id = ctx_actor.browsing_context_id.index.0.get();
|
let browser_id = ctx_actor.browser_id.0.index.0.get();
|
||||||
let outer_window_id = ctx_actor.active_pipeline.get().index.0.get();
|
|
||||||
let browsing_context_id = ctx_actor.browsing_context_id.index.0.get();
|
let browsing_context_id = ctx_actor.browsing_context_id.index.0.get();
|
||||||
|
let outer_window_id = ctx_actor.active_pipeline.get().index.0.get();
|
||||||
let title = ctx_actor.title.borrow().clone();
|
let title = ctx_actor.title.borrow().clone();
|
||||||
let url = ctx_actor.url.borrow().clone();
|
let url = ctx_actor.url.borrow().clone();
|
||||||
|
|
||||||
TabDescriptorActorMsg {
|
TabDescriptorActorMsg {
|
||||||
actor: self.name(),
|
actor: self.name(),
|
||||||
browsing_context_id,
|
|
||||||
browser_id,
|
browser_id,
|
||||||
|
browsing_context_id,
|
||||||
is_zombie_tab: false,
|
is_zombie_tab: false,
|
||||||
outer_window_id,
|
outer_window_id,
|
||||||
selected,
|
selected,
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::net::{Shutdown, TcpListener, TcpStream};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use base::id::{BrowsingContextId, PipelineId};
|
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||||
use crossbeam_channel::{Receiver, Sender, unbounded};
|
use crossbeam_channel::{Receiver, Sender, unbounded};
|
||||||
use devtools_traits::{
|
use devtools_traits::{
|
||||||
ChromeToDevtoolsControlMsg, ConsoleMessage, ConsoleMessageBuilder, DevtoolScriptControlMsg,
|
ChromeToDevtoolsControlMsg, ConsoleMessage, ConsoleMessageBuilder, DevtoolScriptControlMsg,
|
||||||
|
@ -343,13 +343,13 @@ impl DevtoolsInstance {
|
||||||
// TODO: move this into the root or target modules?
|
// TODO: move this into the root or target modules?
|
||||||
fn handle_new_global(
|
fn handle_new_global(
|
||||||
&mut self,
|
&mut self,
|
||||||
ids: (BrowsingContextId, PipelineId, Option<WorkerId>),
|
ids: (BrowsingContextId, PipelineId, Option<WorkerId>, WebViewId),
|
||||||
script_sender: IpcSender<DevtoolScriptControlMsg>,
|
script_sender: IpcSender<DevtoolScriptControlMsg>,
|
||||||
page_info: DevtoolsPageInfo,
|
page_info: DevtoolsPageInfo,
|
||||||
) {
|
) {
|
||||||
let mut actors = self.actors.lock().unwrap();
|
let mut actors = self.actors.lock().unwrap();
|
||||||
|
|
||||||
let (browsing_context_id, pipeline_id, worker_id) = ids;
|
let (browsing_context_id, pipeline_id, worker_id, webview_id) = ids;
|
||||||
|
|
||||||
let console_name = actors.new_name("console");
|
let console_name = actors.new_name("console");
|
||||||
|
|
||||||
|
@ -387,6 +387,7 @@ impl DevtoolsInstance {
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
let browsing_context_actor = BrowsingContextActor::new(
|
let browsing_context_actor = BrowsingContextActor::new(
|
||||||
console_name.clone(),
|
console_name.clone(),
|
||||||
|
webview_id,
|
||||||
browsing_context_id,
|
browsing_context_id,
|
||||||
page_info,
|
page_info,
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
|
|
|
@ -186,6 +186,8 @@ impl WorkerMethods<crate::DomTypeHolder> for Worker {
|
||||||
pipeline_id: global.pipeline_id(),
|
pipeline_id: global.pipeline_id(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let webview_id = global.webview_id().expect("global must have a webview id");
|
||||||
|
|
||||||
let browsing_context = global
|
let browsing_context = global
|
||||||
.downcast::<Window>()
|
.downcast::<Window>()
|
||||||
.map(|w| w.window_proxy().browsing_context_id())
|
.map(|w| w.window_proxy().browsing_context_id())
|
||||||
|
@ -207,7 +209,7 @@ impl WorkerMethods<crate::DomTypeHolder> for Worker {
|
||||||
is_top_level_global: false,
|
is_top_level_global: false,
|
||||||
};
|
};
|
||||||
let _ = chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
|
let _ = chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
|
||||||
(browsing_context, pipeline_id, Some(worker_id)),
|
(browsing_context, pipeline_id, Some(worker_id), webview_id),
|
||||||
devtools_sender.clone(),
|
devtools_sender.clone(),
|
||||||
page_info,
|
page_info,
|
||||||
));
|
));
|
||||||
|
|
|
@ -3248,7 +3248,12 @@ impl ScriptThread {
|
||||||
document.Title(),
|
document.Title(),
|
||||||
final_url.clone(),
|
final_url.clone(),
|
||||||
is_top_level_global,
|
is_top_level_global,
|
||||||
(incomplete.browsing_context_id, incomplete.pipeline_id, None),
|
(
|
||||||
|
incomplete.browsing_context_id,
|
||||||
|
incomplete.pipeline_id,
|
||||||
|
None,
|
||||||
|
incomplete.webview_id,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
document.set_https_state(metadata.https_state);
|
document.set_https_state(metadata.https_state);
|
||||||
|
@ -3278,7 +3283,12 @@ impl ScriptThread {
|
||||||
title: DOMString,
|
title: DOMString,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
is_top_level_global: bool,
|
is_top_level_global: bool,
|
||||||
(bc, p, w): (BrowsingContextId, PipelineId, Option<WorkerId>),
|
(browsing_context_id, pipeline_id, worker_id, webview_id): (
|
||||||
|
BrowsingContextId,
|
||||||
|
PipelineId,
|
||||||
|
Option<WorkerId>,
|
||||||
|
WebViewId,
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
if let Some(ref chan) = self.senders.devtools_server_sender {
|
if let Some(ref chan) = self.senders.devtools_server_sender {
|
||||||
let page_info = DevtoolsPageInfo {
|
let page_info = DevtoolsPageInfo {
|
||||||
|
@ -3287,14 +3297,17 @@ impl ScriptThread {
|
||||||
is_top_level_global,
|
is_top_level_global,
|
||||||
};
|
};
|
||||||
chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
|
chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
|
||||||
(bc, p, w),
|
(browsing_context_id, pipeline_id, worker_id, webview_id),
|
||||||
self.senders.devtools_client_to_script_thread_sender.clone(),
|
self.senders.devtools_client_to_script_thread_sender.clone(),
|
||||||
page_info.clone(),
|
page_info.clone(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let state = NavigationState::Stop(p, page_info);
|
let state = NavigationState::Stop(pipeline_id, page_info);
|
||||||
let _ = chan.send(ScriptToDevtoolsControlMsg::Navigate(bc, state));
|
let _ = chan.send(ScriptToDevtoolsControlMsg::Navigate(
|
||||||
|
browsing_context_id,
|
||||||
|
state,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::net::TcpStream;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use base::cross_process_instant::CrossProcessInstant;
|
use base::cross_process_instant::CrossProcessInstant;
|
||||||
use base::id::{BrowsingContextId, PipelineId};
|
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use http::{HeaderMap, Method};
|
use http::{HeaderMap, Method};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
@ -82,7 +82,7 @@ pub enum ScriptToDevtoolsControlMsg {
|
||||||
/// A new global object was created, associated with a particular pipeline.
|
/// A new global object was created, associated with a particular pipeline.
|
||||||
/// The means of communicating directly with it are provided.
|
/// The means of communicating directly with it are provided.
|
||||||
NewGlobal(
|
NewGlobal(
|
||||||
(BrowsingContextId, PipelineId, Option<WorkerId>),
|
(BrowsingContextId, PipelineId, Option<WorkerId>, WebViewId),
|
||||||
IpcSender<DevtoolScriptControlMsg>,
|
IpcSender<DevtoolScriptControlMsg>,
|
||||||
DevtoolsPageInfo,
|
DevtoolsPageInfo,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue