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

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

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

Powered by Google App Engine
This is Rietveld 408576698