| Index: chrome/browser/ui/views/frame/browser_root_view.cc
|
| diff --git a/chrome/browser/ui/views/frame/browser_root_view.cc b/chrome/browser/ui/views/frame/browser_root_view.cc
|
| index 8eaba179f86a695221aa7829c3ef50b382a47018..9057a6df1492c6830fbc7c2714bd98d5438ffaab 100644
|
| --- a/chrome/browser/ui/views/frame/browser_root_view.cc
|
| +++ b/chrome/browser/ui/views/frame/browser_root_view.cc
|
| @@ -28,7 +28,9 @@ BrowserRootView::BrowserRootView(BrowserView* browser_view,
|
| views::Widget* widget)
|
| : views::internal::RootView(widget),
|
| browser_view_(browser_view),
|
| - forwarding_to_tab_strip_(false) { }
|
| + forwarding_to_tab_strip_(false),
|
| + scroll_amount_x_(0),
|
| + scroll_amount_y_(0) {}
|
|
|
| bool BrowserRootView::GetDropFormats(
|
| int* formats,
|
| @@ -130,19 +132,39 @@ bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) {
|
| if (tabstrip()->Contains(hit_view) ||
|
| hittest == HTCAPTION ||
|
| hittest == HTTOP) {
|
| - int scroll_offset = abs(event.y_offset()) > abs(event.x_offset()) ?
|
| - event.y_offset() : event.x_offset();
|
| + scroll_amount_x_ += event.x_offset();
|
| + scroll_amount_y_ += event.y_offset();
|
| + int scroll_offset = abs(scroll_amount_y_) > abs(scroll_amount_x_)
|
| + ? scroll_amount_y_
|
| + : scroll_amount_x_;
|
| +
|
| + // Number of integer scroll events that have passed
|
| + int whole_scroll_offset = round((double)scroll_offset /
|
| + (double)ui::MouseWheelEvent::kWheelDelta);
|
| +
|
| + if (whole_scroll_offset != 0) {
|
| + // Re-adjust back towards 0
|
| + if (abs(scroll_amount_y_) > abs(scroll_amount_x_)) {
|
| + scroll_amount_y_ -=
|
| + whole_scroll_offset * ui::MouseWheelEvent::kWheelDelta;
|
| + } else {
|
| + scroll_amount_x_ -=
|
| + whole_scroll_offset * ui::MouseWheelEvent::kWheelDelta;
|
| + }
|
| + }
|
| +
|
| Browser* browser = browser_view_->browser();
|
| TabStripModel* model = browser->tab_strip_model();
|
| // Switch to the next tab only if not at the end of the tab-strip.
|
| - if (scroll_offset < 0 && model->active_index() + 1 < model->count()) {
|
| + if (whole_scroll_offset < 0 &&
|
| + model->active_index() + 1 < model->count()) {
|
| chrome::SelectNextTab(browser);
|
| return true;
|
| }
|
|
|
| // Switch to the previous tab only if not at the beginning of the
|
| // tab-strip.
|
| - if (scroll_offset > 0 && model->active_index() > 0) {
|
| + if (whole_scroll_offset > 0 && model->active_index() > 0) {
|
| chrome::SelectPreviousTab(browser);
|
| return true;
|
| }
|
| @@ -151,6 +173,13 @@ bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) {
|
| return RootView::OnMouseWheel(event);
|
| }
|
|
|
| +void BrowserRootView::OnMouseExited(const ui::MouseEvent& event) {
|
| + // Reset such that the tab switch always occurs halfway through a smooth
|
| + // scroll
|
| + scroll_amount_x_ = 0;
|
| + scroll_amount_y_ = 0;
|
| +}
|
| +
|
| void BrowserRootView::OnEventProcessingStarted(ui::Event* event) {
|
| if (event->IsGestureEvent()) {
|
| ui::GestureEvent* gesture_event = event->AsGestureEvent();
|
|
|