summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 23:34:07 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 23:34:07 +0000
commite9adf0702e30800cdfaebce8cfacff7b444b4e79 (patch)
tree49d8ab8fa6e0090c6dd7bbe667008f07e5939af0 /views/controls
parentae5f56fed71e801889db8f0f7ebd2f21d6612521 (diff)
downloadchromium_src-e9adf0702e30800cdfaebce8cfacff7b444b4e79.zip
chromium_src-e9adf0702e30800cdfaebce8cfacff7b444b4e79.tar.gz
chromium_src-e9adf0702e30800cdfaebce8cfacff7b444b4e79.tar.bz2
Replace lots of "int x, int y" with gfx::Point. Also use gfx::Size and gfx::Rect in a few more places.
BUG=none TEST=none Review URL: http://codereview.chromium.org/669130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/button.cc14
-rw-r--r--views/controls/button/button.h4
-rw-r--r--views/controls/button/button_dropdown.cc5
-rw-r--r--views/controls/button/button_dropdown.h5
-rw-r--r--views/controls/button/custom_button.cc6
-rw-r--r--views/controls/button/custom_button.h4
-rw-r--r--views/controls/button/image_button.cc7
-rw-r--r--views/controls/button/image_button.h4
-rw-r--r--views/controls/button/menu_button.cc6
-rw-r--r--views/controls/image_view.cc13
-rw-r--r--views/controls/image_view.h4
-rwxr-xr-xviews/controls/label.cc2
-rw-r--r--views/controls/label.h2
-rw-r--r--views/controls/label_unittest.cc16
-rw-r--r--views/controls/link.cc6
-rw-r--r--views/controls/link.h4
-rw-r--r--views/controls/menu/menu.h12
-rw-r--r--views/controls/menu/menu_controller.cc64
-rw-r--r--views/controls/menu/menu_controller.h8
-rw-r--r--views/controls/menu/menu_delegate.h9
-rw-r--r--views/controls/menu/menu_item_view.cc2
-rw-r--r--views/controls/menu/menu_item_view.h2
-rw-r--r--views/controls/menu/menu_scroll_view_container.cc15
-rw-r--r--views/controls/menu/menu_win.cc4
-rw-r--r--views/controls/menu/submenu_view.cc50
-rw-r--r--views/controls/native_control.cc16
-rw-r--r--views/controls/native_control_win.cc24
-rw-r--r--views/controls/resize_gripper.cc2
-rw-r--r--views/controls/resize_gripper.h2
-rw-r--r--views/controls/scroll_view.cc24
-rw-r--r--views/controls/scroll_view.h4
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc9
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.h5
-rw-r--r--views/controls/single_split_view.cc17
-rw-r--r--views/controls/single_split_view.h7
-rw-r--r--views/controls/tree/tree_view.cc7
36 files changed, 167 insertions, 218 deletions
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc
index 504a2f5..1183951 100644
--- a/views/controls/button/button.cc
+++ b/views/controls/button/button.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -20,12 +20,12 @@ void Button::SetTooltipText(const std::wstring& tooltip_text) {
////////////////////////////////////////////////////////////////////////////////
// Button, View overrides:
-bool Button::GetTooltipText(int x, int y, std::wstring* tooltip) {
- if (!tooltip_text_.empty()) {
- *tooltip = tooltip_text_;
- return true;
- }
- return false;
+bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
+ if (tooltip_text_.empty())
+ return false;
+
+ *tooltip = tooltip_text_;
+ return true;
}
bool Button::GetAccessibleKeyboardShortcut(std::wstring* shortcut) {
diff --git a/views/controls/button/button.h b/views/controls/button/button.h
index 9dd8b13..f9f6e5d 100644
--- a/views/controls/button/button.h
+++ b/views/controls/button/button.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -33,7 +33,7 @@ class Button : public View {
int mouse_event_flags() const { return mouse_event_flags_; }
// Overridden from View:
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
virtual bool GetAccessibleKeyboardShortcut(std::wstring* shortcut);
virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc
index a851c84..2d3f30e 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -106,7 +106,8 @@ void ButtonDropDown::OnMouseExited(const MouseEvent& e) {
//
////////////////////////////////////////////////////////////////////////////////
-void ButtonDropDown::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
+void ButtonDropDown::ShowContextMenu(const gfx::Point& p,
+ bool is_mouse_gesture) {
show_menu_factory_.RevokeAll();
// Make the button look depressed while the menu is open.
// NOTE: SetState() schedules a paint, but it won't occur until after the
diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h
index 118aebd..90aa260 100644
--- a/views/controls/button/button_dropdown.h
+++ b/views/controls/button/button_dropdown.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -39,8 +39,7 @@ class ButtonDropDown : public ImageButton {
// Overridden from View. Used to display the right-click menu, as triggered
// by the keyboard, for instance. Using the member function ShowDropDownMenu
// for the actual display.
- virtual void ShowContextMenu(int x,
- int y,
+ virtual void ShowContextMenu(const gfx::Point& p,
bool is_mouse_gesture);
// Overridden from CustomButton. Returns true if the button should become
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 91bc33c..ce499f1 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.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.
@@ -197,14 +197,14 @@ void CustomButton::OnDragDone() {
SetState(BS_NORMAL);
}
-void CustomButton::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
+void CustomButton::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
if (GetContextMenuController()) {
// We're about to show the context menu. Showing the context menu likely
// means we won't get a mouse exited and reset state. Reset it now to be
// sure.
if (state_ != BS_DISABLED)
SetState(BS_NORMAL);
- View::ShowContextMenu(x, y, is_mouse_gesture);
+ View::ShowContextMenu(p, is_mouse_gesture);
}
}
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index 032db17..c8977f8 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -76,7 +76,7 @@ class CustomButton : public Button,
virtual bool OnKeyPressed(const KeyEvent& e);
virtual bool OnKeyReleased(const KeyEvent& e);
virtual void OnDragDone();
- virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture);
+ virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture);
virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
virtual void SetHotTracked(bool flag);
virtual bool IsHotTracked() const;
diff --git a/views/controls/button/image_button.cc b/views/controls/button/image_button.cc
index adb4bc9..636a8fd 100644
--- a/views/controls/button/image_button.cc
+++ b/views/controls/button/image_button.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.
@@ -157,9 +157,10 @@ void ToggleImageButton::SetImage(ButtonState state, SkBitmap* image) {
////////////////////////////////////////////////////////////////////////////////
// ToggleImageButton, View overrides:
-bool ToggleImageButton::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool ToggleImageButton::GetTooltipText(const gfx::Point& p,
+ std::wstring* tooltip) {
if (!toggled_ || toggled_tooltip_text_.empty())
- return Button::GetTooltipText(x, y, tooltip);
+ return Button::GetTooltipText(p, tooltip);
*tooltip = toggled_tooltip_text_;
return true;
diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h
index 6c079fe..f16444a 100644
--- a/views/controls/button/image_button.h
+++ b/views/controls/button/image_button.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -89,7 +89,7 @@ class ToggleImageButton : public ImageButton {
virtual void SetImage(ButtonState aState, SkBitmap* anImage);
// Overridden from View:
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
private:
// The parent class's images_ member is used for the current images,
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index c3e8522..4c9f0fe 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -172,7 +172,7 @@ bool MenuButton::OnMousePressed(const MouseEvent& e) {
// If we're draggable (GetDragOperations returns a non-zero value), then
// don't pop on press, instead wait for release.
if (e.IsOnlyLeftMouseButton() && HitTest(e.location()) &&
- GetDragOperations(e.x(), e.y()) == DragDropTypes::DRAG_NONE) {
+ GetDragOperations(e.location()) == DragDropTypes::DRAG_NONE) {
TimeDelta delta = Time::Now() - menu_closed_time_;
int64 delta_in_milliseconds = delta.InMilliseconds();
if (delta_in_milliseconds > kMinimumTimeBetweenButtonClicks) {
@@ -189,7 +189,7 @@ void MenuButton::OnMouseReleased(const MouseEvent& e,
// !IsTriggerableEvent it could lead to a situation where we end up showing
// the menu and context menu (this would happen if the right button is not
// triggerable and there's a context menu).
- if (GetDragOperations(e.x(), e.y()) != DragDropTypes::DRAG_NONE &&
+ if (GetDragOperations(e.location()) != DragDropTypes::DRAG_NONE &&
state() != BS_DISABLED && !canceled && !InDrag() &&
e.IsOnlyLeftMouseButton() && HitTest(e.location())) {
Activate();
diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc
index eb918bd..2a7e18d 100644
--- a/views/controls/image_view.cc
+++ b/views/controls/image_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -182,13 +182,12 @@ std::wstring ImageView::GetTooltipText() {
return tooltip_text_;
}
-bool ImageView::GetTooltipText(int x, int y, std::wstring* tooltip) {
- if (tooltip_text_.empty()) {
+bool ImageView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
+ if (tooltip_text_.empty())
return false;
- } else {
- *tooltip = GetTooltipText();
- return true;
- }
+
+ *tooltip = GetTooltipText();
+ return true;
}
} // namespace views
diff --git a/views/controls/image_view.h b/views/controls/image_view.h
index fe7e711..a0da93a 100644
--- a/views/controls/image_view.h
+++ b/views/controls/image_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -78,7 +78,7 @@ class ImageView : public View {
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
// Overriden from View.
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
private:
// Compute the image origin given the desired size and the receiver alignment
diff --git a/views/controls/label.cc b/views/controls/label.cc
index 79f995a..f6f25d1 100755
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -363,7 +363,7 @@ void Label::SetTooltipText(const std::wstring& tooltip_text) {
tooltip_text_ = tooltip_text;
}
-bool Label::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool Label::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
DCHECK(tooltip);
// If a tooltip has been explicitly set, use it.
diff --git a/views/controls/label.h b/views/controls/label.h
index 04e22ee..9aeb951 100644
--- a/views/controls/label.h
+++ b/views/controls/label.h
@@ -154,7 +154,7 @@ class Label : public View {
// when the label is multiline, in which case it just returns false (no
// tooltip). If a custom tooltip has been specified with SetTooltipText()
// it is returned instead.
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
// Mouse enter/exit are overridden to render mouse over background color.
// These invoke SetContainsMouse as necessary.
diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc
index 48a0419..06c159d 100644
--- a/views/controls/label_unittest.cc
+++ b/views/controls/label_unittest.cc
@@ -116,42 +116,42 @@ TEST(LabelTest, TooltipProperty) {
label.SetText(test_text);
std::wstring tooltip;
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
EXPECT_EQ(test_text, tooltip);
std::wstring tooltip_text(L"The tooltip!");
label.SetTooltipText(tooltip_text);
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
EXPECT_EQ(tooltip_text, tooltip);
std::wstring empty_text;
label.SetTooltipText(empty_text);
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
EXPECT_EQ(test_text, tooltip);
// Make the label big enough to hold the text
// and expect there to be no tooltip.
label.SetBounds(0, 0, 1000, 40);
- EXPECT_FALSE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip));
// Verify that setting the tooltip still shows it.
label.SetTooltipText(tooltip_text);
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
EXPECT_EQ(tooltip_text, tooltip);
// Clear out the tooltip.
label.SetTooltipText(empty_text);
// Shrink the bounds and the tooltip should come back.
label.SetBounds(0, 0, 1, 1);
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
// Make the label multiline and there is no tooltip again.
label.SetMultiLine(true);
- EXPECT_FALSE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip));
// Verify that setting the tooltip still shows it.
label.SetTooltipText(tooltip_text);
- EXPECT_TRUE(label.GetTooltipText(0, 0, &tooltip));
+ EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
EXPECT_EQ(tooltip_text, tooltip);
// Clear out the tooltip.
label.SetTooltipText(empty_text);
diff --git a/views/controls/link.cc b/views/controls/link.cc
index 75b1043..e83c0cd 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.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.
@@ -158,8 +158,8 @@ void Link::SetEnabled(bool f) {
}
}
-gfx::NativeCursor Link::GetCursorForPoint(Event::EventType event_type, int x,
- int y) {
+gfx::NativeCursor Link::GetCursorForPoint(Event::EventType event_type,
+ const gfx::Point& p) {
if (!enabled_)
return NULL;
#if defined(OS_WIN)
diff --git a/views/controls/link.h b/views/controls/link.h
index bf5039b..8c281e3 100644
--- a/views/controls/link.h
+++ b/views/controls/link.h
@@ -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.
@@ -53,7 +53,7 @@ class Link : public Label {
virtual void SetEnabled(bool f);
virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
- int x, int y);
+ const gfx::Point& p);
virtual std::string GetClassName() const;
diff --git a/views/controls/menu/menu.h b/views/controls/menu/menu.h
index e3e1c78..624376c 100644
--- a/views/controls/menu/menu.h
+++ b/views/controls/menu/menu.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -10,6 +10,9 @@
#include "views/controls/menu/controller.h"
class SkBitmap;
+namespace gfx {
+class Point;
+}
namespace views {
@@ -71,13 +74,12 @@ class Menu {
// user does the appropriate gesture to show a context menu. The id
// identifies the id of the menu to show the context menu for.
// is_mouse_gesture is true if this is the result of a mouse gesture.
- // If this is not the result of a mouse gesture x/y is the recommended
- // location to display the content menu at. In either case, x/y is in
+ // If this is not the result of a mouse gesture |p| is the recommended
+ // location to display the content menu at. In either case, |p| is in
// screen coordinates.
virtual void ShowContextMenu(Menu* source,
int id,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
}
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index fb35908..49f68ed 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -42,7 +42,7 @@ namespace views {
// Convenience for scrolling the view such that the origin is visible.
static void ScrollToVisible(View* view) {
- view->ScrollRectToVisible(0, 0, view->width(), view->height());
+ view->ScrollRectToVisible(gfx::Rect(gfx::Point(), view->size()));
}
// MenuScrollTask --------------------------------------------------------------
@@ -97,14 +97,10 @@ class MenuController::MenuScrollTask {
const int delta_y = static_cast<int>(
(Time::Now() - start_scroll_time_).InMilliseconds() *
pixels_per_second_ / 1000);
- int target_y = start_y_;
- if (is_scrolling_up_)
- target_y = std::max(0, target_y - delta_y);
- else
- target_y = std::min(submenu_->height() - vis_rect.height(),
- target_y + delta_y);
- submenu_->ScrollRectToVisible(vis_rect.x(), target_y, vis_rect.width(),
- vis_rect.height());
+ vis_rect.set_y(is_scrolling_up_ ?
+ std::max(0, start_y_ - delta_y) :
+ std::min(submenu_->height() - vis_rect.height(), start_y_ + delta_y));
+ submenu_->ScrollRectToVisible(vis_rect);
}
// SubmenuView being scrolled.
@@ -347,8 +343,7 @@ void MenuController::OnMousePressed(SubmenuView* source,
} else {
if (part.menu->GetDelegate()->CanDrag(part.menu)) {
possible_drag_ = true;
- press_x_ = event.x();
- press_y_ = event.y();
+ press_pt_ = event.location();
}
if (part.menu->HasSubmenu())
open_submenu = true;
@@ -370,27 +365,23 @@ void MenuController::OnMouseDragged(SubmenuView* source,
return;
if (possible_drag_) {
- if (View::ExceededDragThreshold(event.x() - press_x_,
- event.y() - press_y_)) {
+ if (View::ExceededDragThreshold(event.x() - press_pt_.x(),
+ event.y() - press_pt_.y())) {
MenuItemView* item = state_.item;
DCHECK(item);
// Points are in the coordinates of the submenu, need to map to that of
// the selected item. Additionally source may not be the parent of
// the selected item, so need to map to screen first then to item.
- gfx::Point press_loc(press_x_, press_y_);
+ gfx::Point press_loc(press_pt_);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
View::ConvertPointToView(NULL, item, &press_loc);
- gfx::Point drag_loc(event.location());
- View::ConvertPointToScreen(source->GetScrollViewContainer(), &drag_loc);
- View::ConvertPointToView(NULL, item, &drag_loc);
gfx::Canvas canvas(item->width(), item->height(), false);
item->Paint(&canvas, true);
OSExchangeData data;
item->GetDelegate()->WriteDragData(item, &data);
- drag_utils::SetDragImageOnDataObject(canvas, item->width(),
- item->height(), press_loc.x(),
- press_loc.y(), &data);
+ drag_utils::SetDragImageOnDataObject(canvas, item->size(), press_loc,
+ &data);
StopScrolling();
int drag_ops = item->GetDelegate()->GetDragOperations(item);
item->GetRootView()->StartDragForViewFromMouseEvent(
@@ -437,8 +428,8 @@ void MenuController::OnMouseReleased(SubmenuView* source,
View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc);
// If we open a context menu just return now
- if (part.menu->GetDelegate()->ShowContextMenu(
- part.menu, part.menu->GetCommand(), loc.x(), loc.y(), true))
+ if (part.menu->GetDelegate()->ShowContextMenu(part.menu,
+ part.menu->GetCommand(), loc, true))
return;
}
@@ -521,12 +512,9 @@ int MenuController::OnDragUpdated(SubmenuView* source,
gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source, &screen_loc);
- if (valid_drop_coordinates_ && screen_loc.x() == drop_x_ &&
- screen_loc.y() == drop_y_) {
+ if (valid_drop_coordinates_ && screen_loc == drop_pt_)
return last_drop_operation_;
- }
- drop_x_ = screen_loc.x();
- drop_y_ = screen_loc.y();
+ drop_pt_ = screen_loc;
valid_drop_coordinates_ = true;
MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y());
@@ -549,10 +537,9 @@ int MenuController::OnDragUpdated(SubmenuView* source,
(menu_item_loc.y() > kDropBetweenPixels &&
menu_item_loc.y() < (menu_item_height - kDropBetweenPixels))) {
drop_position = MenuDelegate::DROP_ON;
- } else if (menu_item_loc.y() < menu_item_height / 2) {
- drop_position = MenuDelegate::DROP_BEFORE;
} else {
- drop_position = MenuDelegate::DROP_AFTER;
+ drop_position = (menu_item_loc.y() < menu_item_height / 2) ?
+ MenuDelegate::DROP_BEFORE : MenuDelegate::DROP_AFTER;
}
query_menu_item = menu_item;
} else {
@@ -562,17 +549,12 @@ int MenuController::OnDragUpdated(SubmenuView* source,
drop_operation = menu_item->GetDelegate()->GetDropOperation(
query_menu_item, event, &drop_position);
- if (menu_item->HasSubmenu()) {
- // The menu has a submenu, schedule the submenu to open.
- SetSelection(menu_item, true, false);
- } else {
- SetSelection(menu_item, false, false);
- }
+ // If the menu has a submenu, schedule the submenu to open.
+ SetSelection(menu_item, menu_item->HasSubmenu(), false);
if (drop_position == MenuDelegate::DROP_NONE ||
- drop_operation == DragDropTypes::DRAG_NONE) {
+ drop_operation == DragDropTypes::DRAG_NONE)
menu_item = NULL;
- }
} else {
SetSelection(source->GetMenuItem(), true, false);
}
@@ -666,8 +648,8 @@ bool MenuController::Dispatch(const MSG& msg) {
if (item && item->GetRootMenuItem() != item) {
gfx::Point screen_loc(0, item->height());
View::ConvertPointToScreen(item, &screen_loc);
- item->GetDelegate()->ShowContextMenu(
- item, item->GetCommand(), screen_loc.x(), screen_loc.y(), false);
+ item->GetDelegate()->ShowContextMenu(item, item->GetCommand(),
+ screen_loc, false);
}
return true;
}
diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h
index c92f4b9..f8a459a 100644
--- a/views/controls/menu/menu_controller.h
+++ b/views/controls/menu/menu_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -386,14 +386,12 @@ class MenuController : public MessageLoopForUI::Dispatcher {
bool possible_drag_;
// Location the mouse was pressed at. Used to detect d&d.
- int press_x_;
- int press_y_;
+ gfx::Point press_pt_;
// We get a slew of drag updated messages as the mouse is over us. To avoid
// continually processing whether we can drop, we cache the coordinates.
bool valid_drop_coordinates_;
- int drop_x_;
- int drop_y_;
+ gfx::Point drop_pt_;
int last_drop_operation_;
// If true, we're in the middle of invoking ShowAt on a submenu.
diff --git a/views/controls/menu/menu_delegate.h b/views/controls/menu/menu_delegate.h
index cbb295a..2ad1feb 100644
--- a/views/controls/menu/menu_delegate.h
+++ b/views/controls/menu/menu_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -59,14 +59,13 @@ class MenuDelegate : Controller {
// user does the appropriate gesture to show a context menu. The id
// identifies the id of the menu to show the context menu for.
// is_mouse_gesture is true if this is the result of a mouse gesture.
- // If this is not the result of a mouse gesture x/y is the recommended
- // location to display the content menu at. In either case, x/y is in
+ // If this is not the result of a mouse gesture |p| is the recommended
+ // location to display the content menu at. In either case, |p| is in
// screen coordinates.
// Returns true if a context menu was displayed, otherwise false
virtual bool ShowContextMenu(MenuItemView* source,
int id,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
return false;
}
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index 2c243c4..95e22d0 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -73,7 +73,7 @@ MenuItemView::~MenuItemView() {
delete submenu_;
}
-bool MenuItemView::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool MenuItemView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
*tooltip = tooltip_;
return !tooltip_.empty();
}
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h
index 6caa09a..b342356 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -72,7 +72,7 @@ class MenuItemView : public View {
virtual ~MenuItemView();
// Overridden from View:
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
// Returns the preferred height of menu items. This is only valid when the
// menu is about to be shown.
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.
diff --git a/views/controls/menu/menu_win.cc b/views/controls/menu/menu_win.cc
index a39ec44..fd03318 100644
--- a/views/controls/menu/menu_win.cc
+++ b/views/controls/menu/menu_win.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.
@@ -96,7 +96,7 @@ class MenuHostWindow : public app::WindowImpl {
void OnRButtonUp(UINT w_param, const CPoint& loc) {
int id;
if (menu_->delegate() && FindMenuIDByLocation(menu_, loc, &id))
- menu_->delegate()->ShowContextMenu(menu_, id, loc.x, loc.y, true);
+ menu_->delegate()->ShowContextMenu(menu_, id, gfx::Point(loc), true);
}
void OnMeasureItem(WPARAM w_param, MEASUREITEMSTRUCT* lpmis) {
diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc
index f89f51c..14aae44 100644
--- a/views/controls/menu/submenu_view.cc
+++ b/views/controls/menu/submenu_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -168,19 +168,13 @@ bool SubmenuView::OnMouseWheel(const MouseWheelEvent& e) {
// Find the index of the first menu item whose y-coordinate is >= visible
// y-coordinate.
- int first_vis_index = -1;
- for (int i = 0; i < menu_item_count; ++i) {
- MenuItemView* menu_item = GetMenuItemAt(i);
- if (menu_item->y() == vis_bounds.y()) {
- first_vis_index = i;
- break;
- } else if (menu_item->y() > vis_bounds.y()) {
- first_vis_index = std::max(0, i - 1);
- break;
- }
- }
- if (first_vis_index == -1)
+ int i = 0;
+ while ((i < menu_item_count) && (GetMenuItemAt(i)->y() < vis_bounds.y()))
+ ++i;
+ if (i == menu_item_count)
return true;
+ int first_vis_index = std::max(0,
+ (GetMenuItemAt(i)->y() == vis_bounds.y()) ? i : i - 1);
// If the first item isn't entirely visible, make it visible, otherwise make
// the next/previous one entirely visible.
@@ -189,31 +183,24 @@ bool SubmenuView::OnMouseWheel(const MouseWheelEvent& e) {
#elif defined(OS_LINUX)
int delta = abs(e.GetOffset());
#endif
- bool scroll_up = (e.GetOffset() > 0);
- while (delta-- > 0) {
- int scroll_amount = 0;
+ for (bool scroll_up = (e.GetOffset() > 0); delta != 0; --delta) {
+ int scroll_target;
if (scroll_up) {
if (GetMenuItemAt(first_vis_index)->y() == vis_bounds.y()) {
- if (first_vis_index != 0) {
- scroll_amount = GetMenuItemAt(first_vis_index - 1)->y() -
- vis_bounds.y();
- first_vis_index--;
- } else {
+ if (first_vis_index == 0)
break;
- }
- } else {
- scroll_amount = GetMenuItemAt(first_vis_index)->y() - vis_bounds.y();
+ first_vis_index--;
}
+ scroll_target = GetMenuItemAt(first_vis_index)->y();
} else {
- if (first_vis_index + 1 == GetMenuItemCount())
+ if (first_vis_index + 1 == menu_item_count)
break;
- scroll_amount = GetMenuItemAt(first_vis_index + 1)->y() -
- vis_bounds.y();
+ scroll_target = GetMenuItemAt(first_vis_index + 1)->y();
if (GetMenuItemAt(first_vis_index)->y() == vis_bounds.y())
first_vis_index++;
}
- ScrollRectToVisible(0, vis_bounds.y() + scroll_amount, vis_bounds.width(),
- vis_bounds.height());
+ ScrollRectToVisible(gfx::Rect(gfx::Point(0, scroll_target),
+ vis_bounds.size()));
vis_bounds = GetVisibleBounds();
}
@@ -238,7 +225,7 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent,
// Force construction of the scroll view container.
GetScrollViewContainer();
// Make sure the first row is visible.
- ScrollRectToVisible(0, 0, 1, 1);
+ ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1)));
host_->Init(parent, bounds, scroll_view_container_, do_capture);
}
@@ -318,8 +305,7 @@ void SubmenuView::SchedulePaintForDropIndicator(
if (position == MenuDelegate::DROP_ON) {
item->SchedulePaint();
} else if (position != MenuDelegate::DROP_NONE) {
- gfx::Rect bounds = CalculateDropIndicatorBounds(item, position);
- SchedulePaint(bounds.x(), bounds.y(), bounds.width(), bounds.height());
+ SchedulePaint(CalculateDropIndicatorBounds(item, position), false);
}
}
diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc
index 961066d..f6b1d75 100644
--- a/views/controls/native_control.cc
+++ b/views/controls/native_control.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.
@@ -260,16 +260,10 @@ void NativeControl::OnContextMenu(const POINT& location) {
if (!GetContextMenuController())
return;
- int x = location.x;
- int y = location.y;
- bool is_mouse = true;
- if (x == -1 && y == -1) {
- gfx::Point point = GetKeyboardContextMenuLocation();
- x = point.x();
- y = point.y();
- is_mouse = false;
- }
- ShowContextMenu(x, y, is_mouse);
+ if (location.x == -1 && location.y == -1)
+ ShowContextMenu(GetKeyboardContextMenuLocation(), false);
+ else
+ ShowContextMenu(gfx::Point(location), true);
}
void NativeControl::Focus() {
diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc
index 9f4d2d6..baa5a19 100644
--- a/views/controls/native_control_win.cc
+++ b/views/controls/native_control_win.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2009 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.
+// 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.
#include "views/controls/native_control_win.h"
+#include <windowsx.h>
+
#include "app/l10n_util_win.h"
#include "base/logging.h"
#include "base/win_util.h"
@@ -36,7 +38,7 @@ bool NativeControlWin::ProcessMessage(UINT message, WPARAM w_param,
LPARAM l_param, LRESULT* result) {
switch (message) {
case WM_CONTEXTMENU:
- ShowContextMenu(gfx::Point(LOWORD(l_param), HIWORD(l_param)));
+ ShowContextMenu(gfx::Point(GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)));
*result = 0;
return true;
case WM_CTLCOLORBTN:
@@ -99,16 +101,10 @@ void NativeControlWin::ShowContextMenu(const gfx::Point& location) {
if (!GetContextMenuController())
return;
- int x = location.x();
- int y = location.y();
- bool is_mouse = true;
- if (x == -1 && y == -1) {
- gfx::Point point = GetKeyboardContextMenuLocation();
- x = point.x();
- y = point.y();
- is_mouse = false;
- }
- View::ShowContextMenu(x, y, is_mouse);
+ if (location.x() == -1 && location.y() == -1)
+ View::ShowContextMenu(GetKeyboardContextMenuLocation(), false);
+ else
+ View::ShowContextMenu(location, true);
}
void NativeControlWin::NativeControlCreated(HWND native_control) {
diff --git a/views/controls/resize_gripper.cc b/views/controls/resize_gripper.cc
index 59a13aa..59a93ab 100644
--- a/views/controls/resize_gripper.cc
+++ b/views/controls/resize_gripper.cc
@@ -34,7 +34,7 @@ std::string ResizeGripper::GetClassName() const {
}
gfx::NativeCursor ResizeGripper::GetCursorForPoint(Event::EventType event_type,
- int x, int y) {
+ const gfx::Point& p) {
if (!enabled_)
return NULL;
#if defined(OS_WIN)
diff --git a/views/controls/resize_gripper.h b/views/controls/resize_gripper.h
index 204aa9f..588b01d 100644
--- a/views/controls/resize_gripper.h
+++ b/views/controls/resize_gripper.h
@@ -40,7 +40,7 @@ class ResizeGripper : public ImageView {
// Overridden from views::View:
virtual std::string GetClassName() const;
virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
- int x, int y);
+ const gfx::Point& p);
virtual bool OnMousePressed(const views::MouseEvent& event);
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
diff --git a/views/controls/scroll_view.cc b/views/controls/scroll_view.cc
index ec0bffa..33e096d 100644
--- a/views/controls/scroll_view.cc
+++ b/views/controls/scroll_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -19,15 +19,15 @@ class Viewport : public View {
Viewport() {}
virtual ~Viewport() {}
- virtual void ScrollRectToVisible(int x, int y, int width, int height) {
+ virtual void ScrollRectToVisible(const gfx::Rect& rect) {
if (!GetChildViewCount() || !GetParent())
return;
View* contents = GetChildViewAt(0);
- x -= contents->x();
- y -= contents->y();
+ gfx::Rect scroll_rect(rect);
+ scroll_rect.Offset(-contents->x(), -contents->y());
static_cast<ScrollView*>(GetParent())->ScrollContentsRegionToBeVisible(
- x, y, width, height);
+ scroll_rect);
}
private:
@@ -268,10 +268,7 @@ gfx::Rect ScrollView::GetVisibleRect() const {
return gfx::Rect(x, y, viewport_->width(), viewport_->height());
}
-void ScrollView::ScrollContentsRegionToBeVisible(int x,
- int y,
- int width,
- int height) {
+void ScrollView::ScrollContentsRegionToBeVisible(const gfx::Rect& rect) {
if (!contents_ || ((!horiz_sb_ || !horiz_sb_->IsVisible()) &&
(!vert_sb_ || !vert_sb_->IsVisible()))) {
return;
@@ -284,16 +281,15 @@ void ScrollView::ScrollContentsRegionToBeVisible(int x,
std::max(viewport_->height(), contents_->height());
// Make sure x and y are within the bounds of [0,contents_max_*].
- x = std::max(0, std::min(contents_max_x, x));
- y = std::max(0, std::min(contents_max_y, y));
+ int x = std::max(0, std::min(contents_max_x, rect.x()));
+ int y = std::max(0, std::min(contents_max_y, rect.y()));
// Figure out how far and down the rectangle will go taking width
// and height into account. This will be "clipped" by the viewport.
const int max_x = std::min(contents_max_x,
- x + std::min(width, viewport_->width()));
+ x + std::min(rect.width(), viewport_->width()));
const int max_y = std::min(contents_max_y,
- y + std::min(height,
- viewport_->height()));
+ y + std::min(rect.height(), viewport_->height()));
// See if the rect is already visible. Note the width is (max_x - x)
// and the height is (max_y - y) to take into account the clipping of
diff --git a/views/controls/scroll_view.h b/views/controls/scroll_view.h
index 43853ad..c05c9e9 100644
--- a/views/controls/scroll_view.h
+++ b/views/controls/scroll_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -55,7 +55,7 @@ class ScrollView : public View,
//
// Client code should use ScrollRectToVisible, which invokes this
// appropriately.
- void ScrollContentsRegionToBeVisible(int x, int y, int width, int height);
+ void ScrollContentsRegionToBeVisible(const gfx::Rect& rect);
// ScrollBarController.
// NOTE: this is intended to be invoked by the ScrollBar, and NOT general
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index ef594c8..bccf9a1 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.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.
@@ -546,13 +546,12 @@ enum ScrollBarContextMenuCommands {
};
void BitmapScrollBar::ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
Widget* widget = GetWidget();
gfx::Rect widget_bounds;
widget->GetBounds(&widget_bounds, true);
- gfx::Point temp_pt(x - widget_bounds.x(), y - widget_bounds.y());
+ gfx::Point temp_pt(p.x() - widget_bounds.x(), p.y() - widget_bounds.y());
View::ConvertPointFromWidget(this, &temp_pt);
context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y();
@@ -568,7 +567,7 @@ void BitmapScrollBar::ShowContextMenu(View* source,
menu->AppendSeparator();
menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev);
menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext);
- menu->RunMenuAt(x, y);
+ menu->RunMenuAt(p.x(), p.y());
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/bitmap_scroll_bar.h
index cb6603b..9a22a2e 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.h
+++ b/views/controls/scrollbar/bitmap_scroll_bar.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -114,8 +114,7 @@ class BitmapScrollBar : public ScrollBar,
// ContextMenuController overrides.
virtual void ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
// Menu::Delegate overrides:
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index 30ecc34..d3031ce 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -115,9 +115,10 @@ gfx::Size SingleSplitView::GetPreferredSize() {
return gfx::Size(width, height);
}
-gfx::NativeCursor SingleSplitView::GetCursorForPoint(Event::EventType event_type,
- int x, int y) {
- if (IsPointInDivider(x, y)) {
+gfx::NativeCursor SingleSplitView::GetCursorForPoint(
+ Event::EventType event_type,
+ const gfx::Point& p) {
+ if (IsPointInDivider(p)) {
#if defined(OS_WIN)
static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE);
static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS);
@@ -132,7 +133,7 @@ gfx::NativeCursor SingleSplitView::GetCursorForPoint(Event::EventType event_type
}
bool SingleSplitView::OnMousePressed(const MouseEvent& event) {
- if (!IsPointInDivider(event.x(), event.y()))
+ if (!IsPointInDivider(event.location()))
return false;
drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y());
drag_info_.initial_divider_offset = divider_offset_;
@@ -172,7 +173,7 @@ void SingleSplitView::OnMouseReleased(const MouseEvent& event, bool canceled) {
}
}
-bool SingleSplitView::IsPointInDivider(int x, int y) {
+bool SingleSplitView::IsPointInDivider(const gfx::Point& p) {
if (GetChildViewCount() < 2)
return false;
@@ -182,9 +183,9 @@ bool SingleSplitView::IsPointInDivider(int x, int y) {
int divider_relative_offset;
if (is_horizontal_) {
divider_relative_offset =
- x - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width();
+ p.x() - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width();
} else {
- divider_relative_offset = y - GetChildViewAt(0)->height();
+ divider_relative_offset = p.y() - GetChildViewAt(0)->height();
}
return (divider_relative_offset >= 0 &&
divider_relative_offset < kDividerSize);
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index af982e4..3ed92ac 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -31,8 +31,7 @@ class SingleSplitView : public views::View {
// Overriden to return a resize cursor when over the divider.
virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
- int x,
- int y);
+ const gfx::Point& p);
void set_divider_offset(int divider_offset) {
divider_offset_ = divider_offset;
@@ -53,7 +52,7 @@ class SingleSplitView : public views::View {
private:
// Returns true if |x| or |y| is over the divider.
- bool IsPointInDivider(int x, int y);
+ bool IsPointInDivider(const gfx::Point& p);
// Returns width in case of horizontal split and height otherwise.
int GetPrimaryAxisSize() {
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index 68bd822..f61b4c58 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -520,8 +520,7 @@ void TreeView::OnContextMenu(const POINT& location) {
TVHITTESTINFO hit_info;
gfx::Point local_loc(location);
ConvertPointToView(NULL, this, &local_loc);
- hit_info.pt.x = local_loc.x();
- hit_info.pt.y = local_loc.y();
+ hit_info.pt = local_loc.ToPOINT();
HTREEITEM hit_item = TreeView_HitTest(tree_view_, &hit_info);
if (!hit_item ||
GetNodeDetails(GetSelectedNode())->tree_item != hit_item ||
@@ -530,7 +529,7 @@ void TreeView::OnContextMenu(const POINT& location) {
return;
}
}
- ShowContextMenu(location.x, location.y, true);
+ ShowContextMenu(gfx::Point(location), true);
}
TreeModelNode* TreeView::GetNodeForTreeItem(HTREEITEM tree_item) {