| 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/compositor/overscroll/ui_scroll_input_manager.h" |
| 10 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 11 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 12 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
| 13 #include "ui/views/background.h" | 14 #include "ui/views/background.h" |
| 14 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
| 15 #include "ui/views/controls/focus_ring.h" | 16 #include "ui/views/controls/focus_ring.h" |
| 16 #include "ui/views/style/platform_style.h" | 17 #include "ui/views/style/platform_style.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 processed = horiz_sb_->OnMouseWheel(e) || processed; | 454 processed = horiz_sb_->OnMouseWheel(e) || processed; |
| 454 | 455 |
| 455 return processed; | 456 return processed; |
| 456 } | 457 } |
| 457 | 458 |
| 458 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { | 459 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { |
| 459 #if defined(OS_MACOSX) | 460 #if defined(OS_MACOSX) |
| 460 if (!contents_) | 461 if (!contents_) |
| 461 return; | 462 return; |
| 462 | 463 |
| 463 // TODO(tapted): Send |event| to a cc::InputHandler. For now, there's nothing | 464 ui::UIScrollInputManager* compositor_scroller = |
| 464 // to do because Widget::OnScrollEvent() will automatically process an | 465 GetWidget()->GetCompositor()->scroll_input_manager(); |
| 465 // unhandled ScrollEvent as a MouseWheelEvent. | 466 DCHECK(compositor_scroller); |
| 467 if (compositor_scroller->OnScrollEvent(*event, contents_->layer())) { |
| 468 event->SetHandled(); |
| 469 event->StopPropagation(); |
| 470 } |
| 466 | 471 |
| 467 // A direction might not be known when the event stream starts, notify both | 472 // A direction might not be known when the event stream starts, notify both |
| 468 // scrollbars that they may be about scroll, or that they may need to cancel | 473 // scrollbars that they may be about scroll, or that they may need to cancel |
| 469 // UI feedback once the scrolling direction is known. | 474 // UI feedback once the scrolling direction is known. |
| 470 if (horiz_sb_) | 475 if (horiz_sb_) |
| 471 horiz_sb_->ObserveScrollEvent(*event); | 476 horiz_sb_->ObserveScrollEvent(*event); |
| 472 if (vert_sb_) | 477 if (vert_sb_) |
| 473 vert_sb_->ObserveScrollEvent(*event); | 478 vert_sb_->ObserveScrollEvent(*event); |
| 474 #endif | 479 #endif |
| 475 } | 480 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 543 } |
| 539 // No view, or the view didn't return a valid amount. | 544 // No view, or the view didn't return a valid amount. |
| 540 if (is_page) { | 545 if (is_page) { |
| 541 return is_horizontal ? contents_viewport_->width() : | 546 return is_horizontal ? contents_viewport_->width() : |
| 542 contents_viewport_->height(); | 547 contents_viewport_->height(); |
| 543 } | 548 } |
| 544 return is_horizontal ? contents_viewport_->width() / 5 : | 549 return is_horizontal ? contents_viewport_->width() / 5 : |
| 545 contents_viewport_->height() / 5; | 550 contents_viewport_->height() / 5; |
| 546 } | 551 } |
| 547 | 552 |
| 553 void ScrollView::OnScrollEventFromScrollBar(ui::ScrollEvent* event) { |
| 554 // Note that |event| can't be used for hit-testing in the cc::InputHandler |
| 555 // as-is, since it will hit a scroll bar Layer. Layer scrolling supports that, |
| 556 // but only if the scroll bar track and thumb Layers implement |
| 557 // cc::ScrollbarLayerInterface. Creating one of those requires a cc::ScrollBar |
| 558 // instance which is more than views:: really needs to care about. The |
| 559 // following works because ScrollView explicitly passes the Layer to scroll. |
| 560 OnScrollEvent(event); |
| 561 } |
| 562 |
| 548 void ScrollView::SetHeaderOrContents(View* parent, | 563 void ScrollView::SetHeaderOrContents(View* parent, |
| 549 View* new_view, | 564 View* new_view, |
| 550 View** member) { | 565 View** member) { |
| 551 if (*member == new_view) | 566 if (*member == new_view) |
| 552 return; | 567 return; |
| 553 | 568 |
| 554 delete *member; | 569 delete *member; |
| 555 *member = new_view; | 570 *member = new_view; |
| 556 if (*member) | 571 if (*member) |
| 557 parent->AddChildView(*member); | 572 parent->AddChildView(*member); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 796 |
| 782 VariableRowHeightScrollHelper::RowInfo | 797 VariableRowHeightScrollHelper::RowInfo |
| 783 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 798 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 784 if (y < top_margin_) | 799 if (y < top_margin_) |
| 785 return RowInfo(0, top_margin_); | 800 return RowInfo(0, top_margin_); |
| 786 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 801 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 787 row_height_); | 802 row_height_); |
| 788 } | 803 } |
| 789 | 804 |
| 790 } // namespace views | 805 } // namespace views |
| OLD | NEW |