diff --git a/components/devtools/actors/browsing_context.rs b/components/devtools/actors/browsing_context.rs index 56f3022b987..5875f039c66 100644 --- a/components/devtools/actors/browsing_context.rs +++ b/components/devtools/actors/browsing_context.rs @@ -10,7 +10,7 @@ use std::cell::{Cell, RefCell}; use std::collections::HashMap; 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::{DevtoolsPageInfo, NavigationState}; use ipc_channel::ipc::{self, IpcSender}; @@ -84,6 +84,9 @@ pub struct BrowsingContextActorMsg { actor: String, title: String, url: String, + /// This correspond to webview_id + #[serde(rename = "browserId")] + browser_id: u32, #[serde(rename = "outerWindowID")] outer_window_id: u32, #[serde(rename = "browsingContextID")] @@ -121,6 +124,8 @@ pub(crate) struct BrowsingContextActor { pub name: String, pub title: RefCell, pub url: RefCell, + /// This correspond to webview_id + pub browser_id: WebViewId, pub active_pipeline: Cell, pub browsing_context_id: BrowsingContextId, pub accessibility: String, @@ -173,6 +178,7 @@ impl Actor for BrowsingContextActor { impl BrowsingContextActor { pub(crate) fn new( console: String, + browser_id: WebViewId, browsing_context_id: BrowsingContextId, page_info: DevtoolsPageInfo, pipeline_id: PipelineId, @@ -225,6 +231,7 @@ impl BrowsingContextActor { title: RefCell::new(title), url: RefCell::new(url.into_string()), active_pipeline: Cell::new(pipeline_id), + browser_id, browsing_context_id, accessibility: accessibility.name(), console, @@ -263,6 +270,7 @@ impl BrowsingContextActor { }, title: self.title.borrow().clone(), url: self.url.borrow().clone(), + browser_id: self.browser_id.0.index.0.get(), //FIXME: shouldn't ignore pipeline namespace field browsing_context_id: self.browsing_context_id.index.0.get(), //FIXME: shouldn't ignore pipeline namespace field diff --git a/components/devtools/actors/root.rs b/components/devtools/actors/root.rs index 18a615993b2..2fb3c4de722 100644 --- a/components/devtools/actors/root.rs +++ b/components/devtools/actors/root.rs @@ -310,6 +310,6 @@ impl RootActor { .find::(target) .encodable(registry, true) }) - .find(|tab| tab.id() == browser_id) + .find(|tab| tab.browser_id() == browser_id) } } diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs index 7d91a274fea..702e765535e 100644 --- a/components/devtools/actors/tab.rs +++ b/components/devtools/actors/tab.rs @@ -25,6 +25,8 @@ use crate::protocol::JsonPacketStream; #[serde(rename_all = "camelCase")] pub struct TabDescriptorActorMsg { actor: String, + /// This correspond to webview_id + #[serde(rename = "browserId")] browser_id: u32, #[serde(rename = "browsingContextID")] browsing_context_id: u32, @@ -38,7 +40,7 @@ pub struct TabDescriptorActorMsg { } impl TabDescriptorActorMsg { - pub fn id(&self) -> u32 { + pub fn browser_id(&self) -> u32 { self.browser_id } } @@ -140,16 +142,16 @@ impl TabDescriptorActor { pub fn encodable(&self, registry: &ActorRegistry, selected: bool) -> TabDescriptorActorMsg { let ctx_actor = registry.find::(&self.browsing_context_actor); - let browser_id = ctx_actor.browsing_context_id.index.0.get(); - let outer_window_id = ctx_actor.active_pipeline.get().index.0.get(); + let browser_id = ctx_actor.browser_id.0.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 url = ctx_actor.url.borrow().clone(); TabDescriptorActorMsg { actor: self.name(), - browsing_context_id, browser_id, + browsing_context_id, is_zombie_tab: false, outer_window_id, selected, diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 3592d6a145a..b8768810bef 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -19,7 +19,7 @@ use std::net::{Shutdown, TcpListener, TcpStream}; use std::sync::{Arc, Mutex}; use std::thread; -use base::id::{BrowsingContextId, PipelineId}; +use base::id::{BrowsingContextId, PipelineId, WebViewId}; use crossbeam_channel::{Receiver, Sender, unbounded}; use devtools_traits::{ ChromeToDevtoolsControlMsg, ConsoleMessage, ConsoleMessageBuilder, DevtoolScriptControlMsg, @@ -343,13 +343,13 @@ impl DevtoolsInstance { // TODO: move this into the root or target modules? fn handle_new_global( &mut self, - ids: (BrowsingContextId, PipelineId, Option), + ids: (BrowsingContextId, PipelineId, Option, WebViewId), script_sender: IpcSender, page_info: DevtoolsPageInfo, ) { 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"); @@ -387,6 +387,7 @@ impl DevtoolsInstance { .or_insert_with(|| { let browsing_context_actor = BrowsingContextActor::new( console_name.clone(), + webview_id, browsing_context_id, page_info, pipeline_id, diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index d3af1287491..278fd541c0b 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -186,6 +186,8 @@ impl WorkerMethods for Worker { pipeline_id: global.pipeline_id(), }; + let webview_id = global.webview_id().expect("global must have a webview id"); + let browsing_context = global .downcast::() .map(|w| w.window_proxy().browsing_context_id()) @@ -207,7 +209,7 @@ impl WorkerMethods for Worker { is_top_level_global: false, }; let _ = chan.send(ScriptToDevtoolsControlMsg::NewGlobal( - (browsing_context, pipeline_id, Some(worker_id)), + (browsing_context, pipeline_id, Some(worker_id), webview_id), devtools_sender.clone(), page_info, )); diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index ef9be18b691..94f2cb48ddb 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -3248,7 +3248,12 @@ impl ScriptThread { document.Title(), final_url.clone(), 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); @@ -3278,7 +3283,12 @@ impl ScriptThread { title: DOMString, url: ServoUrl, is_top_level_global: bool, - (bc, p, w): (BrowsingContextId, PipelineId, Option), + (browsing_context_id, pipeline_id, worker_id, webview_id): ( + BrowsingContextId, + PipelineId, + Option, + WebViewId, + ), ) { if let Some(ref chan) = self.senders.devtools_server_sender { let page_info = DevtoolsPageInfo { @@ -3287,14 +3297,17 @@ impl ScriptThread { is_top_level_global, }; 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(), page_info.clone(), )) .unwrap(); - let state = NavigationState::Stop(p, page_info); - let _ = chan.send(ScriptToDevtoolsControlMsg::Navigate(bc, state)); + let state = NavigationState::Stop(pipeline_id, page_info); + let _ = chan.send(ScriptToDevtoolsControlMsg::Navigate( + browsing_context_id, + state, + )); } } diff --git a/components/shared/devtools/lib.rs b/components/shared/devtools/lib.rs index 4436b58cbc1..88a3649ac2a 100644 --- a/components/shared/devtools/lib.rs +++ b/components/shared/devtools/lib.rs @@ -16,7 +16,7 @@ use std::net::TcpStream; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use base::cross_process_instant::CrossProcessInstant; -use base::id::{BrowsingContextId, PipelineId}; +use base::id::{BrowsingContextId, PipelineId, WebViewId}; use bitflags::bitflags; use http::{HeaderMap, Method}; use ipc_channel::ipc::IpcSender; @@ -82,7 +82,7 @@ pub enum ScriptToDevtoolsControlMsg { /// A new global object was created, associated with a particular pipeline. /// The means of communicating directly with it are provided. NewGlobal( - (BrowsingContextId, PipelineId, Option), + (BrowsingContextId, PipelineId, Option, WebViewId), IpcSender, DevtoolsPageInfo, ),