diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-14 20:58:44 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-14 20:58:44 +0000 |
commit | 96b667d273c25e55150785848942c51f1a98851b (patch) | |
tree | 21ad2f8bc3a2148a517998f4ebb0157b22a75082 /chrome/views/view.cc | |
parent | df40752a0913948b49086fee421b0d019f7de8da (diff) | |
download | chromium_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/view.cc')
-rw-r--r-- | chrome/views/view.cc | 61 |
1 files changed, 20 insertions, 41 deletions
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); } } |