check content view in SetMenuBarVisibility

This commit is contained in:
Cheng Zhao 2018-05-08 15:24:53 +09:00
parent bb2715e7a5
commit ea97f43145
2 changed files with 7 additions and 11 deletions

View file

@ -4,7 +4,7 @@
#include "atom/browser/ui/cocoa/root_view_mac.h" #include "atom/browser/ui/cocoa/root_view_mac.h"
#include "atom/browser/native_window_mac.h" #include "atom/browser/native_window.h"
namespace atom { namespace atom {
@ -15,12 +15,10 @@ RootViewMac::RootViewMac(NativeWindow* window) : window_(window) {
RootViewMac::~RootViewMac() {} RootViewMac::~RootViewMac() {}
void RootViewMac::Layout() { void RootViewMac::Layout() {
views::View* content_view = if (!window_->content_view()) // Not ready yet.
static_cast<NativeWindowMac*>(window_)->content_view();
if (!content_view) // Not ready yet.
return; return;
content_view->SetBoundsRect(gfx::Rect(gfx::Point(), size())); window_->content_view()->SetBoundsRect(gfx::Rect(gfx::Point(), size()));
} }
gfx::Size RootViewMac::GetMinimumSize() const { gfx::Size RootViewMac::GetMinimumSize() const {

View file

@ -4,7 +4,7 @@
#include "atom/browser/ui/views/root_view.h" #include "atom/browser/ui/views/root_view.h"
#include "atom/browser/native_window_views.h" #include "atom/browser/native_window.h"
#include "atom/browser/ui/views/menu_bar.h" #include "atom/browser/ui/views/menu_bar.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
@ -86,7 +86,7 @@ bool RootView::IsMenuBarAutoHide() const {
} }
void RootView::SetMenuBarVisibility(bool visible) { void RootView::SetMenuBarVisibility(bool visible) {
if (!menu_bar_ || menu_bar_visible_ == visible) if (!window_->content_view() || !menu_bar_ || menu_bar_visible_ == visible)
return; return;
// Always show the accelerator when the auto-hide menu bar shows. // Always show the accelerator when the auto-hide menu bar shows.
@ -151,9 +151,7 @@ void RootView::ResetAltState() {
} }
void RootView::Layout() { void RootView::Layout() {
views::View* content_view = if (!window_->content_view()) // Not ready yet.
static_cast<NativeWindowViews*>(window_)->content_view();
if (!content_view) // Not ready yet.
return; return;
const auto menu_bar_bounds = const auto menu_bar_bounds =
@ -162,7 +160,7 @@ void RootView::Layout() {
if (menu_bar_) if (menu_bar_)
menu_bar_->SetBoundsRect(menu_bar_bounds); menu_bar_->SetBoundsRect(menu_bar_bounds);
content_view->SetBoundsRect( window_->content_view()->SetBoundsRect(
gfx::Rect(0, menu_bar_bounds.height(), size().width(), gfx::Rect(0, menu_bar_bounds.height(), size().width(),
size().height() - menu_bar_bounds.height())); size().height() - menu_bar_bounds.height()));
} }