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

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

Issue 2188133002: Scroll with Layers in views::ScrollView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollTrack
Patch Set: Add a test for the transform goop Created 4 years, 4 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
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/logging.h" 8 #include "base/logging.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "ui/events/event.h" 10 #include "ui/events/event.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/native_theme/native_theme.h" 12 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/background.h"
12 #include "ui/views/border.h" 14 #include "ui/views/border.h"
13 #include "ui/views/style/platform_style.h" 15 #include "ui/views/style/platform_style.h"
14 #include "ui/views/widget/root_view.h" 16 #include "ui/views/widget/widget.h"
15 17
16 namespace views { 18 namespace views {
17 19
18 const char ScrollView::kViewClassName[] = "ScrollView"; 20 const char ScrollView::kViewClassName[] = "ScrollView";
19 21
20 namespace { 22 namespace {
21 23
24 const base::Feature kToolkitViewsScrollWithLayers {
25 "ToolkitViewsScrollWithLayers",
26 #if defined(OS_MACOSX)
27 base::FEATURE_ENABLED_BY_DEFAULT
28 #else
29 base::FEATURE_DISABLED_BY_DEFAULT
Ian Vollick 2016/08/09 14:00:49 I'm sure this is a dumb question, but why just mac
tapted 2016/08/10 05:39:04 Mac needs it for elasticity, but (I think!) the pl
Ian Vollick 2016/08/12 13:57:42 Ah, makes sense. Thanks for the explanation.
30 #endif
31 };
32
22 // Subclass of ScrollView that resets the border when the theme changes. 33 // Subclass of ScrollView that resets the border when the theme changes.
23 class ScrollViewWithBorder : public views::ScrollView { 34 class ScrollViewWithBorder : public views::ScrollView {
24 public: 35 public:
25 ScrollViewWithBorder() {} 36 ScrollViewWithBorder() {}
26 37
27 // View overrides; 38 // View overrides;
28 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 39 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
29 SetBorder(Border::CreateSolidBorder( 40 SetBorder(Border::CreateSolidBorder(
30 1, 41 1,
31 theme->GetSystemColor(ui::NativeTheme::kColorId_UnfocusedBorderColor))); 42 theme->GetSystemColor(ui::NativeTheme::kColorId_UnfocusedBorderColor)));
(...skipping 29 matching lines...) Expand all
61 if (current_pos > max) 72 if (current_pos > max)
62 return max; 73 return max;
63 return current_pos; 74 return current_pos;
64 } 75 }
65 76
66 // Make sure the content is not scrolled out of bounds 77 // Make sure the content is not scrolled out of bounds
67 void CheckScrollBounds(View* viewport, View* view) { 78 void CheckScrollBounds(View* viewport, View* view) {
68 if (!view) 79 if (!view)
69 return; 80 return;
70 81
71 int x = CheckScrollBounds(viewport->width(), view->width(), -view->x()); 82 const bool scrolls_with_layers = viewport->layer() != nullptr;
Ian Vollick 2016/08/09 14:00:49 Should this use the ScrollsWithLayers helper funct
tapted 2016/08/10 05:39:04 Added a comment - for now, the header row is still
72 int y = CheckScrollBounds(viewport->height(), view->height(), -view->y()); 83 if (scrolls_with_layers) {
84 DCHECK(view->layer());
85 DCHECK_EQ(0, view->x());
86 DCHECK_EQ(0, view->y());
87 }
88 gfx::ScrollOffset offset = scrolls_with_layers
89 ? view->layer()->CurrentScrollOffset()
90 : gfx::ScrollOffset(-view->x(), -view->y());
73 91
74 // This is no op if bounds are the same 92 int x = CheckScrollBounds(viewport->width(), view->width(), offset.x());
75 view->SetBounds(-x, -y, view->width(), view->height()); 93 int y = CheckScrollBounds(viewport->height(), view->height(), offset.y());
Ian Vollick 2016/08/09 14:00:49 Do you need a test where the scroll bounds are upd
tapted 2016/08/10 05:39:04 Ooh, good catch DCHECK_EQ(offset.x(), x); DCH
94
95 if (scrolls_with_layers) {
96 view->layer()->SetScrollOffset(gfx::ScrollOffset(x, y));
97 } else {
98 // This is no op if bounds are the same
99 view->SetBounds(-x, -y, view->width(), view->height());
Ian Vollick 2016/08/09 14:00:49 nit/bikeshed/ignorable: I realize that this was no
tapted 2016/08/10 05:39:04 I went with ConstrainScrollToBounds - I think that
Ian Vollick 2016/08/12 13:57:42 I like it.
100 }
76 } 101 }
77 102
78 // Used by ScrollToPosition() to make sure the new position fits within the 103 // Used by ScrollToPosition() to make sure the new position fits within the
79 // allowed scroll range. 104 // allowed scroll range.
80 int AdjustPosition(int current_position, 105 int AdjustPosition(int current_position,
81 int new_position, 106 int new_position,
82 int content_size, 107 int content_size,
83 int viewport_size) { 108 int viewport_size) {
84 if (-current_position == new_position) 109 if (-current_position == new_position)
85 return new_position; 110 return new_position;
(...skipping 12 matching lines...) Expand all
98 ~Viewport() override {} 123 ~Viewport() override {}
99 124
100 const char* GetClassName() const override { return "ScrollView::Viewport"; } 125 const char* GetClassName() const override { return "ScrollView::Viewport"; }
101 126
102 void ScrollRectToVisible(const gfx::Rect& rect) override { 127 void ScrollRectToVisible(const gfx::Rect& rect) override {
103 if (!has_children() || !parent()) 128 if (!has_children() || !parent())
104 return; 129 return;
105 130
106 View* contents = child_at(0); 131 View* contents = child_at(0);
107 gfx::Rect scroll_rect(rect); 132 gfx::Rect scroll_rect(rect);
108 scroll_rect.Offset(-contents->x(), -contents->y()); 133
109 static_cast<ScrollView*>(parent())->ScrollContentsRegionToBeVisible( 134 ScrollView* scroll_view = static_cast<ScrollView*>(parent());
110 scroll_rect); 135 if (scroll_view->ScrollsWithLayers()) {
136 // With layer scrolling, there's no need to "undo" the offset done in the
137 // child's View::ScrollRectToVisible() before it calls this.
138 DCHECK_EQ(0, contents->x());
139 DCHECK_EQ(0, contents->y());
140 } else {
141 scroll_rect.Offset(-contents->x(), -contents->y());
142 }
143
144 scroll_view->ScrollContentsRegionToBeVisible(scroll_rect);
111 } 145 }
112 146
113 void ChildPreferredSizeChanged(View* child) override { 147 void ChildPreferredSizeChanged(View* child) override {
114 if (parent()) 148 if (parent())
115 parent()->Layout(); 149 parent()->Layout();
116 } 150 }
117 151
118 private: 152 private:
119 DISALLOW_COPY_AND_ASSIGN(Viewport); 153 DISALLOW_COPY_AND_ASSIGN(Viewport);
120 }; 154 };
121 155
122 ScrollView::ScrollView() 156 ScrollView::ScrollView()
123 : contents_(NULL), 157 : contents_(NULL),
124 contents_viewport_(new Viewport()), 158 contents_viewport_(new Viewport()),
125 header_(NULL), 159 header_(NULL),
126 header_viewport_(new Viewport()), 160 header_viewport_(new Viewport()),
127 horiz_sb_(PlatformStyle::CreateScrollBar(true).release()), 161 horiz_sb_(PlatformStyle::CreateScrollBar(true).release()),
128 vert_sb_(PlatformStyle::CreateScrollBar(false).release()), 162 vert_sb_(PlatformStyle::CreateScrollBar(false).release()),
129 corner_view_(new ScrollCornerView()), 163 corner_view_(new ScrollCornerView()),
130 min_height_(-1), 164 min_height_(-1),
131 max_height_(-1), 165 max_height_(-1),
166 background_color_(SK_ColorTRANSPARENT),
132 hide_horizontal_scrollbar_(false) { 167 hide_horizontal_scrollbar_(false) {
133 set_notify_enter_exit_on_child(true); 168 set_notify_enter_exit_on_child(true);
134 169
135 AddChildView(contents_viewport_); 170 AddChildView(contents_viewport_);
136 AddChildView(header_viewport_); 171 AddChildView(header_viewport_);
137 172
138 // Don't add the scrollbars as children until we discover we need them 173 // Don't add the scrollbars as children until we discover we need them
139 // (ShowOrHideScrollBar). 174 // (ShowOrHideScrollBar).
140 horiz_sb_->SetVisible(false); 175 horiz_sb_->SetVisible(false);
141 horiz_sb_->set_controller(this); 176 horiz_sb_->set_controller(this);
142 vert_sb_->SetVisible(false); 177 vert_sb_->SetVisible(false);
143 vert_sb_->set_controller(this); 178 vert_sb_->set_controller(this);
144 corner_view_->SetVisible(false); 179 corner_view_->SetVisible(false);
180
181 if (!base::FeatureList::IsEnabled(kToolkitViewsScrollWithLayers))
182 return;
183
184 background_color_ = SK_ColorWHITE;
185 contents_viewport_->set_background(
186 Background::CreateSolidBackground(background_color_));
187 contents_viewport_->SetPaintToLayer(true);
188 contents_viewport_->layer()->SetMasksToBounds(true);
145 } 189 }
146 190
147 ScrollView::~ScrollView() { 191 ScrollView::~ScrollView() {
148 // The scrollbars may not have been added, delete them to ensure they get 192 // The scrollbars may not have been added, delete them to ensure they get
149 // deleted. 193 // deleted.
150 delete horiz_sb_; 194 delete horiz_sb_;
151 delete vert_sb_; 195 delete vert_sb_;
152 delete corner_view_; 196 delete corner_view_;
153 } 197 }
154 198
155 // static 199 // static
156 ScrollView* ScrollView::CreateScrollViewWithBorder() { 200 ScrollView* ScrollView::CreateScrollViewWithBorder() {
157 return new ScrollViewWithBorder(); 201 return new ScrollViewWithBorder();
158 } 202 }
159 203
160 void ScrollView::SetContents(View* a_view) { 204 void ScrollView::SetContents(View* a_view) {
205 // Protect against clients passing a contents view that has its own Layer.
206 DCHECK(!a_view->layer());
207 if (ScrollsWithLayers()) {
208 if (!a_view->background() && background_color_ != SK_ColorTRANSPARENT) {
209 a_view->set_background(
210 Background::CreateSolidBackground(background_color_));
Ian Vollick 2016/08/09 14:00:49 I presume that the reason you've duplicated a bit
tapted 2016/08/10 05:39:04 That's also true, but the reason I had in mind is
211 }
212 a_view->SetPaintToLayer(true);
213 a_view->layer()->SetScrollable(
214 contents_viewport_->layer(),
215 base::Bind(&ScrollView::OnLayerScrolled, base::Unretained(this)));
216 }
161 SetHeaderOrContents(contents_viewport_, a_view, &contents_); 217 SetHeaderOrContents(contents_viewport_, a_view, &contents_);
162 } 218 }
163 219
164 void ScrollView::SetHeader(View* header) { 220 void ScrollView::SetHeader(View* header) {
165 SetHeaderOrContents(header_viewport_, header, &header_); 221 SetHeaderOrContents(header_viewport_, header, &header_);
166 } 222 }
167 223
224 void ScrollView::SetBackgroundColor(SkColor color) {
225 background_color_ = color;
226 contents_viewport_->set_background(
227 Background::CreateSolidBackground(background_color_));
228 if (contents_ && ScrollsWithLayers() &&
229 background_color_ != SK_ColorTRANSPARENT) {
230 contents_->set_background(
231 Background::CreateSolidBackground(background_color_));
232 }
233 }
234
168 gfx::Rect ScrollView::GetVisibleRect() const { 235 gfx::Rect ScrollView::GetVisibleRect() const {
169 if (!contents_) 236 if (!contents_)
170 return gfx::Rect(); 237 return gfx::Rect();
171 return gfx::Rect(-contents_->x(), -contents_->y(), 238 gfx::ScrollOffset offset = CurrentOffset();
172 contents_viewport_->width(), contents_viewport_->height()); 239 return gfx::Rect(offset.x(), offset.y(), contents_viewport_->width(),
240 contents_viewport_->height());
173 } 241 }
174 242
175 void ScrollView::ClipHeightTo(int min_height, int max_height) { 243 void ScrollView::ClipHeightTo(int min_height, int max_height) {
176 min_height_ = min_height; 244 min_height_ = min_height;
177 max_height_ = max_height; 245 max_height_ = max_height;
178 } 246 }
179 247
180 int ScrollView::GetScrollBarWidth() const { 248 int ScrollView::GetScrollBarWidth() const {
181 return vert_sb_ ? vert_sb_->GetLayoutSize() : 0; 249 return vert_sb_ ? vert_sb_->GetLayoutSize() : 0;
182 } 250 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // Show the resize corner. 390 // Show the resize corner.
323 corner_view_->SetBounds(vert_sb_->bounds().x(), horiz_sb_->bounds().y(), 391 corner_view_->SetBounds(vert_sb_->bounds().x(), horiz_sb_->bounds().y(),
324 vert_sb_width, horiz_sb_height); 392 vert_sb_width, horiz_sb_height);
325 } 393 }
326 394
327 // Update to the real client size with the visible scrollbars. 395 // Update to the real client size with the visible scrollbars.
328 contents_viewport_->SetBoundsRect(viewport_bounds); 396 contents_viewport_->SetBoundsRect(viewport_bounds);
329 if (should_layout_contents && contents_) 397 if (should_layout_contents && contents_)
330 contents_->Layout(); 398 contents_->Layout();
331 399
400 // Even when |contents_| needs to scroll, it can still be narrower or wider
401 // the viewport. So ensure the scrolling layer can fill the viewport, so that
402 // events will correctly hit it, and overscroll looks correct.
403 if (contents_ && ScrollsWithLayers()) {
404 gfx::Size container_size = contents_ ? contents_->size() : gfx::Size();
405 container_size.SetToMax(viewport_bounds.size());
406 contents_->SetBoundsRect(gfx::Rect(container_size));
407 }
408
332 header_viewport_->SetBounds(contents_x, contents_y, 409 header_viewport_->SetBounds(contents_x, contents_y,
333 viewport_bounds.width(), header_height); 410 viewport_bounds.width(), header_height);
334 if (header_) 411 if (header_)
335 header_->Layout(); 412 header_->Layout();
336 413
337 CheckScrollBounds(header_viewport_, header_); 414 CheckScrollBounds(header_viewport_, header_);
338 CheckScrollBounds(contents_viewport_, contents_); 415 CheckScrollBounds(contents_viewport_, contents_);
339 SchedulePaint(); 416 SchedulePaint();
340 UpdateScrollBarPositions(); 417 UpdateScrollBarPositions();
341 } 418 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 476 }
400 477
401 const char* ScrollView::GetClassName() const { 478 const char* ScrollView::GetClassName() const {
402 return kViewClassName; 479 return kViewClassName;
403 } 480 }
404 481
405 void ScrollView::ScrollToPosition(ScrollBar* source, int position) { 482 void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
406 if (!contents_) 483 if (!contents_)
407 return; 484 return;
408 485
486 gfx::ScrollOffset offset = CurrentOffset();
409 if (source == horiz_sb_ && horiz_sb_->visible()) { 487 if (source == horiz_sb_ && horiz_sb_->visible()) {
410 position = AdjustPosition(contents_->x(), position, contents_->width(), 488 position = AdjustPosition(offset.x(), position, contents_->width(),
411 contents_viewport_->width()); 489 contents_viewport_->width());
412 if (-contents_->x() == position) 490 if (offset.x() == position)
413 return; 491 return;
414 contents_->SetX(-position); 492 offset.set_x(position);
415 if (header_) {
416 header_->SetX(-position);
417 header_->SchedulePaintInRect(header_->GetVisibleBounds());
418 }
419 } else if (source == vert_sb_ && vert_sb_->visible()) { 493 } else if (source == vert_sb_ && vert_sb_->visible()) {
420 position = AdjustPosition(contents_->y(), position, contents_->height(), 494 position = AdjustPosition(offset.y(), position, contents_->height(),
421 contents_viewport_->height()); 495 contents_viewport_->height());
422 if (-contents_->y() == position) 496 if (offset.y() == position)
423 return; 497 return;
424 contents_->SetY(-position); 498 offset.set_y(position);
425 } 499 }
426 contents_->SchedulePaintInRect(contents_->GetVisibleBounds()); 500 ScrollToOffset(offset);
501
502 if (!ScrollsWithLayers())
503 contents_->SchedulePaintInRect(contents_->GetVisibleBounds());
427 } 504 }
428 505
429 int ScrollView::GetScrollIncrement(ScrollBar* source, bool is_page, 506 int ScrollView::GetScrollIncrement(ScrollBar* source, bool is_page,
430 bool is_positive) { 507 bool is_positive) {
431 bool is_horizontal = source->IsHorizontal(); 508 bool is_horizontal = source->IsHorizontal();
432 int amount = 0; 509 int amount = 0;
433 if (contents_) { 510 if (contents_) {
434 if (is_page) { 511 if (is_page) {
435 amount = contents_->GetPageScrollIncrement( 512 amount = contents_->GetPageScrollIncrement(
436 this, is_horizontal, is_positive); 513 this, is_horizontal, is_positive);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // corner. This is done by setting the offset to -X or -Y. For down 574 // corner. This is done by setting the offset to -X or -Y. For down
498 // or right shifts we need to make sure it appears in the 575 // or right shifts we need to make sure it appears in the
499 // lower/right corner. This is calculated by taking max_x or max_y 576 // lower/right corner. This is calculated by taking max_x or max_y
500 // and scaling it back by the size of the viewport. 577 // and scaling it back by the size of the viewport.
501 const int new_x = 578 const int new_x =
502 (vis_rect.x() > x) ? x : std::max(0, max_x - contents_viewport_->width()); 579 (vis_rect.x() > x) ? x : std::max(0, max_x - contents_viewport_->width());
503 const int new_y = 580 const int new_y =
504 (vis_rect.y() > y) ? y : std::max(0, max_y - 581 (vis_rect.y() > y) ? y : std::max(0, max_y -
505 contents_viewport_->height()); 582 contents_viewport_->height());
506 583
507 contents_->SetX(-new_x); 584 ScrollToOffset(gfx::ScrollOffset(new_x, new_y));
508 if (header_)
509 header_->SetX(-new_x);
510 contents_->SetY(-new_y);
511 UpdateScrollBarPositions(); 585 UpdateScrollBarPositions();
512 } 586 }
513 587
514 void ScrollView::ComputeScrollBarsVisibility(const gfx::Size& vp_size, 588 void ScrollView::ComputeScrollBarsVisibility(const gfx::Size& vp_size,
515 const gfx::Size& content_size, 589 const gfx::Size& content_size,
516 bool* horiz_is_shown, 590 bool* horiz_is_shown,
517 bool* vert_is_shown) const { 591 bool* vert_is_shown) const {
518 // Try to fit both ways first, then try vertical bar only, then horizontal 592 // Try to fit both ways first, then try vertical bar only, then horizontal
519 // bar only, then defaults to both shown. 593 // bar only, then defaults to both shown.
520 if (content_size.width() <= vp_size.width() && 594 if (content_size.width() <= vp_size.width() &&
(...skipping 27 matching lines...) Expand all
548 } else { 622 } else {
549 RemoveChildView(control); 623 RemoveChildView(control);
550 control->SetVisible(false); 624 control->SetVisible(false);
551 } 625 }
552 } 626 }
553 627
554 void ScrollView::UpdateScrollBarPositions() { 628 void ScrollView::UpdateScrollBarPositions() {
555 if (!contents_) 629 if (!contents_)
556 return; 630 return;
557 631
632 const gfx::ScrollOffset offset = CurrentOffset();
558 if (horiz_sb_->visible()) { 633 if (horiz_sb_->visible()) {
559 int vw = contents_viewport_->width(); 634 int vw = contents_viewport_->width();
560 int cw = contents_->width(); 635 int cw = contents_->width();
561 int origin = contents_->x(); 636 horiz_sb_->Update(vw, cw, offset.x());
562 horiz_sb_->Update(vw, cw, -origin);
563 } 637 }
564 if (vert_sb_->visible()) { 638 if (vert_sb_->visible()) {
565 int vh = contents_viewport_->height(); 639 int vh = contents_viewport_->height();
566 int ch = contents_->height(); 640 int ch = contents_->height();
567 int origin = contents_->y(); 641 vert_sb_->Update(vh, ch, offset.y());
568 vert_sb_->Update(vh, ch, -origin);
569 } 642 }
570 } 643 }
571 644
645 gfx::ScrollOffset ScrollView::CurrentOffset() const {
646 return ScrollsWithLayers()
647 ? contents_->layer()->CurrentScrollOffset()
648 : gfx::ScrollOffset(-contents_->x(), -contents_->y());
649 }
650
651 void ScrollView::ScrollToOffset(const gfx::ScrollOffset& offset) {
652 if (ScrollsWithLayers()) {
653 contents_->layer()->SetScrollOffset(offset);
654
655 // TODO(tapted): Remove this call to OnLayerScrolled(). It's unnecessary,
656 // but will only be invoked (asynchronously) when a Compositor is present
657 // and commits a frame, which isn't true in some tests.
Ian Vollick 2016/08/12 13:57:42 Please create a bug for this and mention it in the
tapted 2016/08/13 09:03:53 Done.
658 OnLayerScrolled();
659 } else {
660 contents_->SetPosition(gfx::Point(-offset.x(), -offset.y()));
661 ScrollHeader();
662 }
663 }
664
665 bool ScrollView::ScrollsWithLayers() const {
666 // Just check for the presence of a layer since it's cheaper than querying the
667 // Feature flag each time.
668 return contents_viewport_->layer() != nullptr;
669 }
670
671 void ScrollView::OnLayerScrolled() {
672 UpdateScrollBarPositions();
673 ScrollHeader();
674 }
675
676 void ScrollView::ScrollHeader() {
677 if (!header_)
678 return;
679
680 int x_offset = CurrentOffset().x();
681 if (header_->x() != -x_offset) {
682 header_->SetX(-x_offset);
683 header_->SchedulePaintInRect(header_->GetVisibleBounds());
684 }
685 }
686
572 // VariableRowHeightScrollHelper ---------------------------------------------- 687 // VariableRowHeightScrollHelper ----------------------------------------------
573 688
574 VariableRowHeightScrollHelper::VariableRowHeightScrollHelper( 689 VariableRowHeightScrollHelper::VariableRowHeightScrollHelper(
575 Controller* controller) : controller_(controller) { 690 Controller* controller) : controller_(controller) {
576 } 691 }
577 692
578 VariableRowHeightScrollHelper::~VariableRowHeightScrollHelper() { 693 VariableRowHeightScrollHelper::~VariableRowHeightScrollHelper() {
579 } 694 }
580 695
581 int VariableRowHeightScrollHelper::GetPageScrollIncrement( 696 int VariableRowHeightScrollHelper::GetPageScrollIncrement(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 751
637 VariableRowHeightScrollHelper::RowInfo 752 VariableRowHeightScrollHelper::RowInfo
638 FixedRowHeightScrollHelper::GetRowInfo(int y) { 753 FixedRowHeightScrollHelper::GetRowInfo(int y) {
639 if (y < top_margin_) 754 if (y < top_margin_)
640 return RowInfo(0, top_margin_); 755 return RowInfo(0, top_margin_);
641 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 756 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
642 row_height_); 757 row_height_);
643 } 758 }
644 759
645 } // namespace views 760 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698