Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Return early when render widget host view is null
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki authored and bridiver committed Jul 29, 2016
1 parent ede32c2 commit bf0cc2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions atom/browser/api/atom_api_web_contents_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ - (BOOL)isKeyWindow;
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
Expand All @@ -21,8 +24,7 @@ - (BOOL)isKeyWindow;
return false;
}

auto view = web_contents()->GetRenderWidgetHostView();
return view && view->HasFocus();
return view->HasFocus();
}

} // namespace api
Expand Down

0 comments on commit bf0cc2b

Please sign in to comment.