| 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/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 processed = vert_sb_->OnMouseWheel(e); | 451 processed = vert_sb_->OnMouseWheel(e); |
| 452 | 452 |
| 453 if (horiz_sb_->visible()) | 453 if (horiz_sb_->visible()) |
| 454 processed = horiz_sb_->OnMouseWheel(e) || processed; | 454 processed = horiz_sb_->OnMouseWheel(e) || processed; |
| 455 | 455 |
| 456 return processed; | 456 return processed; |
| 457 } | 457 } |
| 458 | 458 |
| 459 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { | 459 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { |
| 460 #if defined(OS_MACOSX) | 460 #if defined(OS_MACOSX) |
| 461 if (!contents_) |
| 462 return; |
| 463 |
| 461 // TODO(tapted): Send |event| to a cc::InputHandler. For now, there's nothing | 464 // TODO(tapted): Send |event| to a cc::InputHandler. For now, there's nothing |
| 462 // to do because Widget::OnScrollEvent() will automatically process an | 465 // to do because Widget::OnScrollEvent() will automatically process an |
| 463 // unhandled ScrollEvent as a MouseWheelEvent. | 466 // unhandled ScrollEvent as a MouseWheelEvent. |
| 467 |
| 468 // A direction might not be known when the event stream starts, notify both |
| 469 // scrollbars that they may be about scroll, or that they may need to cancel |
| 470 // UI feedback once the scrolling direction is known. |
| 471 if (horiz_sb_) |
| 472 horiz_sb_->ObserveScrollEvent(*event); |
| 473 if (vert_sb_) |
| 474 vert_sb_->ObserveScrollEvent(*event); |
| 464 #endif | 475 #endif |
| 465 } | 476 } |
| 466 | 477 |
| 467 void ScrollView::OnGestureEvent(ui::GestureEvent* event) { | 478 void ScrollView::OnGestureEvent(ui::GestureEvent* event) { |
| 468 // If the event happened on one of the scrollbars, then those events are | 479 // If the event happened on one of the scrollbars, then those events are |
| 469 // sent directly to the scrollbars. Otherwise, only scroll events are sent to | 480 // sent directly to the scrollbars. Otherwise, only scroll events are sent to |
| 470 // the scrollbars. | 481 // the scrollbars. |
| 471 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 482 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 472 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 483 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 473 event->type() == ui::ET_GESTURE_SCROLL_END || | 484 event->type() == ui::ET_GESTURE_SCROLL_END || |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 782 |
| 772 VariableRowHeightScrollHelper::RowInfo | 783 VariableRowHeightScrollHelper::RowInfo |
| 773 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 784 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 774 if (y < top_margin_) | 785 if (y < top_margin_) |
| 775 return RowInfo(0, top_margin_); | 786 return RowInfo(0, top_margin_); |
| 776 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 787 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 777 row_height_); | 788 row_height_); |
| 778 } | 789 } |
| 779 | 790 |
| 780 } // namespace views | 791 } // namespace views |
| OLD | NEW |