| OLD | NEW |
| 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 "ash/accelerators/accelerator_commands.h" | 10 #include "ash/accelerators/accelerator_commands.h" |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 } | 1310 } |
| 1311 } else { | 1311 } else { |
| 1312 index = GetInsertionIndexFrom(dragged_bounds, 0); | 1312 index = GetInsertionIndexFrom(dragged_bounds, 0); |
| 1313 } | 1313 } |
| 1314 if (index == -1) { | 1314 if (index == -1) { |
| 1315 const int last_tab_right = | 1315 const int last_tab_right = |
| 1316 attached_tabstrip_->ideal_bounds(tab_count - 1).right(); | 1316 attached_tabstrip_->ideal_bounds(tab_count - 1).right(); |
| 1317 index = (dragged_bounds.right() > last_tab_right) ? tab_count : 0; | 1317 index = (dragged_bounds.right() > last_tab_right) ? tab_count : 0; |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 if (!drag_data_[0].attached_tab) { | 1320 int last_insertion_point = attached_tabstrip_->GetModelIndexOfTab( |
| 1321 // If 'attached_tab' is NULL, it means we're in the process of attaching and | 1321 attached_tabstrip_->GetLastVisibleTab()) + 1; |
| 1322 // don't need to constrain the index. | 1322 if (drag_data_[0].attached_tab) { |
| 1323 return index; | 1323 // We're not in the process of attaching, so clamp the insertion point to |
| 1324 // keep it within the visible region. |
| 1325 last_insertion_point = std::max( |
| 1326 0, last_insertion_point - static_cast<int>(drag_data_.size())); |
| 1324 } | 1327 } |
| 1325 | 1328 |
| 1326 int max_index = GetModel(attached_tabstrip_)->count() - | 1329 // Ensure the first dragged tab always stays in the visible index range. |
| 1327 static_cast<int>(drag_data_.size()); | 1330 return std::min(index, last_insertion_point); |
| 1328 return std::max(0, std::min(max_index, index)); | |
| 1329 } | 1331 } |
| 1330 | 1332 |
| 1331 bool TabDragController::ShouldDragToNextStackedTab( | 1333 bool TabDragController::ShouldDragToNextStackedTab( |
| 1332 const gfx::Rect& dragged_bounds, | 1334 const gfx::Rect& dragged_bounds, |
| 1333 int index) const { | 1335 int index) const { |
| 1334 if (index + 1 >= attached_tabstrip_->tab_count() || | 1336 if (index + 1 >= attached_tabstrip_->tab_count() || |
| 1335 !attached_tabstrip_->touch_layout_->IsStacked(index + 1) || | 1337 !attached_tabstrip_->touch_layout_->IsStacked(index + 1) || |
| 1336 (mouse_move_direction_ & kMovedMouseRight) == 0) | 1338 (mouse_move_direction_ & kMovedMouseRight) == 0) |
| 1337 return false; | 1339 return false; |
| 1338 | 1340 |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 it != browser_list->end(); ++it) { | 1949 it != browser_list->end(); ++it) { |
| 1948 if ((*it)->tab_strip_model()->empty()) | 1950 if ((*it)->tab_strip_model()->empty()) |
| 1949 exclude.insert((*it)->window()->GetNativeWindow()); | 1951 exclude.insert((*it)->window()->GetNativeWindow()); |
| 1950 } | 1952 } |
| 1951 #endif | 1953 #endif |
| 1952 return GetLocalProcessWindowAtPoint(host_desktop_type_, | 1954 return GetLocalProcessWindowAtPoint(host_desktop_type_, |
| 1953 screen_point, | 1955 screen_point, |
| 1954 exclude); | 1956 exclude); |
| 1955 | 1957 |
| 1956 } | 1958 } |
| OLD | NEW |