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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extract DragsWindowUsingCocoaMoveLoop test, cleanup code. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 point_in_screen.x() - 375 point_in_screen.x() -
376 mouse_offset_.x(), 0); 376 mouse_offset_.x(), 0);
377 widget->SetVisibilityChangedAnimationsEnabled(false); 377 widget->SetVisibilityChangedAnimationsEnabled(false);
378 widget->Restore(); 378 widget->Restore();
379 widget->SetBounds(new_bounds); 379 widget->SetBounds(new_bounds);
380 AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width, 380 AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width,
381 point_in_screen, 381 point_in_screen,
382 &drag_bounds); 382 &drag_bounds);
383 widget->SetVisibilityChangedAnimationsEnabled(true); 383 widget->SetVisibilityChangedAnimationsEnabled(true);
384 } 384 }
385 RunMoveLoop(GetWindowOffset(point_in_screen)); 385 RunMoveLoop(GetWindowOffset(start_point_in_screen_));
tapted 2016/03/10 11:51:18 I think this should land first and separately with
themblsha 2016/03/10 17:18:58 Without this fix the DetachToBrowserTabDragControl
tapted 2016/03/11 09:38:28 The problem currently is that it's hard for a revi
themblsha 2016/04/05 17:20:42 Added this comment: // Always use the start
386 return; 386 return;
387 } 387 }
388 } 388 }
389 389
390 ContinueDragging(point_in_screen); 390 ContinueDragging(point_in_screen);
391 } 391 }
392 392
393 void TabDragController::EndDrag(EndDragReason reason) { 393 void TabDragController::EndDrag(EndDragReason reason) {
394 TRACE_EVENT0("views", "TabDragController::EndDrag"); 394 TRACE_EVENT0("views", "TabDragController::EndDrag");
395 395
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return; 517 return;
518 old_focused_view->GetFocusManager()->SetFocusedView(old_focused_view); 518 old_focused_view->GetFocusManager()->SetFocusedView(old_focused_view);
519 } 519 }
520 520
521 bool TabDragController::CanStartDrag(const gfx::Point& point_in_screen) const { 521 bool TabDragController::CanStartDrag(const gfx::Point& point_in_screen) const {
522 // Determine if the mouse has moved beyond a minimum elasticity distance in 522 // Determine if the mouse has moved beyond a minimum elasticity distance in
523 // any direction from the starting point. 523 // any direction from the starting point.
524 static const int kMinimumDragDistance = 10; 524 static const int kMinimumDragDistance = 10;
525 int x_offset = abs(point_in_screen.x() - start_point_in_screen_.x()); 525 int x_offset = abs(point_in_screen.x() - start_point_in_screen_.x());
526 int y_offset = abs(point_in_screen.y() - start_point_in_screen_.y()); 526 int y_offset = abs(point_in_screen.y() - start_point_in_screen_.y());
527 return sqrt(pow(static_cast<float>(x_offset), 2) + 527 bool result = sqrt(pow(static_cast<float>(x_offset), 2) +
tapted 2016/03/10 11:51:18 nit: this change not needed
themblsha 2016/03/10 17:18:58 Done.
528 pow(static_cast<float>(y_offset), 2)) > kMinimumDragDistance; 528 pow(static_cast<float>(y_offset), 2)) > kMinimumDragDistance;
529 return result;
529 } 530 }
530 531
531 void TabDragController::ContinueDragging(const gfx::Point& point_in_screen) { 532 void TabDragController::ContinueDragging(const gfx::Point& point_in_screen) {
532 TRACE_EVENT1("views", "TabDragController::ContinueDragging", 533 TRACE_EVENT1("views", "TabDragController::ContinueDragging",
533 "point_in_screen", point_in_screen.ToString()); 534 "point_in_screen", point_in_screen.ToString());
534 535
535 DCHECK(attached_tabstrip_); 536 DCHECK(attached_tabstrip_);
536 537
537 TabStrip* target_tabstrip = detach_behavior_ == DETACHABLE ? 538 TabStrip* target_tabstrip = detach_behavior_ == DETACHABLE ?
538 GetTargetTabStripForPoint(point_in_screen) : source_tabstrip_; 539 GetTargetTabStripForPoint(point_in_screen) : source_tabstrip_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // observer so we don't get notified and process the event. 602 // observer so we don't get notified and process the event.
602 #if defined(USE_ASH) 603 #if defined(USE_ASH)
603 move_loop_widget_->RemoveObserver(this); 604 move_loop_widget_->RemoveObserver(this);
604 move_loop_widget_ = nullptr; 605 move_loop_widget_ = nullptr;
605 #endif // USE_ASH 606 #endif // USE_ASH
606 views::Widget* browser_widget = GetAttachedBrowserWidget(); 607 views::Widget* browser_widget = GetAttachedBrowserWidget();
607 // Need to release the drag controller before starting the move loop as it's 608 // Need to release the drag controller before starting the move loop as it's
608 // going to trigger capture lost, which cancels drag. 609 // going to trigger capture lost, which cancels drag.
609 attached_tabstrip_->ReleaseDragController(); 610 attached_tabstrip_->ReleaseDragController();
610 target_tabstrip->OwnDragController(this); 611 target_tabstrip->OwnDragController(this);
612
tapted 2016/03/10 11:51:18 nit: remove added line
themblsha 2016/03/10 17:18:58 Done.
611 // Disable animations so that we don't see a close animation on aero. 613 // Disable animations so that we don't see a close animation on aero.
612 browser_widget->SetVisibilityChangedAnimationsEnabled(false); 614 browser_widget->SetVisibilityChangedAnimationsEnabled(false);
613 if (can_release_capture_) 615 if (can_release_capture_)
614 browser_widget->ReleaseCapture(); 616 browser_widget->ReleaseCapture();
615 else 617 else
616 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); 618 target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_);
617 619
618 // The window is going away. Since the drag is still on going we don't want 620 // The window is going away. Since the drag is still on going we don't want
619 // that to effect the position of any windows. 621 // that to effect the position of any windows.
620 SetWindowPositionManaged(browser_widget->GetNativeWindow(), false); 622 SetWindowPositionManaged(browser_widget->GetNativeWindow(), false);
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 // window which was used for dragging is not hidden once all of its tabs are 1809 // window which was used for dragging is not hidden once all of its tabs are
1808 // attached to another browser window in DragBrowserToNewTabStrip(). 1810 // attached to another browser window in DragBrowserToNewTabStrip().
1809 // TODO(pkotwicz): Fix this properly (crbug.com/358482) 1811 // TODO(pkotwicz): Fix this properly (crbug.com/358482)
1810 for (auto* browser : *BrowserList::GetInstance()) { 1812 for (auto* browser : *BrowserList::GetInstance()) {
1811 if (browser->tab_strip_model()->empty()) 1813 if (browser->tab_strip_model()->empty())
1812 exclude.insert(browser->window()->GetNativeWindow()); 1814 exclude.insert(browser->window()->GetNativeWindow());
1813 } 1815 }
1814 #endif 1816 #endif
1815 return GetLocalProcessWindowAtPoint(screen_point, exclude); 1817 return GetLocalProcessWindowAtPoint(screen_point, exclude);
1816 } 1818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698