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

Unified Diff: views/controls/menu/menu_item_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/menu_item_view.cc
===================================================================
--- views/controls/menu/menu_item_view.cc (revision 74117)
+++ views/controls/menu/menu_item_view.cc (working copy)
@@ -400,7 +400,7 @@
return this;
if (!HasSubmenu())
return NULL;
- for (int i = 0; i < GetSubmenu()->GetChildViewCount(); ++i) {
+ for (size_t i = 0; i < GetSubmenu()->child_count(); ++i) {
View* child = GetSubmenu()->GetChildViewAt(i);
if (child->GetID() == MenuItemView::kMenuItemViewID) {
MenuItemView* result = static_cast<MenuItemView*>(child)->
@@ -435,13 +435,13 @@
}
void MenuItemView::Layout() {
- int child_count = GetChildViewCount();
- if (child_count == 0)
+ if (!has_children())
return;
- // Child views are layed out right aligned and given the full height. To right
+ // Child views are laid out right aligned and given the full height. To right
// align start with the last view and progress to the first.
- for (int i = child_count - 1, x = width() - item_right_margin_; i >= 0; --i) {
+ for (size_t i = child_count() - 1, x = width() - item_right_margin_; i >= 0;
sky 2011/02/08 19:11:54 this never stops. PS I don't like size_t.
+ --i) {
View* child = GetChildViewAt(i);
int width = child->GetPreferredSize().width();
child->SetBounds(x - width, 0, width, height());
@@ -581,8 +581,8 @@
void MenuItemView::AddEmptyMenus() {
DCHECK(HasSubmenu());
- if (submenu_->GetChildViewCount() == 0) {
- submenu_->AddChildView(0, new EmptyMenuMenuItem(this));
+ if (!submenu_->has_children()) {
+ submenu_->AddChildViewAt(new EmptyMenuMenuItem(this), 0);
} else {
for (int i = 0, item_count = submenu_->GetMenuItemCount(); i < item_count;
++i) {
@@ -597,7 +597,7 @@
DCHECK(HasSubmenu());
// Iterate backwards as we may end up removing views, which alters the child
// view count.
- for (int i = submenu_->GetChildViewCount() - 1; i >= 0; --i) {
+ for (size_t i = submenu_->child_count() - 1; i >= 0; --i) {
sky 2011/02/08 19:11:54 this never stops. PS I don't like size_t.
View* child = submenu_->GetChildViewAt(i);
if (child->GetID() == MenuItemView::kMenuItemViewID) {
MenuItemView* menu_item = static_cast<MenuItemView*>(child);
@@ -664,12 +664,11 @@
}
int MenuItemView::GetChildPreferredWidth() {
- int child_count = GetChildViewCount();
- if (child_count == 0)
+ if (!has_children())
return 0;
int width = 0;
- for (int i = 0; i < child_count; ++i) {
+ for (size_t i = 0; i < child_count(); ++i) {
if (i)
width += kChildXPadding;
width += GetChildViewAt(i)->GetPreferredSize().width();

Powered by Google App Engine
This is Rietveld 408576698