summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 23:45:09 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 23:45:09 +0000
commit613b80638081101368e31300f6e729c720b160e0 (patch)
tree0b3dc7c7e0dde27abc814d13bdff3a1758ccde2f /chrome
parent41a5ca123f45f471457485e87681c02a21a2f052 (diff)
downloadchromium_src-613b80638081101368e31300f6e729c720b160e0.zip
chromium_src-613b80638081101368e31300f6e729c720b160e0.tar.gz
chromium_src-613b80638081101368e31300f6e729c720b160e0.tar.bz2
Convert HitTest/GetViewForPoint to use gfx::Point
http://crbug.com/2186 Review URL: http://codereview.chromium.org/7331 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/frame/browser_view2.cc5
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc4
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h2
-rw-r--r--chrome/browser/views/old_frames/frame_view.cc3
-rw-r--r--chrome/browser/views/old_frames/simple_xp_frame.cc6
-rw-r--r--chrome/browser/views/old_frames/vista_frame.cc2
-rw-r--r--chrome/browser/views/old_frames/xp_frame.cc13
-rw-r--r--chrome/browser/views/star_toggle.cc4
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc13
-rw-r--r--chrome/browser/views/tabs/tab_strip.h6
-rw-r--r--chrome/views/accessibility/view_accessibility.cc4
-rw-r--r--chrome/views/base_button.cc8
-rw-r--r--chrome/views/button_dropdown.cc4
-rw-r--r--chrome/views/chrome_menu.cc6
-rw-r--r--chrome/views/link.cc4
-rw-r--r--chrome/views/menu_button.cc4
-rw-r--r--chrome/views/root_view.cc6
-rw-r--r--chrome/views/root_view_drop_target.cc2
-rw-r--r--chrome/views/tooltip_manager.cc5
-rw-r--r--chrome/views/view.cc22
-rw-r--r--chrome/views/view.h7
-rw-r--r--chrome/views/view_unittest.cc12
22 files changed, 72 insertions, 70 deletions
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index 05dc75f..f478cc6 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -720,7 +720,7 @@ int BrowserView2::NonClientHitTest(const gfx::Point& point) {
// See if the mouse pointer is within the bounds of the TabStrip.
gfx::Point point_in_tabstrip_coords(point);
View::ConvertPointToView(GetParent(), tabstrip_, &point_in_tabstrip_coords);
- if (tabstrip_->HitTest(point_in_tabstrip_coords.ToPOINT())) {
+ if (tabstrip_->HitTest(point_in_tabstrip_coords)) {
if (tabstrip_->PointIsWithinWindowCaption(point_in_tabstrip_coords))
return HTCAPTION;
return HTCLIENT;
@@ -872,8 +872,7 @@ bool BrowserView2::ShouldForwardToTabStrip(
// Mouse isn't over the tab strip. Only forward if the mouse isn't over
// another view on the tab strip or is over a view we were told the user can
// drop on.
- ChromeViews::View* view_over_mouse =
- GetViewForPoint(CPoint(event.x(), event.y()));
+ ChromeViews::View* view_over_mouse = GetViewForPoint(event.location());
return (view_over_mouse == this || view_over_mouse == tabstrip_ ||
dropable_views_.find(view_over_mouse) != dropable_views_.end());
}
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 5bde0e6..789da0f 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -634,7 +634,7 @@ void OpaqueNonClientView::GetPreferredSize(CSize* out) {
}
ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
- const CPoint& point,
+ const gfx::Point& point,
bool can_create_floating) {
// We override this function because the ClientView can overlap the non -
// client view, making it impossible to click on the window controls. We need
@@ -644,7 +644,7 @@ ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
for (int i = 0; i < arraysize(views); ++i) {
if (!views[i]->IsVisible())
continue;
- if (views[i]->bounds().Contains(gfx::Point(point)))
+ if (views[i]->bounds().Contains(point))
return views[i];
}
return View::GetViewForPoint(point, can_create_floating);
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index 5afae53a..7766ce7 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -57,7 +57,7 @@ class OpaqueNonClientView : public ChromeViews::NonClientView,
virtual void Paint(ChromeCanvas* canvas);
virtual void Layout();
virtual void GetPreferredSize(CSize* out);
- virtual ChromeViews::View* GetViewForPoint(const CPoint& point,
+ virtual ChromeViews::View* GetViewForPoint(const gfx::Point& point,
bool can_create_floating);
virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
diff --git a/chrome/browser/views/old_frames/frame_view.cc b/chrome/browser/views/old_frames/frame_view.cc
index dab87e9..5ebe153 100644
--- a/chrome/browser/views/old_frames/frame_view.cc
+++ b/chrome/browser/views/old_frames/frame_view.cc
@@ -86,8 +86,7 @@ bool FrameView::ShouldForwardToTabStrip(
// Mouse isn't over the tab strip. Only forward if the mouse isn't over
// another view on the tab strip or is over a view we were told the user can
// drop on.
- ChromeViews::View* view_over_mouse =
- GetViewForPoint(CPoint(event.x(), event.y()));
+ ChromeViews::View* view_over_mouse = GetViewForPoint(event.location());
return (view_over_mouse == this ||
view_over_mouse == window_->GetTabStrip() ||
dropable_views_.find(view_over_mouse) != dropable_views_.end());
diff --git a/chrome/browser/views/old_frames/simple_xp_frame.cc b/chrome/browser/views/old_frames/simple_xp_frame.cc
index 550ceef..79046e6 100644
--- a/chrome/browser/views/old_frames/simple_xp_frame.cc
+++ b/chrome/browser/views/old_frames/simple_xp_frame.cc
@@ -124,7 +124,7 @@ void TitleBarMenuButton::Paint(ChromeCanvas* canvas) {
bool TitleBarMenuButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
if (e.GetFlags() & ChromeViews::MouseEvent::EF_IS_DOUBLE_CLICK) {
- if (!HitTest(WTL::CPoint(e.x(), e.y())))
+ if (!HitTest(e.location()))
return true;
title_bar_->CloseWindow();
return true;
@@ -221,8 +221,8 @@ bool SimpleXPFrameTitleBar::WillHandleMouseEvent(int x, int y) {
// If the locale is RTL, we must query for the bounds of the menu button in
// a way that returns the mirrored position and not the position set using
// SetX()/SetBounds().
- CPoint p(x - menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION),
- y - menu_button_->y());
+ gfx::Point p(x - menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION),
+ y - menu_button_->y());
return menu_button_->HitTest(p);
}
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc
index 0d74c7e..6b0d081 100644
--- a/chrome/browser/views/old_frames/vista_frame.cc
+++ b/chrome/browser/views/old_frames/vista_frame.cc
@@ -979,7 +979,7 @@ LRESULT VistaFrame::OnNCHitTest(const CPoint& pt) {
if (tab_pt.x() > 0 && tab_pt.y() >= kTabShadowSize &&
tab_pt.x() < tabstrip_->width() &&
tab_pt.y() < tabstrip_->height()) {
- ChromeViews::View* v = tabstrip_->GetViewForPoint(tab_pt.ToPOINT());
+ ChromeViews::View* v = tabstrip_->GetViewForPoint(tab_pt);
if (v == tabstrip_)
return HTCAPTION;
diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc
index 4b9cc09..e4a80e7 100644
--- a/chrome/browser/views/old_frames/xp_frame.cc
+++ b/chrome/browser/views/old_frames/xp_frame.cc
@@ -1374,16 +1374,15 @@ void XPFrame::OnCaptureChanged(HWND hwnd) {
}
LRESULT XPFrame::OnNCHitTest(const CPoint& pt) {
- CPoint p(pt);
+ gfx::Point p(pt);
CRect r;
GetWindowRect(&r);
// Convert from screen to window coordinates
- p.x -= r.left;
- p.y -= r.top;
+ p.Offset(-r.left, -r.top);
if (!IsTabStripVisible() &&
- ComputeResizeMode(p.x, p.y, r.Width(), r.Height()) == RM_UNDEFINED &&
+ ComputeResizeMode(p.x(), p.y(), r.Width(), r.Height()) == RM_UNDEFINED &&
root_view_.GetViewForPoint(p) == frame_view_) {
return HTCAPTION;
}
@@ -1393,14 +1392,14 @@ LRESULT XPFrame::OnNCHitTest(const CPoint& pt) {
// If the mouse is over the tabstrip. Check if we should move the window or
// capture the mouse.
- if (tabstrip_->CanProcessInputEvents() && tabstrip_->HitTest(tsp.ToPOINT())) {
+ if (tabstrip_->CanProcessInputEvents() && tabstrip_->HitTest(tsp)) {
// The top few pixels of a tab strip are a dropshadow - as we're pretty
// starved of draggable area, let's give it to window dragging (this
// also makes sense visually.
if (!IsZoomed() && tsp.y() < kTabShadowSize)
return HTCAPTION;
- ChromeViews::View* v = tabstrip_->GetViewForPoint(tsp.ToPOINT());
+ ChromeViews::View* v = tabstrip_->GetViewForPoint(tsp);
// If there is not tab at this location, claim the hit was in the title
// bar to get a move action.
if (v == tabstrip_)
@@ -1414,7 +1413,7 @@ LRESULT XPFrame::OnNCHitTest(const CPoint& pt) {
} else {
// The mouse is not above the tab strip. If there is no control under it,
// let's move the window.
- if (ComputeResizeMode(p.x, p.y, r.Width(), r.Height()) == RM_UNDEFINED) {
+ if (ComputeResizeMode(p.x(), p.y(), r.Width(), r.Height()) == RM_UNDEFINED) {
ChromeViews::View* v = root_view_.GetViewForPoint(p);
if (v == frame_view_ || v == off_the_record_image_ ||
v == distributor_logo_) {
diff --git a/chrome/browser/views/star_toggle.cc b/chrome/browser/views/star_toggle.cc
index 8e34d61..43ebed3e 100644
--- a/chrome/browser/views/star_toggle.cc
+++ b/chrome/browser/views/star_toggle.cc
@@ -50,7 +50,7 @@ bool StarToggle::OnMouseDragged(const ChromeViews::MouseEvent& e) {
}
bool StarToggle::OnMousePressed(const ChromeViews::MouseEvent& e) {
- if (e.IsLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (e.IsLeftMouseButton() && HitTest(e.location())) {
RequestFocus();
return true;
}
@@ -59,7 +59,7 @@ bool StarToggle::OnMousePressed(const ChromeViews::MouseEvent& e) {
void StarToggle::OnMouseReleased(const ChromeViews::MouseEvent& e,
bool canceled) {
- if (e.IsLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y())))
+ if (e.IsLeftMouseButton() && HitTest(e.location()))
SwitchState();
}
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 7e70083..835ffa6 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -528,7 +528,7 @@ bool TabStrip::CanProcessInputEvents() const {
}
bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) {
- ChromeViews::View* v = GetViewForPoint(point.ToPOINT());
+ ChromeViews::View* v = GetViewForPoint(point);
// If there is no control at this location, claim the hit was in the title
// bar to get a move action.
@@ -546,7 +546,7 @@ bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) {
gfx::Point point_in_newtab_coords(point);
View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
if (newtab_button_->bounds().Contains(point) &&
- !newtab_button_->HitTest(point_in_newtab_coords.ToPOINT())) {
+ !newtab_button_->HitTest(point_in_newtab_coords)) {
return true;
}
@@ -750,11 +750,11 @@ void TabStrip::SetAccessibleName(const std::wstring& name) {
accessible_name_.assign(name);
}
-ChromeViews::View* TabStrip::GetViewForPoint(const CPoint& point) {
+ChromeViews::View* TabStrip::GetViewForPoint(const gfx::Point& point) {
return GetViewForPoint(point, false);
}
-ChromeViews::View* TabStrip::GetViewForPoint(const CPoint& point,
+ChromeViews::View* TabStrip::GetViewForPoint(const gfx::Point& point,
bool can_create_floating) {
// Return any view that isn't a Tab or this TabStrip immediately. We don't
// want to interfere.
@@ -1566,9 +1566,10 @@ int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const {
return last_tab->x() + last_tab->width();
}
-bool TabStrip::IsPointInTab(Tab* tab, const CPoint& point_in_tabstrip_coords) {
+bool TabStrip::IsPointInTab(Tab* tab,
+ const gfx::Point& point_in_tabstrip_coords) {
gfx::Point point_in_tab_coords(point_in_tabstrip_coords);
View::ConvertPointToView(this, tab, &point_in_tab_coords);
- return tab->HitTest(point_in_tab_coords.ToPOINT());
+ return tab->HitTest(point_in_tab_coords);
}
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index ea50fd4..4d53fa1 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -111,8 +111,8 @@ class TabStrip : public ChromeViews::View,
virtual bool GetAccessibleRole(VARIANT* role);
virtual bool GetAccessibleName(std::wstring* name);
virtual void SetAccessibleName(const std::wstring& name);
- virtual ChromeViews::View* GetViewForPoint(const CPoint& point);
- virtual ChromeViews::View* GetViewForPoint(const CPoint& point,
+ virtual ChromeViews::View* GetViewForPoint(const gfx::Point& point);
+ virtual ChromeViews::View* GetViewForPoint(const gfx::Point& point,
bool can_create_floating);
protected:
@@ -277,7 +277,7 @@ class TabStrip : public ChromeViews::View,
// Returns true if the specified point in TabStrip coords is within the
// hit-test region of the specified Tab.
- bool IsPointInTab(Tab* tab, const CPoint& point_in_tabstrip_coords);
+ bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords);
// -- Member Variables ------------------------------------------------------
diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc
index 6122757..af502fc 100644
--- a/chrome/views/accessibility/view_accessibility.cc
+++ b/chrome/views/accessibility/view_accessibility.cc
@@ -495,7 +495,7 @@ STDMETHODIMP ViewAccessibility::accHitTest(LONG x_left, LONG y_top,
gfx::Point pt(x_left, y_top);
ChromeViews::View::ConvertPointToView(NULL, view_, &pt);
- if (!view_->HitTest(pt.ToPOINT())) {
+ if (!view_->HitTest(pt)) {
// If containing parent is not hit, return with failure.
child->vt = VT_EMPTY;
return S_FALSE;
@@ -508,7 +508,7 @@ STDMETHODIMP ViewAccessibility::accHitTest(LONG x_left, LONG y_top,
// Search for hit within any of the children.
child_view = view_->GetChildViewAt(child_id);
ChromeViews::View::ConvertPointToView(view_, child_view, &pt);
- if (child_view->HitTest(pt.ToPOINT())) {
+ if (child_view->HitTest(pt)) {
// Store child_id (adjusted with +1 to convert to MSAA indexing).
child->lVal = child_id + 1;
child_hit = true;
diff --git a/chrome/views/base_button.cc b/chrome/views/base_button.cc
index e9ab838..325fc4d 100644
--- a/chrome/views/base_button.cc
+++ b/chrome/views/base_button.cc
@@ -144,7 +144,7 @@ void BaseButton::SetTooltipText(const std::wstring& tooltip) {
bool BaseButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
if (state_ != BS_DISABLED) {
- if (IsTriggerableEvent(e) && HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (IsTriggerableEvent(e) && HitTest(e.location())) {
SetState(BS_PUSHED);
}
if (IsFocusable())
@@ -155,7 +155,7 @@ bool BaseButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
bool BaseButton::OnMouseDragged(const ChromeViews::MouseEvent& e) {
if (state_ != BS_DISABLED) {
- if (!HitTest(WTL::CPoint(e.x(), e.y())))
+ if (!HitTest(e.location()))
SetState(BS_NORMAL);
else if (IsTriggerableEvent(e))
SetState(BS_PUSHED);
@@ -173,7 +173,7 @@ void BaseButton::OnMouseReleased(const ChromeViews::MouseEvent& e,
}
if (state_ != BS_DISABLED) {
- if (canceled || !HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (canceled || !HitTest(e.location())) {
SetState(BS_NORMAL);
} else {
SetState(BS_HOT);
@@ -198,7 +198,7 @@ void BaseButton::OnMouseMoved(const ChromeViews::MouseEvent& e) {
using namespace ChromeViews;
if (state_ != BS_DISABLED) {
- if (HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (HitTest(e.location())) {
SetState(BS_HOT);
} else {
SetState(BS_NORMAL);
diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc
index 11523b6..a2d473b 100644
--- a/chrome/views/button_dropdown.cc
+++ b/chrome/views/button_dropdown.cc
@@ -40,7 +40,7 @@ ButtonDropDown::~ButtonDropDown() {
////////////////////////////////////////////////////////////////////////////////
bool ButtonDropDown::OnMousePressed(const ChromeViews::MouseEvent& e) {
- if (IsEnabled() && e.IsLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (IsEnabled() && e.IsLeftMouseButton() && HitTest(e.location())) {
// Store the y pos of the mouse coordinates so we can use them later to
// determine if the user dragged the mouse down (which should pop up the
// drag down menu immediately, instead of waiting for the timer)
@@ -66,7 +66,7 @@ void ButtonDropDown::OnMouseReleased(const ChromeViews::MouseEvent& e,
if (e.IsLeftMouseButton())
show_menu_factory_.RevokeAll();
- if (IsEnabled() && e.IsRightMouseButton() && HitTest(WTL::CPoint(e.x(), e.y()))) {
+ if (IsEnabled() && e.IsRightMouseButton() && HitTest(e.location())) {
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/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index 1e73954..a343efa 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -2148,7 +2148,7 @@ void MenuController::CloseAllNestedMenus() {
}
MenuItemView* MenuController::GetMenuItemAt(View* source, int x, int y) {
- View* child_under_mouse = source->GetViewForPoint(CPoint(x, y));
+ View* child_under_mouse = source->GetViewForPoint(gfx::Point(x, y));
if (child_under_mouse && child_under_mouse->IsEnabled() &&
child_under_mouse->GetID() == MenuItemView::kMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
@@ -2157,7 +2157,7 @@ MenuItemView* MenuController::GetMenuItemAt(View* source, int x, int y) {
}
MenuItemView* MenuController::GetEmptyMenuItemAt(View* source, int x, int y) {
- View* child_under_mouse = source->GetViewForPoint(CPoint(x, y));
+ View* child_under_mouse = source->GetViewForPoint(gfx::Point(x, y));
if (child_under_mouse &&
child_under_mouse->GetID() == EmptyMenuMenuItem::kEmptyMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
@@ -2170,7 +2170,7 @@ bool MenuController::IsScrollButtonAt(SubmenuView* source,
int y,
MenuPart::Type* part) {
MenuScrollViewContainer* scroll_view = source->GetScrollViewContainer();
- View* child_under_mouse = scroll_view->GetViewForPoint(CPoint(x, y));
+ View* child_under_mouse = scroll_view->GetViewForPoint(gfx::Point(x, y));
if (child_under_mouse && child_under_mouse->IsEnabled()) {
if (child_under_mouse == scroll_view->scroll_up_button()) {
*part = MenuPart::SCROLL_UP;
diff --git a/chrome/views/link.cc b/chrome/views/link.cc
index 8350a7b..2d04864 100644
--- a/chrome/views/link.cc
+++ b/chrome/views/link.cc
@@ -84,7 +84,7 @@ bool Link::OnMousePressed(const MouseEvent& e) {
bool Link::OnMouseDragged(const MouseEvent& e) {
SetHighlighted(enabled_ &&
(e.IsLeftMouseButton() || e.IsMiddleMouseButton()) &&
- HitTest(WTL::CPoint(e.x(), e.y())));
+ HitTest(e.location()));
return true;
}
@@ -94,7 +94,7 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) {
SetHighlighted(false);
if (enabled_ && !canceled &&
(e.IsLeftMouseButton() || e.IsMiddleMouseButton()) &&
- HitTest(WTL::CPoint(e.x(), e.y()))) {
+ HitTest(e.location())) {
// Focus the link on click.
RequestFocus();
diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc
index f8b0980..b8fd1b6 100644
--- a/chrome/views/menu_button.cc
+++ b/chrome/views/menu_button.cc
@@ -183,7 +183,7 @@ bool MenuButton::OnMousePressed(const ChromeViews::MouseEvent& e) {
if (GetState() != BS_DISABLED) {
// If we're draggable (GetDragOperations returns a non-zero value), then
// don't pop on press, instead wait for release.
- if (e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y())) &&
+ if (e.IsOnlyLeftMouseButton() && HitTest(e.location()) &&
GetDragOperations(e.x(), e.y()) == DragDropTypes::DRAG_NONE) {
TimeDelta delta = Time::Now() - menu_closed_time_;
int64 delta_in_milliseconds = delta.InMilliseconds();
@@ -199,7 +199,7 @@ void MenuButton::OnMouseReleased(const ChromeViews::MouseEvent& e,
bool canceled) {
if (GetDragOperations(e.x(), e.y()) != DragDropTypes::DRAG_NONE &&
GetState() != BS_DISABLED && !canceled && !InDrag() &&
- e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y()))) {
+ e.IsOnlyLeftMouseButton() && HitTest(e.location())) {
Activate();
} else {
TextButton::OnMouseReleased(e, canceled);
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index 3004db9..c5b1979 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -278,7 +278,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) {
bool hit_disabled_view = false;
// Walk up the tree until we find a view that wants the mouse event.
- for (mouse_pressed_handler_ = GetViewForPoint(WTL::CPoint(e.x(), e.y()));
+ for (mouse_pressed_handler_ = GetViewForPoint(e.location());
mouse_pressed_handler_ && (mouse_pressed_handler_ != this);
mouse_pressed_handler_ = mouse_pressed_handler_->GetParent()) {
if (!mouse_pressed_handler_->IsEnabled()) {
@@ -387,7 +387,7 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) {
}
void RootView::UpdateCursor(const MouseEvent& e) {
- View *v = GetViewForPoint(e.location().ToPOINT());
+ View *v = GetViewForPoint(e.location());
if (v && v != this) {
gfx::Point l(e.location());
@@ -404,7 +404,7 @@ void RootView::UpdateCursor(const MouseEvent& e) {
}
void RootView::OnMouseMoved(const MouseEvent& e) {
- View *v = GetViewForPoint(WTL::CPoint(e.x(), e.y()));
+ View *v = GetViewForPoint(e.location());
// Find the first enabled view.
while (v && !v->IsEnabled())
v = v->GetParent();
diff --git a/chrome/views/root_view_drop_target.cc b/chrome/views/root_view_drop_target.cc
index 405f17b..fae3265 100644
--- a/chrome/views/root_view_drop_target.cc
+++ b/chrome/views/root_view_drop_target.cc
@@ -100,7 +100,7 @@ DWORD RootViewDropTarget::OnDrop(IDataObject* data_object,
View* RootViewDropTarget::CalculateTargetView(
const gfx::Point& root_view_location,
const OSExchangeData& data) {
- View* view = root_view_->GetViewForPoint(root_view_location.ToPOINT());
+ View* view = root_view_->GetViewForPoint(root_view_location);
if (view == deepest_view_) {
// The view the mouse is over hasn't changed; reuse the target.
return target_view_;
diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc
index 4d4e4d8..e4ea574 100644
--- a/chrome/views/tooltip_manager.cc
+++ b/chrome/views/tooltip_manager.cc
@@ -148,7 +148,8 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) {
if (last_view_out_of_sync_) {
// View under the mouse is out of sync, determine it now.
RootView* root_view = view_container_->GetRootView();
- last_tooltip_view_ = root_view->GetViewForPoint(CPoint(last_mouse_x_, last_mouse_y_));
+ last_tooltip_view_ = root_view->GetViewForPoint(
+ gfx::Point(last_mouse_x_, last_mouse_y_));
last_view_out_of_sync_ = false;
}
// Tooltip control is asking for the tooltip to display.
@@ -319,7 +320,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text,
void TooltipManager::UpdateTooltip(int x, int y) {
RootView* root_view = view_container_->GetRootView();
- View* view = root_view->GetViewForPoint(CPoint(x, y));
+ View* view = root_view->GetViewForPoint(gfx::Point(x, y));
if (view != last_tooltip_view_) {
// NOTE: This *must* be sent regardless of the visibility of the tooltip.
// It triggers Windows to ask for the tooltip again.
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 5c86215..f73ca92 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -529,7 +529,7 @@ void View::SetContextMenuController(ContextMenuController* menu_controller) {
bool View::ProcessMousePressed(const MouseEvent& e, DragInfo* drag_info) {
const bool enabled = enabled_;
int drag_operations;
- if (enabled && e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.x(), e.y())))
+ if (enabled && e.IsOnlyLeftMouseButton() && HitTest(e.location()))
drag_operations = GetDragOperations(e.x(), e.y());
else
drag_operations = 0;
@@ -754,7 +754,7 @@ void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
void View::VisibilityChanged(View* starting_from, bool is_visible) {
}
-View* View::GetViewForPoint(const CPoint& point) {
+View* View::GetViewForPoint(const gfx::Point& point) {
return GetViewForPoint(point, true);
}
@@ -775,7 +775,8 @@ bool View::GetNotifyWhenVisibleBoundsInRootChanges() {
return notify_when_visible_bounds_in_root_changes_;
}
-View* View::GetViewForPoint(const CPoint& point, bool can_create_floating) {
+View* View::GetViewForPoint(const gfx::Point& point,
+ bool can_create_floating) {
// Walk the child Views recursively looking for the View that most
// tightly encloses the specified point.
for (int i = GetChildViewCount() - 1 ; i >= 0 ; --i) {
@@ -785,8 +786,8 @@ View* View::GetViewForPoint(const CPoint& point, bool can_create_floating) {
gfx::Point point_in_child_coords(point);
View::ConvertPointToView(this, child, &point_in_child_coords);
- if (child->HitTest(point_in_child_coords.ToPOINT()))
- return child->GetViewForPoint(point_in_child_coords.ToPOINT(), true);
+ if (child->HitTest(point_in_child_coords))
+ return child->GetViewForPoint(point_in_child_coords, true);
}
// We haven't found a view for the point. Try to create floating views
@@ -795,7 +796,8 @@ View* View::GetViewForPoint(const CPoint& point, bool can_create_floating) {
// GetFloatingViewIDForPoint lies or if RetrieveFloatingViewForID creates a
// view which doesn't contain the provided point
int id;
- if (can_create_floating && GetFloatingViewIDForPoint(point.x, point.y, &id)) {
+ if (can_create_floating &&
+ GetFloatingViewIDForPoint(point.x(), point.y(), &id)) {
RetrieveFloatingViewForID(id); // This creates the floating view.
return GetViewForPoint(point, false);
}
@@ -1425,14 +1427,14 @@ bool View::IsVisibleInRootView() const {
return false;
}
-bool View::HitTest(const CPoint& l) const {
- if (l.x >= 0 && l.x < static_cast<int>(width()) &&
- l.y >= 0 && l.y < static_cast<int>(height())) {
+bool View::HitTest(const gfx::Point& l) const {
+ if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
+ l.y() >= 0 && l.y() < static_cast<int>(height())) {
if (HasHitTestMask()) {
gfx::Path mask;
GetHitTestMask(&mask);
ScopedHRGN rgn(mask.CreateHRGN());
- return !!PtInRegion(rgn, l.x, l.y);
+ return !!PtInRegion(rgn, l.x(), l.y());
}
// No mask, but inside our bounds.
return true;
diff --git a/chrome/views/view.h b/chrome/views/view.h
index 75ef38e..d56d94f 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -427,7 +427,7 @@ class View : public AcceleratorTarget {
int GetChildViewCount() const;
// Get the child View at the specified point.
- virtual View* GetViewForPoint(const CPoint& point);
+ virtual View* GetViewForPoint(const gfx::Point& point);
// Get the containing ViewContainer
virtual ViewContainer* GetViewContainer() const;
@@ -893,7 +893,7 @@ class View : public AcceleratorTarget {
virtual HCURSOR GetCursorForPoint(Event::EventType event_type, int x, int y);
// Convenience to test whether a point is within this view's bounds
- virtual bool HitTest(const CPoint &l) const;
+ virtual bool HitTest(const gfx::Point& l) const;
// Gets the tooltip for this View. If the View does not have a tooltip,
// return false. If the View does have a tooltip, copy the tooltip into
@@ -1022,7 +1022,8 @@ class View : public AcceleratorTarget {
void TooltipTextChanged();
// Actual implementation of GetViewForPoint.
- virtual View* GetViewForPoint(const CPoint& point, bool can_create_floating);
+ virtual View* GetViewForPoint(const gfx::Point& point,
+ bool can_create_floating);
// Sets whether this view wants notification when its visible bounds relative
// to the root view changes. If true, this view is notified any time the
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index e476bd1..91c556c 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -538,10 +538,10 @@ class HitTestView : public ChromeViews::View {
DISALLOW_COPY_AND_ASSIGN(HitTestView);
};
-POINT ConvertPointToView(ChromeViews::View* view, const POINT& p) {
+gfx::Point ConvertPointToView(ChromeViews::View* view, const gfx::Point& p) {
gfx::Point tmp(p);
ChromeViews::View::ConvertPointToView(view->GetRootView(), view, &tmp);
- return tmp.ToPOINT();
+ return tmp;
}
}
@@ -560,10 +560,10 @@ TEST_F(ViewTest, HitTestMasks) {
v2->SetBounds(v2_bounds.ToRECT());
root_view->AddChildView(v2);
- POINT v1_centerpoint = v1_bounds.CenterPoint().ToPOINT();
- POINT v2_centerpoint = v2_bounds.CenterPoint().ToPOINT();
- POINT v1_origin = v1_bounds.origin().ToPOINT();
- POINT v2_origin = v2_bounds.origin().ToPOINT();
+ gfx::Point v1_centerpoint = v1_bounds.CenterPoint();
+ gfx::Point v2_centerpoint = v2_bounds.CenterPoint();
+ gfx::Point v1_origin = v1_bounds.origin();
+ gfx::Point v2_origin = v2_bounds.origin();
// Test HitTest
EXPECT_EQ(true, v1->HitTest(ConvertPointToView(v1, v1_centerpoint)));