Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ui/views/controls/scroll_view.cc

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/scrollbar/base_scroll_bar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/style/platform_style.h" 16 #include "ui/views/style/platform_style.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 18
18 namespace views { 19 namespace views {
19 20
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 455
455 void ScrollView::OnMouseExited(const ui::MouseEvent& event) { 456 void ScrollView::OnMouseExited(const ui::MouseEvent& event) {
456 if (horiz_sb_) 457 if (horiz_sb_)
457 horiz_sb_->OnMouseExitedScrollView(event); 458 horiz_sb_->OnMouseExitedScrollView(event);
458 if (vert_sb_) 459 if (vert_sb_)
459 vert_sb_->OnMouseExitedScrollView(event); 460 vert_sb_->OnMouseExitedScrollView(event);
460 } 461 }
461 462
462 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { 463 void ScrollView::OnScrollEvent(ui::ScrollEvent* event) {
463 #if defined(OS_MACOSX) 464 #if defined(OS_MACOSX)
464 // TODO(tapted): Send |event| to a cc::InputHandler. For now, there's nothing 465 ui::UIScrollInputManager* compositor_scroller =
465 // to do because Widget::OnScrollEvent() will automatically process an 466 GetWidget()->GetCompositor()->scroll_input_manager();
466 // unhandled ScrollEvent as a MouseWheelEvent. 467 DCHECK(compositor_scroller);
468 if (compositor_scroller->OnScrollEvent(*event)) {
469 event->SetHandled();
470 event->StopPropagation();
471 }
467 #endif 472 #endif
468 } 473 }
469 474
470 void ScrollView::OnGestureEvent(ui::GestureEvent* event) { 475 void ScrollView::OnGestureEvent(ui::GestureEvent* event) {
471 // If the event happened on one of the scrollbars, then those events are 476 // If the event happened on one of the scrollbars, then those events are
472 // sent directly to the scrollbars. Otherwise, only scroll events are sent to 477 // sent directly to the scrollbars. Otherwise, only scroll events are sent to
473 // the scrollbars. 478 // the scrollbars.
474 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || 479 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
475 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || 480 event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
476 event->type() == ui::ET_GESTURE_SCROLL_END || 481 event->type() == ui::ET_GESTURE_SCROLL_END ||
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 536 }
532 // No view, or the view didn't return a valid amount. 537 // No view, or the view didn't return a valid amount.
533 if (is_page) { 538 if (is_page) {
534 return is_horizontal ? contents_viewport_->width() : 539 return is_horizontal ? contents_viewport_->width() :
535 contents_viewport_->height(); 540 contents_viewport_->height();
536 } 541 }
537 return is_horizontal ? contents_viewport_->width() / 5 : 542 return is_horizontal ? contents_viewport_->width() / 5 :
538 contents_viewport_->height() / 5; 543 contents_viewport_->height() / 5;
539 } 544 }
540 545
546 void ScrollView::OnScrollEventFromScrollBar(ui::ScrollEvent* event) {
547 // If the scroll event is passed to the cc::InputHandler as-is, then it will
548 // hit a scroll bar Layer. Layer scrolling supports that, but only if the
549 // scroll bar track and thumb Layers implement cc::ScrollbarLayerInterface.
550 // Creating one of those requires a cc::ScrollBar instance which is more than
551 // views:: really needs to care about. For now, cheat a little and pretend
552 // events are coming from the point (0, 0) on the viewport.
553 gfx::Point location;
554 ConvertPointToWidget(contents_viewport_, &location);
555 event->set_location(location);
556 OnScrollEvent(event);
557 }
558
541 void ScrollView::SetHeaderOrContents(View* parent, 559 void ScrollView::SetHeaderOrContents(View* parent,
542 View* new_view, 560 View* new_view,
543 View** member) { 561 View** member) {
544 if (*member == new_view) 562 if (*member == new_view)
545 return; 563 return;
546 564
547 delete *member; 565 delete *member;
548 *member = new_view; 566 *member = new_view;
549 if (*member) 567 if (*member)
550 parent->AddChildView(*member); 568 parent->AddChildView(*member);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 784
767 VariableRowHeightScrollHelper::RowInfo 785 VariableRowHeightScrollHelper::RowInfo
768 FixedRowHeightScrollHelper::GetRowInfo(int y) { 786 FixedRowHeightScrollHelper::GetRowInfo(int y) {
769 if (y < top_margin_) 787 if (y < top_margin_)
770 return RowInfo(0, top_margin_); 788 return RowInfo(0, top_margin_);
771 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 789 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
772 row_height_); 790 row_height_);
773 } 791 }
774 792
775 } // namespace views 793 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/scrollbar/base_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698