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

Side by Side Diff: ui/aura/window.cc

Issue 2926383003: Use ContainsValue() instead of std::find() in ui/aura, ui/display and ui/events (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
21 #include "cc/output/compositor_frame_sink.h" 22 #include "cc/output/compositor_frame_sink.h"
22 #include "ui/aura/client/aura_constants.h" 23 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/client/capture_client.h" 24 #include "ui/aura/client/capture_client.h"
24 #include "ui/aura/client/cursor_client.h" 25 #include "ui/aura/client/cursor_client.h"
25 #include "ui/aura/client/event_client.h" 26 #include "ui/aura/client/event_client.h"
26 #include "ui/aura/client/focus_client.h" 27 #include "ui/aura/client/focus_client.h"
27 #include "ui/aura/client/screen_position_client.h" 28 #include "ui/aura/client/screen_position_client.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 params.target = child; 353 params.target = child;
353 params.new_parent = this; 354 params.new_parent = this;
354 params.old_parent = child->parent(); 355 params.old_parent = child->parent();
355 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; 356 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING;
356 NotifyWindowHierarchyChange(params); 357 NotifyWindowHierarchyChange(params);
357 358
358 Window* old_root = child->GetRootWindow(); 359 Window* old_root = child->GetRootWindow();
359 360
360 port_->OnWillAddChild(child); 361 port_->OnWillAddChild(child);
361 362
362 DCHECK(std::find(children_.begin(), children_.end(), child) == 363 DCHECK(!base::ContainsValue(children_, child));
363 children_.end());
364 if (child->parent()) 364 if (child->parent())
365 child->parent()->RemoveChildImpl(child, this); 365 child->parent()->RemoveChildImpl(child, this);
366 366
367 child->parent_ = this; 367 child->parent_ = this;
368 layer()->Add(child->layer()); 368 layer()->Add(child->layer());
369 369
370 children_.push_back(child); 370 children_.push_back(child);
371 if (layout_manager_) 371 if (layout_manager_)
372 layout_manager_->OnWindowAddedToLayout(child); 372 layout_manager_->OnWindowAddedToLayout(child);
373 for (WindowObserver& observer : observers_) 373 for (WindowObserver& observer : observers_)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } 627 }
628 } 628 }
629 #endif 629 #endif
630 630
631 void Window::RemoveOrDestroyChildren() { 631 void Window::RemoveOrDestroyChildren() {
632 while (!children_.empty()) { 632 while (!children_.empty()) {
633 Window* child = children_[0]; 633 Window* child = children_[0];
634 if (child->owned_by_parent_) { 634 if (child->owned_by_parent_) {
635 delete child; 635 delete child;
636 // Deleting the child so remove it from out children_ list. 636 // Deleting the child so remove it from out children_ list.
637 DCHECK(std::find(children_.begin(), children_.end(), child) == 637 DCHECK(!base::ContainsValue(children_, child));
638 children_.end());
639 } else { 638 } else {
640 // Even if we can't delete the child, we still need to remove it from the 639 // Even if we can't delete the child, we still need to remove it from the
641 // parent so that relevant bookkeeping (parent_ back-pointers etc) are 640 // parent so that relevant bookkeeping (parent_ back-pointers etc) are
642 // updated. 641 // updated.
643 RemoveChild(child); 642 RemoveChild(child);
644 } 643 }
645 } 644 }
646 } 645 }
647 646
648 std::unique_ptr<ui::PropertyData> Window::BeforePropertyChange( 647 std::unique_ptr<ui::PropertyData> Window::BeforePropertyChange(
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 layer_name = "Unnamed Window"; 1074 layer_name = "Unnamed Window";
1076 1075
1077 if (id_ != -1) 1076 if (id_ != -1)
1078 layer_name += " " + base::IntToString(id_); 1077 layer_name += " " + base::IntToString(id_);
1079 1078
1080 layer()->set_name(layer_name); 1079 layer()->set_name(layer_name);
1081 #endif 1080 #endif
1082 } 1081 }
1083 1082
1084 } // namespace aura 1083 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698