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

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

Issue 2197503002: Route Scroll events through a cc::InputHandler Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollWheelAsScrollEvent
Patch Set: Abandon DeliverInputForBeginFrame: will not help fix the header row Created 4 years 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/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
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
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
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
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