| OLD | NEW |
| 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 "ui/views/controls/scroll_view.h" | 5 #include "ui/views/controls/scroll_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/base/events/event.h" | 8 #include "ui/base/events/event.h" |
| 9 #include "ui/native_theme/native_theme.h" | 9 #include "ui/native_theme/native_theme.h" |
| 10 #include "ui/views/border.h" | 10 #include "ui/views/border.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // Give vertical scrollbar priority | 426 // Give vertical scrollbar priority |
| 427 if (vert_sb_->visible()) | 427 if (vert_sb_->visible()) |
| 428 processed = vert_sb_->OnKeyPressed(event); | 428 processed = vert_sb_->OnKeyPressed(event); |
| 429 | 429 |
| 430 if (!processed && horiz_sb_->visible()) | 430 if (!processed && horiz_sb_->visible()) |
| 431 processed = horiz_sb_->OnKeyPressed(event); | 431 processed = horiz_sb_->OnKeyPressed(event); |
| 432 | 432 |
| 433 return processed; | 433 return processed; |
| 434 } | 434 } |
| 435 | 435 |
| 436 ui::EventResult ScrollView::OnGestureEvent(ui::GestureEvent* event) { | 436 void ScrollView::OnGestureEvent(ui::GestureEvent* event) { |
| 437 ui::EventResult status = ui::ER_UNHANDLED; | |
| 438 | |
| 439 // If the event happened on one of the scrollbars, then those events are | 437 // If the event happened on one of the scrollbars, then those events are |
| 440 // sent directly to the scrollbars. Otherwise, only scroll events are sent to | 438 // sent directly to the scrollbars. Otherwise, only scroll events are sent to |
| 441 // the scrollbars. | 439 // the scrollbars. |
| 442 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 440 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 443 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 441 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 444 event->type() == ui::ET_GESTURE_SCROLL_END || | 442 event->type() == ui::ET_GESTURE_SCROLL_END || |
| 445 event->type() == ui::ET_SCROLL_FLING_START; | 443 event->type() == ui::ET_SCROLL_FLING_START; |
| 446 | 444 |
| 447 if (vert_sb_->visible()) { | 445 if (vert_sb_->visible()) { |
| 448 if (vert_sb_->bounds().Contains(event->location()) || scroll_event) | 446 if (vert_sb_->bounds().Contains(event->location()) || scroll_event) |
| 449 status = vert_sb_->OnGestureEvent(event); | 447 vert_sb_->OnGestureEvent(event); |
| 450 } | 448 } |
| 451 if (status == ui::ER_UNHANDLED && horiz_sb_->visible()) { | 449 if (!event->handled() && horiz_sb_->visible()) { |
| 452 if (horiz_sb_->bounds().Contains(event->location()) || scroll_event) | 450 if (horiz_sb_->bounds().Contains(event->location()) || scroll_event) |
| 453 status = horiz_sb_->OnGestureEvent(event); | 451 horiz_sb_->OnGestureEvent(event); |
| 454 } | 452 } |
| 455 return status; | |
| 456 } | 453 } |
| 457 | 454 |
| 458 bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) { | 455 bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) { |
| 459 bool processed = false; | 456 bool processed = false; |
| 460 // Give vertical scrollbar priority | 457 // Give vertical scrollbar priority |
| 461 if (vert_sb_->visible()) | 458 if (vert_sb_->visible()) |
| 462 processed = vert_sb_->OnMouseWheel(e); | 459 processed = vert_sb_->OnMouseWheel(e); |
| 463 | 460 |
| 464 if (!processed && horiz_sb_->visible()) | 461 if (!processed && horiz_sb_->visible()) |
| 465 processed = horiz_sb_->OnMouseWheel(e); | 462 processed = horiz_sb_->OnMouseWheel(e); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 543 |
| 547 VariableRowHeightScrollHelper::RowInfo | 544 VariableRowHeightScrollHelper::RowInfo |
| 548 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 545 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 549 if (y < top_margin_) | 546 if (y < top_margin_) |
| 550 return RowInfo(0, top_margin_); | 547 return RowInfo(0, top_margin_); |
| 551 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 548 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 552 row_height_); | 549 row_height_); |
| 553 } | 550 } |
| 554 | 551 |
| 555 } // namespace views | 552 } // namespace views |
| OLD | NEW |