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

Side by Side Diff: ui/views/view.cc

Issue 1485093003: ui: use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review + view.cc fix Created 5 years 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
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/stl_util.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 #include "third_party/skia/include/core/SkRect.h" 19 #include "third_party/skia/include/core/SkRect.h"
19 #include "ui/accessibility/ax_enums.h" 20 #include "ui/accessibility/ax_enums.h"
20 #include "ui/base/cursor/cursor.h" 21 #include "ui/base/cursor/cursor.h"
21 #include "ui/base/dragdrop/drag_drop_types.h" 22 #include "ui/base/dragdrop/drag_drop_types.h"
22 #include "ui/base/ime/input_method.h" 23 #include "ui/base/ime/input_method.h"
23 #include "ui/compositor/clip_recorder.h" 24 #include "ui/compositor/clip_recorder.h"
24 #include "ui/compositor/compositor.h" 25 #include "ui/compositor/compositor.h"
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 ui::LocatedEvent* event) { 1092 ui::LocatedEvent* event) {
1092 event->ConvertLocationToTarget(this, static_cast<View*>(target)); 1093 event->ConvertLocationToTarget(this, static_cast<View*>(target));
1093 } 1094 }
1094 1095
1095 // Accelerators ---------------------------------------------------------------- 1096 // Accelerators ----------------------------------------------------------------
1096 1097
1097 void View::AddAccelerator(const ui::Accelerator& accelerator) { 1098 void View::AddAccelerator(const ui::Accelerator& accelerator) {
1098 if (!accelerators_.get()) 1099 if (!accelerators_.get())
1099 accelerators_.reset(new std::vector<ui::Accelerator>()); 1100 accelerators_.reset(new std::vector<ui::Accelerator>());
1100 1101
1101 if (std::find(accelerators_->begin(), accelerators_->end(), accelerator) == 1102 if (!ContainsValue(*accelerators_.get(), accelerator))
1102 accelerators_->end()) {
1103 accelerators_->push_back(accelerator); 1103 accelerators_->push_back(accelerator);
1104 } 1104
1105 RegisterPendingAccelerators(); 1105 RegisterPendingAccelerators();
1106 } 1106 }
1107 1107
1108 void View::RemoveAccelerator(const ui::Accelerator& accelerator) { 1108 void View::RemoveAccelerator(const ui::Accelerator& accelerator) {
1109 if (!accelerators_.get()) { 1109 if (!accelerators_.get()) {
1110 NOTREACHED() << "Removing non-existing accelerator"; 1110 NOTREACHED() << "Removing non-existing accelerator";
1111 return; 1111 return;
1112 } 1112 }
1113 1113
1114 std::vector<ui::Accelerator>::iterator i( 1114 std::vector<ui::Accelerator>::iterator i(
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 // Message the RootView to do the drag and drop. That way if we're removed 2386 // Message the RootView to do the drag and drop. That way if we're removed
2387 // the RootView can detect it and avoid calling us back. 2387 // the RootView can detect it and avoid calling us back.
2388 gfx::Point widget_location(event.location()); 2388 gfx::Point widget_location(event.location());
2389 ConvertPointToWidget(this, &widget_location); 2389 ConvertPointToWidget(this, &widget_location);
2390 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2390 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2391 // WARNING: we may have been deleted. 2391 // WARNING: we may have been deleted.
2392 return true; 2392 return true;
2393 } 2393 }
2394 2394
2395 } // namespace views 2395 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessibility/native_view_accessibility_auralinux.cc ('k') | ui/wm/core/window_animations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698