summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/os_exchange_data_provider_gtk.cc16
-rw-r--r--app/os_exchange_data_provider_gtk.h13
-rw-r--r--base/gfx/rect.cc5
-rw-r--r--chrome/browser/chromeos/compact_location_bar_view.cc9
-rw-r--r--chrome/browser/chromeos/compact_location_bar_view.h13
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc7
-rw-r--r--chrome/browser/chromeos/frame/browser_view.h3
-rw-r--r--chrome/browser/extensions/browser_action_test_util_views.cc2
-rw-r--r--chrome/browser/views/accessible_toolbar_view.cc6
-rw-r--r--chrome/browser/views/accessible_toolbar_view.h4
-rw-r--r--chrome/browser/views/autofill_profiles_view_win.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc84
-rw-r--r--chrome/browser/views/bookmark_bar_view.h21
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc7
-rw-r--r--chrome/browser/views/bookmark_editor_view.h5
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc71
-rw-r--r--chrome/browser/views/bookmark_manager_view.h9
-rw-r--r--chrome/browser/views/bookmark_menu_controller_views.cc7
-rw-r--r--chrome/browser/views/bookmark_menu_controller_views.h5
-rw-r--r--chrome/browser/views/browser_actions_container.cc17
-rw-r--r--chrome/browser/views/browser_actions_container.h11
-rw-r--r--chrome/browser/views/content_blocked_bubble_contents.cc6
-rw-r--r--chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc8
-rw-r--r--chrome/browser/views/extensions/browser_action_overflow_menu_controller.h3
-rw-r--r--chrome/browser/views/go_button.cc4
-rw-r--r--chrome/browser/views/go_button.h4
-rw-r--r--chrome/browser/views/tabs/tab.cc11
-rw-r--r--chrome/browser/views/tabs/tab.h9
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc4
-rw-r--r--chrome/browser/views/task_manager_view.cc10
-rw-r--r--chrome/browser/views/toolbar_view.cc8
-rw-r--r--chrome/browser/views/toolbar_view.h13
-rw-r--r--views/accessibility/view_accessibility.cc7
-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
-rw-r--r--views/drag_utils.cc12
-rw-r--r--views/drag_utils.h10
-rw-r--r--views/drag_utils_gtk.cc19
-rw-r--r--views/drag_utils_win.cc27
-rw-r--r--views/examples/scroll_view_example.h3
-rw-r--r--views/view.cc79
-rw-r--r--views/view.h59
-rw-r--r--views/view_unittest.cc4
-rw-r--r--views/widget/root_view.cc13
-rw-r--r--views/widget/root_view.h5
-rw-r--r--views/widget/tooltip_manager_gtk.cc8
-rw-r--r--views/widget/tooltip_manager_win.cc12
-rw-r--r--views/widget/widget_gtk.cc4
82 files changed, 455 insertions, 592 deletions
diff --git a/app/os_exchange_data_provider_gtk.cc b/app/os_exchange_data_provider_gtk.cc
index dbae20e..db4c249 100644
--- a/app/os_exchange_data_provider_gtk.cc
+++ b/app/os_exchange_data_provider_gtk.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.
@@ -17,17 +17,13 @@ OSExchangeDataProviderGtk::OSExchangeDataProviderGtk(
: known_formats_(known_formats),
known_custom_formats_(known_custom_formats),
formats_(0),
- drag_image_(NULL),
- cursor_offset_x_(0),
- cursor_offset_y_(0) {
+ drag_image_(NULL) {
}
OSExchangeDataProviderGtk::OSExchangeDataProviderGtk()
: known_formats_(0),
formats_(0),
- drag_image_(NULL),
- cursor_offset_x_(0),
- cursor_offset_y_(0) {
+ drag_image_(NULL) {
}
OSExchangeDataProviderGtk::~OSExchangeDataProviderGtk() {
@@ -227,14 +223,12 @@ bool OSExchangeDataProviderGtk::GetPlainTextURL(GURL* url) const {
}
void OSExchangeDataProviderGtk::SetDragImage(GdkPixbuf* drag_image,
- int cursor_offset_x,
- int cursor_offset_y) {
+ const gfx::Point& cursor_offset) {
if (drag_image_)
g_object_unref(drag_image_);
g_object_ref(drag_image);
drag_image_ = drag_image;
- cursor_offset_x_ = cursor_offset_x;
- cursor_offset_y_ = cursor_offset_y;
+ cursor_offset_ = cursor_offset;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/app/os_exchange_data_provider_gtk.h b/app/os_exchange_data_provider_gtk.h
index 9a56a2d..a53957d 100644
--- a/app/os_exchange_data_provider_gtk.h
+++ b/app/os_exchange_data_provider_gtk.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.
@@ -12,6 +12,7 @@
#include <vector>
#include "app/os_exchange_data.h"
+#include "base/gfx/point.h"
#include "base/pickle.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"
@@ -71,12 +72,9 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider {
// Set the image and cursor offset data for this drag. Will
// increment the ref count of pixbuf.
- void SetDragImage(GdkPixbuf* pixbuf,
- int cursor_offset_x,
- int cursor_offset_y);
+ void SetDragImage(GdkPixbuf* pixbuf, const gfx::Point& cursor_offset);
GdkPixbuf* drag_image() const { return drag_image_; }
- int cursor_offset_x() const { return cursor_offset_x_; }
- int cursor_offset_y() const { return cursor_offset_y_; }
+ gfx::Point cursor_offset() const { return cursor_offset_; }
private:
typedef std::map<OSExchangeData::CustomFormat, Pickle> PickleData;
@@ -110,8 +108,7 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider {
// Drag image and offset data.
GdkPixbuf* drag_image_;
- int cursor_offset_x_;
- int cursor_offset_y_;
+ gfx::Point cursor_offset_;
DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderGtk);
};
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc
index 961fa03..a3c6712 100644
--- a/base/gfx/rect.cc
+++ b/base/gfx/rect.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.
@@ -111,8 +111,7 @@ void Rect::Inset(int left, int top, int right, int bottom) {
}
void Rect::Offset(int horizontal, int vertical) {
- set_x(x() + horizontal);
- set_y(y() + vertical);
+ origin_.Offset(horizontal, vertical);
}
bool Rect::operator==(const Rect& other) const {
diff --git a/chrome/browser/chromeos/compact_location_bar_view.cc b/chrome/browser/chromeos/compact_location_bar_view.cc
index 2083664..0907689 100644
--- a/chrome/browser/chromeos/compact_location_bar_view.cc
+++ b/chrome/browser/chromeos/compact_location_bar_view.cc
@@ -277,11 +277,9 @@ gfx::Rect CompactLocationBarView::GetLocationStackBounds() const {
////////////////////////////////////////////////////////////////////////////////
// views::DragController overrides:
void CompactLocationBarView::WriteDragData(views::View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data) {
- DCHECK(
- GetDragOperations(sender, press_x, press_y) != DragDropTypes::DRAG_NONE);
+ DCHECK(GetDragOperations(sender, press_pt) != DragDropTypes::DRAG_NONE);
UserMetrics::RecordAction("CompactLocationBar_DragStar",
browser()->profile());
@@ -309,8 +307,7 @@ void CompactLocationBarView::WriteDragData(views::View* sender,
}
int CompactLocationBarView::GetDragOperations(views::View* sender,
- int x,
- int y) {
+ const gfx::Point& p) {
DCHECK(sender == star_);
TabContents* tab = browser()->GetSelectedTabContents();
if (!tab || !tab->ShouldDisplayURL() || !tab->GetURL().is_valid()) {
diff --git a/chrome/browser/chromeos/compact_location_bar_view.h b/chrome/browser/chromeos/compact_location_bar_view.h
index 3364158..e4f8d73 100644
--- a/chrome/browser/chromeos/compact_location_bar_view.h
+++ b/chrome/browser/chromeos/compact_location_bar_view.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.
@@ -86,15 +86,12 @@ class CompactLocationBarView : public DropdownBarView,
// views::DragController implementation.
virtual void WriteDragData(View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data);
- virtual int GetDragOperations(View* sender, int x, int y);
+ virtual int GetDragOperations(View* sender, const gfx::Point& p);
virtual bool CanStartDrag(View* sender,
- int press_x,
- int press_y,
- int x,
- int y) {
+ const gfx::Point& press_pt,
+ const gfx::Point& p) {
return true;
}
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index ca90857..ff3836a 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -465,17 +465,18 @@ void BrowserView::ButtonPressed(views::Button* sender,
}
// views::ContextMenuController overrides.
-void BrowserView::ShowContextMenu(views::View* source, int x, int y,
+void BrowserView::ShowContextMenu(views::View* source,
+ const gfx::Point& p,
bool is_mouse_gesture) {
// Only show context menu if point is in unobscured parts of browser, i.e.
// if NonClientHitTest returns :
// - HTCAPTION: in title bar or unobscured part of tabstrip
// - HTNOWHERE: as the name implies.
- gfx::Point point_in_parent_coords(x, y);
+ gfx::Point point_in_parent_coords(p);
views::View::ConvertPointToView(NULL, GetParent(), &point_in_parent_coords);
int hit_test = NonClientHitTest(point_in_parent_coords);
if (hit_test == HTCAPTION || hit_test == HTNOWHERE)
- system_menu_menu_->RunMenuAt(gfx::Point(x, y), views::Menu2::ALIGN_TOPLEFT);
+ system_menu_menu_->RunMenuAt(p, views::Menu2::ALIGN_TOPLEFT);
}
// StatusAreaHost overrides.
diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h
index 223c190..a848172 100644
--- a/chrome/browser/chromeos/frame/browser_view.h
+++ b/chrome/browser/chromeos/frame/browser_view.h
@@ -72,8 +72,7 @@ class BrowserView : public ::BrowserView,
// views::ContextMenuController overrides.
virtual void ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
// StatusAreaHost overrides.
diff --git a/chrome/browser/extensions/browser_action_test_util_views.cc b/chrome/browser/extensions/browser_action_test_util_views.cc
index 3e6b2972..69b034c 100644
--- a/chrome/browser/extensions/browser_action_test_util_views.cc
+++ b/chrome/browser/extensions/browser_action_test_util_views.cc
@@ -52,7 +52,7 @@ std::string BrowserActionTestUtil::GetExtensionId(int index) {
std::string BrowserActionTestUtil::GetTooltip(int index) {
std::wstring text;
GetContainer(browser_)->GetBrowserActionViewAt(index)->button()->
- GetTooltipText(0, 0, &text);
+ GetTooltipText(gfx::Point(), &text);
return WideToUTF8(text);
}
diff --git a/chrome/browser/views/accessible_toolbar_view.cc b/chrome/browser/views/accessible_toolbar_view.cc
index 3556fe7..d85648d0 100644
--- a/chrome/browser/views/accessible_toolbar_view.cc
+++ b/chrome/browser/views/accessible_toolbar_view.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.
@@ -90,10 +90,10 @@ void AccessibleToolbarView::WillLoseFocus() {
}
}
-void AccessibleToolbarView::ShowContextMenu(int x, int y,
+void AccessibleToolbarView::ShowContextMenu(const gfx::Point& p,
bool is_mouse_gesture) {
if (selected_focused_view_)
- selected_focused_view_->ShowContextMenu(x, y, is_mouse_gesture);
+ selected_focused_view_->ShowContextMenu(p, is_mouse_gesture);
}
void AccessibleToolbarView::RequestFocus() {
diff --git a/chrome/browser/views/accessible_toolbar_view.h b/chrome/browser/views/accessible_toolbar_view.h
index f892a74..f2ef13f 100644
--- a/chrome/browser/views/accessible_toolbar_view.h
+++ b/chrome/browser/views/accessible_toolbar_view.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.
@@ -27,7 +27,7 @@ class AccessibleToolbarView : public views::View {
virtual bool OnKeyPressed(const views::KeyEvent& e);
virtual bool OnKeyReleased(const views::KeyEvent& e);
virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e);
- virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture);
+ virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture);
virtual void RequestFocus();
virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc
index b18b365..723d786 100644
--- a/chrome/browser/views/autofill_profiles_view_win.cc
+++ b/chrome/browser/views/autofill_profiles_view_win.cc
@@ -1101,10 +1101,7 @@ void AutoFillProfilesView::AutoFillScrollView::RebuildView() {
// Deletes the old contents view and takes ownership of
// |scroll_contents_view_|.
scroll_view_->SetContents(scroll_contents_view_);
- scroll_contents_view_->ScrollRectToVisible(visible_rectangle.x(),
- visible_rectangle.y(),
- visible_rectangle.width(),
- visible_rectangle.height());
+ scroll_contents_view_->ScrollRectToVisible(visible_rectangle);
}
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index c175881..65c1a3f 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -188,11 +188,10 @@ class BookmarkButton : public views::TextButton {
}
}
- bool GetTooltipText(int x, int y, std::wstring* tooltip) {
- gfx::Point location(x, y);
+ bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
+ gfx::Point location(p);
ConvertPointToScreen(this, &location);
- *tooltip = CreateToolTipForURLAndTitle(
- gfx::Point(location.x(), location.y()), url_, text(),
+ *tooltip = CreateToolTipForURLAndTitle(location, url_, text(),
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
return !tooltip->empty();
}
@@ -716,8 +715,9 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) {
index);
}
-void BookmarkBarView::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
- ShowContextMenu(this, x, y, is_mouse_gesture);
+void BookmarkBarView::ShowContextMenu(const gfx::Point& p,
+ bool is_mouse_gesture) {
+ ShowContextMenu(this, p, is_mouse_gesture);
}
bool BookmarkBarView::IsAccessibleViewTraversable(views::View* view) {
@@ -1094,8 +1094,7 @@ void BookmarkBarView::BookmarkNodeFavIconLoaded(BookmarkModel* model,
}
void BookmarkBarView::WriteDragData(View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data) {
UserMetrics::RecordAction("BookmarkBar_DragButton", profile_);
@@ -1104,9 +1103,8 @@ void BookmarkBarView::WriteDragData(View* sender,
views::TextButton* button = GetBookmarkButton(i);
gfx::Canvas canvas(button->width(), button->height(), false);
button->Paint(&canvas, true);
- drag_utils::SetDragImageOnDataObject(canvas, button->width(),
- button->height(), press_x,
- press_y, data);
+ drag_utils::SetDragImageOnDataObject(canvas, button->size(), press_pt,
+ data);
WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data);
return;
}
@@ -1114,21 +1112,33 @@ void BookmarkBarView::WriteDragData(View* sender,
NOTREACHED();
}
-void BookmarkBarView::WriteDragData(const BookmarkNode* node,
- OSExchangeData* data) {
- DCHECK(node && data);
- BookmarkDragData drag_data(node);
- drag_data.Write(profile_, data);
+int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) {
+ if (size_animation_->IsAnimating() ||
+ (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) {
+ // Don't let the user drag while animating open or we're closed (and not on
+ // the new tab page, on the new tab page size_animation_ is always 0). This
+ // typically is only hit if the user does something to inadvertanty trigger
+ // dnd, such as pressing the mouse and hitting control-b.
+ return DragDropTypes::DRAG_NONE;
+ }
+
+ for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
+ if (sender == GetBookmarkButton(i)) {
+ return bookmark_utils::BookmarkDragOperation(
+ model_->GetBookmarkBarNode()->GetChild(i));
+ }
+ }
+ NOTREACHED();
+ return DragDropTypes::DRAG_NONE;
}
bool BookmarkBarView::CanStartDrag(views::View* sender,
- int press_x,
- int press_y,
- int x,
- int y) {
+ const gfx::Point& press_pt,
+ const gfx::Point& p) {
// Check if we have not moved enough horizontally but we have moved downward
// vertically - downward drag.
- if (!View::ExceededDragThreshold(press_x - x, 0) && press_y < y) {
+ if (!View::ExceededDragThreshold(press_pt.x() - p.x(), 0) &&
+ press_pt.y() < p.y()) {
for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
if (sender == GetBookmarkButton(i)) {
const BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i);
@@ -1146,24 +1156,11 @@ bool BookmarkBarView::CanStartDrag(views::View* sender,
return true;
}
-int BookmarkBarView::GetDragOperations(View* sender, int x, int y) {
- if (size_animation_->IsAnimating() ||
- (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) {
- // Don't let the user drag while animating open or we're closed (and not on
- // the new tab page, on the new tab page size_animation_ is always 0). This
- // typically is only hit if the user does something to inadvertanty trigger
- // dnd, such as pressing the mouse and hitting control-b.
- return DragDropTypes::DRAG_NONE;
- }
-
- for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
- if (sender == GetBookmarkButton(i)) {
- return bookmark_utils::BookmarkDragOperation(
- model_->GetBookmarkBarNode()->GetChild(i));
- }
- }
- NOTREACHED();
- return DragDropTypes::DRAG_NONE;
+void BookmarkBarView::WriteDragData(const BookmarkNode* node,
+ OSExchangeData* data) {
+ DCHECK(node && data);
+ BookmarkDragData drag_data(node);
+ drag_data.Write(profile_, data);
}
void BookmarkBarView::RunMenu(views::View* view, const gfx::Point& pt) {
@@ -1222,8 +1219,7 @@ void BookmarkBarView::ButtonPressed(views::Button* sender,
}
void BookmarkBarView::ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
if (!model_->IsLoaded()) {
// Don't do anything if the model isn't loaded.
@@ -1255,9 +1251,9 @@ void BookmarkBarView::ShowContextMenu(View* source,
PageNavigator* navigator =
browser() ? browser()->GetSelectedTabContents() : NULL;
BookmarkContextMenu controller(GetWindow()->GetNativeWindow(), GetProfile(),
- navigator, parent, nodes,
- BookmarkContextMenuControllerViews::BOOKMARK_BAR);
- controller.RunMenuAt(gfx::Point(x, y));
+ navigator, parent, nodes,
+ BookmarkContextMenuControllerViews::BOOKMARK_BAR);
+ controller.RunMenuAt(p);
}
views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) {
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index c4df926..6eb975c 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.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.
@@ -112,7 +112,7 @@ class BookmarkBarView : public DetachableToolbarView,
virtual int OnDragUpdated(const views::DropTargetEvent& event);
virtual void OnDragExited();
virtual int OnPerformDrop(const views::DropTargetEvent& event);
- virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture);
+ virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture);
// AccessibleToolbarView methods:
virtual bool IsAccessibleViewTraversable(views::View* view);
@@ -331,22 +331,18 @@ class BookmarkBarView : public DetachableToolbarView,
// DragController method. Determines the node representing sender and invokes
// WriteDragData to write the actual data.
virtual void WriteDragData(views::View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data);
+ virtual int GetDragOperations(views::View* sender, const gfx::Point& p);
+
virtual bool CanStartDrag(views::View* sender,
- int press_x,
- int press_y,
- int x,
- int y);
+ const gfx::Point& press_pt,
+ const gfx::Point& p);
// Writes a BookmarkDragData for node to data.
void WriteDragData(const BookmarkNode* node, OSExchangeData* data);
- // Returns the drag operations for the specified button.
- virtual int GetDragOperations(views::View* sender, int x, int y);
-
// ViewMenuDelegate method. Ends up creating a BookmarkMenuController to
// show the menu.
virtual void RunMenu(views::View* view, const gfx::Point& pt);
@@ -358,8 +354,7 @@ class BookmarkBarView : public DetachableToolbarView,
// Invoked for this View, one of the buttons or the 'other' button. Shows the
// appropriate context menu.
virtual void ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
// Creates the button for rendering the specified bookmark node.
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index b993775..fb2d072 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.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.
@@ -236,8 +236,7 @@ void BookmarkEditorView::Close() {
}
void BookmarkEditorView::ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
DCHECK(source == tree_view_);
if (!tree_view_->GetSelectedNode())
@@ -253,7 +252,7 @@ void BookmarkEditorView::ShowContextMenu(View* source,
IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
context_menu_.reset(new views::Menu2(context_menu_contents_.get()));
}
- context_menu_->RunContextMenuAt(gfx::Point(x, y));
+ context_menu_->RunContextMenuAt(p);
}
void BookmarkEditorView::Init() {
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 3c358f7..575b726 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.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.
@@ -122,8 +122,7 @@ class BookmarkEditorView : public BookmarkEditor,
// Shows the context menu.
virtual void ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
private:
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index 84b059c..289a9cc 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.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.
@@ -550,15 +550,13 @@ bool BookmarkManagerView::HandleKeystroke(
}
void BookmarkManagerView::ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
DCHECK(source == table_view_ || source == tree_view_);
bool is_table = (source == table_view_);
- ShowMenu(x, y,
- is_table ?
- BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE :
- BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TREE);
+ ShowMenu(p, is_table ?
+ BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE :
+ BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TREE);
}
void BookmarkManagerView::RunMenu(views::View* source, const gfx::Point& pt) {
@@ -568,14 +566,14 @@ void BookmarkManagerView::RunMenu(views::View* source, const gfx::Point& pt) {
if (!GetBookmarkModel()->IsLoaded())
return;
- int menu_x = pt.x();
- menu_x += UILayoutIsRightToLeft() ? (source->width() - 5) :
- (-source->width() + 5);
+ gfx::Point menu_pt(pt);
+ menu_pt.Offset(UILayoutIsRightToLeft() ?
+ (source->width() - 5) : (-source->width() + 5), 2);
if (source->GetID() == kOrganizeMenuButtonID) {
- ShowMenu(menu_x, pt.y() + 2,
+ ShowMenu(menu_pt,
BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_ORGANIZE_MENU);
} else if (source->GetID() == kToolsMenuButtonID) {
- ShowToolsMenu(menu_x, pt.y() + 2);
+ ShowToolsMenu(menu_pt);
} else {
NOTREACHED();
}
@@ -718,40 +716,30 @@ BookmarkModel* BookmarkManagerView::GetBookmarkModel() const {
}
void BookmarkManagerView::ShowMenu(
- int x, int y,
+ const gfx::Point& p,
BookmarkContextMenuControllerViews::ConfigurationType config) {
if (!GetBookmarkModel()->IsLoaded())
return;
- if (config == BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE ||
- (config ==
- BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_ORGANIZE_MENU &&
+ const BookmarkNode* parent = GetSelectedFolder();
+ std::vector<const BookmarkNode*> nodes;
+ typedef BookmarkContextMenuControllerViews BCMCV; // Such a long name!
+ if (config == BCMCV::BOOKMARK_MANAGER_TABLE ||
+ (config == BCMCV::BOOKMARK_MANAGER_ORGANIZE_MENU &&
table_view_->HasFocus())) {
- std::vector<const BookmarkNode*> nodes = GetSelectedTableNodes();
- const BookmarkNode* parent = GetSelectedFolder();
+ nodes = GetSelectedTableNodes();
if (!parent) {
- if (config ==
- BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE) {
- config =
- BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE_OTHER;
- } else {
- config =
- BookmarkContextMenuControllerViews::
- BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER;
- }
+ config = (config == BCMCV::BOOKMARK_MANAGER_TABLE) ?
+ BCMCV::BOOKMARK_MANAGER_TABLE_OTHER :
+ BCMCV::BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER;
}
- BookmarkContextMenu menu(GetWindow()->GetNativeWindow(), profile_, NULL,
- parent, nodes, config);
- menu.RunMenuAt(gfx::Point(x, y));
} else {
- const BookmarkNode* node = GetSelectedFolder();
- std::vector<const BookmarkNode*> nodes;
- if (node)
- nodes.push_back(node);
- BookmarkContextMenu menu(GetWidget()->GetNativeView(), profile_, NULL,
- node, nodes, config);
- menu.RunMenuAt(gfx::Point(x, y));
+ if (parent)
+ nodes.push_back(parent);
}
+ BookmarkContextMenu menu(GetWidget()->GetNativeView(), profile_, NULL, parent,
+ nodes, config);
+ menu.RunMenuAt(p);
}
void BookmarkManagerView::OnCutCopyPaste(CutCopyPasteType type,
@@ -779,7 +767,7 @@ void BookmarkManagerView::OnCutCopyPaste(CutCopyPasteType type,
}
}
-void BookmarkManagerView::ShowToolsMenu(int x, int y) {
+void BookmarkManagerView::ShowToolsMenu(const gfx::Point& p) {
views::MenuItemView menu(this);
menu.AppendMenuItemWithLabel(
IDS_BOOKMARK_MANAGER_IMPORT_MENU,
@@ -787,10 +775,9 @@ void BookmarkManagerView::ShowToolsMenu(int x, int y) {
menu.AppendMenuItemWithLabel(
IDS_BOOKMARK_MANAGER_EXPORT_MENU,
l10n_util::GetString(IDS_BOOKMARK_MANAGER_EXPORT_MENU));
- views::MenuItemView::AnchorPosition anchor =
- UILayoutIsRightToLeft() ? views::MenuItemView::TOPRIGHT :
- views::MenuItemView::TOPLEFT;
- menu.RunMenuAt(GetWidget()->GetNativeView(), NULL, gfx::Rect(x, y, 0, 0),
+ views::MenuItemView::AnchorPosition anchor = UILayoutIsRightToLeft() ?
+ views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT;
+ menu.RunMenuAt(GetWidget()->GetNativeView(), NULL, gfx::Rect(p, gfx::Size()),
anchor, true);
}
diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h
index 74aee84..470152f 100644
--- a/chrome/browser/views/bookmark_manager_view.h
+++ b/chrome/browser/views/bookmark_manager_view.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.
@@ -151,8 +151,7 @@ class BookmarkManagerView : public views::View,
// ContextMenuController.
virtual void ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
// ViewMenuDelegate.
@@ -193,7 +192,7 @@ class BookmarkManagerView : public views::View,
// Shows the menu. This is invoked to show the context menu for table/tree
// as well as to show the menu from the organize button.
- void ShowMenu(int x, int y,
+ void ShowMenu(const gfx::Point& p,
BookmarkContextMenuControllerViews::ConfigurationType config);
// Invoked to handle cut/copy/paste from the table or tree. If |from_table|
@@ -201,7 +200,7 @@ class BookmarkManagerView : public views::View,
void OnCutCopyPaste(CutCopyPasteType type, bool from_table);
// Shows the tools menu.
- void ShowToolsMenu(int x, int y);
+ void ShowToolsMenu(const gfx::Point& p);
// Shows the import/export file chooser. These invoke
// FileSelected/FileSelectionCanceled when done.
diff --git a/chrome/browser/views/bookmark_menu_controller_views.cc b/chrome/browser/views/bookmark_menu_controller_views.cc
index 66e41f8..2437d7f 100644
--- a/chrome/browser/views/bookmark_menu_controller_views.cc
+++ b/chrome/browser/views/bookmark_menu_controller_views.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.
@@ -194,8 +194,7 @@ int BookmarkMenuController::OnPerformDrop(MenuItemView* menu,
bool BookmarkMenuController::ShowContextMenu(MenuItemView* source,
int id,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) {
DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end());
std::vector<const BookmarkNode*> nodes;
@@ -209,7 +208,7 @@ bool BookmarkMenuController::ShowContextMenu(MenuItemView* source,
nodes,
BookmarkContextMenuControllerViews::BOOKMARK_BAR));
context_menu_->set_observer(this);
- context_menu_->RunMenuAt(gfx::Point(x, y));
+ context_menu_->RunMenuAt(p);
context_menu_.reset(NULL);
return true;
}
diff --git a/chrome/browser/views/bookmark_menu_controller_views.h b/chrome/browser/views/bookmark_menu_controller_views.h
index 13e1295..693c83c 100644
--- a/chrome/browser/views/bookmark_menu_controller_views.h
+++ b/chrome/browser/views/bookmark_menu_controller_views.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.
@@ -95,8 +95,7 @@ class BookmarkMenuController : public BaseBookmarkModelObserver,
const views::DropTargetEvent& event);
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
virtual void DropMenuClosed(views::MenuItemView* menu);
virtual bool CanDrag(views::MenuItemView* menu);
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index f3289fa..7d14eae 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -882,8 +882,9 @@ void BrowserActionsContainer::RunMenu(View* source, const gfx::Point& pt) {
}
}
-void BrowserActionsContainer::WriteDragData(
- View* sender, int press_x, int press_y, OSExchangeData* data) {
+void BrowserActionsContainer::WriteDragData(View* sender,
+ const gfx::Point& press_pt,
+ OSExchangeData* data) {
DCHECK(data);
for (size_t i = 0; i < browser_action_views_.size(); ++i) {
@@ -892,8 +893,8 @@ void BrowserActionsContainer::WriteDragData(
// Set the dragging image for the icon.
scoped_ptr<gfx::Canvas> canvas(
browser_action_views_[i]->GetIconWithBadge());
- drag_utils::SetDragImageOnDataObject(*canvas, button->width(),
- button->height(), press_x, press_y, data);
+ drag_utils::SetDragImageOnDataObject(*canvas, button->size(), press_pt,
+ data);
// Fill in the remaining info.
BrowserActionDragData drag_data(
@@ -904,12 +905,14 @@ void BrowserActionsContainer::WriteDragData(
}
}
-int BrowserActionsContainer::GetDragOperations(View* sender, int x, int y) {
+int BrowserActionsContainer::GetDragOperations(View* sender,
+ const gfx::Point& p) {
return DragDropTypes::DRAG_MOVE;
}
-bool BrowserActionsContainer::CanStartDrag(
- View* sender, int press_x, int press_y, int x, int y) {
+bool BrowserActionsContainer::CanStartDrag(View* sender,
+ const gfx::Point& press_pt,
+ const gfx::Point& p) {
return true;
}
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
index 89b0842..2a55ed6 100644
--- a/chrome/browser/views/browser_actions_container.h
+++ b/chrome/browser/views/browser_actions_container.h
@@ -319,15 +319,12 @@ class BrowserActionsContainer
// Overridden from views::DragController:
virtual void WriteDragData(View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data);
- virtual int GetDragOperations(View* sender, int x, int y);
+ virtual int GetDragOperations(View* sender, const gfx::Point& p);
virtual bool CanStartDrag(View* sender,
- int press_x,
- int press_y,
- int x,
- int y);
+ const gfx::Point& press_pt,
+ const gfx::Point& p);
// Overridden from ResizeGripper::ResizeGripperDelegate:
virtual void OnResize(int resize_amount, bool done_resizing);
diff --git a/chrome/browser/views/content_blocked_bubble_contents.cc b/chrome/browser/views/content_blocked_bubble_contents.cc
index edbb22d..a44311c 100644
--- a/chrome/browser/views/content_blocked_bubble_contents.cc
+++ b/chrome/browser/views/content_blocked_bubble_contents.cc
@@ -43,8 +43,7 @@ class ContentBlockedBubbleContents::Favicon : public views::ImageView {
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
virtual gfx::NativeCursor GetCursorForPoint(
views::Event::EventType event_type,
- int x,
- int y);
+ const gfx::Point& p);
ContentBlockedBubbleContents* parent_;
views::Link* link_;
@@ -82,8 +81,7 @@ void ContentBlockedBubbleContents::Favicon::OnMouseReleased(
gfx::NativeCursor ContentBlockedBubbleContents::Favicon::GetCursorForPoint(
views::Event::EventType event_type,
- int x,
- int y) {
+ const gfx::Point& p) {
#if defined(OS_WIN)
if (!g_hand_cursor)
g_hand_cursor = LoadCursor(NULL, IDC_HAND);
diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
index 85a233a..f0bb80d 100644
--- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
+++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
@@ -84,11 +84,13 @@ void BrowserActionOverflowMenuController::ExecuteCommand(int id) {
}
bool BrowserActionOverflowMenuController::ShowContextMenu(
- views::MenuItemView* source, int id, int x, int y, bool is_mouse_gesture) {
+ views::MenuItemView* source,
+ int id,
+ const gfx::Point& p,
+ bool is_mouse_gesture) {
// This blocks until the user choses something or dismisses the menu.
owner_->GetContextMenu()->Run(
- (*views_)[start_index_ + id - 1]->button()->extension(),
- gfx::Point(x, y));
+ (*views_)[start_index_ + id - 1]->button()->extension(), p);
// The user is done with the context menu, so we can close the underlying
// menu.
diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
index 9f9e2a1..e30db53 100644
--- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
+++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
@@ -43,8 +43,7 @@ class BrowserActionOverflowMenuController : public views::MenuDelegate {
virtual void ExecuteCommand(int id);
virtual bool ShowContextMenu(views::MenuItemView* source,
int id,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
virtual void DropMenuClosed(views::MenuItemView* menu);
// These drag functions offer support for dragging icons into the overflow
diff --git a/chrome/browser/views/go_button.cc b/chrome/browser/views/go_button.cc
index 4f55244..29451c3 100644
--- a/chrome/browser/views/go_button.cc
+++ b/chrome/browser/views/go_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.
@@ -85,7 +85,7 @@ void GoButton::OnMouseExited(const views::MouseEvent& e) {
SetState(BS_NORMAL);
}
-bool GoButton::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool GoButton::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
if (visible_mode_ == MODE_STOP) {
tooltip->assign(l10n_util::GetString(IDS_TOOLTIP_STOP));
return true;
diff --git a/chrome/browser/views/go_button.h b/chrome/browser/views/go_button.h
index 735ca54..8855b5a 100644
--- a/chrome/browser/views/go_button.h
+++ b/chrome/browser/views/go_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.
@@ -41,7 +41,7 @@ class GoButton : public views::ToggleImageButton,
// Overridden from views::View:
virtual void OnMouseExited(const views::MouseEvent& e);
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
private:
void OnButtonTimer();
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index e65fb16..7d99ebd 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.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,7 +168,7 @@ void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
delegate_->CloseTab(this);
}
-bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool Tab::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
std::wstring title = GetTitle();
if (!title.empty()) {
// Only show the tooltip if the title is truncated.
@@ -181,7 +181,7 @@ bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
return false;
}
-bool Tab::GetTooltipTextOrigin(int x, int y, gfx::Point* origin) {
+bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) {
gfx::Font font;
origin->set_x(title_bounds().x() + 10);
origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4);
@@ -203,11 +203,12 @@ bool Tab::GetAccessibleName(std::wstring* name) {
///////////////////////////////////////////////////////////////////////////////
// Tab, views::ContextMenuController implementation:
-void Tab::ShowContextMenu(views::View* source, int x, int y,
+void Tab::ShowContextMenu(views::View* source,
+ const gfx::Point& p,
bool is_mouse_gesture) {
if (!context_menu_contents_.get())
context_menu_contents_.reset(new TabContextMenuContents(this));
- context_menu_contents_->RunMenuAt(gfx::Point(x, y));
+ context_menu_contents_->RunMenuAt(p);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h
index a5638f7..f491291 100644
--- a/chrome/browser/views/tabs/tab.h
+++ b/chrome/browser/views/tabs/tab.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.
@@ -97,16 +97,15 @@ class Tab : public TabRenderer,
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event,
bool canceled);
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
- virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* origin);
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
+ virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin);
virtual std::string GetClassName() const { return kTabClassName; }
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual bool GetAccessibleName(std::wstring* name);
// views::ContextMenuController overrides:
virtual void ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
// views::ButtonListener overrides:
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index a71caf5..0b8cb4b 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.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.
@@ -1375,7 +1375,7 @@ void TabStrip::MaybeStartDrag(Tab* tab, const views::MouseEvent& event) {
return;
}
drag_controller_.reset(new DraggedTabController(tab, this));
- drag_controller_->CaptureDragInfo(gfx::Point(event.x(), event.y()));
+ drag_controller_->CaptureDragInfo(event.location());
}
void TabStrip::ContinueDrag(const views::MouseEvent& event) {
diff --git a/chrome/browser/views/task_manager_view.cc b/chrome/browser/views/task_manager_view.cc
index 6dbbb87..1b5e148 100644
--- a/chrome/browser/views/task_manager_view.cc
+++ b/chrome/browser/views/task_manager_view.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.
@@ -231,8 +231,7 @@ class TaskManagerView : public views::View,
// Menu::Delegate
virtual void ShowContextMenu(views::View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture);
virtual bool IsItemChecked(int id) const;
virtual void ExecuteCommand(int id);
@@ -597,7 +596,8 @@ void TaskManagerView::LinkActivated(views::Link* source, int event_flags) {
task_manager_->OpenAboutMemory();
}
-void TaskManagerView::ShowContextMenu(views::View* source, int x, int y,
+void TaskManagerView::ShowContextMenu(views::View* source,
+ const gfx::Point& p,
bool is_mouse_gesture) {
UpdateStatsCounters();
scoped_ptr<views::Menu> menu(views::Menu::Create(
@@ -606,7 +606,7 @@ void TaskManagerView::ShowContextMenu(views::View* source, int x, int y,
columns_.begin(); i != columns_.end(); ++i) {
menu->AppendMenuItem(i->id, i->title, views::Menu::CHECKBOX);
}
- menu->RunMenuAt(x, y);
+ menu->RunMenuAt(p.x(), p.y());
}
bool TaskManagerView::IsItemChecked(int id) const {
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index b2125d4..9670c24 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -479,11 +479,9 @@ void ToolbarView::ThemeChanged() {
// ToolbarView, views::DragController implementation:
void ToolbarView::WriteDragData(views::View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data) {
- DCHECK(
- GetDragOperations(sender, press_x, press_y) != DragDropTypes::DRAG_NONE);
+ DCHECK(GetDragOperations(sender, press_pt) != DragDropTypes::DRAG_NONE);
UserMetrics::RecordAction("Toolbar_DragStar", profile_);
@@ -508,7 +506,7 @@ void ToolbarView::WriteDragData(views::View* sender,
}
}
-int ToolbarView::GetDragOperations(views::View* sender, int x, int y) {
+int ToolbarView::GetDragOperations(views::View* sender, const gfx::Point& p) {
DCHECK(sender == star_);
TabContents* tab = browser_->GetSelectedTabContents();
if (!tab || !tab->ShouldDisplayURL() || !tab->GetURL().is_valid()) {
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index ffbec68f..23f5232 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.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.
@@ -114,15 +114,12 @@ class ToolbarView : public AccessibleToolbarView,
private:
// Overridden from views::DragController:
virtual void WriteDragData(View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data);
- virtual int GetDragOperations(View* sender, int x, int y);
+ virtual int GetDragOperations(View* sender, const gfx::Point& p);
virtual bool CanStartDrag(View* sender,
- int press_x,
- int press_y,
- int x,
- int y) {
+ const gfx::Point& press_pt,
+ const gfx::Point& p) {
return true;
}
diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc
index f74ae9c..952f6d4 100644
--- a/views/accessibility/view_accessibility.cc
+++ b/views/accessibility/view_accessibility.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.
@@ -379,12 +379,13 @@ STDMETHODIMP ViewAccessibility::get_accDescription(VARIANT var_id, BSTR* desc) {
std::wstring temp_desc;
if (var_id.lVal == CHILDID_SELF) {
- view_->GetTooltipText(0, 0, &temp_desc);
+ view_->GetTooltipText(gfx::Point(), &temp_desc);
} else {
if (!IsValidChild((var_id.lVal - 1), view_)) {
return E_INVALIDARG;
}
- view_->GetChildViewAt(var_id.lVal - 1)->GetTooltipText(0, 0, &temp_desc);
+ view_->GetChildViewAt(var_id.lVal - 1)->GetTooltipText(gfx::Point(),
+ &temp_desc);
}
if (!temp_desc.empty()) {
*desc = SysAllocString(temp_desc.c_str());
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) {
diff --git a/views/drag_utils.cc b/views/drag_utils.cc
index f1d9717..44deeb2 100644
--- a/views/drag_utils.cc
+++ b/views/drag_utils.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.
@@ -50,9 +50,8 @@ void SetURLAndDragImage(const GURL& url,
// Render the image.
gfx::Canvas canvas(prefsize.width(), prefsize.height(), false);
button.Paint(&canvas, true);
- SetDragImageOnDataObject(canvas, prefsize.width(), prefsize.height(),
- prefsize.width() / 2, prefsize.height() / 2,
- data);
+ SetDragImageOnDataObject(canvas, prefsize,
+ gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data);
}
void CreateDragImageForFile(const FilePath::StringType& file_name,
@@ -88,8 +87,9 @@ void CreateDragImageForFile(const FilePath::StringType& file_name,
width, font.height(), gfx::Canvas::TEXT_ALIGN_CENTER);
#endif
- SetDragImageOnDataObject(canvas, width, height, width / 2,
- kLinkDragImageVPadding, data_object);
+ SetDragImageOnDataObject(canvas, gfx::Size(width, height),
+ gfx::Point(width / 2, kLinkDragImageVPadding),
+ data_object);
}
} // namespace drag_utils
diff --git a/views/drag_utils.h b/views/drag_utils.h
index 5ce4def..974d648 100644
--- a/views/drag_utils.h
+++ b/views/drag_utils.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.
@@ -11,6 +11,8 @@
namespace gfx {
class Canvas;
+class Point;
+class Size;
}
class GURL;
class OSExchangeData;
@@ -37,10 +39,8 @@ void CreateDragImageForFile(const FilePath::StringType& file_name,
// are the size of the image to use, and the offsets give the location of
// the hotspot for the drag image.
void SetDragImageOnDataObject(const gfx::Canvas& canvas,
- int width,
- int height,
- int cursor_x_offset,
- int cursor_y_offset,
+ const gfx::Size& size,
+ const gfx::Point& cursor_offset,
OSExchangeData* data_object);
} // namespace drag_utils
diff --git a/views/drag_utils_gtk.cc b/views/drag_utils_gtk.cc
index 1a47aa4..e0d221a 100644
--- a/views/drag_utils_gtk.cc
+++ b/views/drag_utils_gtk.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.
@@ -8,6 +8,8 @@
#include "app/gfx/canvas.h"
#include "app/gfx/gtk_util.h"
+#include "base/gfx/point.h"
+#include "base/gfx/size.h"
#include "base/logging.h"
#include "app/os_exchange_data.h"
#include "app/os_exchange_data_provider_gtk.h"
@@ -15,10 +17,8 @@
namespace drag_utils {
void SetDragImageOnDataObject(const gfx::Canvas& canvas,
- int width,
- int height,
- int cursor_x_offset,
- int cursor_y_offset,
+ const gfx::Size& size,
+ const gfx::Point& cursor_offset,
OSExchangeData* data_object) {
OSExchangeDataProviderGtk& provider(
static_cast<OSExchangeDataProviderGtk&>(data_object->provider()));
@@ -32,13 +32,14 @@ void SetDragImageOnDataObject(const gfx::Canvas& canvas,
gdk_pixbuf_get_colorspace(canvas_pixbuf),
gdk_pixbuf_get_has_alpha(canvas_pixbuf),
gdk_pixbuf_get_bits_per_sample(canvas_pixbuf),
- width,
- height);
- gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, width, height, pixbuf, 0, 0);
+ size.width(),
+ size.height());
+ gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, size.width(), size.height(), pixbuf,
+ 0, 0);
g_object_unref(canvas_pixbuf);
// Set the drag data on to the provider.
- provider.SetDragImage(pixbuf, cursor_x_offset, cursor_y_offset);
+ provider.SetDragImage(pixbuf, cursor_offset);
g_object_unref(pixbuf);
}
diff --git a/views/drag_utils_win.cc b/views/drag_utils_win.cc
index 9b9bd26..c2d4bed 100644
--- a/views/drag_utils_win.cc
+++ b/views/drag_utils_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.
@@ -16,22 +16,18 @@
namespace drag_utils {
static void SetDragImageOnDataObject(HBITMAP hbitmap,
- int width,
- int height,
- int cursor_offset_x,
- int cursor_offset_y,
+ const gfx::Size& size,
+ const gfx::Point& cursor_offset,
IDataObject* data_object) {
IDragSourceHelper* helper = NULL;
HRESULT rv = CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
IID_IDragSourceHelper, reinterpret_cast<LPVOID*>(&helper));
if (SUCCEEDED(rv)) {
SHDRAGIMAGE sdi;
- sdi.sizeDragImage.cx = width;
- sdi.sizeDragImage.cy = height;
+ sdi.sizeDragImage = size.ToSIZE();
sdi.crColorKey = 0xFFFFFFFF;
sdi.hbmpDragImage = hbitmap;
- sdi.ptOffset.x = cursor_offset_x;
- sdi.ptOffset.y = cursor_offset_y;
+ sdi.ptOffset = cursor_offset.ToPOINT();
helper->InitializeFromBitmap(&sdi, data_object);
}
};
@@ -60,18 +56,15 @@ static HBITMAP CreateBitmapFromCanvas(const gfx::Canvas& canvas,
}
void SetDragImageOnDataObject(const gfx::Canvas& canvas,
- int width,
- int height,
- int cursor_x_offset,
- int cursor_y_offset,
+ const gfx::Size& size,
+ const gfx::Point& cursor_offset,
OSExchangeData* data_object) {
- DCHECK(data_object && width > 0 && height > 0);
+ DCHECK(data_object && !size.IsEmpty());
// SetDragImageOnDataObject(HBITMAP) takes ownership of the bitmap.
- HBITMAP bitmap = CreateBitmapFromCanvas(canvas, width, height);
+ HBITMAP bitmap = CreateBitmapFromCanvas(canvas, size.width(), size.height());
// Attach 'bitmap' to the data_object.
- SetDragImageOnDataObject(
- bitmap, width, height, cursor_x_offset, cursor_y_offset,
+ SetDragImageOnDataObject(bitmap, size, cursor_offset,
OSExchangeDataProviderWin::GetIDataObject(*data_object));
}
diff --git a/views/examples/scroll_view_example.h b/views/examples/scroll_view_example.h
index 035c06c..e183b2c 100644
--- a/views/examples/scroll_view_example.h
+++ b/views/examples/scroll_view_example.h
@@ -101,7 +101,8 @@ class ScrollViewExample : public ExampleBase,
scrollable_->SetBounds(0, 0, 100, 100);
scrollable_->SetColor(SK_ColorYELLOW, SK_ColorGREEN);
} else if (sender == scroll_to_) {
- scroll_view_->ScrollContentsRegionToBeVisible(20, 500, 1000, 500);
+ scroll_view_->ScrollContentsRegionToBeVisible(
+ gfx::Rect(20, 500, 1000, 500));
}
scroll_view_->Layout();
}
diff --git a/views/view.cc b/views/view.cc
index ef476f4..d88defc 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -183,14 +183,16 @@ void View::DidChangeBounds(const gfx::Rect& previous,
Layout();
}
-void View::ScrollRectToVisible(int x, int y, int width, int height) {
+void View::ScrollRectToVisible(const gfx::Rect& rect) {
View* parent = GetParent();
// We must take RTL UI mirroring into account when adjusting the position of
// the region.
- if (parent)
- parent->ScrollRectToVisible(
- GetX(APPLY_MIRRORING_TRANSFORMATION) + x, View::y() + y, width, height);
+ if (parent) {
+ gfx::Rect scroll_rect(rect);
+ scroll_rect.Offset(GetX(APPLY_MIRRORING_TRANSFORMATION), y());
+ parent->ScrollRectToVisible(scroll_rect);
+ }
}
/////////////////////////////////////////////////////////////////////////////
@@ -322,10 +324,6 @@ void View::SchedulePaint() {
SchedulePaint(GetLocalBounds(true), false);
}
-void View::SchedulePaint(int x, int y, int w, int h) {
- SchedulePaint(gfx::Rect(x, y, w, h), false);
-}
-
void View::Paint(gfx::Canvas* canvas) {
PaintBackground(canvas);
PaintFocusBorder(canvas);
@@ -421,8 +419,8 @@ gfx::Insets View::GetInsets() const {
return insets;
}
-gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type, int x,
- int y) {
+gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type,
+ const gfx::Point& p) {
return NULL;
}
@@ -450,11 +448,11 @@ void View::SetContextMenuController(ContextMenuController* menu_controller) {
context_menu_controller_ = menu_controller;
}
-void View::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
+void View::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
if (!context_menu_controller_)
return;
- context_menu_controller_->ShowContextMenu(this, x, y, is_mouse_gesture);
+ context_menu_controller_->ShowContextMenu(this, p, is_mouse_gesture);
}
/////////////////////////////////////////////////////////////////////////////
@@ -465,13 +463,11 @@ void View::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
bool View::ProcessMousePressed(const MouseEvent& e, DragInfo* drag_info) {
const bool enabled = enabled_;
- int drag_operations;
- if (enabled && e.IsOnlyLeftMouseButton() && HitTest(e.location()))
- drag_operations = GetDragOperations(e.x(), e.y());
- else
- drag_operations = 0;
- ContextMenuController* context_menu_controller =
- e.IsRightMouseButton() ? context_menu_controller_ : 0;
+ int drag_operations =
+ (enabled && e.IsOnlyLeftMouseButton() && HitTest(e.location())) ?
+ GetDragOperations(e.location()) : 0;
+ ContextMenuController* context_menu_controller = e.IsRightMouseButton() ?
+ context_menu_controller_ : 0;
const bool result = OnMousePressed(e);
// WARNING: we may have been deleted, don't use any View variables;
@@ -480,7 +476,7 @@ bool View::ProcessMousePressed(const MouseEvent& e, DragInfo* drag_info) {
return result;
if (drag_operations != DragDropTypes::DRAG_NONE) {
- drag_info->PossibleDrag(e.x(), e.y());
+ drag_info->PossibleDrag(e.location());
return true;
}
return !!context_menu_controller || result;
@@ -491,15 +487,11 @@ bool View::ProcessMouseDragged(const MouseEvent& e, DragInfo* drag_info) {
// done.
ContextMenuController* context_menu_controller = context_menu_controller_;
const bool possible_drag = drag_info->possible_drag;
- if (possible_drag && ExceededDragThreshold(drag_info->start_x - e.x(),
- drag_info->start_y - e.y())) {
+ if (possible_drag && ExceededDragThreshold(drag_info->start_pt.x() - e.x(),
+ drag_info->start_pt.y() - e.y())) {
if (!drag_controller_ ||
- drag_controller_->CanStartDrag(this,
- drag_info->start_x,
- drag_info->start_y,
- e.x(),
- e.y()))
- DoDrag(e, drag_info->start_x, drag_info->start_y);
+ drag_controller_->CanStartDrag(this, drag_info->start_pt, e.location()))
+ DoDrag(e, drag_info->start_pt);
} else {
if (OnMouseDragged(e))
return true;
@@ -517,7 +509,7 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) {
OnMouseReleased(e, canceled);
if (HitTest(location)) {
ConvertPointToScreen(this, &location);
- ShowContextMenu(location.x(), location.y(), true);
+ ShowContextMenu(location, true);
}
} else {
OnMouseReleased(e, canceled);
@@ -576,13 +568,13 @@ void View::RemoveAllChildViews(bool delete_views) {
UpdateTooltip();
}
-void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
- int drag_operations = GetDragOperations(press_x, press_y);
+void View::DoDrag(const MouseEvent& e, const gfx::Point& press_pt) {
+ int drag_operations = GetDragOperations(press_pt);
if (drag_operations == DragDropTypes::DRAG_NONE)
return;
OSExchangeData data;
- WriteDragData(press_x, press_y, &data);
+ WriteDragData(press_pt, &data);
// Message the RootView to do the drag and drop. That way if we're removed
// the RootView can detect it and avoid calling us back.
@@ -1101,15 +1093,15 @@ void View::UnregisterAccelerators(bool leave_data_intact) {
}
}
-int View::GetDragOperations(int press_x, int press_y) {
- if (!drag_controller_)
- return DragDropTypes::DRAG_NONE;
- return drag_controller_->GetDragOperations(this, press_x, press_y);
+int View::GetDragOperations(const gfx::Point& press_pt) {
+ return drag_controller_ ?
+ drag_controller_->GetDragOperations(this, press_pt) :
+ DragDropTypes::DRAG_NONE;
}
-void View::WriteDragData(int press_x, int press_y, OSExchangeData* data) {
+void View::WriteDragData(const gfx::Point& press_pt, OSExchangeData* data) {
DCHECK(drag_controller_);
- drag_controller_->WriteDragData(this, press_x, press_y, data);
+ drag_controller_->WriteDragData(this, press_pt, data);
}
void View::OnDragDone() {
@@ -1339,11 +1331,11 @@ bool View::ExceededDragThreshold(int delta_x, int delta_y) {
}
// Tooltips -----------------------------------------------------------------
-bool View::GetTooltipText(int x, int y, std::wstring* tooltip) {
+bool View::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
return false;
}
-bool View::GetTooltipTextOrigin(int x, int y, gfx::Point* loc) {
+bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) {
return false;
}
@@ -1459,13 +1451,12 @@ void View::RemoveDescendantToNotify(View* view) {
void View::DragInfo::Reset() {
possible_drag = false;
- start_x = start_y = 0;
+ start_pt = gfx::Point();
}
-void View::DragInfo::PossibleDrag(int x, int y) {
+void View::DragInfo::PossibleDrag(const gfx::Point& p) {
possible_drag = true;
- start_x = x;
- start_y = y;
+ start_pt = p;
}
} // namespace
diff --git a/views/view.h b/views/view.h
index b44c04d..d493a0b 100644
--- a/views/view.h
+++ b/views/view.h
@@ -58,15 +58,14 @@ class Window;
//
class ContextMenuController {
public:
- // Invoked to show the context menu for the source view. If is_mouse_gesture
- // is true, the x/y coordinate are the location of the mouse. If
- // is_mouse_gesture is false, this method was not invoked by a mouse gesture
- // and x/y is the recommended location to show the menu at.
+ // Invoked to show the context menu for the source view. If |is_mouse_gesture|
+ // is true, |p| is the location of the mouse. If |is_mouse_gesture| is false,
+ // this method was not invoked by a mouse gesture and |p| is the recommended
+ // location to show the menu at.
//
- // x/y is in screen coordinates.
+ // |p| is in screen coordinates.
virtual void ShowContextMenu(View* source,
- int x,
- int y,
+ const gfx::Point& p,
bool is_mouse_gesture) = 0;
protected:
@@ -81,22 +80,19 @@ class DragController {
public:
// Writes the data for the drag.
virtual void WriteDragData(View* sender,
- int press_x,
- int press_y,
+ const gfx::Point& press_pt,
OSExchangeData* data) = 0;
// Returns the supported drag operations (see DragDropTypes for possible
// values). A drag is only started if this returns a non-zero value.
- virtual int GetDragOperations(View* sender, int x, int y) = 0;
+ virtual int GetDragOperations(View* sender, const gfx::Point& p) = 0;
// Returns true if a drag operation can be started.
- // |press_x| and |press_y| represent coordinates where mouse was initially
- // pressed down. |x| and |y| are the current mouse coordinates.
+ // |press_pt| represents the coordinates where the mouse was initially
+ // pressed down. |p| is the current mouse coordinates.
virtual bool CanStartDrag(View* sender,
- int press_x,
- int press_y,
- int x,
- int y) = 0;
+ const gfx::Point& press_pt,
+ const gfx::Point& p) = 0;
protected:
virtual ~DragController() {}
@@ -275,7 +271,7 @@ class View : public AcceleratorTarget {
// visible. View's implementation passes the call onto the parent View (after
// adjusting the coordinates). It is up to views that only show a portion of
// the child view, such as Viewport, to override appropriately.
- virtual void ScrollRectToVisible(int x, int y, int width, int height);
+ virtual void ScrollRectToVisible(const gfx::Rect& rect);
// Layout functions
@@ -392,10 +388,6 @@ class View : public AcceleratorTarget {
// possible.
virtual void SchedulePaint();
- // Convenience to schedule a paint given some ints. Painting will occur as
- // soon as possible.
- virtual void SchedulePaint(int x, int y, int w, int h);
-
// Paint the receiving view. g is prepared such as it is in
// receiver's coordinate system. g's state is restored after this
// call so your implementation can change the graphics configuration
@@ -854,8 +846,7 @@ class View : public AcceleratorTarget {
// to provide right-click menu display triggerd by the keyboard (i.e. for the
// Chrome toolbar Back and Forward buttons). No source needs to be specified,
// as it is always equal to the current View.
- virtual void ShowContextMenu(int x,
- int y,
+ virtual void ShowContextMenu(const gfx::Point& p,
bool is_mouse_gesture);
// The background object is owned by this object and may be NULL.
@@ -877,8 +868,7 @@ class View : public AcceleratorTarget {
// platform to platform. On Windows, the cursor is a shared resource but in
// Gtk, the framework destroys the returned cursor after setting it.
virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
- int x,
- int y);
+ const gfx::Point& p);
// Convenience to test whether a point is within this view's bounds
virtual bool HitTest(const gfx::Point& l) const;
@@ -888,13 +878,13 @@ class View : public AcceleratorTarget {
// the supplied string and return true.
// Any time the tooltip text that a View is displaying changes, it must
// invoke TooltipTextChanged.
- // The x/y provide the coordinates of the mouse (relative to this view).
- virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+ // |p| provides the coordinates of the mouse (relative to this view).
+ virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
// Returns the location (relative to this View) for the text on the tooltip
// to display. If false is returned (the default), the tooltip is placed at
// a default position.
- virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* loc);
+ virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc);
// Set whether this view is owned by its parent. A view that is owned by its
// parent is automatically deleted when the parent is deleted. The default is
@@ -1074,8 +1064,8 @@ class View : public AcceleratorTarget {
// the DragController. Subclasses may wish to override rather than install
// a DragController.
// See DragController for a description of these methods.
- virtual int GetDragOperations(int press_x, int press_y);
- virtual void WriteDragData(int press_x, int press_y, OSExchangeData* data);
+ virtual int GetDragOperations(const gfx::Point& press_pt);
+ virtual void WriteDragData(const gfx::Point& press_pt, OSExchangeData* data);
// Invoked from DoDrag after the drag completes. This implementation does
// nothing, and is intended for subclasses to do cleanup.
@@ -1109,17 +1099,16 @@ class View : public AcceleratorTarget {
// RootView prior to invoke ProcessMousePressed.
void Reset();
- // Sets possible_drag to true and start_x/y to the specified coordinates.
+ // Sets possible_drag to true and start_pt to the specified point.
// This is invoked by the target view if it detects the press may generate
// a drag.
- void PossibleDrag(int x, int y);
+ void PossibleDrag(const gfx::Point& p);
// Whether the press may generate a drag.
bool possible_drag;
// Coordinates of the mouse press.
- int start_x;
- int start_y;
+ gfx::Point start_pt;
};
// RootView invokes these. These in turn invoke the appropriate OnMouseXXX
@@ -1131,7 +1120,7 @@ class View : public AcceleratorTarget {
// Starts a drag and drop operation originating from this view. This invokes
// WriteDragData to write the data and GetDragOperations to determine the
// supported drag operations. When done, OnDragDone is invoked.
- void DoDrag(const MouseEvent& e, int press_x, int press_y);
+ void DoDrag(const MouseEvent& e, const gfx::Point& press_pt);
// Removes |view| from the hierarchy tree. If |update_focus_cycle| is true,
// the next and previous focusable views of views pointing to this view are
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 1f4cfc1..1e993d0 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.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.
@@ -429,7 +429,7 @@ TEST_F(ViewTest, DISABLED_Painting) {
v2->Reset();
v3->Reset();
v4->Reset();
- v3->SchedulePaint(10, 10, 10, 10);
+ v3->SchedulePaint(gfx::Rect(10, 10, 10, 10), false);
PaintRootView(root, empty_paint);
SkRect tmp_rect;
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 862d000..c64dc08 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_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.
@@ -135,10 +135,6 @@ void RootView::SchedulePaint() {
View::SchedulePaint();
}
-void RootView::SchedulePaint(int x, int y, int w, int h) {
- View::SchedulePaint();
-}
-
#ifndef NDEBUG
// Sets the value of RootView's |is_processing_paint_| member to true as long
// as ProcessPaint is being called. Sets it to |false| when it returns.
@@ -412,7 +408,7 @@ void RootView::UpdateCursor(const MouseEvent& e) {
if (v && v != this) {
gfx::Point l(e.location());
View::ConvertPointToView(this, v, &l);
- cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
+ cursor = v->GetCursorForPoint(e.GetType(), l);
}
SetActiveCursor(cursor);
}
@@ -477,7 +473,7 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
mouse_move_handler_->OnMouseMoved(moved_event);
gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint(
- moved_event.GetType(), moved_event.x(), moved_event.y());
+ moved_event.GetType(), moved_event.location());
SetActiveCursor(cursor);
} else if (mouse_move_handler_ != NULL) {
MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
@@ -798,8 +794,7 @@ bool RootView::ProcessKeyEvent(const KeyEvent& event) {
// keyboard.
if (v && v->IsEnabled() && ((event.GetKeyCode() == base::VKEY_APPS) ||
(event.GetKeyCode() == base::VKEY_F10 && event.IsShiftDown()))) {
- gfx::Point screen_loc = v->GetKeyboardContextMenuLocation();
- v->ShowContextMenu(screen_loc.x(), screen_loc.y(), false);
+ v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false);
return true;
}
for (; v && v != this && !consumed; v = v->GetParent()) {
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index d175c63..bfc3b2c 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.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,9 +53,6 @@ class RootView : public View,
// Convenience to schedule the whole view
virtual void SchedulePaint();
- // Convenience to schedule a paint given some ints
- virtual void SchedulePaint(int x, int y, int w, int h);
-
// Paint this RootView and its child Views.
virtual void ProcessPaint(gfx::Canvas* canvas);
diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc
index b425356..6aa8254 100644
--- a/views/widget/tooltip_manager_gtk.cc
+++ b/views/widget/tooltip_manager_gtk.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.
@@ -161,7 +161,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
return false;
std::wstring text;
- if (!view->GetTooltipText(view_loc.x(), view_loc.y(), &text))
+ if (!view->GetTooltipText(view_loc, &text))
return false;
AdjustLabel(tooltip);
@@ -169,7 +169,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard,
// Sets the area of the tooltip. This way if different views in the same
// widget have tooltips the tooltip doesn't get stuck at the same location.
gfx::Rect vis_bounds = view->GetVisibleBounds();
- gfx::Point widget_loc(vis_bounds.x(), vis_bounds.y());
+ gfx::Point widget_loc(vis_bounds.origin());
View::ConvertPointToWidget(view, &widget_loc);
GdkRectangle tip_area = { widget_loc.x(), widget_loc.y(),
vis_bounds.width(), vis_bounds.height() };
@@ -209,7 +209,7 @@ void TooltipManagerGtk::ShowKeyboardTooltip(View* view) {
HideKeyboardTooltip();
std::wstring tooltip_text;
- if (!view->GetTooltipText(0, 0, &tooltip_text))
+ if (!view->GetTooltipText(gfx::Point(), &tooltip_text))
return; // The view doesn't have a tooltip, nothing to do.
keyboard_view_ = view;
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index c86bc76..e0b48c3 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -165,8 +165,7 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
gfx::Point view_loc = last_mouse_pos_;
View::ConvertPointToView(widget_->GetRootView(),
last_tooltip_view_, &view_loc);
- if (last_tooltip_view_->GetTooltipText(view_loc.x(), view_loc.y(),
- &tooltip_text_) &&
+ if (last_tooltip_view_->GetTooltipText(view_loc, &tooltip_text_) &&
!tooltip_text_.empty()) {
// View has a valid tip, copy it into TOOLTIPINFO.
clipped_text_ = tooltip_text_;
@@ -199,8 +198,7 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
gfx::Point view_loc = last_mouse_pos_;
View::ConvertPointToView(widget_->GetRootView(),
last_tooltip_view_, &view_loc);
- if (last_tooltip_view_->GetTooltipTextOrigin(
- view_loc.x(), view_loc.y(), &text_origin) &&
+ if (last_tooltip_view_->GetTooltipTextOrigin(view_loc, &text_origin) &&
SetTooltipPosition(text_origin.x(), text_origin.y())) {
// Return true, otherwise the rectangle we specified is ignored.
return TRUE;
@@ -284,8 +282,8 @@ void TooltipManagerWin::UpdateTooltip(const gfx::Point& mouse_pos) {
gfx::Point view_point = mouse_pos;
View::ConvertPointToView(root_view, last_tooltip_view_, &view_point);
std::wstring new_tooltip_text;
- bool has_tooltip_text = last_tooltip_view_->GetTooltipText(
- view_point.x(), view_point.y(), &new_tooltip_text);
+ bool has_tooltip_text =
+ last_tooltip_view_->GetTooltipText(view_point, &new_tooltip_text);
if (!has_tooltip_text || (new_tooltip_text != tooltip_text_)) {
// The text has changed, hide the popup.
SendMessage(tooltip_hwnd_, TTM_POP, 0, 0);
@@ -328,7 +326,7 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) {
}
HideKeyboardTooltip();
std::wstring tooltip_text;
- if (!focused_view->GetTooltipText(0, 0, &tooltip_text))
+ if (!focused_view->GetTooltipText(gfx::Point(), &tooltip_text))
return;
gfx::Rect focused_bounds = focused_view->bounds();
gfx::Point screen_point;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 3c43de7..daa43d1 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -196,8 +196,8 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
if (provider.drag_image())
gtk_drag_set_icon_pixbuf(context,
provider.drag_image(),
- provider.cursor_offset_x(),
- provider.cursor_offset_y());
+ provider.cursor_offset().x(),
+ provider.cursor_offset().y());
if (current_event)
gdk_event_free(current_event);
gtk_target_list_unref(targets);