Update V8 to version 4.7.16.
[chromium-blink-merge.git] / ui / events / event_target_iterator.h
blobfe3eca6c1730b39b2a2d69e1089a5dafd3b99a77
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_
8 #include <vector>
10 namespace ui {
12 class EventTarget;
14 // An interface that allows iterating over a set of EventTargets.
15 class EventTargetIterator {
16 public:
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.
24 template<typename T>
25 class EventTargetIteratorImpl : public EventTargetIterator {
26 public:
27 explicit EventTargetIteratorImpl(const std::vector<T*>& children)
28 : begin_(children.rbegin()),
29 end_(children.rend()) {
31 ~EventTargetIteratorImpl() override {}
33 EventTarget* GetNextTarget() override {
34 if (begin_ == end_)
35 return NULL;
36 EventTarget* target = *(begin_);
37 ++begin_;
38 return target;
41 private:
42 typename std::vector<T*>::const_reverse_iterator begin_;
43 typename std::vector<T*>::const_reverse_iterator end_;
46 } // namespace ui
48 #endif // UI_EVENTS_EVENT_TARGET_ITERATOR_H_