Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/tabs/tab_drag_controller.cc
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
index 146fa9b458baf2a3ff0a1288f68e0ef816e2650f..c4af459fccdc54c529034c53cfa5eb8a8cd3ddbf 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -112,7 +112,7 @@ class DockView : public views::View {
bool rtl_ui = base::i18n::IsRTL();
if (rtl_ui) {
// Flip canvas to draw the mirrored tab images for RTL UI.
- canvas->Translate(gfx::Point(width(), 0));
+ canvas->Translate(gfx::Vector2d(width(), 0));
canvas->Scale(-1, 1);
}
int x_of_active_tab = width() / 2 + kTabSpacing / 2;
@@ -504,8 +504,7 @@ void TabDragController::Drag(const gfx::Point& point_in_screen) {
Attach(source_tabstrip_, gfx::Point());
if (detach_into_browser_ && static_cast<int>(drag_data_.size()) ==
GetModel(source_tabstrip_)->count()) {
- gfx::Point dragged_view_point = GetWindowOffset(point_in_screen);
- RunMoveLoop(dragged_view_point);
+ RunMoveLoop(GetWindowOffset(point_in_screen));
return;
}
}
@@ -1305,8 +1304,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
// All the tabs in a browser are being dragged but all the tabs weren't
// initially being dragged. For this to happen the user would have to
// start dragging a set of tabs, the other tabs close, then detach.
- gfx::Point dragged_view_point = GetWindowOffset(point_in_screen);
- RunMoveLoop(dragged_view_point);
+ RunMoveLoop(GetWindowOffset(point_in_screen));
return;
}
@@ -1320,7 +1318,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
std::vector<gfx::Rect> drag_bounds =
CalculateBoundsForDraggedTabs(attached_point.x());
- gfx::Point drag_offset;
+ gfx::Vector2d drag_offset;
Browser* browser = CreateBrowserForDrag(
attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds);
Detach(DONT_RELEASE_CAPTURE);
@@ -1343,7 +1341,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
RunMoveLoop(drag_offset);
}
-void TabDragController::RunMoveLoop(const gfx::Point& drag_offset) {
+void TabDragController::RunMoveLoop(const gfx::Vector2d& drag_offset) {
// If the user drags the whole window we'll assume they are going to attach to
// another window and therefor want to reorder.
move_behavior_ = REORDER;
@@ -1979,7 +1977,7 @@ bool TabDragController::AreTabsConsecutive() {
Browser* TabDragController::CreateBrowserForDrag(
TabStrip* source,
const gfx::Point& point_in_screen,
- gfx::Point* drag_offset,
+ gfx::Vector2d* drag_offset,
std::vector<gfx::Rect>* drag_bounds) {
gfx::Point center(0, source->height() / 2);
views::View::ConvertPointToWidget(source, &center);
@@ -2006,7 +2004,7 @@ Browser* TabDragController::CreateBrowserForDrag(
break; // Nothing to do for DETACH_ABOVE_OR_BELOW.
}
- *drag_offset = point_in_screen.Subtract(new_bounds.origin());
+ *drag_offset = point_in_screen - new_bounds.origin();
Browser::CreateParams create_params(
Browser::TYPE_TABBED,
@@ -2040,13 +2038,13 @@ gfx::Point TabDragController::GetCursorScreenPoint() {
return screen_->GetCursorScreenPoint();
}
-gfx::Point TabDragController::GetWindowOffset(
+gfx::Vector2d TabDragController::GetWindowOffset(
const gfx::Point& point_in_screen) {
TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
attached_tabstrip_ : source_tabstrip_;
views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
- gfx::Point offset = point_in_screen;
- views::View::ConvertPointFromScreen(toplevel_view, &offset);
- return offset;
+ gfx::Point point = point_in_screen;
+ views::View::ConvertPointFromScreen(toplevel_view, &point);
+ return point.OffsetFromOrigin();
}

Powered by Google App Engine
This is Rietveld 408576698