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

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

Issue 331343002: Misc. cleanup: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 9ce7433b3deb5db8f8e70cb2e7af2e94f9b5a44c..b3f47d9d78537cd40f13d7add000d91bf76b25aa 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -796,8 +796,8 @@ void TabDragController::MoveAttached(const gfx::Point& point_in_screen) {
if ((abs(point_in_screen.x() - last_move_screen_loc_) > threshold ||
(initial_move_ && !AreTabsConsecutive()))) {
TabStripModel* attached_model = GetModel(attached_tabstrip_);
- gfx::Rect bounds = GetDraggedViewTabStripBounds(dragged_view_point);
- int to_index = GetInsertionIndexForDraggedBounds(bounds);
+ int to_index = GetInsertionIndexForDraggedBounds(
+ GetDraggedViewTabStripBounds(dragged_view_point));
Peter Kasting 2014/06/17 03:16:18 I didn't think the old code was bad, but while wor
bool do_move = true;
// While dragging within a tabstrip the expectation is the insertion index
// is based on the left edge of the tabs being dragged. OTOH when dragging
@@ -1004,8 +1004,8 @@ void TabDragController::Attach(TabStrip* attached_tabstrip,
tab_strip_point.set_x(
attached_tabstrip_->GetMirroredXInView(tab_strip_point.x()));
tab_strip_point.Offset(0, -mouse_offset_.y());
- gfx::Rect bounds = GetDraggedViewTabStripBounds(tab_strip_point);
- int index = GetInsertionIndexForDraggedBounds(bounds);
+ int index = GetInsertionIndexForDraggedBounds(
+ GetDraggedViewTabStripBounds(tab_strip_point));
attach_index_ = index;
attach_x_ = tab_strip_point.x();
base::AutoReset<bool> setter(&is_mutating_, true);
@@ -1266,6 +1266,11 @@ int TabDragController::GetInsertionIndexFrom(const gfx::Rect& dragged_bounds,
int TabDragController::GetInsertionIndexForDraggedBounds(
const gfx::Rect& dragged_bounds) const {
+ // If the strip has no tabs, the only position to insert at is 0.
+ const int tab_count = attached_tabstrip_->tab_count();
+ if (!tab_count)
+ return 0;
+
int index = -1;
if (attached_tabstrip_->touch_layout_.get()) {
index = GetInsertionIndexForDraggedBoundsStacked(dragged_bounds);
@@ -1285,14 +1290,9 @@ int TabDragController::GetInsertionIndexForDraggedBounds(
index = GetInsertionIndexFrom(dragged_bounds, 0, 1);
}
if (index == -1) {
- int tab_count = attached_tabstrip_->tab_count();
- int right_tab_x = tab_count == 0 ? 0 :
+ const int last_tab_right =
attached_tabstrip_->ideal_bounds(tab_count - 1).right();
- if (dragged_bounds.right() > right_tab_x) {
- index = GetModel(attached_tabstrip_)->count();
- } else {
- index = 0;
- }
+ index = (dragged_bounds.right() > last_tab_right) ? tab_count : 0;
Peter Kasting 2014/06/17 03:16:18 Note that this assumes attached_tabstrip_->tab_cou
sky 2014/06/17 15:42:42 Yes, they should be equal (with the exception of t
}
if (!drag_data_[0].attached_tab) {
@@ -1800,7 +1800,7 @@ gfx::Rect TabDragController::CalculateDraggedBrowserBounds(
// maximized windows, add an additional vertical offset extracted from the tab
// strip.
if (source->GetWidget()->IsMaximized())
- new_bounds.Offset(0, -source->button_v_offset());
+ new_bounds.Offset(0, -source->kNewTabButtonVerticalOffset);
return new_bounds;
}

Powered by Google App Engine
This is Rietveld 408576698