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" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 focus_ring_->Layout(); | 306 focus_ring_->Layout(); |
| 307 | 307 |
| 308 gfx::Rect available_rect = GetContentsBounds(); | 308 gfx::Rect available_rect = GetContentsBounds(); |
| 309 if (is_bounded()) { | 309 if (is_bounded()) { |
| 310 int content_width = available_rect.width(); | 310 int content_width = available_rect.width(); |
| 311 int content_height = contents()->GetHeightForWidth(content_width); | 311 int content_height = contents()->GetHeightForWidth(content_width); |
| 312 if (content_height > height()) { | 312 if (content_height > height()) { |
| 313 content_width = std::max(content_width - GetScrollBarWidth(), 0); | 313 content_width = std::max(content_width - GetScrollBarWidth(), 0); |
| 314 content_height = contents()->GetHeightForWidth(content_width); | 314 content_height = contents()->GetHeightForWidth(content_width); |
| 315 } | 315 } |
| 316 if (contents()->bounds().size() != gfx::Size(content_width, content_height)) | 316 contents()->SetSize(gfx::Size(content_width, content_height)); |
|
sky
2016/11/16 20:12:57
It would be nice if we were consistent and used co
Evan Stade
2016/11/17 01:14:00
(also done)
| |
| 317 contents()->SetBounds(0, 0, content_width, content_height); | |
| 318 } | 317 } |
| 319 | 318 |
| 320 // Most views will want to auto-fit the available space. Most of them want to | 319 // Most views will want to auto-fit the available space. Most of them want to |
| 321 // use all available width (without overflowing) and only overflow in | 320 // use all available width (without overflowing) and only overflow in |
| 322 // height. Examples are HistoryView, MostVisitedView, DownloadTabView, etc. | 321 // height. Examples are HistoryView, MostVisitedView, DownloadTabView, etc. |
| 323 // Other views want to fit in both ways. An example is PrintView. To make both | 322 // Other views want to fit in both ways. An example is PrintView. To make both |
| 324 // happy, assume a vertical scrollbar but no horizontal scrollbar. To override | 323 // happy, assume a vertical scrollbar but no horizontal scrollbar. To override |
| 325 // this default behavior, the inner view has to calculate the available space, | 324 // this default behavior, the inner view has to calculate the available space, |
| 326 // used ComputeScrollBarsVisibility() to use the same calculation that is done | 325 // used ComputeScrollBarsVisibility() to use the same calculation that is done |
| 327 // here and sets its bound to fit within. | 326 // here and sets its bound to fit within. |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 | 781 |
| 783 VariableRowHeightScrollHelper::RowInfo | 782 VariableRowHeightScrollHelper::RowInfo |
| 784 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 783 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 785 if (y < top_margin_) | 784 if (y < top_margin_) |
| 786 return RowInfo(0, top_margin_); | 785 return RowInfo(0, top_margin_); |
| 787 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 786 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 788 row_height_); | 787 row_height_); |
| 789 } | 788 } |
| 790 | 789 |
| 791 } // namespace views | 790 } // namespace views |
| OLD | NEW |