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

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

Issue 11821036: Fixes couple of bugs in the TabStrip that could cause tabs to dance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | 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_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 // It doesn't make sense to drag tabs out on Win8's single window Metro mode. 1082 // It doesn't make sense to drag tabs out on Win8's single window Metro mode.
1083 if (win8::IsSingleWindowMetroMode()) 1083 if (win8::IsSingleWindowMetroMode())
1084 detach_behavior = TabDragController::NOT_DETACHABLE; 1084 detach_behavior = TabDragController::NOT_DETACHABLE;
1085 #endif 1085 #endif
1086 // Gestures don't automatically do a capture. We don't allow multiple drags at 1086 // Gestures don't automatically do a capture. We don't allow multiple drags at
1087 // the same time, so we explicitly capture. 1087 // the same time, so we explicitly capture.
1088 if (event.type() == ui::ET_GESTURE_BEGIN) 1088 if (event.type() == ui::ET_GESTURE_BEGIN)
1089 GetWidget()->SetCapture(this); 1089 GetWidget()->SetCapture(this);
1090 drag_controller_.reset(new TabDragController); 1090 drag_controller_.reset(new TabDragController);
1091 drag_controller_->Init( 1091 drag_controller_->Init(
1092 this, tab, tabs, gfx::Point(x, y), tab->GetMirroredXInView(event.x()), 1092 this, tab, tabs, gfx::Point(x, y), event.x(),
1093 selection_model, detach_behavior, move_behavior); 1093 selection_model, detach_behavior, move_behavior);
1094 } 1094 }
1095 1095
1096 void TabStrip::ContinueDrag(views::View* view, const gfx::Point& location) { 1096 void TabStrip::ContinueDrag(views::View* view, const gfx::Point& location) {
1097 if (drag_controller_.get()) { 1097 if (drag_controller_.get()) {
1098 gfx::Point screen_location(location); 1098 gfx::Point screen_location(location);
1099 views::View::ConvertPointToScreen(view, &screen_location); 1099 views::View::ConvertPointToScreen(view, &screen_location);
1100 drag_controller_->Drag(screen_location); 1100 drag_controller_->Drag(screen_location);
1101 } 1101 }
1102 } 1102 }
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 RemoveMessageLoopObserver(); 2117 RemoveMessageLoopObserver();
2118 2118
2119 in_tab_close_ = false; 2119 in_tab_close_ = false;
2120 available_width_for_tabs_ = -1; 2120 available_width_for_tabs_ = -1;
2121 int mini_tab_count = GetMiniTabCount(); 2121 int mini_tab_count = GetMiniTabCount();
2122 if (mini_tab_count == tab_count()) { 2122 if (mini_tab_count == tab_count()) {
2123 // Only mini-tabs, we know the tab widths won't have changed (all 2123 // Only mini-tabs, we know the tab widths won't have changed (all
2124 // mini-tabs have the same width), so there is nothing to do. 2124 // mini-tabs have the same width), so there is nothing to do.
2125 return; 2125 return;
2126 } 2126 }
2127 Tab* first_tab = tab_at(mini_tab_count); 2127 // Don't try and avoid layout based on tab sizes. If tabs are small enough
2128 double unselected, selected; 2128 // then the width of the active tab may not change, but other widths may
2129 GetDesiredTabWidths(tab_count(), mini_tab_count, &unselected, &selected); 2129 // have. This is particularly important if we've overflowed (all tabs are at
2130 // TODO: this is always selected, should it be 'selected : unselected'? 2130 // the min).
2131 int w = Round(first_tab->IsActive() ? selected : selected); 2131 StartResizeLayoutAnimation();
2132
2133 // We only want to run the animation if we're not already at the desired
2134 // size.
2135 if (abs(first_tab->width() - w) > 1)
2136 StartResizeLayoutAnimation();
2137 } 2132 }
2138 2133
2139 void TabStrip::ResizeLayoutTabsFromTouch() { 2134 void TabStrip::ResizeLayoutTabsFromTouch() {
2140 // Don't resize if the user is interacting with the tabstrip. 2135 // Don't resize if the user is interacting with the tabstrip.
2141 if (!drag_controller_.get()) 2136 if (!drag_controller_.get())
2142 ResizeLayoutTabs(); 2137 ResizeLayoutTabs();
2143 else 2138 else
2144 StartResizeLayoutTabsFromTouchTimer(); 2139 StartResizeLayoutTabsFromTouchTimer();
2145 } 2140 }
2146 2141
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 if (!adjust_layout_) 2570 if (!adjust_layout_)
2576 return false; 2571 return false;
2577 2572
2578 #if !defined(OS_CHROMEOS) 2573 #if !defined(OS_CHROMEOS)
2579 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2574 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2580 return false; 2575 return false;
2581 #endif 2576 #endif
2582 2577
2583 return true; 2578 return true;
2584 } 2579 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698