mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Track the active tab and browsing context for devtools (#36168)
<!-- Please describe your changes on the following line: --> ---Part of #35867, per Step 5 suggestion. This PR: - Adds active_tab (via RefCell) to RootActor, updated in get_tab_msg_by_browser_id. - Adds browsing_context() helper to TabDescriptorActor. - Adds actor()`getter to TabDescriptorActorMsg for access in root.rs. -Creates the chain (Root - Tab - BrowsingContext) for routing colorSchemeSimulation. <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X ] `./mach build -d` does not report any errors - [X ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they’re structural setup for the actor chain and don’t change the system's behavior yet. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
parent
05e48c3d46
commit
f9831f2bea
3 changed files with 25 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
//!
|
||||
//! [Firefox JS implementation]: https://searchfox.org/mozilla-central/source/devtools/server/actors/root.js
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::net::TcpStream;
|
||||
|
||||
use serde::Serialize;
|
||||
|
@ -129,6 +130,7 @@ pub struct RootActor {
|
|||
pub device: String,
|
||||
pub preference: String,
|
||||
pub process: String,
|
||||
pub active_tab: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
impl Actor for RootActor {
|
||||
|
@ -303,13 +305,24 @@ impl RootActor {
|
|||
registry: &ActorRegistry,
|
||||
browser_id: u32,
|
||||
) -> Option<TabDescriptorActorMsg> {
|
||||
self.tabs
|
||||
let tab_msg = self
|
||||
.tabs
|
||||
.iter()
|
||||
.map(|target| {
|
||||
registry
|
||||
.find::<TabDescriptorActor>(target)
|
||||
.encodable(registry, true)
|
||||
})
|
||||
.find(|tab| tab.browser_id() == browser_id)
|
||||
.find(|tab| tab.browser_id() == browser_id);
|
||||
|
||||
if let Some(ref msg) = tab_msg {
|
||||
*self.active_tab.borrow_mut() = Some(msg.actor());
|
||||
}
|
||||
tab_msg
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn active_tab(&self) -> Option<String> {
|
||||
self.active_tab.borrow().clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ impl TabDescriptorActorMsg {
|
|||
pub fn browser_id(&self) -> u32 {
|
||||
self.browser_id
|
||||
}
|
||||
|
||||
pub fn actor(&self) -> String {
|
||||
self.actor.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -167,4 +171,9 @@ impl TabDescriptorActor {
|
|||
pub(crate) fn is_top_level_global(&self) -> bool {
|
||||
self.is_top_level_global
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn browsing_context(&self) -> String {
|
||||
self.browsing_context_actor.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ impl DevtoolsInstance {
|
|||
performance: performance.name(),
|
||||
preference: preference.name(),
|
||||
process: process.name(),
|
||||
active_tab: None.into(),
|
||||
});
|
||||
|
||||
registry.register(root);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue