From bd2ce5327c4c3d295832c2cdd8a8a6ee9b1ab0ff Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Jul 2016 15:47:52 -0700 Subject: [PATCH 1/2] Return early when render widget host view is null --- atom/browser/api/atom_api_web_contents_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents_mac.mm b/atom/browser/api/atom_api_web_contents_mac.mm index 19246e82ac7f..913951737fe8 100644 --- a/atom/browser/api/atom_api_web_contents_mac.mm +++ b/atom/browser/api/atom_api_web_contents_mac.mm @@ -13,6 +13,9 @@ namespace atom { namespace api { bool WebContents::IsFocused() const { + auto view = web_contents()->GetRenderWidgetHostView(); + if (!view) return false; + if (GetType() != BACKGROUND_PAGE) { auto window = web_contents()->GetTopLevelNativeWindow(); // On Mac the render widget host view does not lose focus when the window @@ -21,8 +24,7 @@ bool WebContents::IsFocused() const { return false; } - auto view = web_contents()->GetRenderWidgetHostView(); - return view && view->HasFocus(); + return view->HasFocus(); } } // namespace api From 5982e3a75ebc1578e60729d8ced873c65637aa11 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Jul 2016 15:48:01 -0700 Subject: [PATCH 2/2] Fix typo in comment --- atom/browser/api/atom_api_web_contents.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 0083ac71eb96..43ef9d35d5af 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -743,7 +743,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) { } // There are three ways of destroying a webContents: -// 1. call webContents.destory(); +// 1. call webContents.destroy(); // 2. garbage collection; // 3. user closes the window of webContents; // For webview only #1 will happen, for BrowserWindow both #1 and #3 may