summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 17:13:33 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 17:13:33 +0000
commitfe84b910e02f66451d9b746d03f761aedfa39032 (patch)
treeba31d5ff4ae9229366bb0675d6dc476fd55645f8
parentce2d72c6918e9707ef3dc9987369241108ed239f (diff)
downloadchromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.zip
chromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.tar.gz
chromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.tar.bz2
Convert some more view methods to the ui/views style.
BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7349021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92705 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/eula_view.cc2
-rw-r--r--chrome/browser/chromeos/login/views_oobe_display.cc2
-rw-r--r--chrome/browser/chromeos/notifications/balloon_view.cc2
-rw-r--r--chrome/browser/chromeos/notifications/notification_panel.cc21
-rw-r--r--chrome/browser/chromeos/status/status_area_view.cc4
-rw-r--r--chrome/browser/ui/touch/frame/keyboard_container_view.cc2
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views.cc4
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc12
-rw-r--r--chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc6
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc4
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc20
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc7
-rw-r--r--chrome/browser/ui/views/bubble/bubble.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_gtk.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view_layout.cc12
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container_view.cc2
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.cc2
-rw-r--r--chrome/browser/ui/views/wrench_menu.cc4
-rw-r--r--chrome/test/interactive_ui/view_event_test_base.cc2
-rw-r--r--views/accessibility/native_view_accessibility_win.cc6
-rw-r--r--views/controls/menu/menu_controller.cc8
-rw-r--r--views/controls/menu/menu_item_view.cc14
-rw-r--r--views/controls/menu/menu_scroll_view_container.cc2
-rw-r--r--views/controls/menu/submenu_view.cc10
-rw-r--r--views/controls/scroll_view.cc2
-rw-r--r--views/controls/single_split_view.cc23
-rw-r--r--views/controls/single_split_view_unittest.cc14
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.cc2
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.cc8
-rw-r--r--views/controls/textfield/native_textfield_win.cc2
-rw-r--r--views/examples/scroll_view_example.cc2
-rw-r--r--views/examples/throbber_example.cc2
-rw-r--r--views/examples/widget_example.cc2
-rw-r--r--views/focus/focus_search.cc10
-rw-r--r--views/layout/box_layout.cc4
-rw-r--r--views/layout/fill_layout.cc4
-rw-r--r--views/layout/grid_layout_unittest.cc6
-rw-r--r--views/view.cc59
-rw-r--r--views/view.h18
-rw-r--r--views/widget/root_view.cc2
42 files changed, 150 insertions, 168 deletions
diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc
index a7778f2..8f4e729 100644
--- a/chrome/browser/chromeos/login/eula_view.cc
+++ b/chrome/browser/chromeos/login/eula_view.cc
@@ -73,7 +73,7 @@ struct FillLayoutWithBorder : public views::LayoutManager {
// Overridden from LayoutManager:
virtual void Layout(views::View* host) {
DCHECK(host->has_children());
- host->GetChildViewAt(0)->SetBoundsRect(host->GetContentsBounds());
+ host->child_at(0)->SetBoundsRect(host->GetContentsBounds());
}
virtual gfx::Size GetPreferredSize(views::View* host) {
return gfx::Size(host->width(), host->height());
diff --git a/chrome/browser/chromeos/login/views_oobe_display.cc b/chrome/browser/chromeos/login/views_oobe_display.cc
index 3863d3f..49b0c81 100644
--- a/chrome/browser/chromeos/login/views_oobe_display.cc
+++ b/chrome/browser/chromeos/login/views_oobe_display.cc
@@ -101,7 +101,7 @@ class ContentView : public views::View {
virtual void Layout() {
for (int i = 0; i < child_count(); ++i) {
- views::View* cur = GetChildViewAt(i);
+ views::View* cur = child_at(i);
if (cur->IsVisible())
cur->SetBounds(0, 0, width(), height());
}
diff --git a/chrome/browser/chromeos/notifications/balloon_view.cc b/chrome/browser/chromeos/notifications/balloon_view.cc
index f23cd8f..659a900 100644
--- a/chrome/browser/chromeos/notifications/balloon_view.cc
+++ b/chrome/browser/chromeos/notifications/balloon_view.cc
@@ -330,7 +330,7 @@ void BalloonViewImpl::Activated() {
// Get the size of Control View.
gfx::Size size =
- control_view_host_->GetRootView()->GetChildViewAt(0)->GetPreferredSize();
+ control_view_host_->GetRootView()->child_at(0)->GetPreferredSize();
control_view_host_->Show();
control_view_host_->SetBounds(
gfx::Rect(width() - size.width() - kControlViewRightMargin,
diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc
index 7bb6114..1a3b058 100644
--- a/chrome/browser/chromeos/notifications/notification_panel.cc
+++ b/chrome/browser/chromeos/notifications/notification_panel.cc
@@ -154,7 +154,7 @@ class BalloonSubContainer : public views::View {
// Layout bottom up
int height = 0;
for (int i = child_count() - 1; i >= 0; --i) {
- views::View* child = GetChildViewAt(i);
+ views::View* child = child_at(i);
child->SetBounds(0, height, child->width(), child->height());
height += child->height() + margin_;
}
@@ -166,7 +166,7 @@ class BalloonSubContainer : public views::View {
int height = 0;
int max_width = 0;
for (int i = child_count() - 1; i >= 0; --i) {
- views::View* child = GetChildViewAt(i);
+ views::View* child = child_at(i);
height += child->height() + margin_;
max_width = std::max(max_width, child->width());
}
@@ -181,8 +181,7 @@ class BalloonSubContainer : public views::View {
gfx::Rect GetNewBounds() {
gfx::Rect rect;
for (int i = child_count() - 1; i >= 0; --i) {
- BalloonViewImpl* view =
- static_cast<BalloonViewImpl*>(GetChildViewAt(i));
+ BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
if (!view->stale()) {
if (rect.IsEmpty()) {
rect = view->bounds();
@@ -198,8 +197,7 @@ class BalloonSubContainer : public views::View {
int GetNewCount() {
int count = 0;
for (int i = child_count() - 1; i >= 0; --i) {
- BalloonViewImpl* view =
- static_cast<BalloonViewImpl*>(GetChildViewAt(i));
+ BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
if (!view->stale())
count++;
}
@@ -209,24 +207,21 @@ class BalloonSubContainer : public views::View {
// Make all notifications stale.
void MakeAllStale() {
for (int i = child_count() - 1; i >= 0; --i) {
- BalloonViewImpl* view =
- static_cast<BalloonViewImpl*>(GetChildViewAt(i));
+ BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
view->set_stale();
}
}
void DismissAll() {
for (int i = child_count() - 1; i >= 0; --i) {
- BalloonViewImpl* view =
- static_cast<BalloonViewImpl*>(GetChildViewAt(i));
+ BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
view->Close(true);
}
}
BalloonViewImpl* FindBalloonView(const Notification& notification) {
for (int i = child_count() - 1; i >= 0; --i) {
- BalloonViewImpl* view =
- static_cast<BalloonViewImpl*>(GetChildViewAt(i));
+ BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
if (view->IsFor(notification)) {
return view;
}
@@ -238,7 +233,7 @@ class BalloonSubContainer : public views::View {
gfx::Point copy(point);
ConvertPointFromWidget(this, &copy);
for (int i = child_count() - 1; i >= 0; --i) {
- views::View* view = GetChildViewAt(i);
+ views::View* view = child_at(i);
if (view->bounds().Contains(copy))
return static_cast<BalloonViewImpl*>(view);
}
diff --git a/chrome/browser/chromeos/status/status_area_view.cc b/chrome/browser/chromeos/status/status_area_view.cc
index b1b07f6..161edfb 100644
--- a/chrome/browser/chromeos/status/status_area_view.cc
+++ b/chrome/browser/chromeos/status/status_area_view.cc
@@ -60,7 +60,7 @@ gfx::Size StatusAreaView::GetPreferredSize() {
int result_h = 0;
for (int i = 0; i < child_count(); i++) {
- views::View* cur = GetChildViewAt(i);
+ views::View* cur = child_at(i);
gfx::Size cur_size = cur->GetPreferredSize();
if (cur->IsVisible() && !cur_size.IsEmpty()) {
if (result_w == 0)
@@ -78,7 +78,7 @@ gfx::Size StatusAreaView::GetPreferredSize() {
void StatusAreaView::Layout() {
int cur_x = kSeparation;
for (int i = 0; i < child_count(); i++) {
- views::View* cur = GetChildViewAt(i);
+ views::View* cur = child_at(i);
gfx::Size cur_size = cur->GetPreferredSize();
if (cur->IsVisible() && !cur_size.IsEmpty()) {
int cur_y = (height() - cur_size.height()) / 2;
diff --git a/chrome/browser/ui/touch/frame/keyboard_container_view.cc b/chrome/browser/ui/touch/frame/keyboard_container_view.cc
index 64162a6..b8c0b80 100644
--- a/chrome/browser/ui/touch/frame/keyboard_container_view.cc
+++ b/chrome/browser/ui/touch/frame/keyboard_container_view.cc
@@ -17,7 +17,7 @@ namespace {
void MakeViewHierarchyUnfocusable(views::View* view) {
view->set_focusable(false);
for (int i = 0; i < view->child_count(); ++i) {
- MakeViewHierarchyUnfocusable(view->GetChildViewAt(i));
+ MakeViewHierarchyUnfocusable(view->child_at(i));
}
}
diff --git a/chrome/browser/ui/views/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility_event_router_views.cc
index 218008e..ce29967 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views.cc
@@ -318,7 +318,7 @@ void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
int* index,
int* count) {
for (int i = 0; i < menu->child_count(); ++i) {
- views::View* child = menu->GetChildViewAt(i);
+ views::View* child = menu->child_at(i);
int previous_count = *count;
RecursiveGetMenuItemIndexAndCount(child, item, index, count);
if (child->GetClassName() == views::MenuItemView::kViewClassName &&
@@ -342,7 +342,7 @@ std::string AccessibilityEventRouterViews::RecursiveGetStaticText(
return UTF16ToUTF8(state.name);
for (int i = 0; i < view->child_count(); ++i) {
- views::View* child = view->GetChildViewAt(i);
+ views::View* child = view->child_at(i);
std::string result = RecursiveGetStaticText(child);
if (!result.empty())
return result;
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index b364a5f..92c55cc 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -274,7 +274,7 @@ void AutocompletePopupContentsView::LayoutChildren() {
gfx::Rect contents_rect = GetContentsBounds();
int top = contents_rect.y();
for (int i = 0; i < child_count(); ++i) {
- View* v = GetChildViewAt(i);
+ View* v = child_at(i);
if (v->IsVisible()) {
v->SetBounds(contents_rect.x(), top, contents_rect.width(),
v->GetPreferredSize().height());
@@ -291,7 +291,7 @@ bool AutocompletePopupContentsView::IsOpen() const {
}
void AutocompletePopupContentsView::InvalidateLine(size_t line) {
- GetChildViewAt(static_cast<int>(line))->SchedulePaint();
+ child_at(static_cast<int>(line))->SchedulePaint();
}
void AutocompletePopupContentsView::UpdatePopupAppearance() {
@@ -323,13 +323,13 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() {
CreateResultView(this, i, result_font_, result_bold_font_);
AddChildViewAt(result_view, static_cast<int>(i));
} else {
- result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i));
+ result_view = static_cast<AutocompleteResultView*>(child_at(i));
result_view->SetVisible(true);
}
result_view->SetMatch(GetMatchAtIndex(i));
}
for (size_t i = model_->result().size(); i < child_rv_count; ++i)
- GetChildViewAt(i)->SetVisible(false);
+ child_at(i)->SetVisible(false);
PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) {
@@ -515,7 +515,7 @@ int AutocompletePopupContentsView::CalculatePopupHeight() {
DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
int popup_height = 0;
for (size_t i = 0; i < model_->result().size(); ++i)
- popup_height += GetChildViewAt(i)->GetPreferredSize().height();
+ popup_height += child_at(i)->GetPreferredSize().height();
return popup_height +
(opt_in_view_ ? opt_in_view_->GetPreferredSize().height() : 0);
}
@@ -659,7 +659,7 @@ size_t AutocompletePopupContentsView::GetIndexForPoint(
int nb_match = model_->result().size();
DCHECK(nb_match <= child_count());
for (int i = 0; i < nb_match; ++i) {
- views::View* child = GetChildViewAt(i);
+ views::View* child = child_at(i);
gfx::Point point_in_child_coords(point);
View::ConvertPointToView(this, child, &point_in_child_coords);
if (child->HitTest(point_in_child_coords))
diff --git a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc
index 0ea17b6..db590db 100644
--- a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc
@@ -107,7 +107,7 @@ int TouchAutocompletePopupContentsView::CalculatePopupHeight() {
int popup_height = 0;
for (size_t i = 0; i < model_->result().size(); ++i) {
popup_height = std::max(popup_height,
- GetChildViewAt(i)->GetPreferredSize().height());
+ child_at(i)->GetPreferredSize().height());
}
popup_height = std::max(popup_height, opt_in_view_ ?
opt_in_view_->GetPreferredSize().height() : 0);
@@ -126,8 +126,8 @@ std::vector<views::View*>
TouchAutocompletePopupContentsView::GetVisibleChildren() {
std::vector<View*> visible_children;
for (int i = 0; i < child_count(); ++i) {
- View* v = GetChildViewAt(i);
- if (GetChildViewAt(i)->IsVisible())
+ View* v = child_at(i);
+ if (child_at(i)->IsVisible())
visible_children.push_back(v);
}
return visible_children;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
index ea82275..85c3c5c 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc
@@ -42,7 +42,7 @@ BookmarkBarInstructionsView::BookmarkBarInstructionsView(Delegate* delegate)
gfx::Size BookmarkBarInstructionsView::GetPreferredSize() {
int ascent = 0, descent = 0, height = 0, width = 0;
for (int i = 0; i < child_count(); ++i) {
- views::View* view = GetChildViewAt(i);
+ views::View* view = child_at(i);
gfx::Size pref = view->GetPreferredSize();
int baseline = view->GetBaseline();
if (baseline != -1) {
@@ -63,7 +63,7 @@ void BookmarkBarInstructionsView::Layout() {
int remaining_width = width();
int x = 0;
for (int i = 0; i < child_count(); ++i) {
- views::View* view = GetChildViewAt(i);
+ views::View* view = child_at(i);
gfx::Size pref = view->GetPreferredSize();
int baseline = view->GetBaseline();
int y;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 76f1663..8a54bef 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -434,7 +434,7 @@ void BookmarkBarView::SetProfile(Profile* profile) {
// Remove any existing bookmark buttons.
while (GetBookmarkButtonCount())
- delete GetChildViewAt(0);
+ delete child_at(0);
model_ = profile_->GetBookmarkModel();
if (model_) {
@@ -496,7 +496,7 @@ const BookmarkNode* BookmarkBarView::GetNodeForButtonAtModelIndex(
// Check the buttons first.
for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
- views::View* child = GetChildViewAt(i);
+ views::View* child = child_at(i);
if (!child->IsVisible())
break;
if (child->bounds().Contains(adjusted_loc))
@@ -528,7 +528,7 @@ views::MenuButton* BookmarkBarView::GetMenuButtonForNode(
int index = model_->GetBookmarkBarNode()->GetIndexOf(node);
if (index == -1 || !node->is_folder())
return NULL;
- return static_cast<views::MenuButton*>(GetChildViewAt(index));
+ return static_cast<views::MenuButton*>(child_at(index));
}
void BookmarkBarView::GetAnchorPositionForButton(
@@ -966,7 +966,7 @@ void BookmarkBarView::BookmarkNodeChildrenReordered(BookmarkModel* model,
// Remove the existing buttons.
while (GetBookmarkButtonCount()) {
- views::View* button = GetChildViewAt(0);
+ views::View* button = child_at(0);
RemoveChildView(button);
MessageLoop::current()->DeleteSoon(FROM_HERE, button);
}
@@ -1212,7 +1212,7 @@ int BookmarkBarView::GetBookmarkButtonCount() {
views::TextButton* BookmarkBarView::GetBookmarkButton(int index) {
DCHECK(index >= 0 && index < GetBookmarkButtonCount());
- return static_cast<views::TextButton*>(GetChildViewAt(index));
+ return static_cast<views::TextButton*>(child_at(index));
}
int BookmarkBarView::GetFirstHiddenNodeIndex() {
@@ -1349,7 +1349,7 @@ void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkModel* model,
return;
}
DCHECK(index >= 0 && index < GetBookmarkButtonCount());
- views::View* button = GetChildViewAt(index);
+ views::View* button = child_at(index);
RemoveChildView(button);
MessageLoop::current()->DeleteSoon(FROM_HERE, button);
Layout();
@@ -1554,7 +1554,7 @@ void BookmarkBarView::StartThrobbing(const BookmarkNode* node,
// Node is hidden, animate the overflow button.
throbbing_view_ = overflow_button_;
} else if (!overflow_only) {
- throbbing_view_ = static_cast<CustomButton*>(GetChildViewAt(index));
+ throbbing_view_ = static_cast<CustomButton*>(child_at(index));
}
} else if (!overflow_only) {
throbbing_view_ = other_bookmarked_button_;
@@ -1584,7 +1584,7 @@ views::CustomButton* BookmarkBarView::DetermineViewToThrobFromRemove(
// Node is hidden, animate the overflow button.
return overflow_button_;
}
- return static_cast<CustomButton*>(GetChildViewAt(old_index_on_bb));
+ return static_cast<CustomButton*>(child_at(old_index_on_bb));
}
// Node wasn't on the bookmark bar, use the other bookmark button.
return other_bookmarked_button_;
@@ -1674,7 +1674,7 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
instructions_->SetVisible(false);
for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
- views::View* child = GetChildViewAt(i);
+ views::View* child = child_at(i);
gfx::Size pref = child->GetPreferredSize();
int next_x = x + pref.width() + kButtonPadding;
if (!compute_bounds_only) {
@@ -1688,7 +1688,7 @@ gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
// Layout the right side of the bar.
const bool all_visible =
(GetBookmarkButtonCount() == 0 ||
- GetChildViewAt(GetBookmarkButtonCount() - 1)->IsVisible());
+ child_at(GetBookmarkButtonCount() - 1)->IsVisible());
// Layout the right side buttons.
if (!compute_bounds_only)
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index 07d76da..225284f 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -839,7 +839,7 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase {
ASSERT_TRUE(scroll_container != NULL);
scroll_container = scroll_container->parent();
ASSERT_TRUE(scroll_container != NULL);
- views::View* scroll_down_button = scroll_container->GetChildViewAt(1);
+ views::View* scroll_down_button = scroll_container->child_at(1);
ASSERT_TRUE(scroll_down_button);
gfx::Point loc(scroll_down_button->width() / 2,
scroll_down_button->height() / 2);
@@ -1188,9 +1188,8 @@ class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase {
views::SubmenuView* submenu = menu->GetSubmenu();
views::View* separator_view = NULL;
for (int i = 0; i < submenu->child_count(); ++i) {
- if (submenu->GetChildViewAt(i)->id() !=
- views::MenuItemView::kMenuItemViewID) {
- separator_view = submenu->GetChildViewAt(i);
+ if (submenu->child_at(i)->id() != views::MenuItemView::kMenuItemViewID) {
+ separator_view = submenu->child_at(i);
break;
}
}
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index 4c4f6a6..02b2cdf7 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -335,7 +335,7 @@ void Bubble::OnActivate(UINT action, BOOL minimized, HWND window) {
GetWidget()->Close();
} else if (action == WA_ACTIVE) {
DCHECK(GetWidget()->GetRootView()->has_children());
- GetWidget()->GetRootView()->GetChildViewAt(0)->RequestFocus();
+ GetWidget()->GetRootView()->child_at(0)->RequestFocus();
}
}
#elif defined(TOOLKIT_USES_GTK)
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index 4da7f4d..62c66b6 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -74,7 +74,7 @@ views::View* BrowserFrame::GetFrameView() const {
void BrowserFrame::TabStripDisplayModeChanged() {
if (GetRootView()->has_children()) {
// Make sure the child of the root view gets Layout again.
- GetRootView()->GetChildViewAt(0)->InvalidateLayout();
+ GetRootView()->child_at(0)->InvalidateLayout();
}
GetRootView()->Layout();
native_browser_frame_->TabStripDisplayModeChanged();
diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
index 96d302c..b1e7d87 100644
--- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc
@@ -53,7 +53,7 @@ int BrowserFrameGtk::GetMinimizeButtonOffset() const {
void BrowserFrameGtk::TabStripDisplayModeChanged() {
if (GetWidget()->GetRootView()->has_children()) {
// Make sure the child of the root view gets Layout again.
- GetWidget()->GetRootView()->GetChildViewAt(0)->InvalidateLayout();
+ GetWidget()->GetRootView()->child_at(0)->InvalidateLayout();
}
GetWidget()->GetRootView()->Layout();
}
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 8ec5e24..4e852a1 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1821,7 +1821,7 @@ void BrowserView::PaintChildren(gfx::Canvas* canvas) {
// Paint the |infobar_container_| last so that it may paint its
// overlapping tabs.
for (int i = 0; i < child_count(); ++i) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
if (child != infobar_container_)
child->Paint(canvas);
}
@@ -1870,7 +1870,7 @@ bool BrowserView::DrawInfoBarArrows(int* x) const {
bool BrowserView::SplitHandleMoved(views::SingleSplitView* view) {
for (int i = 0; i < view->child_count(); ++i)
- view->GetChildViewAt(i)->InvalidateLayout();
+ view->child_at(i)->InvalidateLayout();
SchedulePaint();
Layout();
return false;
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index d94b776..e78ac75 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -546,7 +546,7 @@ void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
views::SingleSplitView* sidebar_split = browser_view_->sidebar_split_;
if (sidebar_split) {
- DCHECK(sidebar_split == contents_split_->GetChildViewAt(0));
+ DCHECK(sidebar_split == contents_split_->child_at(0));
sidebar_split->CalculateChildrenBounds(
sidebar_split_bounds, &contents_bounds, &sidebar_bounds);
} else {
@@ -599,14 +599,14 @@ int BrowserViewLayout::GetTopMarginForActiveContent() {
return 0;
}
- if (contents_split_->GetChildViewAt(1) &&
- contents_split_->GetChildViewAt(1)->IsVisible())
+ if (contents_split_->child_at(1) &&
+ contents_split_->child_at(1)->IsVisible())
return 0;
if (SidebarManager::IsSidebarAllowed()) {
- views::View* sidebar_split = contents_split_->GetChildViewAt(0);
- if (sidebar_split->GetChildViewAt(1) &&
- sidebar_split->GetChildViewAt(1)->IsVisible())
+ views::View* sidebar_split = contents_split_->child_at(0);
+ if (sidebar_split->child_count() >= 2 &&
+ sidebar_split->child_at(1)->IsVisible())
return 0;
}
diff --git a/chrome/browser/ui/views/infobars/infobar_container_view.cc b/chrome/browser/ui/views/infobars/infobar_container_view.cc
index d9e0e14..1ae3dd5 100644
--- a/chrome/browser/ui/views/infobars/infobar_container_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_container_view.cc
@@ -32,7 +32,7 @@ void InfoBarContainerView::Layout() {
int top = GetVerticalOverlap(NULL);
for (int i = 0; i < child_count(); ++i) {
- InfoBarView* child = static_cast<InfoBarView*>(GetChildViewAt(i));
+ InfoBarView* child = static_cast<InfoBarView*>(child_at(i));
top -= child->arrow_height();
int child_height = child->total_height();
child->SetBounds(0, top, width(), child_height);
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
index 15cfbda..b979c75 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc
@@ -230,7 +230,7 @@ void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
AddChildView(close_button_);
} else if ((close_button_ != NULL) && (parent == this) &&
(child != close_button_) && (close_button_->parent() == this) &&
- (GetChildViewAt(child_count() - 1) != close_button_)) {
+ (child_at(child_count() - 1) != close_button_)) {
// For accessibility, ensure the close button is the last child view.
RemoveChildView(close_button_);
AddChildView(close_button_);
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index c08882f..e84ac23 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -351,7 +351,7 @@ class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
// All buttons are given the same width.
int width = GetMaxChildViewPreferredWidth();
for (int i = 0; i < child_count(); ++i)
- GetChildViewAt(i)->SetBounds(i * width, 0, width, height());
+ child_at(i)->SetBounds(i * width, 0, width, height());
}
// ButtonListener
@@ -364,7 +364,7 @@ class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
int GetMaxChildViewPreferredWidth() {
int width = 0;
for (int i = 0; i < child_count(); ++i)
- width = std::max(width, GetChildViewAt(i)->GetPreferredSize().width());
+ width = std::max(width, child_at(i)->GetPreferredSize().width());
return width;
}
diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc
index 77e4479..3a32538 100644
--- a/chrome/test/interactive_ui/view_event_test_base.cc
+++ b/chrome/test/interactive_ui/view_event_test_base.cc
@@ -35,7 +35,7 @@ class TestView : public views::View {
}
virtual void Layout() {
- View* child_view = GetChildViewAt(0);
+ View* child_view = child_at(0);
child_view->SetBounds(0, 0, width(), height());
}
diff --git a/views/accessibility/native_view_accessibility_win.cc b/views/accessibility/native_view_accessibility_win.cc
index c75cb07..12a0b46 100644
--- a/views/accessibility/native_view_accessibility_win.cc
+++ b/views/accessibility/native_view_accessibility_win.cc
@@ -127,7 +127,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate(
if (nav_dir == NAVDIR_LASTCHILD)
child_id = view_->child_count() - 1;
- views::View* child = view_->GetChildViewAt(child_id);
+ views::View* child = view_->child_at(child_id);
end->vt = VT_DISPATCH;
end->pdispVal = child->GetNativeViewAccessible();
end->pdispVal->AddRef();
@@ -162,7 +162,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate(
}
}
- views::View* child = parent->GetChildViewAt(view_index);
+ views::View* child = parent->child_at(view_index);
end->pdispVal = child->GetNativeViewAccessible();
end->vt = VT_DISPATCH;
end->pdispVal->AddRef();
@@ -224,7 +224,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child,
int child_id_as_index = child_id - 1;
if (child_id_as_index < view_->child_count()) {
// Note: child_id is a one based index when indexing children.
- child_view = view_->GetChildViewAt(child_id_as_index);
+ child_view = view_->child_at(child_id_as_index);
} else {
// Attempt to retrieve a child view with the specified id.
child_view = view_->GetViewByID(child_id);
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index d5e3305..b2038da 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -82,7 +82,7 @@ static View* GetFirstHotTrackedView(View* view) {
return view;
for (int i = 0; i < view->child_count(); ++i) {
- View* hot_view = GetFirstHotTrackedView(view->GetChildViewAt(i));
+ View* hot_view = GetFirstHotTrackedView(view->child_at(i));
if (hot_view)
return hot_view;
}
@@ -97,15 +97,13 @@ static View* GetFirstHotTrackedView(View* view) {
static View* GetFirstFocusableView(View* view, int start, bool forward) {
if (forward) {
for (int i = start == -1 ? 0 : start; i < view->child_count(); ++i) {
- View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1,
- forward);
+ View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward);
if (deepest)
return deepest;
}
} else {
for (int i = start == -1 ? view->child_count() - 1 : start; i >= 0; --i) {
- View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1,
- forward);
+ View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward);
if (deepest)
return deepest;
}
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index a20e725..6c70190 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -289,7 +289,7 @@ void MenuItemView::RemoveMenuItemAt(int index) {
DCHECK_LE(0, index);
DCHECK_GT(submenu_->child_count(), index);
- View* item = submenu_->GetChildViewAt(index);
+ View* item = submenu_->child_at(index);
DCHECK(item);
submenu_->RemoveChildView(item);
@@ -446,7 +446,7 @@ MenuItemView* MenuItemView::GetMenuItemByID(int id) {
if (!HasSubmenu())
return NULL;
for (int i = 0; i < GetSubmenu()->child_count(); ++i) {
- View* child = GetSubmenu()->GetChildViewAt(i);
+ View* child = GetSubmenu()->child_at(i);
if (child->id() == MenuItemView::kMenuItemViewID) {
MenuItemView* result = static_cast<MenuItemView*>(child)->
GetMenuItemByID(id);
@@ -487,7 +487,7 @@ void MenuItemView::Layout() {
if (child_count() == 1 && GetTitle().size() == 0) {
// We only have one child and no title so let the view take over all the
// space.
- View* child = GetChildViewAt(0);
+ View* child = child_at(0);
gfx::Size size = child->GetPreferredSize();
child->SetBounds(label_start_, GetTopMargin(), size.width(), size.height());
} else {
@@ -495,7 +495,7 @@ void MenuItemView::Layout() {
// 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) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
int width = child->GetPreferredSize().width();
child->SetBounds(x - width, 0, width, height());
x -= width - kChildXPadding;
@@ -667,7 +667,7 @@ void MenuItemView::RemoveEmptyMenus() {
// Iterate backwards as we may end up removing views, which alters the child
// view count.
for (int i = submenu_->child_count() - 1; i >= 0; --i) {
- View* child = submenu_->GetChildViewAt(i);
+ View* child = submenu_->child_at(i);
if (child->id() == MenuItemView::kMenuItemViewID) {
MenuItemView* menu_item = static_cast<MenuItemView*>(child);
if (menu_item->HasSubmenu())
@@ -745,7 +745,7 @@ gfx::Size MenuItemView::GetChildPreferredSize() {
return gfx::Size();
if (GetTitle().size() == 0 && child_count() == 1) {
- View* child = GetChildViewAt(0);
+ View* child = child_at(0);
return child->GetPreferredSize();
}
@@ -753,7 +753,7 @@ gfx::Size MenuItemView::GetChildPreferredSize() {
for (int i = 0; i < child_count(); ++i) {
if (i)
width += kChildXPadding;
- width += GetChildViewAt(i)->GetPreferredSize().width();
+ width += child_at(i)->GetPreferredSize().width();
}
// Return a height of 0 to indicate that we should use the title height
// instead.
diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc
index 6aed7cf..5f1b94e 100644
--- a/views/controls/menu/menu_scroll_view_container.cc
+++ b/views/controls/menu/menu_scroll_view_container.cc
@@ -150,7 +150,7 @@ class MenuScrollViewContainer::MenuScrollView : public View {
// Returns the contents, which is the SubmenuView.
View* GetContents() {
- return GetChildViewAt(0);
+ return child_at(0);
}
private:
diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc
index 84e4cd1..987cf15 100644
--- a/views/controls/menu/submenu_view.cc
+++ b/views/controls/menu/submenu_view.cc
@@ -55,7 +55,7 @@ SubmenuView::~SubmenuView() {
int SubmenuView::GetMenuItemCount() {
int count = 0;
for (int i = 0; i < child_count(); ++i) {
- if (GetChildViewAt(i)->id() == MenuItemView::kMenuItemViewID)
+ if (child_at(i)->id() == MenuItemView::kMenuItemViewID)
count++;
}
return count;
@@ -63,9 +63,9 @@ int SubmenuView::GetMenuItemCount() {
MenuItemView* SubmenuView::GetMenuItemAt(int index) {
for (int i = 0, count = 0; i < child_count(); ++i) {
- if (GetChildViewAt(i)->id() == MenuItemView::kMenuItemViewID &&
+ if (child_at(i)->id() == MenuItemView::kMenuItemViewID &&
count++ == index) {
- return static_cast<MenuItemView*>(GetChildViewAt(i));
+ return static_cast<MenuItemView*>(child_at(i));
}
}
NOTREACHED();
@@ -91,7 +91,7 @@ void SubmenuView::Layout() {
int y = insets.top();
int menu_item_width = width() - insets.width();
for (int i = 0; i < child_count(); ++i) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
if (child->IsVisible()) {
gfx::Size child_pref_size = child->GetPreferredSize();
child->SetBounds(x, y, menu_item_width, child_pref_size.height());
@@ -108,7 +108,7 @@ gfx::Size SubmenuView::GetPreferredSize() {
int max_width = 0;
int height = 0;
for (int i = 0; i < child_count(); ++i) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
gfx::Size child_pref_size = child->IsVisible() ?
child->GetPreferredSize() : gfx::Size();
max_width = std::max(max_width, child_pref_size.width());
diff --git a/views/controls/scroll_view.cc b/views/controls/scroll_view.cc
index 6a2b912..dd2c650 100644
--- a/views/controls/scroll_view.cc
+++ b/views/controls/scroll_view.cc
@@ -22,7 +22,7 @@ class Viewport : public View {
if (!has_children() || !parent())
return;
- View* contents = GetChildViewAt(0);
+ View* contents = child_at(0);
gfx::Rect scroll_rect(rect);
scroll_rect.Offset(-contents->x(), -contents->y());
static_cast<ScrollView*>(parent())->ScrollContentsRegionToBeVisible(
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index 0397810..5addbb9 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.cc
@@ -49,11 +49,11 @@ void SingleSplitView::Layout() {
CalculateChildrenBounds(bounds(), &leading_bounds, &trailing_bounds);
if (has_children()) {
- if (GetChildViewAt(0)->IsVisible())
- GetChildViewAt(0)->SetBoundsRect(leading_bounds);
+ if (child_at(0)->IsVisible())
+ child_at(0)->SetBoundsRect(leading_bounds);
if (child_count() > 1) {
- if (GetChildViewAt(1)->IsVisible())
- GetChildViewAt(1)->SetBoundsRect(trailing_bounds);
+ if (child_at(1)->IsVisible())
+ child_at(1)->SetBoundsRect(trailing_bounds);
}
}
@@ -76,7 +76,7 @@ gfx::Size SingleSplitView::GetPreferredSize() {
int width = 0;
int height = 0;
for (int i = 0; i < 2 && i < child_count(); ++i) {
- View* view = GetChildViewAt(i);
+ View* view = child_at(i);
gfx::Size pref = view->GetPreferredSize();
if (is_horizontal_) {
width += pref.width();
@@ -110,9 +110,8 @@ void SingleSplitView::CalculateChildrenBounds(
const gfx::Rect& bounds,
gfx::Rect* leading_bounds,
gfx::Rect* trailing_bounds) const {
- bool is_leading_visible = has_children() && GetChildViewAt(0)->IsVisible();
- bool is_trailing_visible =
- child_count() > 1 && GetChildViewAt(1)->IsVisible();
+ bool is_leading_visible = has_children() && child_at(0)->IsVisible();
+ bool is_trailing_visible = child_count() > 1 && child_at(1)->IsVisible();
if (!is_leading_visible && !is_trailing_visible) {
*leading_bounds = gfx::Rect();
@@ -171,7 +170,7 @@ bool SingleSplitView::OnMouseDragged(const MouseEvent& event) {
if (is_horizontal_ && base::i18n::IsRTL())
delta_offset *= -1;
// Honor the minimum size when resizing.
- gfx::Size min = GetChildViewAt(0)->GetMinimumSize();
+ gfx::Size min = child_at(0)->GetMinimumSize();
int new_size = std::max(GetPrimaryAxisSize(min.width(), min.height()),
drag_info_.initial_divider_offset + delta_offset);
@@ -206,15 +205,15 @@ bool SingleSplitView::IsPointInDivider(const gfx::Point& p) {
if (child_count() < 2)
return false;
- if (!GetChildViewAt(0)->IsVisible() || !GetChildViewAt(1)->IsVisible())
+ if (!child_at(0)->IsVisible() || !child_at(1)->IsVisible())
return false;
int divider_relative_offset;
if (is_horizontal_) {
divider_relative_offset =
- p.x() - GetChildViewAt(base::i18n::IsRTL() ? 1 : 0)->width();
+ p.x() - child_at(base::i18n::IsRTL() ? 1 : 0)->width();
} else {
- divider_relative_offset = p.y() - GetChildViewAt(0)->height();
+ divider_relative_offset = p.y() - child_at(0)->height();
}
return (divider_relative_offset >= 0 &&
divider_relative_offset < kDividerSize);
diff --git a/views/controls/single_split_view_unittest.cc b/views/controls/single_split_view_unittest.cc
index f880528..c3375d8 100644
--- a/views/controls/single_split_view_unittest.cc
+++ b/views/controls/single_split_view_unittest.cc
@@ -15,8 +15,8 @@ namespace {
static void VerifySplitViewLayout(const views::SingleSplitView& split) {
ASSERT_EQ(2, split.child_count());
- const views::View* leading = split.GetChildViewAt(0);
- const views::View* trailing = split.GetChildViewAt(1);
+ const views::View* leading = split.child_at(0);
+ const views::View* trailing = split.child_at(1);
if (split.bounds().IsEmpty()) {
EXPECT_TRUE(leading->bounds().IsEmpty());
@@ -113,16 +113,16 @@ TEST(SingleSplitViewTest, Resize) {
}
// Special cases, one of the child views is hidden.
- split.GetChildViewAt(0)->SetVisible(false);
+ split.child_at(0)->SetVisible(false);
split.Layout();
- EXPECT_EQ(split.size(), split.GetChildViewAt(1)->size());
+ EXPECT_EQ(split.size(), split.child_at(1)->size());
- split.GetChildViewAt(0)->SetVisible(true);
- split.GetChildViewAt(1)->SetVisible(false);
+ split.child_at(0)->SetVisible(true);
+ split.child_at(1)->SetVisible(false);
split.Layout();
- EXPECT_EQ(split.size(), split.GetChildViewAt(0)->size());
+ EXPECT_EQ(split.size(), split.child_at(0)->size());
}
}
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
index ac3ff19..37b24d1 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
@@ -205,7 +205,7 @@ View* NativeTabbedPaneGtk::GetTabViewAt(int index) {
Widget* widget = GetWidgetAt(index);
DCHECK(widget);
DCHECK_EQ(1, widget->GetRootView()->child_count());
- return widget->GetRootView()->GetChildViewAt(0);
+ return widget->GetRootView()->child_at(0);
}
void NativeTabbedPaneGtk::OnSwitchPage(int selected_tab_index) {
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
index 829d5a3..5499051 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
@@ -57,7 +57,7 @@ class TabLayout : public LayoutManager {
// Switches to the tab page identified by the given index.
void SwitchToPage(View* host, View* page) {
for (int i = 0; i < host->child_count(); ++i) {
- View* child = host->GetChildViewAt(i);
+ View* child = host->child_at(i);
// The child might not have been laid out yet.
if (child == page)
child->SetBoundsRect(host->GetContentsBounds());
@@ -77,7 +77,7 @@ class TabLayout : public LayoutManager {
virtual void Layout(View* host) {
gfx::Rect bounds(host->GetContentsBounds());
for (int i = 0; i < host->child_count(); ++i) {
- View* child = host->GetChildViewAt(i);
+ View* child = host->child_at(i);
// We only layout visible children, since it may be expensive.
if (child->IsVisible() && child->bounds() != bounds)
child->SetBoundsRect(bounds);
@@ -88,7 +88,7 @@ class TabLayout : public LayoutManager {
// First, query the preferred sizes to determine a good width.
int width = 0;
for (int i = 0; i < host->child_count(); ++i) {
- View* page = host->GetChildViewAt(i);
+ View* page = host->child_at(i);
width = std::max(width, page->GetPreferredSize().width());
}
// After we know the width, decide on the height.
@@ -98,7 +98,7 @@ class TabLayout : public LayoutManager {
virtual int GetPreferredHeightForWidth(View* host, int width) {
int height = 0;
for (int i = 0; i < host->child_count(); ++i) {
- View* page = host->GetChildViewAt(i);
+ View* page = host->child_at(i);
height = std::max(height, page->GetHeightForWidth(width));
}
return height;
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index c14fb4d..f53e67b 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -462,7 +462,7 @@ void NativeTextfieldWin::InitializeAccessibilityInfo() {
// Try to find the name of this text field.
// We expect it to be a Label preceeding this view (if it exists).
string16 name;
- View* label_view = parent->GetChildViewAt(label_index);
+ View* label_view = parent->child_at(label_index);
if (label_view->GetClassName() == Label::kViewClassName) {
ui::AccessibleViewState state;
label_view->GetAccessibleState(&state);
diff --git a/views/examples/scroll_view_example.cc b/views/examples/scroll_view_example.cc
index 29febeb..3f47a15 100644
--- a/views/examples/scroll_view_example.cc
+++ b/views/examples/scroll_view_example.cc
@@ -31,7 +31,7 @@ class ScrollViewExample::ScrollableView : public views::View {
}
void PlaceChildY(int index, int y) {
- views::View* view = GetChildViewAt(index);
+ views::View* view = child_at(index);
gfx::Size size = view->GetPreferredSize();
view->SetBounds(0, y, size.width(), size.height());
}
diff --git a/views/examples/throbber_example.cc b/views/examples/throbber_example.cc
index 9def3ce..495b71f 100644
--- a/views/examples/throbber_example.cc
+++ b/views/examples/throbber_example.cc
@@ -27,7 +27,7 @@ class ThrobberView : public views::View {
}
virtual void Layout() {
- views::View* child = GetChildViewAt(0);
+ views::View* child = child_at(0);
gfx::Size ps = child->GetPreferredSize();
child->SetBounds((width() - ps.width()) / 2,
(height() - ps.height()) / 2,
diff --git a/views/examples/widget_example.cc b/views/examples/widget_example.cc
index 07d21d1..a2c834c 100644
--- a/views/examples/widget_example.cc
+++ b/views/examples/widget_example.cc
@@ -21,7 +21,7 @@ class CenterLayout : public views::LayoutManager {
// Overridden from LayoutManager:
virtual void Layout(views::View* host) {
- views::View* child = host->GetChildViewAt(0);
+ views::View* child = host->child_at(0);
gfx::Size size = child->GetPreferredSize();
child->SetBounds((host->width() - size.width()) / 2,
(host->height() - size.height()) / 2,
diff --git a/views/focus/focus_search.cc b/views/focus/focus_search.cc
index eea5f48..cbb95c5 100644
--- a/views/focus/focus_search.cc
+++ b/views/focus/focus_search.cc
@@ -37,10 +37,8 @@ View* FocusSearch::FindNextFocusableView(View* starting_view,
if (!starting_view) {
// Default to the first/last child
- starting_view =
- reverse ?
- root_->GetChildViewAt(root_->child_count() - 1) :
- root_->GetChildViewAt(0);
+ starting_view = reverse ? root_->child_at(root_->child_count() - 1) :
+ root_->child_at(0);
// If there was no starting view, then the one we select is a potential
// focus candidate.
check_starting_view = true;
@@ -159,7 +157,7 @@ View* FocusSearch::FindNextFocusableViewImpl(
// First let's try the left child.
if (can_go_down) {
if (starting_view->has_children()) {
- View* v = FindNextFocusableViewImpl(starting_view->GetChildViewAt(0),
+ View* v = FindNextFocusableViewImpl(starting_view->child_at(0),
true, false, true, skip_group_id,
focus_traversable,
focus_traversable_view);
@@ -225,7 +223,7 @@ View* FocusSearch::FindPreviousFocusableViewImpl(
if (starting_view->has_children()) {
View* view =
- starting_view->GetChildViewAt(starting_view->child_count() - 1);
+ starting_view->child_at(starting_view->child_count() - 1);
View* v = FindPreviousFocusableViewImpl(view, true, false, true,
skip_group_id,
focus_traversable,
diff --git a/views/layout/box_layout.cc b/views/layout/box_layout.cc
index bc9f46a..5441e87 100644
--- a/views/layout/box_layout.cc
+++ b/views/layout/box_layout.cc
@@ -31,7 +31,7 @@ void BoxLayout::Layout(View* host) {
int x = child_area.x();
int y = child_area.y();
for (int i = 0; i < host->child_count(); ++i) {
- View* child = host->GetChildViewAt(i);
+ View* child = host->child_at(i);
if (child->IsVisible()) {
gfx::Rect bounds(x, y, child_area.width(), child_area.height());
gfx::Size size(child->GetPreferredSize());
@@ -52,7 +52,7 @@ gfx::Size BoxLayout::GetPreferredSize(View* host) {
gfx::Rect bounds;
int position = 0;
for (int i = 0; i < host->child_count(); ++i) {
- View* child = host->GetChildViewAt(i);
+ View* child = host->child_at(i);
if (child->IsVisible()) {
gfx::Size size(child->GetPreferredSize());
if (orientation_ == kHorizontal) {
diff --git a/views/layout/fill_layout.cc b/views/layout/fill_layout.cc
index 6fbfe4d..13fbcce 100644
--- a/views/layout/fill_layout.cc
+++ b/views/layout/fill_layout.cc
@@ -18,13 +18,13 @@ void FillLayout::Layout(View* host) {
if (!host->has_children())
return;
- View* frame_view = host->GetChildViewAt(0);
+ View* frame_view = host->child_at(0);
frame_view->SetBounds(0, 0, host->width(), host->height());
}
gfx::Size FillLayout::GetPreferredSize(View* host) {
DCHECK_EQ(1, host->child_count());
- return host->GetChildViewAt(0)->GetPreferredSize();
+ return host->child_at(0)->GetPreferredSize();
}
} // namespace views
diff --git a/views/layout/grid_layout_unittest.cc b/views/layout/grid_layout_unittest.cc
index c893d09..542d7c5 100644
--- a/views/layout/grid_layout_unittest.cc
+++ b/views/layout/grid_layout_unittest.cc
@@ -63,7 +63,7 @@ class GridLayoutTest : public testing::Test {
virtual void RemoveAll() {
for (int i = host.child_count() - 1; i >= 0; i--)
- host.RemoveChildView(host.GetChildViewAt(i));
+ host.RemoveChildView(host.child_at(i));
}
void GetPreferredSize() {
@@ -92,7 +92,7 @@ class GridLayoutAlignmentTest : public testing::Test {
virtual void RemoveAll() {
for (int i = host.child_count() - 1; i >= 0; i--)
- host.RemoveChildView(host.GetChildViewAt(i));
+ host.RemoveChildView(host.child_at(i));
}
void TestAlignment(GridLayout::Alignment alignment, gfx::Rect* bounds) {
@@ -402,7 +402,7 @@ TEST_F(GridLayoutTest, FixedSize) {
for (int i = 0; i < column_count; ++i) {
for (int row = 0; row < row_count; ++row) {
- View* view = host.GetChildViewAt(row * column_count + i);
+ View* view = host.child_at(row * column_count + i);
ExpectViewBoundsEquals(
2 + title_width * i + (title_width - pref_width) / 2,
2 + pref_height * row,
diff --git a/views/view.cc b/views/view.cc
index 04cec8f..ace1fcd 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -223,15 +223,6 @@ void View::RemoveAllChildViews(bool delete_children) {
UpdateTooltip();
}
-const View* View::GetChildViewAt(int index) const {
- return index < child_count() ? children_[index] : NULL;
-}
-
-View* View::GetChildViewAt(int index) {
- return
- const_cast<View*>(const_cast<const View*>(this)->GetChildViewAt(index));
-}
-
bool View::Contains(const View* view) const {
for (const View* v = view; v; v = v->parent_) {
if (v == this)
@@ -540,7 +531,7 @@ void View::Layout() {
// just propagate the Layout() call down the hierarchy, so whoever receives
// the call can take appropriate action.
for (int i = 0, count = child_count(); i < count; ++i) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
if (child->needs_layout_ || !layout_manager_.get()) {
child->needs_layout_ = false;
child->Layout();
@@ -588,7 +579,7 @@ const View* View::GetViewByID(int id) const {
return const_cast<View*>(this);
for (int i = 0, count = child_count(); i < count; ++i) {
- const View* view = GetChildViewAt(i)->GetViewByID(id);
+ const View* view = child_at(i)->GetViewByID(id);
if (view)
return view;
}
@@ -618,7 +609,7 @@ void View::GetViewsInGroup(int group, Views* views) {
views->push_back(this);
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->GetViewsInGroup(group, views);
+ child_at(i)->GetViewsInGroup(group, views);
}
View* View::GetSelectedViewForGroup(int group) {
@@ -801,7 +792,7 @@ View* View::GetEventHandlerForPoint(const gfx::Point& point) {
// Walk the child Views recursively looking for the View that most
// tightly encloses the specified point.
for (int i = child_count() - 1; i >= 0; --i) {
- View* child = GetChildViewAt(i);
+ View* child = child_at(i);
if (!child->IsVisible())
continue;
@@ -1137,14 +1128,8 @@ void View::NativeViewHierarchyChanged(bool attached,
// Painting --------------------------------------------------------------------
void View::PaintChildren(gfx::Canvas* canvas) {
- for (int i = 0, count = child_count(); i < count; ++i) {
- View* child = GetChildViewAt(i);
- if (!child) {
- NOTREACHED() << "Should not have a NULL child View for index in bounds";
- continue;
- }
- child->Paint(canvas);
- }
+ for (int i = 0, count = child_count(); i < count; ++i)
+ child_at(i)->Paint(canvas);
}
void View::OnPaint(gfx::Canvas* canvas) {
@@ -1180,7 +1165,7 @@ void View::PaintComposite() {
}
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->PaintComposite();
+ child_at(i)->PaintComposite();
}
void View::SchedulePaintInternal(const gfx::Rect& rect) {
@@ -1205,7 +1190,7 @@ void View::PaintToLayer(const gfx::Rect& dirty_region) {
} else {
// Forward to all children as a descendant may be dirty and have a layer.
for (int i = child_count() - 1; i >= 0; --i) {
- View* child_view = GetChildViewAt(i);
+ View* child_view = child_at(i);
gfx::Rect child_dirty_rect = dirty_region;
child_dirty_rect.Offset(-child_view->GetMirroredX(), -child_view->y());
@@ -1214,7 +1199,7 @@ void View::PaintToLayer(const gfx::Rect& dirty_region) {
child_dirty_rect);
if (!child_dirty_rect.IsEmpty())
- GetChildViewAt(i)->PaintToLayer(child_dirty_rect);
+ child_at(i)->PaintToLayer(child_dirty_rect);
}
}
}
@@ -1292,7 +1277,7 @@ void View::CreateLayerIfNecessary() {
CreateLayer();
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->CreateLayerIfNecessary();
+ child_at(i)->CreateLayerIfNecessary();
}
void View::MoveLayerToParent(ui::Layer* parent_layer,
@@ -1306,13 +1291,13 @@ void View::MoveLayerToParent(ui::Layer* parent_layer,
gfx::Rect(local_point.x(), local_point.y(), width(), height()));
} else {
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->MoveLayerToParent(parent_layer, local_point);
+ child_at(i)->MoveLayerToParent(parent_layer, local_point);
}
}
void View::DestroyLayerRecurse() {
for (int i = child_count() - 1; i >= 0; --i)
- GetChildViewAt(i)->DestroyLayerRecurse();
+ child_at(i)->DestroyLayerRecurse();
DestroyLayer();
}
@@ -1324,7 +1309,7 @@ void View::UpdateLayerBounds(const gfx::Point& offset) {
} else {
gfx::Point new_offset(offset.x() + x(), offset.y() + y());
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->UpdateLayerBounds(new_offset);
+ child_at(i)->UpdateLayerBounds(new_offset);
}
}
@@ -1482,7 +1467,7 @@ void View::DoRemoveChildView(View* view,
void View::PropagateRemoveNotifications(View* parent) {
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->PropagateRemoveNotifications(parent);
+ child_at(i)->PropagateRemoveNotifications(parent);
for (View* v = this; v; v = v->parent_)
v->ViewHierarchyChangedImpl(true, false, parent, this);
@@ -1490,7 +1475,7 @@ void View::PropagateRemoveNotifications(View* parent) {
void View::PropagateAddNotifications(View* parent, View* child) {
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->PropagateAddNotifications(parent, child);
+ child_at(i)->PropagateAddNotifications(parent, child);
ViewHierarchyChangedImpl(true, true, parent, child);
}
@@ -1498,7 +1483,7 @@ void View::PropagateNativeViewHierarchyChanged(bool attached,
gfx::NativeView native_view,
internal::RootView* root_view) {
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->PropagateNativeViewHierarchyChanged(attached,
+ child_at(i)->PropagateNativeViewHierarchyChanged(attached,
native_view,
root_view);
NativeViewHierarchyChanged(attached, native_view, root_view);
@@ -1533,7 +1518,7 @@ void View::ViewHierarchyChangedImpl(bool register_accelerators,
void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
for (int i = 0, count = child_count(); i < count; ++i)
- GetChildViewAt(i)->PropagateVisibilityNotifications(start, is_visible);
+ child_at(i)->PropagateVisibilityNotifications(start, is_visible);
VisibilityChangedImpl(start, is_visible);
}
@@ -1608,7 +1593,7 @@ void View::RegisterChildrenForVisibleBoundsNotification(View* view) {
if (view->NeedsNotificationWhenVisibleBoundsChange())
view->RegisterForVisibleBoundsNotification();
for (int i = 0; i < view->child_count(); ++i)
- RegisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i));
+ RegisterChildrenForVisibleBoundsNotification(view->child_at(i));
}
// static
@@ -1616,7 +1601,7 @@ void View::UnregisterChildrenForVisibleBoundsNotification(View* view) {
if (view->NeedsNotificationWhenVisibleBoundsChange())
view->UnregisterForVisibleBoundsNotification();
for (int i = 0; i < view->child_count(); ++i)
- UnregisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i));
+ UnregisterChildrenForVisibleBoundsNotification(view->child_at(i));
}
void View::RegisterForVisibleBoundsNotification() {
@@ -1958,13 +1943,13 @@ void View::InitFocusSiblings(View* v, int index) {
void View::PropagateThemeChanged() {
for (int i = child_count() - 1; i >= 0; --i)
- GetChildViewAt(i)->PropagateThemeChanged();
+ child_at(i)->PropagateThemeChanged();
OnThemeChanged();
}
void View::PropagateLocaleChanged() {
for (int i = child_count() - 1; i >= 0; --i)
- GetChildViewAt(i)->PropagateLocaleChanged();
+ child_at(i)->PropagateLocaleChanged();
OnLocaleChanged();
}
@@ -2042,7 +2027,7 @@ std::string View::PrintViewGraph(bool first) {
// Children.
for (int i = 0, count = child_count(); i < count; ++i)
- result.append(GetChildViewAt(i)->PrintViewGraph(false));
+ result.append(child_at(i)->PrintViewGraph(false));
if (first)
result.append("}\n");
diff --git a/views/view.h b/views/view.h
index 879242e..a277a69 100644
--- a/views/view.h
+++ b/views/view.h
@@ -13,6 +13,7 @@
#include <vector>
#include "base/i18n/rtl.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "ui/base/dragdrop/os_exchange_data.h"
@@ -136,13 +137,20 @@ class View : public AcceleratorTarget {
// the views are deleted, unless marked as not parent owned.
void RemoveAllChildViews(bool delete_children);
- // Returns the child view at |index|.
- const View* GetChildViewAt(int index) const;
- View* GetChildViewAt(int index);
-
- // Returns the number of child views.
+ // STL-style accessors.
+ Views::const_iterator children_begin() { return children_.begin(); }
+ Views::const_iterator children_end() { return children_.end(); }
+ Views::const_reverse_iterator children_rbegin() { return children_.rbegin(); }
+ Views::const_reverse_iterator children_rend() { return children_.rend(); }
int child_count() const { return static_cast<int>(children_.size()); }
bool has_children() const { return !children_.empty(); }
+ View* child_at(int index) {
+ DCHECK_LT(index, child_count());
+ return children_[index];
+ }
+ const View* child_at(int index) const {
+ return const_cast<View*>(const_cast<const View*>(this))->child_at(index);
+ }
// Returns the parent view.
const View* parent() const { return parent_; }
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 83415a9..c3e0f12 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -72,7 +72,7 @@ void RootView::SetContentsView(View* contents_view) {
}
View* RootView::GetContentsView() {
- return child_count() > 0 ? GetChildViewAt(0) : NULL;
+ return child_count() > 0 ? child_at(0) : NULL;
}
void RootView::NotifyNativeViewHierarchyChanged(bool attached,