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() { ...@@ -491,9 +491,7 @@ void MediaNotificationView::UpdateForegroundColor() {
kMediaButtonIconSize, foreground); kMediaButtonIconSize, foreground);
// Update action buttons. // Update action buttons.
for (int i = 0; i < button_row_->child_count(); ++i) { for (views::View* child : button_row_->children()) {
views::View* child = button_row_->child_at(i);
// Skip the play pause button since it is a special case. // Skip the play pause button since it is a special case.
if (child == play_pause_button_) if (child == play_pause_button_)
continue; continue;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/bind.h" #include "base/bind.h"
#include "base/containers/circular_deque.h"
#include "base/guid.h" #include "base/guid.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/run_loop.h" #include "base/run_loop.h"
...@@ -384,21 +385,19 @@ IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest, ...@@ -384,21 +385,19 @@ IN_PROC_BROWSER_TEST_F(ChromeMimeHandlerViewBrowserPluginTest,
ASSERT_TRUE(widget->GetRootView()); ASSERT_TRUE(widget->GetRootView());
// Find WebView corresponding to embedder_web_contents(). // Find WebView corresponding to embedder_web_contents().
const std::string kWebViewClassName = views::WebView::kViewClassName;
views::View* aura_webview = nullptr; views::View* aura_webview = nullptr;
base::queue<views::View*> queue; for (base::circular_deque<views::View*> deque = {widget->GetRootView()};
queue.push(widget->GetRootView()); !deque.empty(); deque.pop_front()) {
while (!queue.empty()) { views::View* current = deque.front();
views::View* current = queue.front(); if (current->GetClassName() == kWebViewClassName &&
queue.pop();
if (std::string(current->GetClassName()).find("WebView") !=
std::string::npos &&
static_cast<views::WebView*>(current)->GetWebContents() == static_cast<views::WebView*>(current)->GetWebContents() ==
embedder_web_contents()) { embedder_web_contents()) {
aura_webview = current; aura_webview = current;
break; break;
} }
for (int i = 0; i < current->child_count(); ++i) const auto& children = current->children();
queue.push(current->child_at(i)); deque.insert(deque.end(), children.cbegin(), children.cend());
} }
ASSERT_TRUE(aura_webview); ASSERT_TRUE(aura_webview);
gfx::Rect bounds(aura_webview->bounds()); gfx::Rect bounds(aura_webview->bounds());
......
...@@ -98,15 +98,11 @@ bool DoesViewHaveAccessibilityErrors(views::View* view, ...@@ -98,15 +98,11 @@ bool DoesViewHaveAccessibilityErrors(views::View* view,
bool DoesViewHaveAccessibilityErrorsRecursive(views::View* view, bool DoesViewHaveAccessibilityErrorsRecursive(views::View* view,
std::string* error_message) { std::string* error_message) {
if (DoesViewHaveAccessibilityErrors(view, error_message)) const auto recurse = [error_message](auto* v) {
return true; return DoesViewHaveAccessibilityErrorsRecursive(v, error_message);
for (int i = 0; i < view->child_count(); ++i) { };
if (DoesViewHaveAccessibilityErrorsRecursive(view->child_at(i), return DoesViewHaveAccessibilityErrors(view, error_message) ||
error_message)) std::any_of(view->children().begin(), view->children().end(), recurse);
return true;
}
return false; // All views in this subtree passed all checker.
} }
} // namespace } // namespace
......
...@@ -436,12 +436,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, ...@@ -436,12 +436,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// the views are deleted, unless marked as not parent owned. // the views are deleted, unless marked as not parent owned.
void RemoveAllChildViews(bool delete_children); void RemoveAllChildViews(bool delete_children);
// TODO(https://crbug.com/940135): Remove child_count() and child_at() in // TODO(https://crbug.com/940135): Remove child_at() in favor of this.
// favor of this.
const Views& children() const { return children_; } const Views& children() const { return children_; }
int child_count() const { return static_cast<int>(children_.size()); }
// Returns the child view at |index|. // Returns the child view at |index|.
const View* child_at(int index) const { const View* child_at(int index) const {
DCHECK_GE(index, 0); 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