summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 18:20:37 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 18:20:37 +0000
commit0872ffcfbc2e1dfdca3d1fbda5e3416c1214b4b4 (patch)
tree512901c50f52358af6030f2739636aefc9492388
parent21eec7b3ced5a264f55c1c040ed6899ac58c97d5 (diff)
downloadchromium_src-0872ffcfbc2e1dfdca3d1fbda5e3416c1214b4b4.zip
chromium_src-0872ffcfbc2e1dfdca3d1fbda5e3416c1214b4b4.tar.gz
chromium_src-0872ffcfbc2e1dfdca3d1fbda5e3416c1214b4b4.tar.bz2
ui: Remove gfx::Point Add() and Subtract() which were non-mutating member methods.
Replace use of these with operator +, +=, -, -=. Covered by existing unit tests. R=sky BUG=158416,160158 Review URL: https://chromiumcodereview.appspot.com/11362173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166933 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/drag_drop/drag_drop_controller.cc6
-rw-r--r--ash/launcher/launcher_tooltip_manager_unittest.cc2
-rw-r--r--ash/tooltips/tooltip_controller.cc4
-rw-r--r--ash/wm/workspace/workspace_event_handler_unittest.cc6
-rw-r--r--chrome/browser/notifications/balloon.h2
-rw-r--r--chrome/browser/ui/gtk/gtk_util.cc2
-rw-r--r--chrome/browser/ui/panels/panel_and_desktop_notification_browsertest.cc2
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc2
-rw-r--r--chrome/browser/ui/panels/panel_drag_browsertest.cc54
-rw-r--r--chrome/browser/ui/panels/panel_drag_controller.cc4
-rw-r--r--chrome/browser/ui/panels/panel_resize_browsertest.cc49
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc3
-rw-r--r--ui/aura/test/event_generator.h6
-rw-r--r--ui/gfx/point.h8
-rw-r--r--ui/gfx/point_base.h22
-rw-r--r--ui/gfx/point_f.h8
-rw-r--r--ui/gfx/render_text.cc4
-rw-r--r--ui/views/view.cc8
18 files changed, 91 insertions, 101 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 6f7ecd7..a7c73fd 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -76,12 +76,12 @@ int DragDropController::StartDragAndDrop(
drag_image_->SetImage(provider.drag_image());
drag_image_offset_ = provider.drag_image_offset();
drag_image_->SetBoundsInScreen(gfx::Rect(
- root_location.Subtract(drag_image_offset_),
+ root_location - drag_image_offset_,
drag_image_->GetPreferredSize()));
drag_image_->SetWidgetVisible(true);
drag_window_ = NULL;
- drag_start_location_ = root_location.Subtract(drag_image_offset_);
+ drag_start_location_ = root_location - drag_image_offset_;
#if !defined(OS_MACOSX)
if (should_block_during_drag_drop_) {
@@ -140,7 +140,7 @@ void DragDropController::DragUpdate(aura::Window* target,
ash::wm::ConvertPointToScreen(target->GetRootWindow(),
&root_location_in_screen);
drag_image_->SetScreenPosition(
- root_location_in_screen.Subtract(drag_image_offset_));
+ root_location_in_screen - drag_image_offset_);
}
}
diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc
index 71b80da..896ba4e 100644
--- a/ash/launcher/launcher_tooltip_manager_unittest.cc
+++ b/ash/launcher/launcher_tooltip_manager_unittest.cc
@@ -195,7 +195,7 @@ TEST_F(LauncherTooltipManagerTest, HideForMouseEvent) {
EXPECT_TRUE(TooltipIsVisible());
// Should hide if the mouse is out of the tooltip.
- test_api.set_location(tooltip_rect.origin().Add(gfx::Vector2d(-1, -1)));
+ test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1));
EXPECT_FALSE(event_filter->PreHandleMouseEvent(root_window, &mouse_event));
RunAllPendingInMessageLoop();
EXPECT_FALSE(TooltipIsVisible());
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index aa0290e..f9d053e7 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -459,8 +459,8 @@ void TooltipController::UpdateIfRequired() {
GetTooltip()->Hide();
} else {
string16 tooltip_text(tooltip_text_);
- gfx::Point widget_loc = curr_mouse_loc_.Add(
- tooltip_window_->GetBoundsInScreen().OffsetFromOrigin());
+ gfx::Point widget_loc = curr_mouse_loc_ +
+ tooltip_window_->GetBoundsInScreen().OffsetFromOrigin();
GetTooltip()->SetText(tooltip_text, widget_loc);
GetTooltip()->Show();
tooltip_shown_timer_.Start(FROM_HERE,
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
index d67a123..0046f72 100644
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
@@ -154,12 +154,10 @@ TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) {
aura::test::EventGenerator generator(window->GetRootWindow());
generator.MoveMouseToCenterOf(window.get());
generator.PressLeftButton();
- generator.MoveMouseTo(
- generator.current_location().Add(gfx::Vector2d(50, 50)));
+ generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50));
DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString());
window.reset();
- generator.MoveMouseTo(
- generator.current_location().Add(gfx::Vector2d(50, 50)));
+ generator.MoveMouseTo(generator.current_location() + gfx::Vector2d(50, 50));
}
// Verifies deleting the window while in a run loop doesn't crash.
diff --git a/chrome/browser/notifications/balloon.h b/chrome/browser/notifications/balloon.h
index 165b51b..c1c3eba 100644
--- a/chrome/browser/notifications/balloon.h
+++ b/chrome/browser/notifications/balloon.h
@@ -59,7 +59,7 @@ class Balloon {
Profile* profile() const { return profile_; }
gfx::Point GetPosition() const {
- return position_.Add(offset_);
+ return position_ + offset_;
}
void SetPosition(const gfx::Point& upper_left, bool reposition);
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc
index a74ebb7..84dc13d 100644
--- a/chrome/browser/ui/gtk/gtk_util.cc
+++ b/chrome/browser/ui/gtk/gtk_util.cc
@@ -484,7 +484,7 @@ void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) {
DCHECK(widget);
DCHECK(p);
- *p = p->Add(ui::GetWidgetScreenOffset(widget));
+ *p += ui::GetWidgetScreenOffset(widget);
}
GtkWidget* CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget,
diff --git a/chrome/browser/ui/panels/panel_and_desktop_notification_browsertest.cc b/chrome/browser/ui/panels/panel_and_desktop_notification_browsertest.cc
index 026f95c..d646f3a 100644
--- a/chrome/browser/ui/panels/panel_and_desktop_notification_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_and_desktop_notification_browsertest.cc
@@ -105,7 +105,7 @@ class PanelAndDesktopNotificationTest : public BasePanelBrowserTest {
PanelManager* panel_manager = PanelManager::GetInstance();
gfx::Point mouse_location = panel->GetBounds().origin();
panel_manager->StartResizingByMouse(panel, mouse_location, side);
- panel_manager->ResizeByMouse(mouse_location.Add(delta));
+ panel_manager->ResizeByMouse(mouse_location + delta);
panel_manager->EndResizingByMouse(false);
}
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index df9539e..862a57f 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -513,7 +513,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_AnimateBounds) {
// dragged.
gfx::Point mouse_location(panel->GetBounds().origin());
panel_testing->PressLeftMouseButtonTitlebar(mouse_location);
- panel_testing->DragTitlebar(mouse_location.Add(gfx::Vector2d(-100, 5)));
+ panel_testing->DragTitlebar(mouse_location + gfx::Vector2d(-100, 5));
EXPECT_FALSE(panel_testing->IsAnimatingBounds());
panel_testing->FinishDragTitlebar();
diff --git a/chrome/browser/ui/panels/panel_drag_browsertest.cc b/chrome/browser/ui/panels/panel_drag_browsertest.cc
index e053aeb..a9ceddf 100644
--- a/chrome/browser/ui/panels/panel_drag_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_drag_browsertest.cc
@@ -40,7 +40,7 @@ class PanelDragBrowserTest : public BasePanelBrowserTest {
CreateNativePanelTesting(panel));
gfx::Point mouse_location(panel->GetBounds().origin());
panel_testing->PressLeftMouseButtonTitlebar(mouse_location);
- panel_testing->DragTitlebar(mouse_location.Add(delta));
+ panel_testing->DragTitlebar(mouse_location + delta);
panel_testing->FinishDragTitlebar();
}
@@ -195,7 +195,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) {
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
- mouse_location = mouse_location.Subtract(small_delta);
+ mouse_location = mouse_location - small_delta;
panel1_testing->DragTitlebar(mouse_location);
EXPECT_EQ(mouse_location, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
@@ -211,7 +211,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) {
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
- mouse_location = position2.Add(gfx::Vector2d(1, 0));
+ mouse_location = position2 + gfx::Vector2d(1, 0);
panel1_testing->DragTitlebar(mouse_location);
EXPECT_EQ(mouse_location, panel1->GetBounds().origin());
EXPECT_EQ(position1, panel2->GetBounds().origin());
@@ -227,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) {
EXPECT_EQ(position2, panel1->GetBounds().origin());
EXPECT_EQ(position1, panel2->GetBounds().origin());
- mouse_location = mouse_location.Add(small_delta);
+ mouse_location = mouse_location + small_delta;
panel1_testing->DragTitlebar(mouse_location);
EXPECT_EQ(mouse_location, panel1->GetBounds().origin());
EXPECT_EQ(position1, panel2->GetBounds().origin());
@@ -243,7 +243,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) {
EXPECT_EQ(position2, panel1->GetBounds().origin());
EXPECT_EQ(position1, panel2->GetBounds().origin());
- mouse_location = position1.Add(gfx::Vector2d(1, 0));
+ mouse_location = position1 + gfx::Vector2d(1, 0);
panel1_testing->DragTitlebar(mouse_location);
EXPECT_EQ(mouse_location, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
@@ -260,7 +260,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) {
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
- mouse_location = position2.Add(gfx::Vector2d(1, 0));
+ mouse_location = position2 + gfx::Vector2d(1, 0);
panel1_testing->DragTitlebar(mouse_location);
EXPECT_EQ(mouse_location, panel1->GetBounds().origin());
EXPECT_EQ(position1, panel2->GetBounds().origin());
@@ -294,13 +294,13 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) {
EXPECT_EQ(position2, panel2->GetBounds().origin());
EXPECT_EQ(position3, panel3->GetBounds().origin());
- mouse_location = position2.Add(gfx::Vector2d(1, 0));
+ mouse_location = position2 + gfx::Vector2d(1, 0);
panel3_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position3, panel2->GetBounds().origin());
EXPECT_EQ(mouse_location, panel3->GetBounds().origin());
- mouse_location = position1.Add(gfx::Vector2d(1, 0));
+ mouse_location = position1 + gfx::Vector2d(1, 0);
panel3_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position2, panel1->GetBounds().origin());
EXPECT_EQ(position3, panel2->GetBounds().origin());
@@ -323,13 +323,13 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) {
EXPECT_EQ(position3, panel2->GetBounds().origin());
EXPECT_EQ(position1, panel3->GetBounds().origin());
- mouse_location = position2.Add(gfx::Vector2d(1, 0));
+ mouse_location = position2 + gfx::Vector2d(1, 0);
panel3_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position3, panel2->GetBounds().origin());
EXPECT_EQ(mouse_location, panel3->GetBounds().origin());
- mouse_location = position3.Add(gfx::Vector2d(1, 0));
+ mouse_location = position3 + gfx::Vector2d(1, 0);
panel3_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
@@ -349,7 +349,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) {
EXPECT_EQ(position3, panel2->GetBounds().origin());
EXPECT_EQ(position1, panel3->GetBounds().origin());
- mouse_location = position1.Add(gfx::Vector2d(1, 0));
+ mouse_location = position1 + gfx::Vector2d(1, 0);
panel2_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position3, panel1->GetBounds().origin());
EXPECT_EQ(mouse_location, panel2->GetBounds().origin());
@@ -369,7 +369,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) {
EXPECT_EQ(position1, panel2->GetBounds().origin());
EXPECT_EQ(position2, panel3->GetBounds().origin());
- mouse_location = position3.Add(gfx::Vector2d(1, 0));
+ mouse_location = position3 + gfx::Vector2d(1, 0);
panel2_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position2, panel1->GetBounds().origin());
EXPECT_EQ(mouse_location, panel2->GetBounds().origin());
@@ -391,7 +391,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) {
EXPECT_EQ(position3, panel2->GetBounds().origin());
EXPECT_EQ(position1, panel3->GetBounds().origin());
- mouse_location = position3.Add(gfx::Vector2d(1, 0));
+ mouse_location = position3 + gfx::Vector2d(1, 0);
panel3_testing->DragTitlebar(mouse_location);
EXPECT_EQ(position1, panel1->GetBounds().origin());
EXPECT_EQ(position2, panel2->GetBounds().origin());
@@ -863,7 +863,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Detach) {
// Expect that the panel is still docked and only x coordinate of its position
// is changed.
gfx::Vector2d drag_delta_to_remain_docked = GetDragDeltaToRemainDocked();
- mouse_location = mouse_location.Add(drag_delta_to_remain_docked);
+ mouse_location = mouse_location + drag_delta_to_remain_docked;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(1, docked_strip->num_panels());
ASSERT_EQ(0, detached_strip->num_panels());
@@ -875,7 +875,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Detach) {
// Continue dragging up the panel in big offset that triggers the detach.
// Expect that the panel is previewed as detached.
gfx::Vector2d drag_delta_to_detach = GetDragDeltaToDetach();
- mouse_location = mouse_location.Add(drag_delta_to_detach);
+ mouse_location = mouse_location + drag_delta_to_detach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -918,7 +918,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAndCancel) {
// Expect that the panel is still docked and only x coordinate of its position
// is changed.
gfx::Vector2d drag_delta_to_remain_docked = GetDragDeltaToRemainDocked();
- mouse_location = mouse_location.Add(drag_delta_to_remain_docked);
+ mouse_location = mouse_location + drag_delta_to_remain_docked;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(1, docked_strip->num_panels());
ASSERT_EQ(0, detached_strip->num_panels());
@@ -930,7 +930,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAndCancel) {
// Continue dragging up the panel in big offset that triggers the detach.
// Expect that the panel is previewed as detached.
gfx::Vector2d drag_delta_to_detach = GetDragDeltaToDetach();
- mouse_location = mouse_location.Add(drag_delta_to_detach);
+ mouse_location = mouse_location + drag_delta_to_detach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -974,7 +974,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Attach) {
// Expect that the panel is still detached.
gfx::Vector2d drag_delta_to_remain_detached =
GetDragDeltaToRemainDetached(panel);
- mouse_location = mouse_location.Add(drag_delta_to_remain_detached);
+ mouse_location = mouse_location + drag_delta_to_remain_detached;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -987,7 +987,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Attach) {
// work area.
// Expect that the panel is previewed as docked.
gfx::Vector2d drag_delta_to_attach = GetDragDeltaToAttach(panel);
- mouse_location = mouse_location.Add(drag_delta_to_attach);
+ mouse_location = mouse_location + drag_delta_to_attach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(1, docked_strip->num_panels());
ASSERT_EQ(0, detached_strip->num_panels());
@@ -1033,7 +1033,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, AttachAndCancel) {
// Expect that the panel is still detached.
gfx::Vector2d drag_delta_to_remain_detached =
GetDragDeltaToRemainDetached(panel);
- mouse_location = mouse_location.Add(drag_delta_to_remain_detached);
+ mouse_location = mouse_location + drag_delta_to_remain_detached;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -1046,7 +1046,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, AttachAndCancel) {
// work area.
// Expect that the panel is previewed as docked.
gfx::Vector2d drag_delta_to_attach = GetDragDeltaToAttach(panel);
- mouse_location = mouse_location.Add(drag_delta_to_attach);
+ mouse_location = mouse_location + drag_delta_to_attach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(1, docked_strip->num_panels());
ASSERT_EQ(0, detached_strip->num_panels());
@@ -1086,7 +1086,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAttachAndCancel) {
// Drag up the panel to trigger the detach.
// Expect that the panel is previewed as detached.
gfx::Vector2d drag_delta_to_detach = GetDragDeltaToDetach();
- mouse_location = mouse_location.Add(drag_delta_to_detach);
+ mouse_location = mouse_location + drag_delta_to_detach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -1097,7 +1097,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAttachAndCancel) {
// Continue dragging down the panel to trigger the re-attach.
gfx::Vector2d drag_delta_to_reattach = GetDragDeltaToAttach(panel);
- mouse_location = mouse_location.Add(drag_delta_to_reattach);
+ mouse_location = mouse_location + drag_delta_to_reattach;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(1, docked_strip->num_panels());
ASSERT_EQ(0, detached_strip->num_panels());
@@ -1107,7 +1107,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAttachAndCancel) {
// Continue dragging up the panel to trigger the detach again.
gfx::Vector2d drag_delta_to_detach_again = GetDragDeltaToDetach();
- mouse_location = mouse_location.Add(drag_delta_to_detach_again);
+ mouse_location = mouse_location + drag_delta_to_detach_again;
panel_testing->DragTitlebar(mouse_location);
ASSERT_EQ(0, docked_strip->num_panels());
ASSERT_EQ(1, detached_strip->num_panels());
@@ -1157,7 +1157,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachWithSqueeze) {
EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type());
EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type());
gfx::Point panel2_new_position =
- panel2_docked_position.Add(drag_delta_to_detach);
+ panel2_docked_position + drag_delta_to_detach;
EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
// Drag to detach the left-most docked panel.
@@ -1175,7 +1175,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachWithSqueeze) {
EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type());
EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
gfx::Point panel4_new_position =
- panel4_docked_position.Add(drag_delta_to_detach);
+ panel4_docked_position + drag_delta_to_detach;
EXPECT_EQ(panel4_new_position, panel4->GetBounds().origin());
// Drag to detach the right-most docked panel.
@@ -1193,7 +1193,7 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachWithSqueeze) {
EXPECT_EQ(PanelStrip::DOCKED, panel3->panel_strip()->type());
EXPECT_EQ(PanelStrip::DETACHED, panel4->panel_strip()->type());
EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type());
- gfx::Point panel1_new_position = docked_position1.Add(drag_delta_to_detach);
+ gfx::Point panel1_new_position = docked_position1 + drag_delta_to_detach;
EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin());
EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
EXPECT_EQ(panel4_new_position, panel4->GetBounds().origin());
diff --git a/chrome/browser/ui/panels/panel_drag_controller.cc b/chrome/browser/ui/panels/panel_drag_controller.cc
index 37c6848..40265eb 100644
--- a/chrome/browser/ui/panels/panel_drag_controller.cc
+++ b/chrome/browser/ui/panels/panel_drag_controller.cc
@@ -27,7 +27,7 @@ PanelDragController::~PanelDragController() {
gfx::Point PanelDragController::GetPanelPositionForMouseLocation(
const gfx::Point& mouse_location) const {
- return mouse_location.Subtract(offset_from_mouse_location_on_drag_start_);
+ return mouse_location - offset_from_mouse_location_on_drag_start_;
}
void PanelDragController::StartDragging(Panel* panel,
@@ -194,7 +194,7 @@ bool PanelDragController::CanDragToDetachedStrip(
// the panel should follow the mouse movement. The size remains unchanged.
gfx::Rect target_panel_bounds = dragging_panel_->GetBounds();
target_panel_bounds.set_origin(
- mouse_location.Subtract(offset_from_mouse_location_on_drag_start_));
+ mouse_location - offset_from_mouse_location_on_drag_start_);
// Panels in the detached strip are always at their full size.
target_panel_bounds.set_size(dragging_panel()->full_size());
diff --git a/chrome/browser/ui/panels/panel_resize_browsertest.cc b/chrome/browser/ui/panels/panel_resize_browsertest.cc
index 9d39794..e437b26 100644
--- a/chrome/browser/ui/panels/panel_resize_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_resize_browsertest.cc
@@ -52,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the top.
- mouse_location = bounds.origin().Add(gfx::Vector2d(10, 1));
+ mouse_location = bounds.origin() + gfx::Vector2d(10, 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_TOP);
mouse_location.Offset(5, -10);
@@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the left side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(1, 30));
+ mouse_location = bounds.origin() + gfx::Vector2d(1, 30);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_LEFT);
mouse_location.Offset(-5, 25);
@@ -80,7 +80,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the top right side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 2));
+ mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_TOP_RIGHT);
mouse_location.Offset(30, 20);
@@ -96,7 +96,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the right side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 30));
+ mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 30);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_RIGHT);
mouse_location.Offset(5, 25);
@@ -111,7 +111,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the bottom side; verify resize won't work.
- mouse_location = bounds.origin().Add(gfx::Vector2d(10, bounds.height() - 1));
+ mouse_location = bounds.origin() + gfx::Vector2d(10, bounds.height() - 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM);
mouse_location.Offset(30, -10);
@@ -122,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the bottom left corner; verify resize won't work.
- mouse_location = bounds.origin().Add(gfx::Vector2d(1, bounds.height() - 1));
+ mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM_LEFT);
mouse_location.Offset(-10, 15);
@@ -133,8 +133,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the bottom right corner; verify resize won't work.
- mouse_location = bounds.origin().Add(
- gfx::Vector2d(bounds.width() - 2, bounds.height()));
+ mouse_location = bounds.origin() +
+ gfx::Vector2d(bounds.width() - 2, bounds.height());
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM_RIGHT);
mouse_location.Offset(20, 10);
@@ -156,8 +156,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
gfx::Rect bounds = panel->GetBounds();
// Try resizing by the right side; verify resize will change width only.
- gfx::Point mouse_location = bounds.origin().Add(
- gfx::Vector2d(bounds.width() - 1, 30));
+ gfx::Point mouse_location = bounds.origin() +
+ gfx::Vector2d(bounds.width() - 1, 30);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_RIGHT);
mouse_location.Offset(5, 25);
@@ -170,7 +170,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the bottom left side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(1, bounds.height() - 1));
+ mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM_LEFT);
mouse_location.Offset(-10, 15);
@@ -184,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the top right side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 2));
+ mouse_location = bounds.origin() + gfx::Vector2d(bounds.width() - 1, 2);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_TOP_RIGHT);
mouse_location.Offset(30, 20);
@@ -198,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
EXPECT_EQ(bounds, panel->GetBounds());
// Try resizing by the top left side.
- mouse_location = bounds.origin().Add(gfx::Vector2d(1, 0));
+ mouse_location = bounds.origin() + gfx::Vector2d(1, 0);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_TOP_LEFT);
mouse_location.Offset(-20, -10);
@@ -223,8 +223,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) {
gfx::Rect bounds = panel->GetBounds();
// Make sure the panel does not resize smaller than its min size.
- gfx::Point mouse_location = bounds.origin().Add(
- gfx::Vector2d(30, bounds.height() - 2));
+ gfx::Point mouse_location = bounds.origin() +
+ gfx::Vector2d(30, bounds.height() - 2);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM);
mouse_location.Offset(-20, -500);
@@ -237,8 +237,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) {
EXPECT_EQ(bounds, panel->GetBounds());
// Make sure the panel can resize larger than its size. User is in control.
- mouse_location = bounds.origin().Add(
- gfx::Vector2d(bounds.width(), bounds.height() - 2));
+ mouse_location = bounds.origin() +
+ gfx::Vector2d(bounds.width(), bounds.height() - 2);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM_RIGHT);
@@ -276,8 +276,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, CloseDetachedPanelOnResize) {
// Start resizing panel1, and close panel2 in the process.
// Panel1 is not affected.
- gfx::Point mouse_location = panel1_bounds.origin().Add(
- gfx::Vector2d(1, panel1_bounds.height() - 1));
+ gfx::Point mouse_location = panel1_bounds.origin() +
+ gfx::Vector2d(1, panel1_bounds.height() - 1);
panel_manager->StartResizingByMouse(panel1, mouse_location,
panel::RESIZE_BOTTOM_LEFT);
mouse_location.Offset(-10, 15);
@@ -297,8 +297,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, CloseDetachedPanelOnResize) {
// Start resizing panel3, and close it in the process.
// Resize should abort, panel1 will not be affected.
- mouse_location = panel3_bounds.origin().Add(
- gfx::Vector2d(panel3_bounds.width() - 1, panel3_bounds.height() - 2));
+ mouse_location = panel3_bounds.origin() +
+ gfx::Vector2d(panel3_bounds.width() - 1, panel3_bounds.height() - 2);
panel_manager->StartResizingByMouse(panel3, mouse_location,
panel::RESIZE_BOTTOM_RIGHT);
mouse_location.Offset(7, -12);
@@ -333,8 +333,8 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) {
// Resizing the panel, then cancelling should return it to the original state.
// Try resizing by the top right side.
gfx::Rect bounds = panel->GetBounds();
- gfx::Point mouse_location = bounds.origin().Add(
- gfx::Vector2d(bounds.width() - 1, 1));
+ gfx::Point mouse_location = bounds.origin() +
+ gfx::Vector2d(bounds.width() - 1, 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_TOP_RIGHT);
mouse_location.Offset(5, 25);
@@ -349,8 +349,7 @@ IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) {
// Try resizing by the bottom left side.
bounds = panel->GetBounds();
- mouse_location = bounds.origin().Add(
- gfx::Vector2d(1, bounds.height() - 1));
+ mouse_location = bounds.origin() + gfx::Vector2d(1, bounds.height() - 1);
panel_manager->StartResizingByMouse(panel, mouse_location,
panel::RESIZE_BOTTOM_LEFT);
mouse_location.Offset(-10, 15);
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index b6fd5db..1582e57 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -474,8 +474,7 @@ gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage(
// The background image starts tiling horizontally at the window left edge and
// vertically at the top edge of the horizontal tab strip (or where it would
// be). We expect our parent's origin to be the window origin.
- gfx::Point window_point(
- point.Add(GetMirroredPosition().OffsetFromOrigin()));
+ gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin());
window_point.Offset(frame_->GetThemeBackgroundXInset(),
-frame_->GetTabStripInsets(false).top);
return window_point;
diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h
index 29aebcf..1e1626c 100644
--- a/ui/aura/test/event_generator.h
+++ b/ui/aura/test/event_generator.h
@@ -85,7 +85,7 @@ class EventGenerator {
}
void MoveMouseBy(int x, int y) {
- MoveMouseTo(current_location_.Add(gfx::Vector2d(x, y)));
+ MoveMouseTo(current_location_ + gfx::Vector2d(x, y));
}
// Generates events to drag mouse to given |point|.
@@ -96,7 +96,7 @@ class EventGenerator {
}
void DragMouseBy(int dx, int dy) {
- DragMouseTo(current_location_.Add(gfx::Vector2d(dx, dy)));
+ DragMouseTo(current_location_ + gfx::Vector2d(dx, dy));
}
// Generates events to move the mouse to the center of the window.
@@ -120,7 +120,7 @@ class EventGenerator {
}
void PressMoveAndReleaseTouchBy(int x, int y) {
- PressMoveAndReleaseTouchTo(current_location_.Add(gfx::Vector2d(x, y)));
+ PressMoveAndReleaseTouchTo(current_location_ + gfx::Vector2d(x, y));
}
// Generates press, move and release events to move touch
diff --git a/ui/gfx/point.h b/ui/gfx/point.h
index 2e476d0..85bd8ac 100644
--- a/ui/gfx/point.h
+++ b/ui/gfx/point.h
@@ -70,11 +70,15 @@ inline bool operator!=(const Point& lhs, const Point& rhs) {
}
inline Point operator+(const Point& lhs, const Vector2d& rhs) {
- return lhs.Add(rhs);
+ Point result(lhs);
+ result += rhs;
+ return result;
}
inline Point operator-(const Point& lhs, const Vector2d& rhs) {
- return lhs.Subtract(rhs);
+ Point result(lhs);
+ result -= rhs;
+ return result;
}
inline Vector2d operator-(const Point& lhs, const Point& rhs) {
diff --git a/ui/gfx/point_base.h b/ui/gfx/point_base.h
index acaefe1..2eed614 100644
--- a/ui/gfx/point_base.h
+++ b/ui/gfx/point_base.h
@@ -33,26 +33,12 @@ class UI_EXPORT PointBase {
y_ += delta_y;
}
- void operator+=(const VectorClass& other) {
- Offset(other.x(), other.y());
+ void operator+=(const VectorClass& vector) {
+ Offset(vector.x(), vector.y());
}
- void operator-=(const VectorClass& other) {
- Offset(-other.x(), -other.y());
- }
-
- Class Add(const VectorClass& other) const WARN_UNUSED_RESULT {
- const Class* orig = static_cast<const Class*>(this);
- Class copy = *orig;
- copy.Offset(other.x(), other.y());
- return copy;
- }
-
- Class Subtract(const VectorClass& other) const WARN_UNUSED_RESULT {
- const Class* orig = static_cast<const Class*>(this);
- Class copy = *orig;
- copy.Offset(-other.x(), -other.y());
- return copy;
+ void operator-=(const VectorClass& vector) {
+ Offset(-vector.x(), -vector.y());
}
Class Middle(const Class& other) const WARN_UNUSED_RESULT {
diff --git a/ui/gfx/point_f.h b/ui/gfx/point_f.h
index 3e69bd7..46bd8e2 100644
--- a/ui/gfx/point_f.h
+++ b/ui/gfx/point_f.h
@@ -41,11 +41,15 @@ inline bool operator!=(const PointF& lhs, const PointF& rhs) {
}
inline PointF operator+(const PointF& lhs, const Vector2dF& rhs) {
- return lhs.Add(rhs);
+ PointF result(lhs);
+ result += rhs;
+ return result;
}
inline PointF operator-(const PointF& lhs, const Vector2dF& rhs) {
- return lhs.Subtract(rhs);
+ PointF result(lhs);
+ result -= rhs;
+ return result;
}
inline Vector2dF operator-(const PointF& lhs, const PointF& rhs) {
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 17d1fe8..55f0e0c 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -847,11 +847,11 @@ Vector2d RenderText::GetTextOffset() {
}
Point RenderText::ToTextPoint(const Point& point) {
- return point.Subtract(GetTextOffset());
+ return point - GetTextOffset();
}
Point RenderText::ToViewPoint(const Point& point) {
- return point.Add(GetTextOffset());
+ return point + GetTextOffset();
}
int RenderText::GetContentWidth() {
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 71b8acb..3a0da70 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -630,8 +630,8 @@ void View::ConvertPointToTarget(const View* source,
// API defines NULL |source| as returning the point in screen coordinates.
if (!source) {
- *point = point->Subtract(
- root->GetWidget()->GetClientAreaBoundsInScreen().OffsetFromOrigin());
+ *point -=
+ root->GetWidget()->GetClientAreaBoundsInScreen().OffsetFromOrigin();
}
}
@@ -660,7 +660,7 @@ void View::ConvertPointToScreen(const View* src, gfx::Point* p) {
const Widget* widget = src->GetWidget();
if (widget) {
ConvertPointToWidget(src, p);
- *p = p->Add(widget->GetClientAreaBoundsInScreen().OffsetFromOrigin());
+ *p += widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
}
}
@@ -672,7 +672,7 @@ void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) {
const views::Widget* widget = dst->GetWidget();
if (!widget)
return;
- *p = p->Add(-widget->GetClientAreaBoundsInScreen().OffsetFromOrigin());
+ *p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
views::View::ConvertPointFromWidget(dst, p);
}