Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / events / gestures / gesture_recognizer_impl.h
blobc59166d379325684aa56037f1732c8d04f762fa2
1 // Copyright (c) 2012 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_GESTURES_GESTURE_RECOGNIZER_IMPL_H_
6 #define UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_IMPL_H_
8 #include <map>
9 #include <vector>
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/events/event_constants.h"
14 #include "ui/events/events_export.h"
15 #include "ui/events/gestures/gesture_provider_aura.h"
16 #include "ui/events/gestures/gesture_recognizer.h"
17 #include "ui/gfx/geometry/point.h"
19 namespace ui {
20 class GestureConsumer;
21 class GestureEvent;
22 class GestureEventHelper;
23 class TouchEvent;
25 // TODO(tdresser): Once the unified gesture recognition process sticks
26 // (crbug.com/332418), GestureRecognizerImpl can be cleaned up
27 // significantly.
28 class EVENTS_EXPORT GestureRecognizerImpl : public GestureRecognizer,
29 public GestureProviderAuraClient {
30 public:
31 typedef std::map<int, GestureConsumer*> TouchIdToConsumerMap;
33 GestureRecognizerImpl();
34 ~GestureRecognizerImpl() override;
36 std::vector<GestureEventHelper*>& helpers() { return helpers_; }
38 // Overridden from GestureRecognizer
39 GestureConsumer* GetTouchLockedTarget(const TouchEvent& event) override;
40 GestureConsumer* GetTargetForGestureEvent(const GestureEvent& event) override;
41 GestureConsumer* GetTargetForLocation(const gfx::PointF& location,
42 int source_device_id) override;
43 void CancelActiveTouchesExcept(GestureConsumer* not_cancelled) override;
44 void TransferEventsTo(GestureConsumer* current_consumer,
45 GestureConsumer* new_consumer) override;
46 bool GetLastTouchPointForTarget(GestureConsumer* consumer,
47 gfx::PointF* point) override;
48 bool CancelActiveTouches(GestureConsumer* consumer) override;
50 protected:
51 virtual GestureProviderAura* GetGestureProviderForConsumer(
52 GestureConsumer* c);
54 private:
55 // Sets up the target consumer for gestures based on the touch-event.
56 void SetupTargets(const TouchEvent& event, GestureConsumer* consumer);
58 void DispatchGestureEvent(GestureEvent* event);
60 // Overridden from GestureRecognizer
61 bool ProcessTouchEventPreDispatch(TouchEvent* event,
62 GestureConsumer* consumer) override;
64 Gestures* AckAsyncTouchEvent(ui::EventResult result,
65 GestureConsumer* consumer) override;
67 Gestures* AckSyncTouchEvent(const uint64 unique_event_id,
68 ui::EventResult result,
69 GestureConsumer* consumer) override;
71 bool CleanupStateForConsumer(GestureConsumer* consumer) override;
72 void AddGestureEventHelper(GestureEventHelper* helper) override;
73 void RemoveGestureEventHelper(GestureEventHelper* helper) override;
75 // Overridden from GestureProviderAuraClient
76 void OnGestureEvent(GestureEvent* event) override;
78 // Convenience method to find the GestureEventHelper that can dispatch events
79 // to a specific |consumer|.
80 GestureEventHelper* FindDispatchHelperForConsumer(GestureConsumer* consumer);
81 std::map<GestureConsumer*, GestureProviderAura*> consumer_gesture_provider_;
83 // Both |touch_id_target_| and |touch_id_target_for_gestures_| map a touch-id
84 // to its target window. touch-ids are removed from |touch_id_target_| on
85 // ET_TOUCH_RELEASE and ET_TOUCH_CANCEL. |touch_id_target_for_gestures_| are
86 // removed in ConsumerDestroyed().
87 TouchIdToConsumerMap touch_id_target_;
88 TouchIdToConsumerMap touch_id_target_for_gestures_;
90 std::vector<GestureEventHelper*> helpers_;
92 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerImpl);
95 // Provided only for testing:
96 EVENTS_EXPORT void SetGestureRecognizerForTesting(
97 GestureRecognizer* gesture_recognizer);
99 } // namespace ui
101 #endif // UI_EVENTS_GESTURES_GESTURE_RECOGNIZER_IMPL_H_