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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cf3e782fff76104315e1dd055e03d697e5180824..bf353bea4fa25e33968046abdcef7663c240420e 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -1317,15 +1317,18 @@ int TabDragController::GetInsertionIndexForDraggedBounds(
index = (dragged_bounds.right() > last_tab_right) ? tab_count : 0;
}
- if (!drag_data_[0].attached_tab) {
- // If 'attached_tab' is NULL, it means we're in the process of attaching and
- // don't need to constrain the index.
- return index;
+ const Tab* last_visible_tab = attached_tabstrip_->GetLastVisibleTab();
+ int last_insertion_point = last_visible_tab ?
+ (attached_tabstrip_->GetModelIndexOfTab(last_visible_tab) + 1) : 0;
+ if (drag_data_[0].attached_tab) {
+ // We're not in the process of attaching, so clamp the insertion point to
+ // keep it within the visible region.
+ last_insertion_point = std::max(
+ 0, last_insertion_point - static_cast<int>(drag_data_.size()));
}
- int max_index = GetModel(attached_tabstrip_)->count() -
- static_cast<int>(drag_data_.size());
- return std::max(0, std::min(max_index, index));
+ // Ensure the first dragged tab always stays in the visible index range.
+ return std::min(index, last_insertion_point);
}
bool TabDragController::ShouldDragToNextStackedTab(
« 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