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

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

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: fix comments Created 3 years, 11 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/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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 void ScrollView::SetContents(View* a_view) { 202 void ScrollView::SetContents(View* a_view) {
203 // Protect against clients passing a contents view that has its own Layer. 203 // Protect against clients passing a contents view that has its own Layer.
204 DCHECK(!a_view->layer()); 204 DCHECK(!a_view->layer());
205 if (ScrollsWithLayers()) { 205 if (ScrollsWithLayers()) {
206 if (!a_view->background() && background_color_ != SK_ColorTRANSPARENT) { 206 if (!a_view->background() && background_color_ != SK_ColorTRANSPARENT) {
207 a_view->set_background( 207 a_view->set_background(
208 Background::CreateSolidBackground(background_color_)); 208 Background::CreateSolidBackground(background_color_));
209 } 209 }
210 a_view->SetPaintToLayer(true); 210 a_view->SetPaintToLayer();
211 a_view->layer()->SetScrollable( 211 a_view->layer()->SetScrollable(
212 contents_viewport_->layer(), 212 contents_viewport_->layer(),
213 base::Bind(&ScrollView::OnLayerScrolled, base::Unretained(this))); 213 base::Bind(&ScrollView::OnLayerScrolled, base::Unretained(this)));
214 } 214 }
215 SetHeaderOrContents(contents_viewport_, a_view, &contents_); 215 SetHeaderOrContents(contents_viewport_, a_view, &contents_);
216 } 216 }
217 217
218 void ScrollView::SetHeader(View* header) { 218 void ScrollView::SetHeader(View* header) {
219 SetHeaderOrContents(header_viewport_, header, &header_); 219 SetHeaderOrContents(header_viewport_, header, &header_);
220 } 220 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 bool ScrollView::ScrollsWithLayers() const { 709 bool ScrollView::ScrollsWithLayers() const {
710 // Just check for the presence of a layer since it's cheaper than querying the 710 // Just check for the presence of a layer since it's cheaper than querying the
711 // Feature flag each time. 711 // Feature flag each time.
712 return contents_viewport_->layer() != nullptr; 712 return contents_viewport_->layer() != nullptr;
713 } 713 }
714 714
715 void ScrollView::EnableViewPortLayer() { 715 void ScrollView::EnableViewPortLayer() {
716 background_color_ = SK_ColorWHITE; 716 background_color_ = SK_ColorWHITE;
717 contents_viewport_->set_background( 717 contents_viewport_->set_background(
718 Background::CreateSolidBackground(background_color_)); 718 Background::CreateSolidBackground(background_color_));
719 contents_viewport_->SetPaintToLayer(true); 719 contents_viewport_->SetPaintToLayer();
720 contents_viewport_->layer()->SetMasksToBounds(true); 720 contents_viewport_->layer()->SetMasksToBounds(true);
721 } 721 }
722 722
723 void ScrollView::OnLayerScrolled() { 723 void ScrollView::OnLayerScrolled() {
724 UpdateScrollBarPositions(); 724 UpdateScrollBarPositions();
725 ScrollHeader(); 725 ScrollHeader();
726 } 726 }
727 727
728 void ScrollView::ScrollHeader() { 728 void ScrollView::ScrollHeader() {
729 if (!header_) 729 if (!header_)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 803
804 VariableRowHeightScrollHelper::RowInfo 804 VariableRowHeightScrollHelper::RowInfo
805 FixedRowHeightScrollHelper::GetRowInfo(int y) { 805 FixedRowHeightScrollHelper::GetRowInfo(int y) {
806 if (y < top_margin_) 806 if (y < top_margin_)
807 return RowInfo(0, top_margin_); 807 return RowInfo(0, top_margin_);
808 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 808 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
809 row_height_); 809 row_height_);
810 } 810 }
811 811
812 } // namespace views 812 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698