Change to let media_stream_devices_controller.cc decide if a gUM request fail if...
[chromium-blink-merge.git] / ui / events / event_targeter.cc
blob50fe7e92051814b2d7d7c6996e1571aa1c1ac1c4
1 // Copyright (c) 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 #include "ui/events/event_targeter.h"
7 #include "ui/events/event.h"
8 #include "ui/events/event_target.h"
9 #include "ui/events/event_target_iterator.h"
11 namespace ui {
13 EventTargeter::~EventTargeter() {
16 EventTarget* EventTargeter::FindTargetForEvent(EventTarget* root,
17 Event* event) {
18 if (event->IsMouseEvent() ||
19 event->IsScrollEvent() ||
20 event->IsTouchEvent() ||
21 event->IsGestureEvent()) {
22 return FindTargetForLocatedEvent(root,
23 static_cast<LocatedEvent*>(event));
25 return root;
28 EventTarget* EventTargeter::FindTargetForLocatedEvent(EventTarget* root,
29 LocatedEvent* event) {
30 scoped_ptr<EventTargetIterator> iter = root->GetChildIterator();
31 if (iter) {
32 EventTarget* target = root;
33 EventTarget* child = NULL;
34 while ((child = iter->GetNextTarget())) {
35 EventTargeter* targeter = child->GetEventTargeter();
36 if (!targeter)
37 targeter = this;
38 if (!targeter->SubtreeShouldBeExploredForEvent(child, *event))
39 continue;
40 target->ConvertEventToTarget(child, event);
41 target = child;
42 EventTarget* child_target = targeter ?
43 targeter->FindTargetForLocatedEvent(child, event) :
44 FindTargetForLocatedEvent(child, event);
45 if (child_target)
46 return child_target;
48 target->ConvertEventToTarget(root, event);
50 return root->CanAcceptEvent(*event) ? root : NULL;
53 bool EventTargeter::SubtreeShouldBeExploredForEvent(EventTarget* target,
54 const LocatedEvent& event) {
55 return true;
58 } // namespace ui