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

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

Issue 6462022: It turns out I had the sense of the GetLocalBounds bool wrong everywhere, so ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/scroll_view.h" 5 #include "views/controls/scroll_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "views/controls/scrollbar/native_scroll_bar.h" 8 #include "views/controls/scrollbar/native_scroll_bar.h"
9 #include "views/widget/root_view.h" 9 #include "views/widget/root_view.h"
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 void ScrollView::Layout() { 141 void ScrollView::Layout() {
142 // Most views will want to auto-fit the available space. Most of them want to 142 // Most views will want to auto-fit the available space. Most of them want to
143 // use the all available width (without overflowing) and only overflow in 143 // use the all available width (without overflowing) and only overflow in
144 // height. Examples are HistoryView, MostVisitedView, DownloadTabView, etc. 144 // height. Examples are HistoryView, MostVisitedView, DownloadTabView, etc.
145 // Other views want to fit in both ways. An example is PrintView. To make both 145 // Other views want to fit in both ways. An example is PrintView. To make both
146 // happy, assume a vertical scrollbar but no horizontal scrollbar. To 146 // happy, assume a vertical scrollbar but no horizontal scrollbar. To
147 // override this default behavior, the inner view has to calculate the 147 // override this default behavior, the inner view has to calculate the
148 // available space, used ComputeScrollBarsVisibility() to use the same 148 // available space, used ComputeScrollBarsVisibility() to use the same
149 // calculation that is done here and sets its bound to fit within. 149 // calculation that is done here and sets its bound to fit within.
150 gfx::Rect viewport_bounds = GetContentsBounds(); 150 gfx::Rect viewport_bounds = GetLocalBounds();
151 // Realign it to 0 so it can be used as-is for SetBounds(). 151 // Realign it to 0 so it can be used as-is for SetBounds().
152 viewport_bounds.set_origin(gfx::Point(0, 0)); 152 viewport_bounds.set_origin(gfx::Point(0, 0));
153 // viewport_size is the total client space available. 153 // viewport_size is the total client space available.
154 gfx::Size viewport_size = viewport_bounds.size(); 154 gfx::Size viewport_size = viewport_bounds.size();
155 if (viewport_bounds.IsEmpty()) { 155 if (viewport_bounds.IsEmpty()) {
156 // There's nothing to layout. 156 // There's nothing to layout.
157 return; 157 return;
158 } 158 }
159 159
160 // Assumes a vertical scrollbar since most the current views are designed for 160 // Assumes a vertical scrollbar since most the current views are designed for
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 501
502 VariableRowHeightScrollHelper::RowInfo 502 VariableRowHeightScrollHelper::RowInfo
503 FixedRowHeightScrollHelper::GetRowInfo(int y) { 503 FixedRowHeightScrollHelper::GetRowInfo(int y) {
504 if (y < top_margin_) 504 if (y < top_margin_)
505 return RowInfo(0, top_margin_); 505 return RowInfo(0, top_margin_);
506 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 506 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
507 row_height_); 507 row_height_);
508 } 508 }
509 509
510 } // namespace views 510 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698