]> khamidou — GitHub mirrors - electron.git/commitdiff
views: Add menu should not change window size.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 21 Jul 2014 12:58:15 +0000 (20:58 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 21 Jul 2014 12:58:15 +0000 (20:58 +0800)
atom/browser/native_window_views.cc
atom/browser/native_window_views.h
spec/api-browser-window-spec.coffee

index b123c09fd1bd7d7bb2193a4a82c07fb4c4ca59bc..981b150301ce6ddf749e70c8881dcbd2b2d15485 100644 (file)
@@ -65,6 +65,7 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
       menu_bar_(NULL),
       web_view_(inspectable_web_contents()->GetView()->GetView()),
       keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
+      use_content_size_(false),
       resizable_(true) {
   options.Get(switches::kResizable, &resizable_);
   options.Get(switches::kTitle, &title_);
@@ -102,10 +103,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
   set_background(views::Background::CreateStandardPanelBackground());
   AddChildView(web_view_);
 
-  bool use_content_size;
   if (has_frame_ &&
-      options.Get(switches::kUseContentSize, &use_content_size) &&
-      use_content_size)
+      options.Get(switches::kUseContentSize, &use_content_size_) &&
+      use_content_size_)
     bounds = ContentBoundsToWindowBounds(bounds);
 
   window_->CenterWindow(bounds.size());
@@ -302,7 +302,9 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
     gfx::Size content_size = GetContentSize();
     menu_bar_ = new MenuBar;
     AddChildViewAt(menu_bar_, 0);
-    SetContentSize(content_size);
+
+    if (use_content_size_)
+      SetContentSize(content_size);
   }
 
   menu_bar_->SetMenu(menu_model);
index c4cf6cb80940e3f720cfb426d06d5af2243947dc..d4db4934e4c24be7f73a35bf8b9145c41be17cb6 100644 (file)
@@ -132,6 +132,7 @@ class NativeWindowViews : public NativeWindow,
   // Map from accelerator to menu item's command id.
   accelerator_util::AcceleratorTable accelerator_table_;
 
+  bool use_content_size_;
   bool resizable_;
   std::string title_;
   gfx::Size minimum_size_;
index f9eb37d4d92766bcc3b0319f52d680407e1cf6e0..957ea271d092bf9c0544563b3fb343a89e45a79a 100644 (file)
@@ -103,12 +103,9 @@ describe 'browser-window module', ->
       assert.equal contentSize[1], 400
 
     it 'make window created with window size when not used', ->
-      # No way to reliably set size when window has not been shown on Linux.
-      return if process.platform is 'linux'
-
-      contentSize = w.getSize()
-      assert.equal contentSize[0], 400
-      assert.equal contentSize[1], 400
+      size = w.getSize()
+      assert.equal size[0], 400
+      assert.equal size[1], 400
 
   describe 'beforeunload handler', ->
     it 'returning true would not prevent close', (done) ->