Sort unlaunched apps on app list start page by apps grid order.
[chromium-blink-merge.git] / ui / events / event_targeter.cc
blob5d43b29ba941114c7357ea8c930800d8272dff64
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 for (EventTarget* child = iter->GetNextTarget(); child;
34 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 =
43 targeter->FindTargetForLocatedEvent(child, event);
44 if (child_target)
45 return child_target;
47 target->ConvertEventToTarget(root, event);
49 return root->CanAcceptEvent(*event) ? root : NULL;
52 bool EventTargeter::SubtreeShouldBeExploredForEvent(EventTarget* target,
53 const LocatedEvent& event) {
54 return SubtreeCanAcceptEvent(target, event) &&
55 EventLocationInsideBounds(target, event);
58 EventTarget* EventTargeter::FindNextBestTarget(EventTarget* previous_target,
59 Event* event) {
60 return NULL;
63 bool EventTargeter::SubtreeCanAcceptEvent(EventTarget* target,
64 const LocatedEvent& event) const {
65 return true;
68 bool EventTargeter::EventLocationInsideBounds(EventTarget* target,
69 const LocatedEvent& event) const {
70 return true;
73 } // namespace ui