summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 20:58:44 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 20:58:44 +0000
commit96b667d273c25e55150785848942c51f1a98851b (patch)
tree21ad2f8bc3a2148a517998f4ebb0157b22a75082 /chrome/views
parentdf40752a0913948b49086fee421b0d019f7de8da (diff)
downloadchromium_src-96b667d273c25e55150785848942c51f1a98851b.zip
chromium_src-96b667d273c25e55150785848942c51f1a98851b.tar.gz
chromium_src-96b667d273c25e55150785848942c51f1a98851b.tar.bz2
Change all ConvertPointTo* methods to use gfx::Point instead of CPoint.
http://crbug.com/2186 Review URL: http://codereview.chromium.org/7317 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/accessibility/view_accessibility.cc12
-rw-r--r--chrome/views/bitmap_scroll_bar.cc4
-rw-r--r--chrome/views/button_dropdown.cc4
-rw-r--r--chrome/views/chrome_menu.cc81
-rw-r--r--chrome/views/chrome_menu.h4
-rw-r--r--chrome/views/hwnd_view.cc8
-rw-r--r--chrome/views/hwnd_view_container.cc10
-rw-r--r--chrome/views/menu_button.cc11
-rw-r--r--chrome/views/root_view.cc21
-rw-r--r--chrome/views/root_view.h2
-rw-r--r--chrome/views/root_view_drop_target.cc23
-rw-r--r--chrome/views/root_view_drop_target.h6
-rw-r--r--chrome/views/tooltip_manager.cc41
-rw-r--r--chrome/views/tree_view.cc12
-rw-r--r--chrome/views/view.cc61
-rw-r--r--chrome/views/view.h11
-rw-r--r--chrome/views/view_unittest.cc4
17 files changed, 148 insertions, 167 deletions
diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc
index 259eb5c..6122757 100644
--- a/chrome/views/accessibility/view_accessibility.cc
+++ b/chrome/views/accessibility/view_accessibility.cc
@@ -474,10 +474,10 @@ STDMETHODIMP ViewAccessibility::accLocation(LONG* x_left, LONG* y_top,
*width = view_bounds.width();
*height = view_bounds.height();
- CPoint topleft = view_bounds.origin().ToPOINT();
+ gfx::Point topleft(view_bounds.origin());
ChromeViews::View::ConvertPointToScreen(parent, &topleft);
- *x_left = topleft.x;
- *y_top = topleft.y;
+ *x_left = topleft.x();
+ *y_top = topleft.y();
} else {
return E_FAIL;
}
@@ -492,10 +492,10 @@ STDMETHODIMP ViewAccessibility::accHitTest(LONG x_left, LONG y_top,
return E_INVALIDARG;
}
- CPoint pt(x_left, y_top);
+ gfx::Point pt(x_left, y_top);
ChromeViews::View::ConvertPointToView(NULL, view_, &pt);
- if (!view_->HitTest(pt)) {
+ if (!view_->HitTest(pt.ToPOINT())) {
// 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)) {
+ if (child_view->HitTest(pt.ToPOINT())) {
// Store child_id (adjusted with +1 to convert to MSAA indexing).
child->lVal = child_id + 1;
child_hit = true;
diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc
index 948846bd..334701b 100644
--- a/chrome/views/bitmap_scroll_bar.cc
+++ b/chrome/views/bitmap_scroll_bar.cc
@@ -542,9 +542,9 @@ void BitmapScrollBar::ShowContextMenu(View* source, int x, int y,
ViewContainer* vc = GetViewContainer();
CRect vc_bounds;
vc->GetBounds(&vc_bounds, true);
- CPoint temp_pt(x - vc_bounds.left, y - vc_bounds.top);
+ gfx::Point temp_pt(x - vc_bounds.left, y - vc_bounds.top);
View::ConvertPointFromViewContainer(this, &temp_pt);
- context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x : temp_pt.y;
+ context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y();
Menu menu(this, Menu::TOPLEFT, GetViewContainer()->GetHWND());
menu.AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere);
diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc
index aef0e1d..11523b6 100644
--- a/chrome/views/button_dropdown.cc
+++ b/chrome/views/button_dropdown.cc
@@ -112,7 +112,7 @@ void ButtonDropDown::ShowDropDownMenu(HWND window) {
// Both the menu position and the menu anchor type change if the UI layout
// is right-to-left.
- CPoint menu_position = CPoint(lb.TopLeft());
+ gfx::Point menu_position(lb.TopLeft());
menu_position.Offset(0, lb.Height() - 1);
if (UILayoutIsRightToLeft())
menu_position.Offset(lb.Width() - 1, 0);
@@ -139,7 +139,7 @@ void ButtonDropDown::ShowDropDownMenu(HWND window) {
}
}
- menu.RunMenuAt(menu_position.x, menu_position.y);
+ menu.RunMenuAt(menu_position.x(), menu_position.y());
// Need to explicitly clear mouse handler so that events get sent
// properly after the menu finishes running. If we don't do this, then
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index f51e964..1e73954 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -1735,10 +1735,10 @@ void MenuController::OnMouseDragged(SubmenuView* source,
// 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.
- CPoint press_loc(press_x_, press_y_);
+ gfx::Point press_loc(press_x_, press_y_);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
View::ConvertPointToView(NULL, item, &press_loc);
- CPoint drag_loc(event.x(), event.y());
+ gfx::Point drag_loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &drag_loc);
View::ConvertPointToView(NULL, item, &drag_loc);
in_drag_ = true;
@@ -1748,8 +1748,8 @@ void MenuController::OnMouseDragged(SubmenuView* source,
scoped_refptr<OSExchangeData> data(new OSExchangeData);
item->GetDelegate()->WriteDragData(item, data.get());
drag_utils::SetDragImageOnDataObject(canvas, item->width(),
- item->height(), press_loc.x,
- press_loc.y, data);
+ item->height(), press_loc.x(),
+ press_loc.y(), data);
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
int drag_ops = item->GetDelegate()->GetDragOperations(item);
@@ -1797,12 +1797,12 @@ void MenuController::OnMouseReleased(SubmenuView* source,
bool open_submenu = (state_.item == pending_state_.item &&
state_.submenu_open);
SetSelection(pending_state_.item, open_submenu, true);
- CPoint loc(event.x(), event.y());
+ gfx::Point loc(event.location());
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))
+ part.menu, part.menu->GetCommand(), loc.x(), loc.y(), true))
return;
}
@@ -1867,14 +1867,14 @@ int MenuController::OnDragUpdated(SubmenuView* source,
const DropTargetEvent& event) {
StopCancelAllTimer();
- CPoint screen_loc(event.x(), event.y());
+ 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.x() == drop_x_ &&
+ screen_loc.y() == drop_y_) {
return last_drop_operation_;
}
- drop_x_ = screen_loc.x;
- drop_y_ = screen_loc.y;
+ drop_x_ = screen_loc.x();
+ drop_y_ = screen_loc.y();
valid_drop_coordinates_ = true;
MenuItemView* menu_item = GetMenuItemAt(source, event.x(), event.y());
@@ -1888,17 +1888,17 @@ int MenuController::OnDragUpdated(SubmenuView* source,
MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE;
int drop_operation = DragDropTypes::DRAG_NONE;
if (menu_item) {
- CPoint menu_item_loc(event.x(), event.y());
+ gfx::Point menu_item_loc(event.location());
View::ConvertPointToView(source, menu_item, &menu_item_loc);
MenuItemView* query_menu_item;
if (!over_empty_menu) {
int menu_item_height = menu_item->height();
if (menu_item->HasSubmenu() &&
- (menu_item_loc.y > MenuItemView::kDropBetweenPixels &&
- menu_item_loc.y < (menu_item_height -
- MenuItemView::kDropBetweenPixels))) {
+ (menu_item_loc.y() > MenuItemView::kDropBetweenPixels &&
+ menu_item_loc.y() < (menu_item_height -
+ MenuItemView::kDropBetweenPixels))) {
drop_position = MenuDelegate::DROP_ON;
- } else if (menu_item_loc.y < menu_item_height / 2) {
+ } else if (menu_item_loc.y() < menu_item_height / 2) {
drop_position = MenuDelegate::DROP_BEFORE;
} else {
drop_position = MenuDelegate::DROP_AFTER;
@@ -2190,7 +2190,7 @@ MenuController::MenuPart MenuController::GetMenuPartByScreenCoordinate(
int source_y) {
MenuPart part;
- CPoint screen_loc(source_x, source_y);
+ gfx::Point screen_loc(source_x, source_y);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
MenuItemView* item = state_.item;
@@ -2208,20 +2208,20 @@ MenuController::MenuPart MenuController::GetMenuPartByScreenCoordinate(
bool MenuController::GetMenuPartByScreenCoordinateImpl(
SubmenuView* menu,
- const CPoint& screen_loc,
+ const gfx::Point& screen_loc,
MenuPart* part) {
// Is the mouse over the scroll buttons?
- CPoint scroll_view_loc = screen_loc;
+ gfx::Point scroll_view_loc = screen_loc;
View* scroll_view_container = menu->GetScrollViewContainer();
View::ConvertPointToView(NULL, scroll_view_container, &scroll_view_loc);
- if (scroll_view_loc.x < 0 ||
- scroll_view_loc.x >= scroll_view_container->width() ||
- scroll_view_loc.y < 0 ||
- scroll_view_loc.y >= scroll_view_container->height()) {
+ if (scroll_view_loc.x() < 0 ||
+ scroll_view_loc.x() >= scroll_view_container->width() ||
+ scroll_view_loc.y() < 0 ||
+ scroll_view_loc.y() >= scroll_view_container->height()) {
// Point isn't contained in menu.
return false;
}
- if (IsScrollButtonAt(menu, scroll_view_loc.x, scroll_view_loc.y,
+ if (IsScrollButtonAt(menu, scroll_view_loc.x(), scroll_view_loc.y(),
&(part->type))) {
part->submenu = menu;
return true;
@@ -2229,9 +2229,9 @@ bool MenuController::GetMenuPartByScreenCoordinateImpl(
// Not over the scroll button. Check the actual menu.
if (DoesSubmenuContainLocation(menu, screen_loc)) {
- CPoint menu_loc = screen_loc;
+ gfx::Point menu_loc = screen_loc;
View::ConvertPointToView(NULL, menu, &menu_loc);
- part->menu = GetMenuItemAt(menu, menu_loc.x, menu_loc.y);
+ part->menu = GetMenuItemAt(menu, menu_loc.x(), menu_loc.y());
part->type = MenuPart::MENU_ITEM;
return true;
}
@@ -2243,11 +2243,11 @@ bool MenuController::GetMenuPartByScreenCoordinateImpl(
}
bool MenuController::DoesSubmenuContainLocation(SubmenuView* submenu,
- const CPoint& screen_loc) {
- CPoint view_loc = screen_loc;
+ const gfx::Point& screen_loc) {
+ gfx::Point view_loc = screen_loc;
View::ConvertPointToView(NULL, submenu, &view_loc);
gfx::Rect vis_rect = submenu->GetVisibleBounds();
- return vis_rect.Contains(view_loc.x, view_loc.y);
+ return vis_rect.Contains(view_loc.x(), view_loc.y());
}
void MenuController::CommitPendingSelection() {
@@ -2455,7 +2455,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
} else {
// Not the first menu; position it relative to the bounds of the menu
// item.
- CPoint item_loc(0, 0);
+ gfx::Point item_loc;
View::ConvertPointToScreen(item, &item_loc);
// We must make sure we take into account the UI layout. If the layout is
@@ -2466,26 +2466,26 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
(!prefer_leading && layout_is_rtl);
if (create_on_the_right) {
- x = item_loc.x + item->width() - kSubmenuHorizontalInset;
+ x = item_loc.x() + item->width() - kSubmenuHorizontalInset;
if (state_.monitor_bounds.width() != 0 &&
x + pref.cx > state_.monitor_bounds.right()) {
if (layout_is_rtl)
*is_leading = true;
else
*is_leading = false;
- x = item_loc.x - pref.cx + kSubmenuHorizontalInset;
+ x = item_loc.x() - pref.cx + kSubmenuHorizontalInset;
}
} else {
- x = item_loc.x - pref.cx + kSubmenuHorizontalInset;
+ x = item_loc.x() - pref.cx + kSubmenuHorizontalInset;
if (state_.monitor_bounds.width() != 0 && x < state_.monitor_bounds.x()) {
if (layout_is_rtl)
*is_leading = false;
else
*is_leading = true;
- x = item_loc.x + item->width() - kSubmenuHorizontalInset;
+ x = item_loc.x() + item->width() - kSubmenuHorizontalInset;
}
}
- y = item_loc.y - kSubmenuBorderSize;
+ y = item_loc.y() - kSubmenuBorderSize;
if (state_.monitor_bounds.width() != 0) {
pref.cy = std::min(pref.cy,
static_cast<LONG>(state_.monitor_bounds.height()));
@@ -2636,9 +2636,9 @@ bool MenuController::SelectByChar(wchar_t character) {
void MenuController::RepostEvent(SubmenuView* source,
const MouseEvent& event) {
- CPoint screen_loc(event.x(), event.y());
+ gfx::Point screen_loc(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
- HWND window = WindowFromPoint(screen_loc);
+ HWND window = WindowFromPoint(screen_loc.ToPOINT());
if (window) {
#ifdef DEBUG_MENU
DLOG(INFO) << "RepostEvent on press";
@@ -2661,13 +2661,14 @@ void MenuController::RepostEvent(SubmenuView* source,
// Convert the coordinates to the target window.
RECT window_bounds;
GetWindowRect(window, &window_bounds);
- int window_x = screen_loc.x - window_bounds.left;
- int window_y = screen_loc.y - window_bounds.top;
+ int window_x = screen_loc.x() - window_bounds.left;
+ int window_y = screen_loc.y() - window_bounds.top;
// Determine whether the click was in the client area or not.
// NOTE: WM_NCHITTEST coordinates are relative to the screen.
LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0,
- MAKELPARAM(screen_loc.x, screen_loc.y));
+ MAKELPARAM(screen_loc.x(),
+ screen_loc.y()));
const bool in_client_area = (nc_hit_result == HTCLIENT);
// TODO(sky): this isn't right. The event to generate should correspond
diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h
index b192c9c..3e07e21 100644
--- a/chrome/views/chrome_menu.h
+++ b/chrome/views/chrome_menu.h
@@ -757,13 +757,13 @@ class MenuController : public MessageLoopForUI::Dispatcher {
// true if the supplied SubmenuView contains the location in terms of the
// screen. If it does, part is set appropriately and true is returned.
bool GetMenuPartByScreenCoordinateImpl(SubmenuView* menu,
- const CPoint& screen_loc,
+ const gfx::Point& screen_loc,
MenuPart* part);
// Returns true if the SubmenuView contains the specified location. This does
// NOT included the scroll buttons, only the submenu view.
bool DoesSubmenuContainLocation(SubmenuView* submenu,
- const CPoint& screen_loc);
+ const gfx::Point& screen_loc);
// Opens/Closes the necessary menus such that state_ matches that of
// pending_state_. This is invoked if submenus are not opened immediately,
diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc
index e9d0a37..c163704 100644
--- a/chrome/views/hwnd_view.cc
+++ b/chrome/views/hwnd_view.cc
@@ -71,9 +71,7 @@ void HWNDView::UpdateHWNDBounds() {
// of the ViewContainer that hosts our View hierarchy) they need to be
// positioned in the coordinate system of the ViewContainer, not the current
// view.
- CPoint top_left;
-
- top_left.x = top_left.y = 0;
+ gfx::Point top_left;
ConvertPointToViewContainer(this, &top_left);
gfx::Rect vis_bounds = GetVisibleBounds();
@@ -114,7 +112,7 @@ void HWNDView::UpdateHWNDBounds() {
// In a fast resize, we move the window and clip it with SetWindowRgn.
CRect rect;
GetWindowRect(hwnd_, &rect);
- ::SetWindowPos(hwnd_, 0, top_left.x, top_left.y, rect.Width(),
+ ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), rect.Width(),
rect.Height(), swp_flags);
HRGN clip_region = CreateRectRgn(0, 0,
@@ -123,7 +121,7 @@ void HWNDView::UpdateHWNDBounds() {
SetWindowRgn(hwnd_, clip_region, FALSE);
installed_clip_ = true;
} else {
- ::SetWindowPos(hwnd_, 0, top_left.x, top_left.y, bounds_.Width(),
+ ::SetWindowPos(hwnd_, 0, top_left.x(), top_left.y(), bounds_.Width(),
bounds_.Height(), swp_flags);
}
} else if (::IsWindowVisible(hwnd_)) {
diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc
index 8000f45..d4f4ae2 100644
--- a/chrome/views/hwnd_view_container.cc
+++ b/chrome/views/hwnd_view_container.cc
@@ -745,15 +745,15 @@ void HWNDViewContainer::ProcessMouseMoved(const CPoint &point, UINT flags,
if (has_capture_ && is_mouse_down_) {
ProcessMouseDragged(point, flags);
} else {
- CPoint screen_loc = point;
+ gfx::Point screen_loc(point);
View::ConvertPointToScreen(root_view_.get(), &screen_loc);
- if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x &&
- last_mouse_move_y_ == screen_loc.y) {
+ if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() &&
+ last_mouse_move_y_ == screen_loc.y()) {
// Don't generate a mouse event for the same location as the last.
return;
}
- last_mouse_move_x_ = screen_loc.x;
- last_mouse_move_y_ = screen_loc.y;
+ last_mouse_move_x_ = screen_loc.x();
+ last_mouse_move_y_ = screen_loc.y();
last_mouse_event_was_move_ = true;
MouseEvent mouse_move(Event::ET_MOUSE_MOVED,
point.x,
diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc
index b2bdbea..f8b0980 100644
--- a/chrome/views/menu_button.cc
+++ b/chrome/views/menu_button.cc
@@ -129,9 +129,9 @@ bool MenuButton::Activate() {
// The position of the menu depends on whether or not the locale is
// right-to-left.
- CPoint menu_position = lb.BottomRight();
+ gfx::Point menu_position(lb.BottomRight());
if (UILayoutIsRightToLeft())
- menu_position.x = lb.left;
+ menu_position.set_x(lb.left);
View::ConvertPointToScreen(this, &menu_position);
if (UILayoutIsRightToLeft())
@@ -140,8 +140,8 @@ bool MenuButton::Activate() {
menu_position.Offset(-2, -4);
int max_x_coordinate = GetMaximumScreenXCoordinate();
- if (max_x_coordinate && max_x_coordinate <= menu_position.x)
- menu_position.x = max_x_coordinate - 1;
+ if (max_x_coordinate && max_x_coordinate <= menu_position.x())
+ menu_position.set_x(max_x_coordinate - 1);
// We're about to show the menu from a mouse press. By showing from the
// mouse press event we block RootView in mouse dispatching. This also
@@ -153,7 +153,8 @@ bool MenuButton::Activate() {
GetRootView()->SetMouseHandler(NULL);
menu_visible_ = true;
- menu_delegate_->RunMenu(this, menu_position, GetViewContainer()->GetHWND());
+ menu_delegate_->RunMenu(this, menu_position.ToPOINT(),
+ GetViewContainer()->GetHWND());
menu_visible_ = false;
menu_closed_time_ = Time::Now();
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index d3d1e96..3004db9 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -323,7 +323,8 @@ bool RootView::OnMousePressed(const MouseEvent& e) {
return hit_disabled_view;
}
-bool RootView::ConvertPointToMouseHandler(const CPoint &l, CPoint *p) {
+bool RootView::ConvertPointToMouseHandler(const gfx::Point& l,
+ gfx::Point* p) {
//
// If the mouse_handler was set explicitly, we need to keep
// sending events even if it was reparented in a different
@@ -354,9 +355,9 @@ bool RootView::OnMouseDragged(const MouseEvent& e) {
if (mouse_pressed_handler_) {
SetMouseLocationAndFlags(e);
- CPoint p;
- ConvertPointToMouseHandler(WTL::CPoint(e.x(), e.y()), &p);
- MouseEvent mouse_event(e.GetType(), p.x, p.y, e.GetFlags());
+ gfx::Point p;
+ ConvertPointToMouseHandler(e.location(), &p);
+ MouseEvent mouse_event(e.GetType(), p.x(), p.y(), e.GetFlags());
if (!mouse_pressed_handler_->ProcessMouseDragged(mouse_event,
&drag_info)) {
mouse_pressed_handler_ = NULL;
@@ -372,9 +373,9 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) {
UpdateCursor(e);
if (mouse_pressed_handler_) {
- CPoint p;
- ConvertPointToMouseHandler(WTL::CPoint(e.x(), e.y()), &p);
- MouseEvent mouse_released(e.GetType(), p.x, p.y, e.GetFlags());
+ gfx::Point p;
+ ConvertPointToMouseHandler(e.location(), &p);
+ MouseEvent mouse_released(e.GetType(), p.x(), p.y(), e.GetFlags());
// We allow the view to delete us from ProcessMouseReleased. As such,
// configure state such that we're done first, then call View.
View* mouse_pressed_handler = mouse_pressed_handler_;
@@ -386,12 +387,12 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) {
}
void RootView::UpdateCursor(const MouseEvent& e) {
- View *v = GetViewForPoint(WTL::CPoint(e.x(), e.y()));
+ View *v = GetViewForPoint(e.location().ToPOINT());
if (v && v != this) {
- CPoint l(e.x(), e.y());
+ gfx::Point l(e.location());
View::ConvertPointToView(this, v, &l);
- HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x, l.y);
+ HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
if (cursor) {
::SetCursor(cursor);
return;
diff --git a/chrome/views/root_view.h b/chrome/views/root_view.h
index 34bce21..99d744b 100644
--- a/chrome/views/root_view.h
+++ b/chrome/views/root_view.h
@@ -204,7 +204,7 @@ class RootView : public View,
// Convert a point to our current mouse handler. Returns false if the
// mouse handler is not connected to a ViewContainer. In that case, the
// conversion cannot take place and *p is unchanged
- bool ConvertPointToMouseHandler(const CPoint &l, CPoint *p);
+ bool ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point *p);
// Update the cursor given a mouse event. This is called by non mouse_move
// event handlers to honor the cursor desired by views located under the
diff --git a/chrome/views/root_view_drop_target.cc b/chrome/views/root_view_drop_target.cc
index a75bf71f..405f17b 100644
--- a/chrome/views/root_view_drop_target.cc
+++ b/chrome/views/root_view_drop_target.cc
@@ -4,6 +4,7 @@
#include "chrome/views/root_view_drop_target.h"
+#include "base/gfx/point.h"
#include "base/logging.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/views/root_view.h"
@@ -33,7 +34,7 @@ DWORD RootViewDropTarget::OnDragOver(IDataObject* data_object,
POINT cursor_position,
DWORD effect) {
const OSExchangeData data(data_object);
- CPoint root_view_location(cursor_position.x, cursor_position.y);
+ gfx::Point root_view_location(cursor_position.x, cursor_position.y);
View::ConvertPointToView(NULL, root_view_, &root_view_location);
View* view = CalculateTargetView(root_view_location, data);
@@ -43,22 +44,22 @@ DWORD RootViewDropTarget::OnDragOver(IDataObject* data_object,
target_view_->OnDragExited();
target_view_ = view;
if (target_view_) {
- CPoint target_view_location(root_view_location.x, root_view_location.y);
+ gfx::Point target_view_location(root_view_location);
View::ConvertPointToView(root_view_, target_view_, &target_view_location);
DropTargetEvent enter_event(data,
- target_view_location.x,
- target_view_location.y,
+ target_view_location.x(),
+ target_view_location.y(),
DragDropTypes::DropEffectToDragOperation(effect));
target_view_->OnDragEntered(enter_event);
}
}
if (target_view_) {
- CPoint target_view_location(root_view_location.x, root_view_location.y);
+ gfx::Point target_view_location(root_view_location);
View::ConvertPointToView(root_view_, target_view_, &target_view_location);
DropTargetEvent enter_event(data,
- target_view_location.x,
- target_view_location.y,
+ target_view_location.x(),
+ target_view_location.y(),
DragDropTypes::DropEffectToDragOperation(effect));
int result_operation = target_view_->OnDragUpdated(enter_event);
return DragDropTypes::DragOperationToDropEffect(result_operation);
@@ -83,9 +84,9 @@ DWORD RootViewDropTarget::OnDrop(IDataObject* data_object,
View* drop_view = target_view_;
deepest_view_ = target_view_ = NULL;
if (drop_effect != DROPEFFECT_NONE) {
- CPoint view_location(cursor_position.x, cursor_position.y);
+ gfx::Point view_location(cursor_position.x, cursor_position.y);
View::ConvertPointToView(NULL, drop_view, &view_location);
- DropTargetEvent drop_event(data, view_location.x, view_location.y,
+ DropTargetEvent drop_event(data, view_location.x(), view_location.y(),
DragDropTypes::DropEffectToDragOperation(effect));
return DragDropTypes::DragOperationToDropEffect(
drop_view->OnPerformDrop(drop_event));
@@ -97,9 +98,9 @@ DWORD RootViewDropTarget::OnDrop(IDataObject* data_object,
}
View* RootViewDropTarget::CalculateTargetView(
- const CPoint& root_view_location,
+ const gfx::Point& root_view_location,
const OSExchangeData& data) {
- View* view = root_view_->GetViewForPoint(root_view_location);
+ View* view = root_view_->GetViewForPoint(root_view_location.ToPOINT());
if (view == deepest_view_) {
// The view the mouse is over hasn't changed; reuse the target.
return target_view_;
diff --git a/chrome/views/root_view_drop_target.h b/chrome/views/root_view_drop_target.h
index 4c100c5..8764689 100644
--- a/chrome/views/root_view_drop_target.h
+++ b/chrome/views/root_view_drop_target.h
@@ -12,6 +12,10 @@
#include "base/base_drop_target.h"
#include "chrome/common/os_exchange_data.h"
+namespace gfx {
+class Point;
+}
+
namespace ChromeViews {
class RootView;
@@ -51,7 +55,7 @@ class RootViewDropTarget : public BaseDropTarget {
// the coordinate system of the rootview. This tries to avoid continually
// querying CanDrop by returning target_view_ if the mouse is still over
// target_view_.
- View* CalculateTargetView(const CPoint& root_view_location,
+ View* CalculateTargetView(const gfx::Point& root_view_location,
const OSExchangeData& data);
// RootView we were created for.
diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc
index a146933..4d4e4d8 100644
--- a/chrome/views/tooltip_manager.cc
+++ b/chrome/views/tooltip_manager.cc
@@ -163,10 +163,10 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) {
if (last_tooltip_view_ != NULL) {
tooltip_text_.clear();
// Mouse is over a View, ask the View for it's tooltip.
- CPoint view_loc(last_mouse_x_, last_mouse_y_);
+ gfx::Point view_loc(last_mouse_x_, last_mouse_y_);
View::ConvertPointToView(view_container_->GetRootView(),
last_tooltip_view_, &view_loc);
- if (last_tooltip_view_->GetTooltipText(view_loc.x, view_loc.y,
+ if (last_tooltip_view_->GetTooltipText(view_loc.x(), view_loc.y(),
&tooltip_text_) &&
!tooltip_text_.empty()) {
// View has a valid tip, copy it into TOOLTIPINFO.
@@ -192,11 +192,11 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) {
CPoint text_origin;
if (tooltip_height_ == 0)
tooltip_height_ = CalcTooltipHeight();
- CPoint view_loc(last_mouse_x_, last_mouse_y_);
+ gfx::Point view_loc(last_mouse_x_, last_mouse_y_);
View::ConvertPointToView(view_container_->GetRootView(),
last_tooltip_view_, &view_loc);
if (last_tooltip_view_->GetTooltipTextOrigin(
- view_loc.x, view_loc.y, &text_origin) &&
+ view_loc.x(), view_loc.y(), &text_origin) &&
SetTooltipPosition(text_origin.x, text_origin.y)) {
// Return true, otherwise the rectangle we specified is ignored.
return TRUE;
@@ -216,12 +216,12 @@ bool TooltipManager::SetTooltipPosition(int text_x, int text_y) {
// is good enough for our usage.
// Calculate the bounds the tooltip will get.
- CPoint view_loc(0, 0);
+ gfx::Point view_loc;
View::ConvertPointToScreen(last_tooltip_view_, &view_loc);
- RECT bounds = { view_loc.x + text_x,
- view_loc.y + text_y,
- view_loc.x + text_x + tooltip_width_,
- view_loc.y + line_count_ * GetTooltipHeight() };
+ RECT bounds = { view_loc.x() + text_x,
+ view_loc.y() + text_y,
+ view_loc.x() + text_x + tooltip_width_,
+ view_loc.y() + line_count_ * GetTooltipHeight() };
SendMessage(tooltip_hwnd_, TTM_ADJUSTRECT, TRUE, (LPARAM)&bounds);
// Make sure the rectangle completely fits on the current monitor. If it
@@ -282,10 +282,10 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text,
*text = text->substr(0, kMaxTooltipLength);
// Determine the available width for the tooltip.
- CPoint screen_loc(position_x, position_y);
+ gfx::Point screen_loc(position_x, position_y);
View::ConvertPointToScreen(view_container_->GetRootView(), &screen_loc);
gfx::Rect monitor_bounds =
- win_util::GetMonitorBoundsForRect(gfx::Rect(screen_loc.x, screen_loc.y,
+ win_util::GetMonitorBoundsForRect(gfx::Rect(screen_loc.x(), screen_loc.y(),
0, 0));
RECT tooltip_margin;
SendMessage(window, TTM_GETMARGIN, 0, (LPARAM)&tooltip_margin);
@@ -328,10 +328,10 @@ void TooltipManager::UpdateTooltip(int x, int y) {
} else if (last_tooltip_view_ != NULL) {
// Tooltip is showing, and mouse is over the same view. See if the tooltip
// text has changed.
- CPoint view_point(x, y);
+ gfx::Point view_point(x, y);
View::ConvertPointToView(root_view, last_tooltip_view_, &view_point);
std::wstring new_tooltip_text;
- if (last_tooltip_view_->GetTooltipText(view_point.x, view_point.y,
+ if (last_tooltip_view_->GetTooltipText(view_point.x(), view_point.y(),
&new_tooltip_text) &&
new_tooltip_text != tooltip_text_) {
// The text has changed, hide the popup.
@@ -381,9 +381,9 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) {
if (!focused_view->GetTooltipText(0, 0, &tooltip_text))
return;
gfx::Rect focused_bounds = focused_view->bounds();
- CPoint screen_point;
+ gfx::Point screen_point;
focused_view->ConvertPointToScreen(focused_view, &screen_point);
- CPoint relative_point_coordinates;
+ gfx::Point relative_point_coordinates;
focused_view->ConvertPointToViewContainer(focused_view,
&relative_point_coordinates);
keyboard_tooltip_hwnd_ = CreateWindowEx(
@@ -394,8 +394,8 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) {
int tooltip_width;
int line_count;
TrimTooltipToFit(&tooltip_text, &tooltip_width, &line_count,
- relative_point_coordinates.x, relative_point_coordinates.y,
- keyboard_tooltip_hwnd_);
+ relative_point_coordinates.x(),
+ relative_point_coordinates.y(), keyboard_tooltip_hwnd_);
TOOLINFO keyboard_toolinfo;
memset(&keyboard_toolinfo, 0, sizeof(keyboard_toolinfo));
keyboard_toolinfo.cbSize = sizeof(keyboard_toolinfo);
@@ -408,9 +408,10 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) {
reinterpret_cast<LPARAM>(&keyboard_toolinfo));
if (!tooltip_height_)
tooltip_height_ = CalcTooltipHeight();
- RECT rect_bounds = {screen_point.x, screen_point.y + focused_bounds.height(),
- screen_point.x + tooltip_width,
- screen_point.y + focused_bounds.height() +
+ RECT rect_bounds = {screen_point.x(),
+ screen_point.y() + focused_bounds.height(),
+ screen_point.x() + tooltip_width,
+ screen_point.y() + focused_bounds.height() +
line_count * tooltip_height_ };
gfx::Rect monitor_bounds =
win_util::GetMonitorBoundsForRect(gfx::Rect(rect_bounds));
diff --git a/chrome/views/tree_view.cc b/chrome/views/tree_view.cc
index 3952ec0..662f7194 100644
--- a/chrome/views/tree_view.cc
+++ b/chrome/views/tree_view.cc
@@ -447,20 +447,20 @@ void TreeView::OnContextMenu(const CPoint& location) {
x = width() / 2;
y = height() / 2;
}
- CPoint screen_loc(x, y);
+ gfx::Point screen_loc(x, y);
ConvertPointToScreen(this, &screen_loc);
- GetContextMenuController()->ShowContextMenu(this, screen_loc.x,
- screen_loc.y, false);
+ GetContextMenuController()->ShowContextMenu(this, screen_loc.x(),
+ screen_loc.y(), false);
} else if (!show_context_menu_only_when_node_selected_) {
GetContextMenuController()->ShowContextMenu(this, location.x, location.y,
true);
} else if (GetSelectedNode()) {
// Make sure the mouse is over the selected node.
TVHITTESTINFO hit_info;
- CPoint local_loc(location);
+ 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.x = local_loc.x();
+ hit_info.pt.y = local_loc.y();
HTREEITEM hit_item = TreeView_HitTest(tree_view_, &hit_info);
if (hit_item &&
GetNodeDetails(GetSelectedNode())->tree_item == hit_item &&
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index def0ec6..5c86215 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -569,11 +569,11 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) {
if (!canceled && context_menu_controller_ && e.IsOnlyRightMouseButton()) {
// Assume that if there is a context menu controller we won't be deleted
// from mouse released.
- CPoint location(e.x(), e.y());
+ gfx::Point location(e.location());
ConvertPointToScreen(this, &location);
ContextMenuController* context_menu_controller = context_menu_controller_;
OnMouseReleased(e, canceled);
- context_menu_controller_->ShowContextMenu(this, location.x, location.y,
+ context_menu_controller_->ShowContextMenu(this, location.x(), location.y(),
true);
} else {
OnMouseReleased(e, canceled);
@@ -783,10 +783,10 @@ View* View::GetViewForPoint(const CPoint& point, bool can_create_floating) {
if (!child->IsVisible())
continue;
- CPoint point_in_child_coords(point);
+ gfx::Point point_in_child_coords(point);
View::ConvertPointToView(this, child, &point_in_child_coords);
- if (child->HitTest(point_in_child_coords))
- return child->GetViewForPoint(point_in_child_coords, true);
+ if (child->HitTest(point_in_child_coords.ToPOINT()))
+ return child->GetViewForPoint(point_in_child_coords.ToPOINT(), true);
}
// We haven't found a view for the point. Try to create floating views
@@ -1284,26 +1284,12 @@ bool View::EnumerateFloatingViewsForInterval(int low_bound, int high_bound,
}
// static
-void View::ConvertPointToView(View* src,
- View* dst,
- gfx::Point* point) {
+void View::ConvertPointToView(View* src, View* dst, gfx::Point* point) {
ConvertPointToView(src, dst, point, true);
}
// static
-void View::ConvertPointToView(View* src,
- View* dst,
- CPoint* point) {
- gfx::Point tmp_point(point->x, point->y);
- ConvertPointToView(src, dst, &tmp_point, true);
- point->x = tmp_point.x();
- point->y = tmp_point.y();
-}
-
-// static
-void View::ConvertPointToView(View* src,
- View* dst,
- gfx::Point* point,
+void View::ConvertPointToView(View* src, View* dst, gfx::Point* point,
bool try_other_direction) {
// src can be NULL
DCHECK(dst);
@@ -1343,45 +1329,38 @@ void View::ConvertPointToView(View* src,
}
// static
-void View::ConvertPointToViewContainer(View* src, CPoint* p) {
+void View::ConvertPointToViewContainer(View* src, gfx::Point* p) {
DCHECK(src);
DCHECK(p);
- View *v;
- CPoint offset(0, 0);
+ View *v;
+ gfx::Point offset;
for (v = src; v; v = v->GetParent()) {
- offset.x += v->GetX(APPLY_MIRRORING_TRANSFORMATION);
- offset.y += v->y();
+ offset.set_x(offset.x() + v->GetX(APPLY_MIRRORING_TRANSFORMATION));
+ offset.set_y(offset.y() + v->y());
}
- p->x += offset.x;
- p->y += offset.y;
+ p->SetPoint(p->x() + offset.x(), p->y() + offset.y());
}
// static
-void View::ConvertPointFromViewContainer(View *source, CPoint *p) {
- CPoint t(0, 0);
+void View::ConvertPointFromViewContainer(View *source, gfx::Point* p) {
+ gfx::Point t;
ConvertPointToViewContainer(source, &t);
- p->x -= t.x;
- p->y -= t.y;
+ p->SetPoint(p->x() - t.x(), p->y() - t.y());
}
// static
-void View::ConvertPointToScreen(View* src, CPoint* p) {
+void View::ConvertPointToScreen(View* src, gfx::Point* p) {
DCHECK(src);
DCHECK(p);
- // If the view is not connected to a tree, do nothing
- if (src->GetViewContainer() == NULL) {
- return;
- }
-
- ConvertPointToViewContainer(src, p);
+ // If the view is not connected to a tree, there's nothing we can do.
ViewContainer* vc = src->GetViewContainer();
if (vc) {
+ ConvertPointToViewContainer(src, p);
CRect r;
vc->GetBounds(&r, false);
- p->x += r.left;
- p->y += r.top;
+ p->SetPoint(p->x() + r.left, p->y() + r.top);
}
}
diff --git a/chrome/views/view.h b/chrome/views/view.h
index 6e46336..75ef38e 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -672,24 +672,19 @@ class View : public AcceleratorTarget {
static void ConvertPointToView(View* src,
View* dst,
gfx::Point* point);
- // WARNING: DEPRECATED. Will be removed once everything is converted to
- // gfx::Point. Don't add code that use this overload.
- static void ConvertPointToView(View* src,
- View* dst,
- CPoint* point);
// Convert a point from the coordinate system of a View to that of the
// ViewContainer. This is useful for example when sizing HWND children
// of the ViewContainer that don't know about the View hierarchy and need
// to be placed relative to the ViewContainer that is their parent.
- static void ConvertPointToViewContainer(View* src, CPoint* point);
+ static void ConvertPointToViewContainer(View* src, gfx::Point* point);
// Convert a point from a view ViewContainer to a View dest
- static void ConvertPointFromViewContainer(View *dest, CPoint *p);
+ static void ConvertPointFromViewContainer(View *dest, gfx::Point* p);
// Convert a point from the coordinate system of a View to that of the
// screen. This is useful for example when placing popup windows.
- static void ConvertPointToScreen(View* src, CPoint* point);
+ static void ConvertPointToScreen(View* src, gfx::Point* point);
// Event Handlers
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 94de4d2..e476bd1 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -539,9 +539,9 @@ class HitTestView : public ChromeViews::View {
};
POINT ConvertPointToView(ChromeViews::View* view, const POINT& p) {
- CPoint tmp = p;
+ gfx::Point tmp(p);
ChromeViews::View::ConvertPointToView(view->GetRootView(), view, &tmp);
- return tmp;
+ return tmp.ToPOINT();
}
}