From daa00e6539ece0cb91d4f6125403587c49376582 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 7 Aug 2014 14:48:02 +0800 Subject: [PATCH] views: Add some asserts and comments. --- atom/browser/native_window_views.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 75b8d55..d740af4 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -440,7 +440,7 @@ void NativeWindowViews::OnWidgetActivationChanged( else NotifyWindowBlur(); - // The menu bar should be hide when window is closed + // Hide menu bar when window is blured. if (!active && menu_bar_autohide_ && menu_bar_show_) { SetMenuBarVisibility(false); Layout(); @@ -538,6 +538,7 @@ views::NonClientFrameView* NativeWindowViews::CreateNonClientFrameView( } void NativeWindowViews::HandleMouseDown() { + // Hide menu bar when web view is clicked. if (menu_bar_autohide_ && menu_bar_show_) { SetMenuBarVisibility(false); Layout(); @@ -549,6 +550,7 @@ void NativeWindowViews::HandleKeyboardEvent( const content::NativeWebKeyboardEvent& event) { if (menu_bar_autohide_ && (event.modifiers & content::NativeWebKeyboardEvent::AltKey) && + // 164 and 165 represent VK_LALT and VK_RALT. (event.windowsKeyCode == 164 || event.windowsKeyCode == 165) && (event.type == blink::WebInputEvent::RawKeyDown)) { SetMenuBarVisibility(!menu_bar_show_); @@ -594,10 +596,13 @@ void NativeWindowViews::SetMenuBarVisibility(bool visible) { return; menu_bar_show_ = visible; - if (visible) + if (visible) { + DCHECK_EQ(child_count(), 1); AddChildView(menu_bar_.get()); - else + } else { + DCHECK_EQ(child_count(), 2); RemoveChildView(menu_bar_.get()); + } } // static -- 2.7.4