OLD | NEW |
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 Loading... |
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 EnableViewPortLayer(); | 186 |
| 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); |
187 } | 192 } |
188 | 193 |
189 ScrollView::~ScrollView() { | 194 ScrollView::~ScrollView() { |
190 // The scrollbars may not have been added, delete them to ensure they get | 195 // The scrollbars may not have been added, delete them to ensure they get |
191 // deleted. | 196 // deleted. |
192 delete horiz_sb_; | 197 delete horiz_sb_; |
193 delete vert_sb_; | 198 delete vert_sb_; |
194 delete corner_view_; | 199 delete corner_view_; |
195 } | 200 } |
196 | 201 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 ScrollHeader(); | 692 ScrollHeader(); |
688 } | 693 } |
689 } | 694 } |
690 | 695 |
691 bool ScrollView::ScrollsWithLayers() const { | 696 bool ScrollView::ScrollsWithLayers() const { |
692 // Just check for the presence of a layer since it's cheaper than querying the | 697 // Just check for the presence of a layer since it's cheaper than querying the |
693 // Feature flag each time. | 698 // Feature flag each time. |
694 return contents_viewport_->layer() != nullptr; | 699 return contents_viewport_->layer() != nullptr; |
695 } | 700 } |
696 | 701 |
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 | |
705 void ScrollView::OnLayerScrolled() { | 702 void ScrollView::OnLayerScrolled() { |
706 UpdateScrollBarPositions(); | 703 UpdateScrollBarPositions(); |
707 ScrollHeader(); | 704 ScrollHeader(); |
708 } | 705 } |
709 | 706 |
710 void ScrollView::ScrollHeader() { | 707 void ScrollView::ScrollHeader() { |
711 if (!header_) | 708 if (!header_) |
712 return; | 709 return; |
713 | 710 |
714 int x_offset = CurrentOffset().x(); | 711 int x_offset = CurrentOffset().x(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 782 |
786 VariableRowHeightScrollHelper::RowInfo | 783 VariableRowHeightScrollHelper::RowInfo |
787 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 784 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
788 if (y < top_margin_) | 785 if (y < top_margin_) |
789 return RowInfo(0, top_margin_); | 786 return RowInfo(0, top_margin_); |
790 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 787 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
791 row_height_); | 788 row_height_); |
792 } | 789 } |
793 | 790 |
794 } // namespace views | 791 } // namespace views |
OLD | NEW |