summaryrefslogtreecommitdiffstats
path: root/views/controls/menu/menu_scroll_view_container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls/menu/menu_scroll_view_container.cc')
-rw-r--r--views/controls/menu/menu_scroll_view_container.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc
index 64aa4ab..25817e4 100644
--- a/views/controls/menu/menu_scroll_view_container.cc
+++ b/views/controls/menu/menu_scroll_view_container.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -139,16 +139,15 @@ class MenuScrollViewContainer::MenuScrollView : public View {
AddChildView(child);
}
- virtual void ScrollRectToVisible(int x, int y, int width, int height) {
+ virtual void ScrollRectToVisible(const gfx::Rect& rect) {
// NOTE: this assumes we only want to scroll in the y direction.
+ // Convert rect.y() to view's coordinates and make sure we don't show past
+ // the bottom of the view.
View* child = GetContents();
- // Convert y to view's coordinates.
- y -= child->y();
- gfx::Size pref = child->GetPreferredSize();
- // Constrain y to make sure we don't show past the bottom of the view.
- y = std::max(0, std::min(pref.height() - this->height(), y));
- child->SetY(-y);
+ child->SetY(-std::max(0, std::min(
+ child->GetPreferredSize().height() - this->height(),
+ rect.y() - child->y())));
}
// Returns the contents, which is the SubmenuView.