Fix typo in AshWindowTreeHostOzone
[chromium-blink-merge.git] / ui / events / event_targeter.cc
blobe76b58921974f4358c5b2395298b86d699247a8c
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 SubtreeCanAcceptEvent(target, event) &&
56 EventLocationInsideBounds(target, event);
59 EventTarget* EventTargeter::FindNextBestTarget(EventTarget* previous_target,
60 Event* event) {
61 return NULL;
64 bool EventTargeter::SubtreeCanAcceptEvent(EventTarget* target,
65 const LocatedEvent& event) const {
66 return true;
69 bool EventTargeter::EventLocationInsideBounds(EventTarget* target,
70 const LocatedEvent& event) const {
71 return true;
74 } // namespace ui