Chromium Code Reviews| 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" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
| 13 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
| 14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 15 #include "ui/views/controls/focus_ring.h" | |
| 15 #include "ui/views/style/platform_style.h" | 16 #include "ui/views/style/platform_style.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 const char ScrollView::kViewClassName[] = "ScrollView"; | 21 const char ScrollView::kViewClassName[] = "ScrollView"; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const base::Feature kToolkitViewsScrollWithLayers { | 25 const base::Feature kToolkitViewsScrollWithLayers { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 if (!is_bounded()) | 288 if (!is_bounded()) |
| 288 return View::GetHeightForWidth(width); | 289 return View::GetHeightForWidth(width); |
| 289 | 290 |
| 290 gfx::Insets insets = GetInsets(); | 291 gfx::Insets insets = GetInsets(); |
| 291 width = std::max(0, width - insets.width()); | 292 width = std::max(0, width - insets.width()); |
| 292 int height = contents()->GetHeightForWidth(width) + insets.height(); | 293 int height = contents()->GetHeightForWidth(width) + insets.height(); |
| 293 return std::min(std::max(height, min_height_), max_height_); | 294 return std::min(std::max(height, min_height_), max_height_); |
| 294 } | 295 } |
| 295 | 296 |
| 296 void ScrollView::Layout() { | 297 void ScrollView::Layout() { |
| 298 // If there's a focus ring, lay it out first. | |
| 299 for (int i = 0; i < child_count(); ++i) | |
|
sky
2016/10/12 20:08:53
I suspect tree isn't the only place that wants scr
Elly Fong-Jones
2016/10/12 21:10:22
Done.
| |
| 300 if (child_at(i)->GetClassName() == FocusRing::kViewClassName) | |
| 301 child_at(i)->Layout(); | |
| 302 | |
| 297 gfx::Rect available_rect = GetContentsBounds(); | 303 gfx::Rect available_rect = GetContentsBounds(); |
| 298 if (is_bounded()) { | 304 if (is_bounded()) { |
| 299 int content_width = available_rect.width(); | 305 int content_width = available_rect.width(); |
| 300 int content_height = contents()->GetHeightForWidth(content_width); | 306 int content_height = contents()->GetHeightForWidth(content_width); |
| 301 if (content_height > height()) { | 307 if (content_height > height()) { |
| 302 content_width = std::max(content_width - GetScrollBarWidth(), 0); | 308 content_width = std::max(content_width - GetScrollBarWidth(), 0); |
| 303 content_height = contents()->GetHeightForWidth(content_width); | 309 content_height = contents()->GetHeightForWidth(content_width); |
| 304 } | 310 } |
| 305 if (contents()->bounds().size() != gfx::Size(content_width, content_height)) | 311 if (contents()->bounds().size() != gfx::Size(content_width, content_height)) |
| 306 contents()->SetBounds(0, 0, content_width, content_height); | 312 contents()->SetBounds(0, 0, content_width, content_height); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 | 772 |
| 767 VariableRowHeightScrollHelper::RowInfo | 773 VariableRowHeightScrollHelper::RowInfo |
| 768 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 774 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 769 if (y < top_margin_) | 775 if (y < top_margin_) |
| 770 return RowInfo(0, top_margin_); | 776 return RowInfo(0, top_margin_); |
| 771 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 777 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 772 row_height_); | 778 row_height_); |
| 773 } | 779 } |
| 774 | 780 |
| 775 } // namespace views | 781 } // namespace views |
| OLD | NEW |