1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_EVENT_TARGET_ITERATOR_H_
6 #define UI_EVENTS_EVENT_TARGET_ITERATOR_H_
14 // An interface that allows iterating over a set of EventTargets.
15 class EventTargetIterator {
17 virtual ~EventTargetIterator() {}
18 virtual EventTarget* GetNextTarget() = 0;
21 // Provides an EventTargetIterator implementation for iterating over a list of
22 // EventTargets. The list is iterated in the reverse order, since typically the
23 // EventTargets are maintained in increasing z-order in the lists.
25 class EventTargetIteratorImpl : public EventTargetIterator {
27 explicit EventTargetIteratorImpl(const std::vector<T*>& children)
28 : begin_(children.rbegin()),
29 end_(children.rend()) {
31 virtual ~EventTargetIteratorImpl() {}
33 virtual EventTarget* GetNextTarget() OVERRIDE {
36 EventTarget* target = *(begin_);
42 typename std::vector<T*>::const_reverse_iterator begin_;
43 typename std::vector<T*>::const_reverse_iterator end_;
48 #endif // UI_EVENTS_EVENT_TARGET_ITERATOR_H_