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:
atbrakhi 2025-03-19 09:59:38 +01:00 committed by GitHub
parent 4acaa08cf5
commit 2362e4c134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 43 additions and 17 deletions

View file

@ -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<String>,
pub url: RefCell<String>,
/// This correspond to webview_id
pub browser_id: WebViewId,
pub active_pipeline: Cell<PipelineId>,
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

View file

@ -310,6 +310,6 @@ impl RootActor {
.find::<TabDescriptorActor>(target)
.encodable(registry, true)
})
.find(|tab| tab.id() == browser_id)
.find(|tab| tab.browser_id() == browser_id)
}
}

View file

@ -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::<BrowsingContextActor>(&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,

View file

@ -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<WorkerId>),
ids: (BrowsingContextId, PipelineId, Option<WorkerId>, WebViewId),
script_sender: IpcSender<DevtoolScriptControlMsg>,
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,

View file

@ -186,6 +186,8 @@ impl WorkerMethods<crate::DomTypeHolder> 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::<Window>()
.map(|w| w.window_proxy().browsing_context_id())
@ -207,7 +209,7 @@ impl WorkerMethods<crate::DomTypeHolder> 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,
));

View file

@ -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<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 {
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,
));
}
}

View file

@ -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<WorkerId>),
(BrowsingContextId, PipelineId, Option<WorkerId>, WebViewId),
IpcSender<DevtoolScriptControlMsg>,
DevtoolsPageInfo,
),