Chromium Code Reviews| Index: ui/wm/core/compound_event_filter.cc |
| diff --git a/ui/wm/core/compound_event_filter.cc b/ui/wm/core/compound_event_filter.cc |
| index 0e655257a32558c86f56f84a353eda1b35b61389..86ca81289d7eb1c80833ad25628f036738e1a2d0 100644 |
| --- a/ui/wm/core/compound_event_filter.cc |
| +++ b/ui/wm/core/compound_event_filter.cc |
| @@ -129,29 +129,26 @@ void CompoundEventFilter::UpdateCursor(aura::Window* target, |
| } |
| void CompoundEventFilter::FilterKeyEvent(ui::KeyEvent* event) { |
| - if (handlers_.might_have_observers()) { |
| - base::ObserverListBase<ui::EventHandler>::Iterator it(&handlers_); |
| - ui::EventHandler* handler; |
| - while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL) |
| - handler->OnKeyEvent(event); |
| + for (auto& handler : handlers_) { |
| + if (event->stopped_propagation()) |
|
dcheng
2016/10/12 23:04:45
I'm not sure that this actually needs to be checke
|
| + break; |
| + handler.OnKeyEvent(event); |
| } |
| } |
| void CompoundEventFilter::FilterMouseEvent(ui::MouseEvent* event) { |
| - if (handlers_.might_have_observers()) { |
| - base::ObserverListBase<ui::EventHandler>::Iterator it(&handlers_); |
| - ui::EventHandler* handler; |
| - while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL) |
| - handler->OnMouseEvent(event); |
| + for (auto& handler : handlers_) { |
| + if (event->stopped_propagation()) |
| + break; |
| + handler.OnMouseEvent(event); |
| } |
| } |
| void CompoundEventFilter::FilterTouchEvent(ui::TouchEvent* event) { |
| - if (handlers_.might_have_observers()) { |
| - base::ObserverListBase<ui::EventHandler>::Iterator it(&handlers_); |
| - ui::EventHandler* handler; |
| - while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL) |
| - handler->OnTouchEvent(event); |
| + for (auto& handler : handlers_) { |
| + if (event->stopped_propagation()) |
| + break; |
| + handler.OnTouchEvent(event); |
| } |
| } |
| @@ -240,11 +237,10 @@ void CompoundEventFilter::OnTouchEvent(ui::TouchEvent* event) { |
| } |
| void CompoundEventFilter::OnGestureEvent(ui::GestureEvent* event) { |
| - if (handlers_.might_have_observers()) { |
| - base::ObserverListBase<ui::EventHandler>::Iterator it(&handlers_); |
| - ui::EventHandler* handler; |
| - while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL) |
| - handler->OnGestureEvent(event); |
| + for (auto& handler : handlers_) { |
| + if (event->stopped_propagation()) |
| + break; |
| + handler.OnGestureEvent(event); |
| } |
| } |