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,