Commit 8497a043 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove View::child_count().

Bug: 940135
TBR: wjmaclean
Change-Id: Ibf2be7d23cbca593dc639e2f946c72d32466f18b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574943
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652573}
parent 099cff7a
......@@ -491,9 +491,7 @@ void MediaNotificationView::UpdateForegroundColor() {
kMediaButtonIconSize, foreground);
// Update action buttons.
for (int i = 0; i < button_row_->child_count(); ++i) {
views::View* child = button_row_->child_at(i);
for (views::View* child : button_row_->children()) {
// Skip the play pause button since it is a special case.
if (child == play_pause_button_)
continue;
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
#include "base/containers/circular_deque.h"
#include "base/guid.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
......@@ -384,21 +385,19 @@ IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest,
ASSERT_TRUE(widget->GetRootView());
// Find WebView corresponding to embedder_web_contents().
const std::string kWebViewClassName = views::WebView::kViewClassName;
views::View* aura_webview = nullptr;
base::queue<views::View*> queue;
queue.push(widget->GetRootView());
while (!queue.empty()) {
views::View* current = queue.front();
queue.pop();
if (std::string(current->GetClassName()).find("WebView") !=
std::string::npos &&
for (base::circular_deque<views::View*> deque = {widget->GetRootView()};
!deque.empty(); deque.pop_front()) {
views::View* current = deque.front();
if (current->GetClassName() == kWebViewClassName &&
static_cast<views::WebView*>(current)->GetWebContents() ==
embedder_web_contents()) {
aura_webview = current;
break;
}
for (int i = 0; i < current->child_count(); ++i)
queue.push(current->child_at(i));
const auto& children = current->children();
deque.insert(deque.end(), children.cbegin(), children.cend());
}
ASSERT_TRUE(aura_webview);
gfx::Rect bounds(aura_webview->bounds());
......
......@@ -98,15 +98,11 @@ bool DoesViewHaveAccessibilityErrors(views::View* view,
bool DoesViewHaveAccessibilityErrorsRecursive(views::View* view,
std::string* error_message) {
if (DoesViewHaveAccessibilityErrors(view, error_message))
return true;
for (int i = 0; i < view->child_count(); ++i) {
if (DoesViewHaveAccessibilityErrorsRecursive(view->child_at(i),
error_message))
return true;
}
return false; // All views in this subtree passed all checker.
const auto recurse = [error_message](auto* v) {
return DoesViewHaveAccessibilityErrorsRecursive(v, error_message);
};
return DoesViewHaveAccessibilityErrors(view, error_message) ||
std::any_of(view->children().begin(), view->children().end(), recurse);
}
} // namespace
......
......@@ -436,12 +436,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// the views are deleted, unless marked as not parent owned.
void RemoveAllChildViews(bool delete_children);
// TODO(https://crbug.com/940135): Remove child_count() and child_at() in
// favor of this.
// TODO(https://crbug.com/940135): Remove child_at() in favor of this.
const Views& children() const { return children_; }
int child_count() const { return static_cast<int>(children_.size()); }
// Returns the child view at |index|.
const View* child_at(int index) const {
DCHECK_GE(index, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment