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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 ScrollHeader(); | 676 ScrollHeader(); |
677 } | 677 } |
678 } | 678 } |
679 | 679 |
680 bool ScrollView::ScrollsWithLayers() const { | 680 bool ScrollView::ScrollsWithLayers() const { |
681 // Just check for the presence of a layer since it's cheaper than querying the | 681 // Just check for the presence of a layer since it's cheaper than querying the |
682 // Feature flag each time. | 682 // Feature flag each time. |
683 return contents_viewport_->layer() != nullptr; | 683 return contents_viewport_->layer() != nullptr; |
684 } | 684 } |
685 | 685 |
686 void ScrollView::ActivateLayer(bool force_layer_creation) { | |
sky
2016/10/14 22:59:27
This name is mildly confusing and why does it take
djacobo_
2016/10/14 23:35:32
I am still trying to figure out how to do the prop
| |
687 if (force_layer_creation || ChildrenLayerCheck(contents_viewport_)) { | |
688 background_color_ = SK_ColorWHITE; | |
689 contents_viewport_->set_background( | |
690 Background::CreateSolidBackground(background_color_)); | |
691 contents_viewport_->SetPaintToLayer(true); | |
692 contents_viewport_->layer()->SetMasksToBounds(true); | |
693 } | |
694 } | |
695 | |
696 bool ScrollView::ChildrenLayerCheck(View* child) const { | |
697 if (!child) | |
698 return false; | |
699 if (child->layer() != nullptr) | |
700 return true; | |
701 | |
702 for (int i = 0; i < child->child_count(); ++i) | |
703 if (ChildrenLayerCheck(child->child_at(i))) | |
704 return true; | |
705 return false; | |
706 } | |
707 | |
686 void ScrollView::OnLayerScrolled() { | 708 void ScrollView::OnLayerScrolled() { |
687 UpdateScrollBarPositions(); | 709 UpdateScrollBarPositions(); |
688 ScrollHeader(); | 710 ScrollHeader(); |
689 } | 711 } |
690 | 712 |
691 void ScrollView::ScrollHeader() { | 713 void ScrollView::ScrollHeader() { |
692 if (!header_) | 714 if (!header_) |
693 return; | 715 return; |
694 | 716 |
695 int x_offset = CurrentOffset().x(); | 717 int x_offset = CurrentOffset().x(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 | 788 |
767 VariableRowHeightScrollHelper::RowInfo | 789 VariableRowHeightScrollHelper::RowInfo |
768 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 790 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
769 if (y < top_margin_) | 791 if (y < top_margin_) |
770 return RowInfo(0, top_margin_); | 792 return RowInfo(0, top_margin_); |
771 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 793 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
772 row_height_); | 794 row_height_); |
773 } | 795 } |
774 | 796 |
775 } // namespace views | 797 } // namespace views |
OLD | NEW |