| Index: chrome/browser/ui/views/tabs/tab_strip.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
|
| index 5375cdf77e94e123f61aabca1d6bb7699f5b785f..9cf214f8bf29d54df964938da417e9a935d948d1 100644
|
| --- a/chrome/browser/ui/views/tabs/tab_strip.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
|
| @@ -511,7 +511,7 @@ TabStrip::TabStrip(TabStripController* controller)
|
| in_tab_close_(false),
|
| animation_container_(new gfx::AnimationContainer()),
|
| bounds_animator_(this),
|
| - layout_type_(TAB_STRIP_LAYOUT_SHRINK),
|
| + stacked_layout_(false),
|
| adjust_layout_(false),
|
| reset_to_shrink_on_exit_(false),
|
| mouse_move_count_(0),
|
| @@ -547,10 +547,8 @@ void TabStrip::RemoveObserver(TabStripObserver* observer) {
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| -void TabStrip::SetLayoutType(TabStripLayoutType layout_type,
|
| - bool adjust_layout) {
|
| - adjust_layout_ = adjust_layout;
|
| - if (layout_type == layout_type_)
|
| +void TabStrip::SetStackedLayout(bool stacked_layout) {
|
| + if (stacked_layout == stacked_layout_)
|
| return;
|
|
|
| const int active_index = controller_->GetActiveIndex();
|
| @@ -559,7 +557,7 @@ void TabStrip::SetLayoutType(TabStripLayoutType layout_type,
|
| active_center = ideal_bounds(active_index).x() +
|
| ideal_bounds(active_index).width() / 2;
|
| }
|
| - layout_type_ = layout_type;
|
| + stacked_layout_ = stacked_layout;
|
| SetResetToShrinkOnExit(false);
|
| SwapLayoutIfNecessary();
|
| // When transitioning to stacked try to keep the active tab centered.
|
| @@ -1119,7 +1117,7 @@ void TabStrip::MouseMovedOutOfHost() {
|
| ResizeLayoutTabs();
|
| if (reset_to_shrink_on_exit_) {
|
| reset_to_shrink_on_exit_ = false;
|
| - SetLayoutType(TAB_STRIP_LAYOUT_SHRINK, true);
|
| + SetStackedLayout(false);
|
| controller_->LayoutTypeMaybeChanged();
|
| }
|
| }
|
| @@ -1150,8 +1148,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas,
|
| // Since |touch_layout_| is created based on number of tabs and width we use
|
| // the ideal state to determine if we should paint stacked. This minimizes
|
| // painting changes as we switch between the two.
|
| - const bool stacking = (layout_type_ == TAB_STRIP_LAYOUT_STACKED) ||
|
| - IsStackingDraggedTabs();
|
| + const bool stacking = stacked_layout_ || IsStackingDraggedTabs();
|
|
|
| const chrome::HostDesktopType host_desktop_type =
|
| chrome::GetHostDesktopTypeForNativeView(GetWidget()->GetNativeView());
|
| @@ -1486,7 +1483,7 @@ void TabStrip::OnGestureEvent(ui::GestureEvent* event) {
|
| case ui::ET_GESTURE_END:
|
| EndDrag(END_DRAG_COMPLETE);
|
| if (adjust_layout_) {
|
| - SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true);
|
| + SetStackedLayout(true);
|
| controller_->LayoutTypeMaybeChanged();
|
| }
|
| break;
|
| @@ -1988,18 +1985,18 @@ void TabStrip::PaintClosingTabs(gfx::Canvas* canvas,
|
|
|
| void TabStrip::UpdateLayoutTypeFromMouseEvent(views::View* source,
|
| const ui::MouseEvent& event) {
|
| - if (!GetAdjustLayout())
|
| + if (!adjust_layout_)
|
| return;
|
|
|
| - // The following code attempts to switch to TAB_STRIP_LAYOUT_SHRINK when the
|
| - // mouse exits the tabstrip (or the mouse is pressed on a stacked tab) and
|
| - // TAB_STRIP_LAYOUT_STACKED when a touch device is used. This is made
|
| - // problematic by windows generating mouse move events that do not clearly
|
| - // indicate the move is the result of a touch device. This assumes a real
|
| - // mouse is used if |kMouseMoveCountBeforeConsiderReal| mouse move events are
|
| - // received within the time window |kMouseMoveTimeMS|. At the time we get a
|
| - // mouse press we know whether its from a touch device or not, but we don't
|
| - // layout then else everything shifts. Instead we wait for the release.
|
| + // The following code attempts to switch to shrink (not stacked) layout when
|
| + // the mouse exits the tabstrip (or the mouse is pressed on a stacked tab) and
|
| + // to stacked layout when a touch device is used. This is made problematic by
|
| + // windows generating mouse move events that do not clearly indicate the move
|
| + // is the result of a touch device. This assumes a real mouse is used if
|
| + // |kMouseMoveCountBeforeConsiderReal| mouse move events are received within
|
| + // the time window |kMouseMoveTimeMS|. At the time we get a mouse press we
|
| + // know whether its from a touch device or not, but we don't layout then else
|
| + // everything shifts. Instead we wait for the release.
|
| //
|
| // TODO(sky): revisit this when touch events are really plumbed through.
|
|
|
| @@ -2013,7 +2010,7 @@ void TabStrip::UpdateLayoutTypeFromMouseEvent(views::View* source,
|
| views::View::ConvertPointToTarget(source, this, &tab_strip_point);
|
| Tab* tab = FindTabForEvent(tab_strip_point);
|
| if (tab && touch_layout_->IsStacked(GetModelIndexOfTab(tab))) {
|
| - SetLayoutType(TAB_STRIP_LAYOUT_SHRINK, true);
|
| + SetStackedLayout(false);
|
| controller_->LayoutTypeMaybeChanged();
|
| }
|
| }
|
| @@ -2053,7 +2050,7 @@ void TabStrip::UpdateLayoutTypeFromMouseEvent(views::View* source,
|
| mouse_move_count_ = 0;
|
| last_mouse_move_time_ = base::TimeTicks();
|
| if ((event.flags() & ui::EF_FROM_TOUCH) == ui::EF_FROM_TOUCH) {
|
| - SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true);
|
| + SetStackedLayout(true);
|
| controller_->LayoutTypeMaybeChanged();
|
| }
|
| break;
|
| @@ -2612,7 +2609,7 @@ void TabStrip::SwapLayoutIfNecessary() {
|
| }
|
|
|
| bool TabStrip::NeedsTouchLayout() const {
|
| - if (layout_type_ == TAB_STRIP_LAYOUT_SHRINK)
|
| + if (!stacked_layout_)
|
| return false;
|
|
|
| int mini_tab_count = GetMiniTabCount();
|
| @@ -2626,11 +2623,11 @@ bool TabStrip::NeedsTouchLayout() const {
|
| }
|
|
|
| void TabStrip::SetResetToShrinkOnExit(bool value) {
|
| - if (!GetAdjustLayout())
|
| + if (!adjust_layout_)
|
| return;
|
|
|
| - if (value && layout_type_ == TAB_STRIP_LAYOUT_SHRINK)
|
| - value = false; // We're already at TAB_STRIP_LAYOUT_SHRINK.
|
| + if (value && !stacked_layout_)
|
| + value = false; // We're already using shrink (not stacked) layout.
|
|
|
| if (value == reset_to_shrink_on_exit_)
|
| return;
|
| @@ -2642,10 +2639,3 @@ void TabStrip::SetResetToShrinkOnExit(bool value) {
|
| else
|
| RemoveMessageLoopObserver();
|
| }
|
| -
|
| -bool TabStrip::GetAdjustLayout() const {
|
| - if (!adjust_layout_)
|
| - return false;
|
| - return chrome::GetHostDesktopTypeForNativeView(
|
| - GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH;
|
| -}
|
|
|