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

Unified Diff: views/controls/menu/submenu_view.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (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 side-by-side diff with in-line comments
Download patch
Index: views/controls/menu/submenu_view.cc
===================================================================
--- views/controls/menu/submenu_view.cc (revision 74117)
+++ views/controls/menu/submenu_view.cc (working copy)
@@ -47,7 +47,7 @@
int SubmenuView::GetMenuItemCount() {
int count = 0;
- for (int i = 0; i < GetChildViewCount(); ++i) {
+ for (size_t i = 0; i < child_count(); ++i) {
if (GetChildViewAt(i)->GetID() == MenuItemView::kMenuItemViewID)
count++;
}
@@ -55,9 +55,9 @@
}
MenuItemView* SubmenuView::GetMenuItemAt(int index) {
- for (int i = 0, count = 0; i < GetChildViewCount(); ++i) {
+ for (size_t i = 0, count = 0; i < child_count(); ++i) {
if (GetChildViewAt(i)->GetID() == MenuItemView::kMenuItemViewID &&
- count++ == index) {
+ count++ == static_cast<size_t>(index)) {
return static_cast<MenuItemView*>(GetChildViewAt(i));
}
}
@@ -67,24 +67,23 @@
void SubmenuView::Layout() {
// We're in a ScrollView, and need to set our width/height ourselves.
- View* parent = GetParent();
- if (!parent)
+ if (!parent())
return;
// Use our current y, unless it means part of the menu isn't visible anymore.
int pref_height = GetPreferredSize().height();
int new_y;
- if (pref_height > parent->height())
- new_y = std::max(parent->height() - pref_height, y());
+ if (pref_height > parent()->height())
+ new_y = std::max(parent()->height() - pref_height, y());
else
new_y = 0;
- SetBounds(x(), new_y, parent->width(), pref_height);
+ SetBounds(x(), new_y, parent()->width(), pref_height);
gfx::Insets insets = GetInsets();
int x = insets.left();
int y = insets.top();
int menu_item_width = width() - insets.width();
- for (int i = 0; i < GetChildViewCount(); ++i) {
+ for (size_t i = 0; i < child_count(); ++i) {
View* child = GetChildViewAt(i);
if (child->IsVisible()) {
gfx::Size child_pref_size = child->GetPreferredSize();
@@ -95,13 +94,13 @@
}
gfx::Size SubmenuView::GetPreferredSize() {
- if (GetChildViewCount() == 0)
+ if (!has_children())
return gfx::Size();
max_accelerator_width_ = 0;
int max_width = 0;
int height = 0;
- for (int i = 0; i < GetChildViewCount(); ++i) {
+ for (size_t i = 0; i < child_count(); ++i) {
View* child = GetChildViewAt(i);
gfx::Size child_pref_size = child->IsVisible() ?
child->GetPreferredSize() : gfx::Size();

Powered by Google App Engine
This is Rietveld 408576698