From 14db4a194679369acef651a3fdb45bd66db12111 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 4 Jan 2016 10:46:30 +0800 Subject: [PATCH] Add isDevToolsFocused to webview --- atom/browser/api/atom_api_window.cc | 5 ----- atom/browser/api/atom_api_window.h | 1 - atom/browser/native_window.cc | 4 ---- atom/browser/native_window.h | 1 - atom/renderer/lib/web-view/web-view.coffee | 1 + docs/api/web-contents.md | 10 +++++++--- docs/api/web-view-tag.md | 4 ++++ 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 08b5bc4f7b7a..222f2cae03f1 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -468,10 +468,6 @@ bool Window::IsWebViewFocused() { return window_->IsWebViewFocused(); } -bool Window::IsDevToolsFocused() { - return window_->IsDevToolsFocused(); -} - void Window::SetRepresentedFilename(const std::string& filename) { window_->SetRepresentedFilename(filename); } @@ -670,7 +666,6 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("focusOnWebView", &Window::FocusOnWebView) .SetMethod("blurWebView", &Window::BlurWebView) .SetMethod("isWebViewFocused", &Window::IsWebViewFocused) - .SetMethod("isDevToolsFocused", &Window::IsDevToolsFocused) .SetMethod("capturePage", &Window::CapturePage) .SetMethod("setProgressBar", &Window::SetProgressBar) .SetMethod("setOverlayIcon", &Window::SetOverlayIcon) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 3611c6e33fbc..9297b2fe7562 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -121,7 +121,6 @@ class Window : public mate::TrackableObject, void FocusOnWebView(); void BlurWebView(); bool IsWebViewFocused(); - bool IsDevToolsFocused(); void SetRepresentedFilename(const std::string& filename); std::string GetRepresentedFilename(); void SetDocumentEdited(bool edited); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 3013923ecd8f..d946704b9f73 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -268,10 +268,6 @@ bool NativeWindow::IsWebViewFocused() { return host_view && host_view->HasFocus(); } -bool NativeWindow::IsDevToolsFocused() { - return inspectable_web_contents_->GetView()->IsDevToolsViewFocused(); -} - void NativeWindow::CapturePage(const gfx::Rect& rect, const CapturePageCallback& callback) { const auto view = web_contents()->GetRenderWidgetHostView(); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 3eb235b03c66..c60c0dd5f1d6 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -157,7 +157,6 @@ class NativeWindow : public base::SupportsUserData, virtual void FocusOnWebView(); virtual void BlurWebView(); virtual bool IsWebViewFocused(); - virtual bool IsDevToolsFocused(); // Captures the page with |rect|, |callback| would be called when capturing is // done. diff --git a/atom/renderer/lib/web-view/web-view.coffee b/atom/renderer/lib/web-view/web-view.coffee index 2d81bd6aa6e9..fc01725746ef 100644 --- a/atom/renderer/lib/web-view/web-view.coffee +++ b/atom/renderer/lib/web-view/web-view.coffee @@ -273,6 +273,7 @@ registerWebViewElement = -> 'openDevTools' 'closeDevTools' 'isDevToolsOpened' + 'isDevToolsFocused' 'inspectElement' 'setAudioMuted' 'isAudioMuted' diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 2057b515c025..7fd19103930c 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -596,15 +596,19 @@ Removes the specified path from DevTools workspace. * `options` Object (optional). Properties: * `detach` Boolean - opens DevTools in a new window -Opens the developer tools. +Opens the devtools. ### `webContents.closeDevTools()` -Closes the developer tools. +Closes the devtools. ### `webContents.isDevToolsOpened()` -Returns whether the developer tools are opened. +Returns whether the devtools is opened. + +### `webContents.isDevToolsFocused()` + +Returns whether the devtools view is focused . ### `webContents.toggleDevTools()` diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 79e759c8cb81..a4c1be0e20da 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -279,6 +279,10 @@ Closes the DevTools window of guest page. Returns a boolean whether guest page has a DevTools window attached. +### `.isDevToolsFocused()` + +Returns a boolean whether DevTools window of guest page is focused. + ### `.inspectElement(x, y)` * `x` Integer