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

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

Issue 339923005: Clip tabs in overflow mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit tests 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/accelerators/accelerator_commands.h" 10 #include "ash/accelerators/accelerator_commands.h"
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const Tab* last_visible_tab = attached_tabstrip_->GetLastVisibleTab();
1321 // If 'attached_tab' is NULL, it means we're in the process of attaching and 1321 int last_insertion_point = last_visible_tab ?
1322 // don't need to constrain the index. 1322 (attached_tabstrip_->GetModelIndexOfTab(last_visible_tab) + 1) : 0;
1323 return index; 1323 if (drag_data_[0].attached_tab) {
1324 // We're not in the process of attaching, so clamp the insertion point to
1325 // keep it within the visible region.
1326 last_insertion_point = std::max(
1327 0, last_insertion_point - static_cast<int>(drag_data_.size()));
1324 } 1328 }
1325 1329
1326 int max_index = GetModel(attached_tabstrip_)->count() - 1330 // Ensure the first dragged tab always stays in the visible index range.
1327 static_cast<int>(drag_data_.size()); 1331 return std::min(index, last_insertion_point);
1328 return std::max(0, std::min(max_index, index));
1329 } 1332 }
1330 1333
1331 bool TabDragController::ShouldDragToNextStackedTab( 1334 bool TabDragController::ShouldDragToNextStackedTab(
1332 const gfx::Rect& dragged_bounds, 1335 const gfx::Rect& dragged_bounds,
1333 int index) const { 1336 int index) const {
1334 if (index + 1 >= attached_tabstrip_->tab_count() || 1337 if (index + 1 >= attached_tabstrip_->tab_count() ||
1335 !attached_tabstrip_->touch_layout_->IsStacked(index + 1) || 1338 !attached_tabstrip_->touch_layout_->IsStacked(index + 1) ||
1336 (mouse_move_direction_ & kMovedMouseRight) == 0) 1339 (mouse_move_direction_ & kMovedMouseRight) == 0)
1337 return false; 1340 return false;
1338 1341
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 it != browser_list->end(); ++it) { 1950 it != browser_list->end(); ++it) {
1948 if ((*it)->tab_strip_model()->empty()) 1951 if ((*it)->tab_strip_model()->empty())
1949 exclude.insert((*it)->window()->GetNativeWindow()); 1952 exclude.insert((*it)->window()->GetNativeWindow());
1950 } 1953 }
1951 #endif 1954 #endif
1952 return GetLocalProcessWindowAtPoint(host_desktop_type_, 1955 return GetLocalProcessWindowAtPoint(host_desktop_type_,
1953 screen_point, 1956 screen_point,
1954 exclude); 1957 exclude);
1955 1958
1956 } 1959 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698