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

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

Issue 1392193004: Miscellaneous cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge Created 5 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 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 364 }
365 started_drag_ = true; 365 started_drag_ = true;
366 Attach(source_tabstrip_, gfx::Point()); 366 Attach(source_tabstrip_, gfx::Point());
367 if (static_cast<int>(drag_data_.size()) == 367 if (static_cast<int>(drag_data_.size()) ==
368 GetModel(source_tabstrip_)->count()) { 368 GetModel(source_tabstrip_)->count()) {
369 if (was_source_maximized_ || was_source_fullscreen_) { 369 if (was_source_maximized_ || was_source_fullscreen_) {
370 did_restore_window_ = true; 370 did_restore_window_ = true;
371 // When all tabs in a maximized browser are dragged the browser gets 371 // When all tabs in a maximized browser are dragged the browser gets
372 // restored during the drag and maximized back when the drag ends. 372 // restored during the drag and maximized back when the drag ends.
373 views::Widget* widget = GetAttachedBrowserWidget(); 373 views::Widget* widget = GetAttachedBrowserWidget();
374 const int last_tabstrip_width = attached_tabstrip_->tab_area_width(); 374 const int last_tabstrip_width = attached_tabstrip_->GetTabAreaWidth();
375 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); 375 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs();
376 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); 376 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds);
377 gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_, 377 gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_,
378 point_in_screen, 378 point_in_screen,
379 &drag_bounds)); 379 &drag_bounds));
380 new_bounds.Offset(-widget->GetRestoredBounds().x() + 380 new_bounds.Offset(-widget->GetRestoredBounds().x() +
381 point_in_screen.x() - 381 point_in_screen.x() -
382 mouse_offset_.x(), 0); 382 mouse_offset_.x(), 0);
383 widget->SetVisibilityChangedAnimationsEnabled(false); 383 widget->SetVisibilityChangedAnimationsEnabled(false);
384 widget->Restore(); 384 widget->Restore();
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 const gfx::Point& point_in_screen) { 1017 const gfx::Point& point_in_screen) {
1018 if (GetModel(attached_tabstrip_)->count() == 1018 if (GetModel(attached_tabstrip_)->count() ==
1019 static_cast<int>(drag_data_.size())) { 1019 static_cast<int>(drag_data_.size())) {
1020 // All the tabs in a browser are being dragged but all the tabs weren't 1020 // All the tabs in a browser are being dragged but all the tabs weren't
1021 // initially being dragged. For this to happen the user would have to 1021 // initially being dragged. For this to happen the user would have to
1022 // start dragging a set of tabs, the other tabs close, then detach. 1022 // start dragging a set of tabs, the other tabs close, then detach.
1023 RunMoveLoop(GetWindowOffset(point_in_screen)); 1023 RunMoveLoop(GetWindowOffset(point_in_screen));
1024 return; 1024 return;
1025 } 1025 }
1026 1026
1027 const int last_tabstrip_width = attached_tabstrip_->tab_area_width(); 1027 const int last_tabstrip_width = attached_tabstrip_->GetTabAreaWidth();
1028 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); 1028 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs();
1029 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); 1029 OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds);
1030 1030
1031 gfx::Vector2d drag_offset; 1031 gfx::Vector2d drag_offset;
1032 Browser* browser = CreateBrowserForDrag( 1032 Browser* browser = CreateBrowserForDrag(
1033 attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds); 1033 attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds);
1034 1034
1035 BrowserView* dragged_browser_view = 1035 BrowserView* dragged_browser_view =
1036 BrowserView::GetBrowserViewForBrowser(browser); 1036 BrowserView::GetBrowserViewForBrowser(browser);
1037 views::Widget* dragged_widget = dragged_browser_view->GetWidget(); 1037 views::Widget* dragged_widget = dragged_browser_view->GetWidget();
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 new_bounds.Offset(0, -source->kNewTabButtonVerticalOffset); 1694 new_bounds.Offset(0, -source->kNewTabButtonVerticalOffset);
1695 return new_bounds; 1695 return new_bounds;
1696 } 1696 }
1697 1697
1698 void TabDragController::AdjustBrowserAndTabBoundsForDrag( 1698 void TabDragController::AdjustBrowserAndTabBoundsForDrag(
1699 int last_tabstrip_width, 1699 int last_tabstrip_width,
1700 const gfx::Point& point_in_screen, 1700 const gfx::Point& point_in_screen,
1701 std::vector<gfx::Rect>* drag_bounds) { 1701 std::vector<gfx::Rect>* drag_bounds) {
1702 attached_tabstrip_->InvalidateLayout(); 1702 attached_tabstrip_->InvalidateLayout();
1703 attached_tabstrip_->DoLayout(); 1703 attached_tabstrip_->DoLayout();
1704 const int dragged_tabstrip_width = attached_tabstrip_->tab_area_width(); 1704 const int dragged_tabstrip_width = attached_tabstrip_->GetTabAreaWidth();
1705 1705
1706 // If the new tabstrip is smaller than the old resize the tabs. 1706 // If the new tabstrip is smaller than the old resize the tabs.
1707 if (dragged_tabstrip_width < last_tabstrip_width) { 1707 if (dragged_tabstrip_width < last_tabstrip_width) {
1708 const float leading_ratio = 1708 const float leading_ratio =
1709 drag_bounds->front().x() / static_cast<float>(last_tabstrip_width); 1709 drag_bounds->front().x() / static_cast<float>(last_tabstrip_width);
1710 *drag_bounds = CalculateBoundsForDraggedTabs(); 1710 *drag_bounds = CalculateBoundsForDraggedTabs();
1711 1711
1712 if (drag_bounds->back().right() < dragged_tabstrip_width) { 1712 if (drag_bounds->back().right() < dragged_tabstrip_width) {
1713 const int delta_x = 1713 const int delta_x =
1714 std::min(static_cast<int>(leading_ratio * dragged_tabstrip_width), 1714 std::min(static_cast<int>(leading_ratio * dragged_tabstrip_width),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 it != browser_list->end(); ++it) { 1813 it != browser_list->end(); ++it) {
1814 if ((*it)->tab_strip_model()->empty()) 1814 if ((*it)->tab_strip_model()->empty())
1815 exclude.insert((*it)->window()->GetNativeWindow()); 1815 exclude.insert((*it)->window()->GetNativeWindow());
1816 } 1816 }
1817 #endif 1817 #endif
1818 return GetLocalProcessWindowAtPoint(host_desktop_type_, 1818 return GetLocalProcessWindowAtPoint(host_desktop_type_,
1819 screen_point, 1819 screen_point,
1820 exclude); 1820 exclude);
1821 1821
1822 } 1822 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698