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 | |
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')
36 files changed, 283 insertions, 303 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup.cc b/chrome/browser/autocomplete/autocomplete_popup.cc index c9ca6a1..c30bbb5 100644 --- a/chrome/browser/autocomplete/autocomplete_popup.cc +++ b/chrome/browser/autocomplete/autocomplete_popup.cc @@ -172,9 +172,9 @@ void AutocompletePopupView::UpdatePopupAppearance() { CRect rc = edit_view_->parent_view()->bounds().ToRECT(); // Subtract the top left corner to make the coordinates relative to the // location bar view itself, and convert to screen coordinates. - CPoint top_left(-rc.TopLeft()); + gfx::Point top_left(-rc.TopLeft()); ChromeViews::View::ConvertPointToScreen(edit_view_->parent_view(), &top_left); - rc.OffsetRect(top_left); + rc.OffsetRect(top_left.ToPOINT()); // Expand by one pixel on each side since that's the amount the location bar // view is inset from the divider line that edges the adjacent buttons. // Deflate the top and bottom by the height of the extra graphics around the diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 1456adc..c7bb3d5 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1148,13 +1148,13 @@ void AutomationProvider::WindowGetViewBounds(const IPC::Message& message, ChromeViews::View* view = root_view->GetViewByID(view_id); if (view) { succeeded = true; - CPoint point(0, 0); + gfx::Point point; if (screen_coordinates) ChromeViews::View::ConvertPointToScreen(view, &point); else ChromeViews::View::ConvertPointToView(view, root_view, &point); view->GetLocalBounds(&bounds, false); - bounds.MoveToXY(point.x, point.y); + bounds.MoveToXY(point.x(), point.y()); } } } @@ -1182,9 +1182,9 @@ class MouseEventTask : public Task { // the drag code moved away from using mouse event locations was because // our conversion to screen location doesn't work well with multiple // monitors, so this only works reliably in a single monitor setup. - CPoint screen_location = CPoint(point_.x, point_.y); + gfx::Point screen_location(point_.x, point_.y); view_->ConvertPointToScreen(view_, &screen_location); - ::SetCursorPos(screen_location.x, screen_location.y); + ::SetCursorPos(screen_location.x(), screen_location.y()); switch (type_) { case ChromeViews::Event::ET_MOUSE_PRESSED: view_->OnMousePressed(event); diff --git a/chrome/browser/automation/ui_controls.cc b/chrome/browser/automation/ui_controls.cc index 9fe42201..ab5f572 100644 --- a/chrome/browser/automation/ui_controls.cc +++ b/chrome/browser/automation/ui_controls.cc @@ -336,9 +336,9 @@ void MoveMouseToCenterAndPress( ChromeViews::View* view, MouseButton button, int state, Task* task) { DCHECK(view); DCHECK(view->GetViewContainer()); - CPoint view_center(view->width() / 2, view->height() / 2); + gfx::Point view_center(view->width() / 2, view->height() / 2); ChromeViews::View::ConvertPointToScreen(view, &view_center); - SendMouseMove(view_center.x, view_center.y); + SendMouseMove(view_center.x(), view_center.y()); SendMouseEventsNotifyWhenDone(button, state, task); } diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc index 67c819c..916dc7d 100644 --- a/chrome/browser/find_in_page_controller.cc +++ b/chrome/browser/find_in_page_controller.cc @@ -491,9 +491,9 @@ void FindInPageController::GetDialogBounds(gfx::Rect* bounds) { // toolbar is the child of another view that isn't the top level view. // This is required to ensure correct positioning relative to the top,left // of the window. - CPoint topleft(0, 0); + gfx::Point topleft; ChromeViews::View::ConvertPointToViewContainer(toolbar, &topleft); - toolbar_bounds.Offset(topleft.x, topleft.y); + toolbar_bounds.Offset(topleft.x(), topleft.y()); } // If the bookmarks bar is available, we need to update our diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc index 064e215..bdf29ba 100644 --- a/chrome/browser/history_view.cc +++ b/chrome/browser/history_view.cc @@ -557,11 +557,11 @@ void HistoryItemRenderer::SetDisplayStyle(bool show_full) { void HistoryItemRenderer::StarStateChanged(bool state) { // Show the user a tip that can be used to edit the bookmark/star. - CPoint star_location(0, 0); + gfx::Point star_location; ChromeViews::View::ConvertPointToScreen(star_toggle_, &star_location); // Shift the location to make the bubble appear at a visually pleasing // location. - gfx::Rect star_bounds(star_location.x, star_location.y + 4, + gfx::Rect star_bounds(star_location.x(), star_location.y() + 4, star_toggle_->width(), star_toggle_->height()); HWND parent = GetViewContainer()->GetHWND(); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 20bee0b..8b628f6 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -242,10 +242,10 @@ class BookmarkButton : public ChromeViews::TextButton { } bool GetTooltipText(int x, int y, std::wstring* tooltip) { - CPoint location(x, y); + gfx::Point location(x, y); ConvertPointToScreen(this, &location); *tooltip = CreateToolTipForURLAndTitle( - gfx::Point(location.x, location.y), url_, GetText(), + gfx::Point(location.x(), location.y()), url_, GetText(), profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); return !tooltip->empty(); } @@ -1403,12 +1403,12 @@ void BookmarkBarView::RunMenu(ChromeViews::View* view, else anchor_point = MenuItemView::TOPLEFT; } - CPoint screen_loc(x, 0); + gfx::Point screen_loc(x, 0); View::ConvertPointToScreen(this, &screen_loc); menu_runner_.reset(new MenuRunner(this, node, start_index)); HWND parent_hwnd = GetViewContainer()->GetHWND(); menu_runner_->RunMenuAt(parent_hwnd, - gfx::Rect(screen_loc.x, screen_loc.y, + gfx::Rect(screen_loc.x(), screen_loc.y(), view->width(), bar_height), anchor_point, false); @@ -1586,11 +1586,11 @@ void BookmarkBarView::ShowDropFolderForNode(BookmarkNode* node) { drop_info_->is_menu_showing = true; drop_menu_runner_.reset(new MenuRunner(this, node, start_index)); - CPoint screen_loc(0, 0); + gfx::Point screen_loc; View::ConvertPointToScreen(view_to_position_menu_from, &screen_loc); drop_menu_runner_->RunMenuAt( GetViewContainer()->GetHWND(), - gfx::Rect(screen_loc.x, screen_loc.y, + gfx::Rect(screen_loc.x(), screen_loc.y(), view_to_position_menu_from->width(), view_to_position_menu_from->height()), anchor, true); diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index 547f992..2fc0d30 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -243,7 +243,7 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { // NOTE: this code assume there is a left margin, which is currently // true. If that changes, this code will need to find another empty space // to press the mouse on. - CPoint mouse_loc(0, 0); + gfx::Point mouse_loc; ChromeViews::View::ConvertPointToScreen(bb_view_, &mouse_loc); ui_controls::SendMouseMove(0, 0); ui_controls::SendMouseEventsNotifyWhenDone( @@ -428,24 +428,24 @@ class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { void Step3() { ChromeViews::MenuItemView* target_menu = bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); - CPoint loc(1, target_menu->height() - 1); + gfx::Point loc(1, target_menu->height() - 1); ChromeViews::View::ConvertPointToScreen(target_menu, &loc); // Start a drag. - ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, + ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), CreateEventTask(this, &BookmarkBarViewTest5::Step4)); // See comment above this method as to why we do this. - ScheduleMouseMoveInBackground(loc.x, loc.y); + ScheduleMouseMoveInBackground(loc.x(), loc.y()); } void Step4() { // Drop the item so that it's now the second item. ChromeViews::MenuItemView* target_menu = bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); - CPoint loc(1, target_menu->height() - 1); + gfx::Point loc(1, target_menu->height() - 1); ChromeViews::View::ConvertPointToScreen(target_menu, &loc); - ui_controls::SendMouseMove(loc.x, loc.y); + ui_controls::SendMouseMove(loc.x(), loc.y()); ui_controls::SendMouseEventsNotifyWhenDone(ui_controls::LEFT, ui_controls::UP, @@ -537,15 +537,15 @@ class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { // Drag over other button. ChromeViews::TextButton* other_button = bb_view_->other_bookmarked_button(); - CPoint loc(other_button->width() / 2, other_button->height() / 2); + gfx::Point loc(other_button->width() / 2, other_button->height() / 2); ChromeViews::View::ConvertPointToScreen(other_button, &loc); // Start a drag. - ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, + ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), NewRunnableMethod(this, &BookmarkBarViewTest7::Step4)); // See comment above this method as to why we do this. - ScheduleMouseMoveInBackground(loc.x, loc.y); + ScheduleMouseMoveInBackground(loc.x(), loc.y()); } void Step4() { @@ -555,9 +555,9 @@ class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { ChromeViews::MenuItemView* target_menu = drop_menu->GetSubmenu()->GetMenuItemAt(0); - CPoint loc(1, 1); + gfx::Point loc(1, 1); ChromeViews::View::ConvertPointToScreen(target_menu, &loc); - ui_controls::SendMouseMove(loc.x, loc.y); + ui_controls::SendMouseMove(loc.x(), loc.y()); ui_controls::SendMouseEventsNotifyWhenDone( ui_controls::LEFT, ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest7::Step5)); @@ -610,15 +610,15 @@ class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { // Drag over other button. ChromeViews::TextButton* other_button = bb_view_->other_bookmarked_button(); - CPoint loc(other_button->width() / 2, other_button->height() / 2); + gfx::Point loc(other_button->width() / 2, other_button->height() / 2); ChromeViews::View::ConvertPointToScreen(other_button, &loc); // Start a drag. - ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, + ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), NewRunnableMethod(this, &BookmarkBarViewTest8::Step4)); // See comment above this method as to why we do this. - ScheduleMouseMoveInBackground(loc.x, loc.y); + ScheduleMouseMoveInBackground(loc.x(), loc.y()); } void Step4() { @@ -628,9 +628,9 @@ class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { // Now drag back over first menu. ChromeViews::TextButton* button = bb_view_->GetBookmarkButton(0); - CPoint loc(button->width() / 2, button->height() / 2); + gfx::Point loc(button->width() / 2, button->height() / 2); ChromeViews::View::ConvertPointToScreen(button, &loc); - ui_controls::SendMouseMoveNotifyWhenDone(loc.x, loc.y, + ui_controls::SendMouseMoveNotifyWhenDone(loc.x(), loc.y(), NewRunnableMethod(this, &BookmarkBarViewTest8::Step5)); } @@ -682,9 +682,9 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); first_menu_ = menu->GetSubmenu()->GetMenuItemAt(0); - CPoint menu_loc; + gfx::Point menu_loc; ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); - start_y_ = menu_loc.y; + start_y_ = menu_loc.y(); // Move the mouse over the scroll button. ChromeViews::View* scroll_container = menu->GetSubmenu()->GetParent(); @@ -693,11 +693,11 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(scroll_container != NULL); ChromeViews::View* scroll_down_button = scroll_container->GetChildViewAt(1); ASSERT_TRUE(scroll_down_button); - CPoint loc(scroll_down_button->width() / 2, - scroll_down_button->height() / 2); + gfx::Point loc(scroll_down_button->width() / 2, + scroll_down_button->height() / 2); ChromeViews::View::ConvertPointToScreen(scroll_down_button, &loc); ui_controls::SendMouseMoveNotifyWhenDone( - loc.x, loc.y, CreateEventTask(this, &BookmarkBarViewTest9::Step3)); + loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3)); } void Step3() { @@ -706,9 +706,9 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { } void Step4() { - CPoint menu_loc; + gfx::Point menu_loc; ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); - ASSERT_NE(start_y_, menu_loc.y); + ASSERT_NE(start_y_, menu_loc.y()); // Hide menu. bb_view_->GetMenu()->GetMenuController()->Cancel(true); diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 0da72f0..256b727 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -599,7 +599,7 @@ bool DownloadItemView::OnMousePressed(const ChromeViews::MouseEvent& event) { complete_animation_->End(); if (event.IsOnlyLeftMouseButton()) { - WTL::CPoint point(event.x(), event.y()); + gfx::Point point(event.location()); if (event.x() < drop_down_x_) { SetState(PUSHED, NORMAL); return true; @@ -624,18 +624,18 @@ bool DownloadItemView::OnMousePressed(const ChromeViews::MouseEvent& event) { // // TODO(idana): when bug# 1163334 is fixed the following check should be // replaced with UILayoutIsRightToLeft(). - point.y = height(); + point.set_y(height()); if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { - point.x = width(); + point.set_x(width()); } else { - point.x = drop_down_x_; + point.set_x(drop_down_x_); } ChromeViews::View::ConvertPointToScreen(this, &point); download_util::DownloadShelfContextMenu menu(download_, GetViewContainer()->GetHWND(), model_.get(), - point); + point.ToPOINT()); drop_down_pressed_ = false; // Showing the menu blocks. Here we revert the state. SetState(NORMAL, NORMAL); diff --git a/chrome/browser/views/download_tab_view.cc b/chrome/browser/views/download_tab_view.cc index 679aa54..e4edec9 100644 --- a/chrome/browser/views/download_tab_view.cc +++ b/chrome/browser/views/download_tab_view.cc @@ -697,24 +697,23 @@ void DownloadItemTabView::DidChangeBounds(const CRect& previous, } bool DownloadItemTabView::OnMousePressed(const ChromeViews::MouseEvent& event) { - CPoint point(event.x(), event.y()); + gfx::Point point(event.location()); // If the click is in the highlight region, then highlight this download. // Otherwise, remove the highlighting from any download. - CRect select_rect(kDownloadIconOffset - download_util::kBigProgressIconOffset, - 0, - kDownloadIconOffset - - download_util::kBigProgressIconOffset + - download_util::kBigProgressIconSize + kInfoPadding + - kFilenameSize, - download_util::kBigProgressIconSize); + gfx::Rect select_rect( + kDownloadIconOffset - download_util::kBigProgressIconOffset, + 0, + kDownloadIconOffset - download_util::kBigProgressIconOffset + + download_util::kBigProgressIconSize + kInfoPadding + kFilenameSize, + download_util::kBigProgressIconSize); // The position of the highlighted region does not take into account the // View's UI layout so we have to manually mirror the position if the View is // using a right-to-left UI layout. gfx::Rect mirrored_rect(select_rect); - select_rect.MoveToX(MirroredLeftPointForRect(mirrored_rect)); - if (select_rect.PtInRect(point)) { + select_rect.set_x(MirroredLeftPointForRect(mirrored_rect)); + if (select_rect.Contains(point)) { parent_->ItemBecameSelected(model_); // Don't show the right-click menu if we are prompting the user for a @@ -724,7 +723,7 @@ bool DownloadItemTabView::OnMousePressed(const ChromeViews::MouseEvent& event) { ChromeViews::View::ConvertPointToScreen(this, &point); download_util::DownloadDestinationContextMenu menu( - model_, GetViewContainer()->GetHWND(), point); + model_, GetViewContainer()->GetHWND(), point.ToPOINT()); } } else { parent_->ItemBecameSelected(NULL); diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc index 6ed9661..fbfa661 100644 --- a/chrome/browser/views/frame/browser_view2.cc +++ b/chrome/browser/views/frame/browser_view2.cc @@ -712,13 +712,13 @@ int BrowserView2::NonClientHitTest(const gfx::Point& point) { // animating. if (IsTabStripVisible() && tabstrip_->CanProcessInputEvents()) { ChromeViews::Window* window = frame_->GetWindow(); - CPoint point_in_view_coords(point.ToPOINT()); + gfx::Point point_in_view_coords(point); View::ConvertPointToView(GetParent(), this, &point_in_view_coords); // See if the mouse pointer is within the bounds of the TabStrip. - CPoint point_in_tabstrip_coords(point.ToPOINT()); + gfx::Point point_in_tabstrip_coords(point); View::ConvertPointToView(GetParent(), tabstrip_, &point_in_tabstrip_coords); - if (tabstrip_->HitTest(point_in_tabstrip_coords)) { + if (tabstrip_->HitTest(point_in_tabstrip_coords.ToPOINT())) { if (tabstrip_->PointIsWithinWindowCaption(point_in_tabstrip_coords)) return HTCAPTION; return HTCLIENT; @@ -728,7 +728,7 @@ int BrowserView2::NonClientHitTest(const gfx::Point& point) { // starved of dragable area, let's give it to window dragging (this also // makes sense visually). if (!window->IsMaximized() && - (point_in_view_coords.y < tabstrip_->y() + kTabShadowSize)) { + (point_in_view_coords.y() < tabstrip_->y() + kTabShadowSize)) { // We return HTNOWHERE as this is a signal to our containing // NonClientView that it should figure out what the correct hit-test // code is given the mouse position... diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 5941d23..a60494f 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -576,10 +576,10 @@ void LocationBarView::OnMouseEvent(const ChromeViews::MouseEvent& event, if (event.IsRightMouseButton()) flags |= MK_RBUTTON; - CPoint screen_point(event.x(), event.y()); + gfx::Point screen_point(event.location()); ConvertPointToScreen(this, &screen_point); - location_entry_->HandleExternalMsg(msg, flags, screen_point); + location_entry_->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); } bool LocationBarView::GetAccessibleRole(VARIANT* role) { @@ -874,23 +874,23 @@ void LocationBarView::ShowFirstRunBubbleInternal() { return; } - CPoint location(0, 0); + gfx::Point location; // If the UI layout is RTL, the coordinate system is not transformed and // therefore we need to adjust the X coordinate so that bubble appears on the // right hand side of the location bar. if (UILayoutIsRightToLeft()) - location.x += width(); + location.Offset(width(), 0); ChromeViews::View::ConvertPointToScreen(this, &location); // We try to guess that 20 pixels offset is a good place for the first // letter in the OmniBox. - gfx::Rect bounds(location.x, location.y, 20, height()); + gfx::Rect bounds(location.x(), location.y(), 20, height()); // Moving the bounds "backwards" so that it appears within the location bar // if the UI layout is RTL. if (UILayoutIsRightToLeft()) - bounds.set_x(location.x - 20); + bounds.set_x(location.x() - 20); FirstRunBubble::Show( location_entry_view_->GetRootView()->GetViewContainer()->GetHWND(), @@ -954,9 +954,9 @@ void LocationBarView::SecurityImageView::ShowInfoBubble() { SkColor text_color; model_->GetIconHoverText(&text, &text_color); - CPoint location(0, 0); + gfx::Point location; ChromeViews::View::ConvertPointToScreen(this, &location); - gfx::Rect bounds(location.x, location.y, width(), height()); + gfx::Rect bounds(location.x(), location.y(), width(), height()); ChromeViews::Label* label = new ChromeViews::Label(text); label->SetMultiLine(true); diff --git a/chrome/browser/views/old_frames/simple_xp_frame.cc b/chrome/browser/views/old_frames/simple_xp_frame.cc index 44a5a54..550ceef 100644 --- a/chrome/browser/views/old_frames/simple_xp_frame.cc +++ b/chrome/browser/views/old_frames/simple_xp_frame.cc @@ -195,13 +195,13 @@ void SimpleXPFrameTitleBar::RunMenu(ChromeViews::View* source, // when the UI layout is RTL and hence we use the mirroring transformation // flag. We also adjust the menu position because RTL menus use a different // anchor point. - CPoint p(menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION), - menu_button_->y() + menu_button_->height()); + gfx::Point p(menu_button_->GetX(APPLY_MIRRORING_TRANSFORMATION), + menu_button_->y() + menu_button_->height()); if (UILayoutIsRightToLeft()) - p.x += menu_button_->width(); + p.set_x(p.x() + menu_button_->width()); View::ConvertPointToScreen(this, &p); - parent_->RunMenu(p, hwnd); + parent_->RunMenu(p.ToPOINT(), hwnd); } void SimpleXPFrameTitleBar::Layout() { @@ -342,12 +342,12 @@ void SimpleXPFrame::Layout() { LRESULT SimpleXPFrame::OnNCHitTest(const CPoint& pt) { if (IsTitleBarVisible()) { - CPoint p(pt); + gfx::Point p(pt); ChromeViews::View::ConvertPointToView(NULL, title_bar_, &p); - if (!title_bar_->WillHandleMouseEvent(p.x, p.y) && - p.x >= 0 && p.y >= kTopResizeBarHeight && - p.x < title_bar_->width() && - p.y < title_bar_->height()) { + if (!title_bar_->WillHandleMouseEvent(p.x(), p.y()) && + p.x() >= 0 && p.y() >= kTopResizeBarHeight && + p.x() < title_bar_->width() && + p.y() < title_bar_->height()) { return HTCAPTION; } } diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc index e7cf71d..0d74c7e 100644 --- a/chrome/browser/views/old_frames/vista_frame.cc +++ b/chrome/browser/views/old_frames/vista_frame.cc @@ -588,18 +588,18 @@ gfx::Rect VistaFrame::GetBoundsForContentBounds(const gfx::Rect content_rect) { Layout(); } - CPoint p(0, 0); + gfx::Point p; ChromeViews::View::ConvertPointToViewContainer(tab_contents_container_, &p); CRect bounds; GetBounds(&bounds, true); gfx::Rect r; - r.set_x(content_rect.x() - p.x); - r.set_y(content_rect.y() - p.y); - r.set_width(p.x + content_rect.width() + - (bounds.Width() - (p.x + tab_contents_container_->width()))); - r.set_height(p.y + content_rect.height() + - (bounds.Height() - (p.y + + r.set_x(content_rect.x() - p.x()); + r.set_y(content_rect.y() - p.y()); + r.set_width(p.x() + content_rect.width() + + (bounds.Width() - (p.x() + tab_contents_container_->width()))); + r.set_height(p.y() + content_rect.height() + + (bounds.Height() - (p.y() + tab_contents_container_->height()))); return r; } @@ -972,14 +972,14 @@ LRESULT VistaFrame::OnNCHitTest(const CPoint& pt) { CRect cr; GetBounds(&cr, false); - CPoint tab_pt(pt); + gfx::Point tab_pt(pt); ChromeViews::View::ConvertPointToView(NULL, tabstrip_, &tab_pt); // If we are over the tabstrip - 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); + 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()); if (v == tabstrip_) return HTCAPTION; @@ -1363,10 +1363,10 @@ bool VistaFrame::VistaFrameView::ShouldForwardToTabStrip( if (min_x != std::numeric_limits<int>::max() && max_x != std::numeric_limits<int>::min() && max_y != std::numeric_limits<int>::min()) { - CPoint screen_drag_point(event.x(), event.y()); + gfx::Point screen_drag_point(event.x(), event.y()); ConvertPointToScreen(this, &screen_drag_point); - if (screen_drag_point.x >= min_x && screen_drag_point.x <= max_x && - screen_drag_point.y <= max_y) { + if (screen_drag_point.x() >= min_x && screen_drag_point.x() <= max_x && + screen_drag_point.y() <= max_y) { return false; } } diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc index 36f6111..4b9cc09 100644 --- a/chrome/browser/views/old_frames/xp_frame.cc +++ b/chrome/browser/views/old_frames/xp_frame.cc @@ -1388,19 +1388,19 @@ LRESULT XPFrame::OnNCHitTest(const CPoint& pt) { return HTCAPTION; } - CPoint tsp(p); + gfx::Point tsp(p); ChromeViews::View::ConvertPointToView(&root_view_, tabstrip_, &tsp); // If the mouse is over the tabstrip. Check if we should move the window or // capture the mouse. - if (tabstrip_->CanProcessInputEvents() && tabstrip_->HitTest(tsp)) { + if (tabstrip_->CanProcessInputEvents() && tabstrip_->HitTest(tsp.ToPOINT())) { // 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) + if (!IsZoomed() && tsp.y() < kTabShadowSize) return HTCAPTION; - ChromeViews::View* v = tabstrip_->GetViewForPoint(tsp); + ChromeViews::View* v = tabstrip_->GetViewForPoint(tsp.ToPOINT()); // If there is not tab at this location, claim the hit was in the title // bar to get a move action. if (v == tabstrip_) @@ -1815,18 +1815,18 @@ gfx::Rect XPFrame::GetBoundsForContentBounds(const gfx::Rect content_rect) { Layout(); } - CPoint p(0, 0); + gfx::Point p; ChromeViews::View::ConvertPointToViewContainer(tab_contents_container_, &p); CRect bounds; GetBounds(&bounds, true); gfx::Rect r; - r.set_x(content_rect.x() - p.x); - r.set_y(content_rect.y() - p.y); - r.set_width(p.x + content_rect.width() + - (bounds.Width() - (p.x + tab_contents_container_->width()))); - r.set_height(p.y + content_rect.height() + - (bounds.Height() - (p.y + + r.set_x(content_rect.x() - p.x()); + r.set_y(content_rect.y() - p.y()); + r.set_width(p.x() + content_rect.width() + + (bounds.Width() - (p.x() + tab_contents_container_->width()))); + r.set_height(p.y() + content_rect.height() + + (bounds.Height() - (p.y() + tab_contents_container_->height()))); return r; } diff --git a/chrome/browser/views/status_bubble.cc b/chrome/browser/views/status_bubble.cc index d3efa85..9021634 100644 --- a/chrome/browser/views/status_bubble.cc +++ b/chrome/browser/views/status_bubble.cc @@ -567,12 +567,12 @@ void StatusBubble::AvoidMouse() { GetCursorPos(&cursor_location); // Get the position of the frame. - CPoint top_left(0, 0); + gfx::Point top_left; ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); // Get the cursor position relative to the popup. - cursor_location.x -= (top_left.x + position_.x); - cursor_location.y -= (top_left.y + position_.y); + cursor_location.x -= (top_left.x() + position_.x); + cursor_location.y -= (top_left.y() + position_.y); // If the mouse is in a position where we think it would move the // status bubble, figure out where and how the bubble should be moved. @@ -605,15 +605,15 @@ void StatusBubble::AvoidMouse() { } offset_ = offset; - popup_->MoveWindow(top_left.x + position_.x, - top_left.y + position_.y + offset_, + popup_->MoveWindow(top_left.x() + position_.x, + top_left.y() + position_.y + offset_, size_.cx, size_.cy); } else if (offset_ != 0) { offset_ = 0; view_->SetStyle(StatusView::STYLE_STANDARD); - popup_->MoveWindow(top_left.x + position_.x, - top_left.y + position_.y, + popup_->MoveWindow(top_left.x() + position_.x, + top_left.y() + position_.y, size_.cx, size_.cy); } @@ -621,11 +621,11 @@ void StatusBubble::AvoidMouse() { void StatusBubble::Reposition() { if (popup_) { - CPoint top_left(0, 0); + gfx::Point top_left; ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); - popup_->MoveWindow(top_left.x + position_.x, - top_left.y + position_.y, + popup_->MoveWindow(top_left.x() + position_.x, + top_left.y() + position_.y, size_.cx, size_.cy); } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index ef649e8..bb93238 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -71,10 +71,10 @@ class WindowFinder { gfx::Point ConvertScreenPointToTabStripPoint(TabStrip* tabstrip, const gfx::Point& screen_point) { - CPoint tabstrip_topleft(0, 0); + gfx::Point tabstrip_topleft; ChromeViews::View::ConvertPointToScreen(tabstrip, &tabstrip_topleft); - return gfx::Point(screen_point.x() - tabstrip_topleft.x, - screen_point.y() - tabstrip_topleft.y); + return gfx::Point(screen_point.x() - tabstrip_topleft.x(), + screen_point.y() - tabstrip_topleft.y()); } } @@ -271,11 +271,10 @@ void DraggedTabController::DidProcessMessage(const MSG& msg) { // DraggedTabController, private: void DraggedTabController::InitWindowCreatePoint() { - CPoint mouse_offset_cpoint(mouse_offset_.x(), mouse_offset_.y()); + window_create_point_.SetPoint(mouse_offset_.x(), mouse_offset_.y()); Tab* first_tab = attached_tabstrip_->GetTabAt(0); ChromeViews::View::ConvertPointToViewContainer(first_tab, - &mouse_offset_cpoint); - window_create_point_.SetPoint(mouse_offset_cpoint.x, mouse_offset_cpoint.y); + &window_create_point_); } gfx::Point DraggedTabController::GetWindowCreatePoint() const { @@ -727,11 +726,11 @@ gfx::Point DraggedTabController::GetCursorScreenPoint() const { gfx::Rect DraggedTabController::GetViewScreenBounds( ChromeViews::View* view) const { - CPoint view_topleft(0, 0); + gfx::Point view_topleft; ChromeViews::View::ConvertPointToScreen(view, &view_topleft); CRect view_screen_bounds; view->GetLocalBounds(&view_screen_bounds, true); - view_screen_bounds.OffsetRect(view_topleft); + view_screen_bounds.OffsetRect(view_topleft.ToPOINT()); return gfx::Rect(view_screen_bounds); } diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 083036b..7e70083 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -527,8 +527,8 @@ bool TabStrip::CanProcessInputEvents() const { return IsAnimating() == NULL; } -bool TabStrip::PointIsWithinWindowCaption(const CPoint& point) { - ChromeViews::View* v = GetViewForPoint(point); +bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) { + ChromeViews::View* v = GetViewForPoint(point.ToPOINT()); // If there is no control at this location, claim the hit was in the title // bar to get a move action. @@ -543,10 +543,10 @@ bool TabStrip::PointIsWithinWindowCaption(const CPoint& point) { // Check to see if the point is within the non-button parts of the new tab // button. The button has a non-rectangular shape, so if it's not in the // visual portions of the button we treat it as a click to the caption. - CPoint point_in_newtab_coords(point); + gfx::Point point_in_newtab_coords(point); View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords); - if (newtab_button_->bounds().Contains(gfx::Point(point)) && - !newtab_button_->HitTest(point_in_newtab_coords)) { + if (newtab_button_->bounds().Contains(point) && + !newtab_button_->HitTest(point_in_newtab_coords.ToPOINT())) { return true; } @@ -1241,9 +1241,9 @@ void TabStrip::ResizeLayoutTabs() { bool TabStrip::IsCursorInTabStripZone() { CRect bounds; GetLocalBounds(&bounds, true); - CPoint tabstrip_topleft = bounds.TopLeft(); + gfx::Point tabstrip_topleft(bounds.TopLeft()); View::ConvertPointToScreen(this, &tabstrip_topleft); - bounds.MoveToXY(tabstrip_topleft); + bounds.MoveToXY(tabstrip_topleft.ToPOINT()); bounds.bottom += kTabStripAnimationVSlop; CPoint cursor_point; @@ -1309,9 +1309,10 @@ gfx::Rect TabStrip::GetDropBounds(int drop_index, center_x = MirroredXCoordinateInsideView(center_x); // Determine the screen bounds. - CPoint drop_loc(center_x - drop_indicator_width / 2, -drop_indicator_height); + gfx::Point drop_loc(center_x - drop_indicator_width / 2, + -drop_indicator_height); ConvertPointToScreen(this, &drop_loc); - gfx::Rect drop_bounds(drop_loc.x, drop_loc.y, drop_indicator_width, + gfx::Rect drop_bounds(drop_loc.x(), drop_loc.y(), drop_indicator_width, drop_indicator_height); // If the rect doesn't fit on the monitor, push the arrow to the bottom. @@ -1566,8 +1567,8 @@ int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const { } bool TabStrip::IsPointInTab(Tab* tab, const CPoint& point_in_tabstrip_coords) { - CPoint point_in_tab_coords(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); + return tab->HitTest(point_in_tab_coords.ToPOINT()); } diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 656dd12..ea50fd4 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -66,7 +66,7 @@ class TabStrip : public ChromeViews::View, // portion of the TabStrip that should be treated as the containing Window's // titlebar for dragging purposes. // TODO(beng): (Cleanup) should be const, but GetViewForPoint isn't, so fie! - bool PointIsWithinWindowCaption(const CPoint& point); + bool PointIsWithinWindowCaption(const gfx::Point& point); // Return true if this tab strip is compatible with the provided tab strip. // Compatible tab strips can transfer tabs during drag and drop. diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc index d6b1740..050fc02 100644 --- a/chrome/browser/views/toolbar_star_toggle.cc +++ b/chrome/browser/views/toolbar_star_toggle.cc @@ -37,12 +37,12 @@ void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) { return; } - CPoint star_location(0, 0); + gfx::Point star_location; ChromeViews::View::ConvertPointToScreen(this, &star_location); // Shift the x location by 1 as visually the center of the star appears 1 // pixel to the right. By doing this bubble arrow points to the center // of the star. - gfx::Rect star_bounds(star_location.x + 1, star_location.y, width(), + gfx::Rect star_bounds(star_location.x() + 1, star_location.y(), width(), height()); BookmarkBubbleView::Show(host_->browser()->GetTopLevelHWND(), star_bounds, this, host_->profile(), url, newly_bookmarked); 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(); } } |