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

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

Issue 2436543003: reland: Reusing Ok/Cancel buttons for intent picker (Closed)
Patch Set: Modifying the way I create a dummy event for the testing. 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') | no next file » | 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/events/event.h" 10 #include "ui/events/event.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Don't add the scrollbars as children until we discover we need them 176 // Don't add the scrollbars as children until we discover we need them
177 // (ShowOrHideScrollBar). 177 // (ShowOrHideScrollBar).
178 horiz_sb_->SetVisible(false); 178 horiz_sb_->SetVisible(false);
179 horiz_sb_->set_controller(this); 179 horiz_sb_->set_controller(this);
180 vert_sb_->SetVisible(false); 180 vert_sb_->SetVisible(false);
181 vert_sb_->set_controller(this); 181 vert_sb_->set_controller(this);
182 corner_view_->SetVisible(false); 182 corner_view_->SetVisible(false);
183 183
184 if (!base::FeatureList::IsEnabled(kToolkitViewsScrollWithLayers)) 184 if (!base::FeatureList::IsEnabled(kToolkitViewsScrollWithLayers))
185 return; 185 return;
186 186 EnableViewPortLayer();
187 background_color_ = SK_ColorWHITE;
188 contents_viewport_->set_background(
189 Background::CreateSolidBackground(background_color_));
190 contents_viewport_->SetPaintToLayer(true);
191 contents_viewport_->layer()->SetMasksToBounds(true);
192 } 187 }
193 188
194 ScrollView::~ScrollView() { 189 ScrollView::~ScrollView() {
195 // The scrollbars may not have been added, delete them to ensure they get 190 // The scrollbars may not have been added, delete them to ensure they get
196 // deleted. 191 // deleted.
197 delete horiz_sb_; 192 delete horiz_sb_;
198 delete vert_sb_; 193 delete vert_sb_;
199 delete corner_view_; 194 delete corner_view_;
200 } 195 }
201 196
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 ScrollHeader(); 687 ScrollHeader();
693 } 688 }
694 } 689 }
695 690
696 bool ScrollView::ScrollsWithLayers() const { 691 bool ScrollView::ScrollsWithLayers() const {
697 // Just check for the presence of a layer since it's cheaper than querying the 692 // Just check for the presence of a layer since it's cheaper than querying the
698 // Feature flag each time. 693 // Feature flag each time.
699 return contents_viewport_->layer() != nullptr; 694 return contents_viewport_->layer() != nullptr;
700 } 695 }
701 696
697 void ScrollView::EnableViewPortLayer() {
698 background_color_ = SK_ColorWHITE;
699 contents_viewport_->set_background(
700 Background::CreateSolidBackground(background_color_));
701 contents_viewport_->SetPaintToLayer(true);
702 contents_viewport_->layer()->SetMasksToBounds(true);
703 }
704
702 void ScrollView::OnLayerScrolled() { 705 void ScrollView::OnLayerScrolled() {
703 UpdateScrollBarPositions(); 706 UpdateScrollBarPositions();
704 ScrollHeader(); 707 ScrollHeader();
705 } 708 }
706 709
707 void ScrollView::ScrollHeader() { 710 void ScrollView::ScrollHeader() {
708 if (!header_) 711 if (!header_)
709 return; 712 return;
710 713
711 int x_offset = CurrentOffset().x(); 714 int x_offset = CurrentOffset().x();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 785
783 VariableRowHeightScrollHelper::RowInfo 786 VariableRowHeightScrollHelper::RowInfo
784 FixedRowHeightScrollHelper::GetRowInfo(int y) { 787 FixedRowHeightScrollHelper::GetRowInfo(int y) {
785 if (y < top_margin_) 788 if (y < top_margin_)
786 return RowInfo(0, top_margin_); 789 return RowInfo(0, top_margin_);
787 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 790 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
788 row_height_); 791 row_height_);
789 } 792 }
790 793
791 } // namespace views 794 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698