Commit 5b5407fc authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Revert "Activate the next/previous tab on horizonal scroll"

This effectively reverts commit 90496b3b.

This turns out to be unpopular, as well as causing issues on the Mac,
particularly with Magic Mice.

BUG=2384,965753

Change-Id: I69803bcbde01b1978c58ef1454280ac08403a24d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730631Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683311}
parent 4fe688c0
......@@ -1871,34 +1871,6 @@ void TabStrip::Layout() {
CompleteAnimationAndLayout();
}
bool TabStrip::OnMouseWheel(const ui::MouseWheelEvent& event) {
// Change the selected tab on horizontal wheel scrolls.
// Honor wheel scrolls over the tabs themselves, but not the NTB/surrounding
// space.
if ((!event.x_offset() && !event.IsShiftDown()) || tab_count() < 2 ||
!FindTabHitByPoint(event.location()))
return false;
accumulated_horizontal_scroll_ +=
(event.x_offset() ? event.x_offset() : event.y_offset());
int horizontal_offset =
accumulated_horizontal_scroll_ / ui::MouseWheelEvent::kWheelDelta;
if (!horizontal_offset)
return true;
accumulated_horizontal_scroll_ %= ui::MouseWheelEvent::kWheelDelta;
int new_active_index =
(controller_->GetActiveIndex() + horizontal_offset) % tab_count();
if (new_active_index < 0)
new_active_index += tab_count();
DCHECK(IsValidModelIndex(new_active_index));
controller_->SelectTab(new_active_index, event);
return true;
}
void TabStrip::PaintChildren(const views::PaintInfo& paint_info) {
// This is used to log to UMA. NO EARLY RETURNS!
base::ElapsedTimer paint_timer;
......
......@@ -282,7 +282,6 @@ class TabStrip : public views::AccessiblePaneView,
// views::AccessiblePaneView:
void Layout() override;
bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
void PaintChildren(const views::PaintInfo& paint_info) override;
const char* GetClassName() const override;
gfx::Size CalculatePreferredSize() const override;
......@@ -640,10 +639,6 @@ class TabStrip : public views::AccessiblePaneView,
// Number of mouse moves.
int mouse_move_count_ = 0;
// Accumulatated offsets from thumb wheel. Used to throttle horizontal
// scroll from thumb wheel.
int accumulated_horizontal_scroll_ = 0;
// Timer used when a tab is closed and we need to relayout. Only used when a
// tab close comes from a touch device.
base::OneShotTimer resize_layout_timer_;
......
......@@ -975,52 +975,6 @@ TEST_P(TabStripTest, EventsOnClosingTab) {
EXPECT_EQ(first_tab, tab_strip_->GetEventHandlerForPoint(tab_center));
}
// Switch selected tabs on horizontal scroll events.
TEST_P(TabStripTest, HorizontalScroll) {
tab_strip_->SetBounds(0, 0, 200, 20);
for (int i = 0; i < 3; i++)
controller_->AddTab(i, true /* is_active */);
Tab* tab = tab_strip_->tab_at(0);
gfx::Point tab_center = tab->bounds().CenterPoint();
for (int i = 0; i < tab_strip_->tab_count(); ++i) {
ui::MouseWheelEvent wheel_event(
gfx::Vector2d(ui::MouseWheelEvent::kWheelDelta, 0), tab_center,
tab_center, ui::EventTimeForNow(), 0, 0);
tab_strip_->OnMouseWheel(wheel_event);
EXPECT_EQ(i, controller_->GetActiveIndex());
}
controller_->SelectTab(0, dummy_event_);
for (int i = tab_strip_->tab_count() - 1; i >= 0; --i) {
ui::MouseWheelEvent wheel_event(
gfx::Vector2d(-ui::MouseWheelEvent::kWheelDelta, 0), tab_center,
tab_center, ui::EventTimeForNow(), 0, 0);
tab_strip_->OnMouseWheel(wheel_event);
EXPECT_EQ(i, controller_->GetActiveIndex());
}
// When offset is smaller than kWheelDelta, we don't scroll immediately.
// We wait offset until accumulated offset gets bigger than kWheelDelta.
const int small_offset = ui::MouseWheelEvent::kWheelDelta / 3;
int next_accumulated_offset = small_offset;
while (next_accumulated_offset < ui::MouseWheelEvent::kWheelDelta) {
ui::MouseWheelEvent wheel_event(gfx::Vector2d(small_offset, 0), tab_center,
tab_center, ui::EventTimeForNow(), 0, 0);
tab_strip_->OnMouseWheel(wheel_event);
EXPECT_EQ(0, controller_->GetActiveIndex());
next_accumulated_offset += small_offset;
}
ui::MouseWheelEvent wheel_event(gfx::Vector2d(small_offset, 0), tab_center,
tab_center, ui::EventTimeForNow(), 0, 0);
tab_strip_->OnMouseWheel(wheel_event);
EXPECT_EQ(1, controller_->GetActiveIndex());
}
TEST_P(TabStripTest, AnimationOnTabAdd) {
tab_strip_->SetBounds(0, 0, 1000, 100);
// Show widget to enable animations.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment