diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:26:21 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:26:21 +0000 |
commit | 8a340e008c9ddf072d1deea25af7c142db7f8b50 (patch) | |
tree | a5a69500024f14615cfd2bc538ba104936537bc9 | |
parent | e88f7c284d81cdddcc60363d33d042d126e7f482 (diff) | |
download | chromium_src-8a340e008c9ddf072d1deea25af7c142db7f8b50.zip chromium_src-8a340e008c9ddf072d1deea25af7c142db7f8b50.tar.gz chromium_src-8a340e008c9ddf072d1deea25af7c142db7f8b50.tar.bz2 |
fixes for misc visual issues of domui menu
* use minimum width when set the bound of menu. This fixes
problem where menu was shown in incorrect place for short period of time
on OOBE.
* clears the content when menu is hidden. This fixes the problem where bigger menu window is showne when opening a menu.
* Update zoom controls only if the menu is root.
* use plain property for scrollEnabled.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3775003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62636 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/views/domui_menu_widget.cc | 17 | ||||
-rw-r--r-- | chrome/browser/resources/menu.js | 22 |
3 files changed, 23 insertions, 21 deletions
diff --git a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc index 21a2913..d5f7a6c 100644 --- a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc +++ b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc @@ -13,6 +13,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/chromeos/views/domui_menu_widget.h" #include "chrome/browser/chromeos/views/native_menu_domui.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_registrar.h" @@ -74,6 +75,10 @@ void WrenchMenuUI::Observe(NotificationType type, } void WrenchMenuUI::UpdateZoomControls() { + DOMUIMenuWidget* widget = DOMUIMenuWidget::FindDOMUIMenuWidget( + tab_contents()->GetNativeView()); + if (!widget || !widget->is_root()) + return; Browser* browser = BrowserList::GetLastActive(); if (!browser) return; diff --git a/chrome/browser/chromeos/views/domui_menu_widget.cc b/chrome/browser/chromeos/views/domui_menu_widget.cc index 4edfe68..9c34e61 100644 --- a/chrome/browser/chromeos/views/domui_menu_widget.cc +++ b/chrome/browser/chromeos/views/domui_menu_widget.cc @@ -270,6 +270,8 @@ void DOMUIMenuWidget::Init(gfx::NativeView parent, const gfx::Rect& bounds) { void DOMUIMenuWidget::Hide() { ReleaseGrab(); WidgetGtk::Hide(); + // Clears the content. + ExecuteJavascript(L"updateModel({'items':[]})"); } void DOMUIMenuWidget::Close() { @@ -403,9 +405,18 @@ void DOMUIMenuWidget::SetSize(const gfx::Size& new_size) { DCHECK(domui_menu_); // Ignore the empty new_size request which is called when // menu.html is loaded. - if (new_size.IsEmpty()) return; - - menu_locator_->SetBounds(this, new_size); + if (new_size.IsEmpty()) + return; + int width, height; + gtk_widget_get_size_request(GetNativeView(), &width, &height); + gfx::Size real_size(std::max(new_size.width(), width), + new_size.height()); + // Ignore the size request with the same size. + gfx::Rect bounds; + GetBounds(&bounds, false); + if (bounds.size() == real_size) + return; + menu_locator_->SetBounds(this, real_size); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/resources/menu.js b/chrome/browser/resources/menu.js index 805550c..b5d1afe 100644 --- a/chrome/browser/resources/menu.js +++ b/chrome/browser/resources/menu.js @@ -238,7 +238,7 @@ Menu.prototype = { * True to enable scroll button. * @type {boolean} */ - scrollEnabled_ : false, + scrollEnabled : false, /** * Decorates the menu element. @@ -443,21 +443,6 @@ Menu.prototype = { }, /** - * Enable/disable menu scroll. - * @param {boolean} enabled True to enable scroll, or false otherwise. - */ - set scrollEnabled(enabled) { - this.scrollEnabled_ = enabled; - }, - - /** - * Tells if the menu scroll is enabled. - */ - get scrollEnabled() { - return this.scrollEnabled_; - }, - - /** * Handle keyboard navigation and activation. * @private */ @@ -528,7 +513,8 @@ Menu.prototype = { onResize_: function() { var up = document.getElementById('scroll-up'); var down = document.getElementById('scroll-down'); - if (window.innerHeight == 0) { + // this needs to be < 2 as empty page has height of 1. + if (window.innerHeight < 2) { // menu window is not visible yet. just hide buttons. up.classList.add('hidden'); down.classList.add('hidden'); @@ -537,7 +523,7 @@ Menu.prototype = { // Do not use screen width to determin if we need scroll buttons // as the max renderer hight can be shorter than actual screen size. // TODO(oshima): Fix this when we implement transparent renderer. - if (this.scrollHeight > window.innerHeight && this.scrollEnabled_) { + if (this.scrollHeight > window.innerHeight && this.scrollEnabled) { this.style.height = (window.innerHeight - this.buttonHeight_) + 'px'; up.classList.remove('hidden'); down.classList.remove('hidden'); |