mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
feat: Focus DevTools when breakpoint is triggered (#48701)
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
if (life_stage_ != kLoadCompleted)
return;
\#if BUILDFLAG(IS_ANDROID)
NOTIMPLEMENTED();
\#else
if (is_docked_ && GetInspectedBrowserWindow())
main_web_contents_->Focus();
else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.
Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.
Only supported for DevTools manged by `electron::InspectableWebContents`.
Closes: #37388
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michał Pichliński <michal.pichlinski@here.io>
This commit is contained in:
@@ -519,6 +519,12 @@ void InspectableWebContents::UpdateDevToolsZoomLevel(double level) {
|
||||
}
|
||||
|
||||
void InspectableWebContents::ActivateWindow() {
|
||||
if (embedder_message_dispatcher_) {
|
||||
if (managed_devtools_web_contents_ && view_) {
|
||||
view_->ActivateDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
// Set the zoom level.
|
||||
SetZoomLevelForWebContents(GetDevToolsWebContents(), GetDevToolsZoomLevel());
|
||||
}
|
||||
|
||||
@@ -132,6 +132,23 @@ void InspectableWebContentsView::ShowDevTools(bool activate) {
|
||||
}
|
||||
}
|
||||
|
||||
void InspectableWebContentsView::ActivateDevTools() {
|
||||
if (!devtools_visible_) {
|
||||
return;
|
||||
}
|
||||
if (devtools_window_) {
|
||||
if (!devtools_window_->IsActive()) {
|
||||
devtools_window_->Activate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (devtools_web_view_) {
|
||||
if (!devtools_web_view_->HasFocus()) {
|
||||
devtools_web_view_->RequestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InspectableWebContentsView::CloseDevTools() {
|
||||
if (!devtools_visible_)
|
||||
return;
|
||||
|
||||
@@ -49,6 +49,7 @@ class InspectableWebContentsView : public views::View {
|
||||
void SetCornerRadii(const gfx::RoundedCornersF& corner_radii);
|
||||
|
||||
void ShowDevTools(bool activate);
|
||||
void ActivateDevTools();
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsViewShowing();
|
||||
bool IsDevToolsViewFocused();
|
||||
|
||||
Reference in New Issue
Block a user