Chromium Code Reviews| Index: views/view.cc |
| diff --git a/views/view.cc b/views/view.cc |
| index 45c9a284320e53bd44bb8b919865448a4dcf71b4..fd49d0840deb9d28ac6fed167e64fea914c6f1a9 100644 |
| --- a/views/view.cc |
| +++ b/views/view.cc |
| @@ -873,9 +873,9 @@ void View::AddAccelerator(const Accelerator& accelerator) { |
| if (!accelerators_.get()) |
| accelerators_.reset(new std::vector<Accelerator>()); |
| - std::vector<Accelerator>::iterator iter = |
| - std::find(accelerators_->begin(), accelerators_->end(), accelerator); |
| - DCHECK(iter == accelerators_->end()) |
| + std::vector<Accelerator>::iterator i( |
| + std::find(accelerators_->begin(), accelerators_->end(), accelerator)); |
| + DCHECK(i == accelerators_->end()) |
|
sky
2011/06/09 17:06:34
move the std::find into the DCHECK, eg:
DCHECK(std
tfarina
2011/06/09 17:17:06
Done.
|
| << "Registering the same accelerator multiple times"; |
| accelerators_->push_back(accelerator); |
| @@ -883,16 +883,20 @@ void View::AddAccelerator(const Accelerator& accelerator) { |
| } |
| void View::RemoveAccelerator(const Accelerator& accelerator) { |
| - std::vector<Accelerator>::iterator iter; |
| - if (!accelerators_.get() || |
| - ((iter = std::find(accelerators_->begin(), accelerators_->end(), |
| - accelerator)) == accelerators_->end())) { |
| + if (!accelerators_.get()) { |
| + NOTREACHED() << "Removing non-existing accelerator"; |
| + return; |
| + } |
| + |
| + std::vector<Accelerator>::iterator i( |
| + std::find(accelerators_->begin(), accelerators_->end(), accelerator)); |
| + if (i == accelerators_->end()) { |
| NOTREACHED() << "Removing non-existing accelerator"; |
| return; |
| } |
| - size_t index = iter - accelerators_->begin(); |
| - accelerators_->erase(iter); |
| + size_t index = i - accelerators_->begin(); |
| + accelerators_->erase(i); |
| if (index >= registered_accelerator_count_) { |
| // The accelerator is not registered to FocusManager. |
| return; |
| @@ -1342,7 +1346,7 @@ void View::DoRemoveChildView(View* view, |
| bool update_tool_tip, |
| bool delete_removed_view) { |
| DCHECK(view); |
| - const Views::iterator i = std::find(children_.begin(), children_.end(), view); |
| + const Views::iterator i(std::find(children_.begin(), children_.end(), view)); |
| scoped_ptr<View> view_to_be_deleted; |
| if (i != children_.end()) { |
| if (update_focus_cycle) { |
| @@ -1479,7 +1483,7 @@ void View::BoundsChanged(const gfx::Rect& previous_bounds) { |
| // Notify interested Views that visible bounds within the root view may have |
| // changed. |
| if (descendants_to_notify_.get()) { |
| - for (Views::iterator i = descendants_to_notify_->begin(); |
| + for (Views::iterator i(descendants_to_notify_->begin()); |
| i != descendants_to_notify_->end(); ++i) { |
| (*i)->OnVisibleBoundsChanged(); |
| } |
| @@ -1534,9 +1538,8 @@ void View::AddDescendantToNotify(View* view) { |
| void View::RemoveDescendantToNotify(View* view) { |
| DCHECK(view && descendants_to_notify_.get()); |
| - Views::iterator i = std::find(descendants_to_notify_->begin(), |
| - descendants_to_notify_->end(), |
| - view); |
| + Views::iterator i(std::find( |
| + descendants_to_notify_->begin(), descendants_to_notify_->end(), view)); |
| DCHECK(i != descendants_to_notify_->end()); |
| descendants_to_notify_->erase(i); |
| if (descendants_to_notify_->empty()) |
| @@ -1728,10 +1731,10 @@ void View::RegisterPendingAccelerators() { |
| // Only register accelerators if we are visible. |
| if (!IsVisibleInRootView()) |
| return; |
| - std::vector<Accelerator>::const_iterator iter; |
| - for (iter = accelerators_->begin() + registered_accelerator_count_; |
| - iter != accelerators_->end(); ++iter) { |
| - accelerator_focus_manager_->RegisterAccelerator(*iter, this); |
| + for (std::vector<Accelerator>::const_iterator i( |
| + accelerators_->begin() + registered_accelerator_count_); |
| + i != accelerators_->end(); ++i) { |
| + accelerator_focus_manager_->RegisterAccelerator(*i, this); |
| } |
| registered_accelerator_count_ = accelerators_->size(); |
| } |