OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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. | |
4 | |
5 #ifndef UI_EVENTS_PLATFORM_EVENT_PLATFORM_EVENT_BUILDER_H_ | |
6 #define UI_EVENTS_PLATFORM_EVENT_PLATFORM_EVENT_BUILDER_H_ | |
7 | |
8 #include "base/event_types.h" | |
9 #include "base/gtest_prod_util.h" | |
10 | |
11 namespace ui { | |
12 | |
13 class Event; | |
14 class KeyEvent; | |
15 class LocatedEvent; | |
16 class MouseEvent; | |
17 class MouseWheelEvent; | |
18 class ScrollEvent; | |
19 class TouchEvent; | |
20 | |
21 // Builds ui::Events from native events. | |
22 // | |
23 // In chromium, this functionality was put inline on the individual Event | |
24 // subclasses. This was fine there since all chromium binaries included the | |
25 // system windowing system libraries. In mojo, we have small binaries which | |
26 // have want to have generic events while only the native viewport needs the | |
27 // capability to generate events from platform events. | |
28 class PlatformEventBuilder { | |
29 public: | |
30 static MouseEvent BuildMouseEvent(const base::NativeEvent& native_event); | |
31 static MouseWheelEvent BuildMouseWheelEvent( | |
32 const base::NativeEvent& native_event); | |
33 static TouchEvent BuildTouchEvent(const base::NativeEvent& native_event); | |
34 static KeyEvent BuildKeyEvent(const base::NativeEvent& native_event); | |
35 static ScrollEvent BuildScrollEvent(const base::NativeEvent& native_event); | |
36 | |
37 // Returns the repeat count based on the previous mouse click, if it is | |
38 // recent enough and within a small enough distance. Exposed for testing. | |
39 static int GetRepeatCount(const base::NativeEvent& native_event, | |
40 const MouseEvent& event); | |
41 | |
42 private: | |
43 FRIEND_TEST_ALL_PREFIXES(PlatformEventBuilderXTest, | |
44 DoubleClickRequiresRelease); | |
45 FRIEND_TEST_ALL_PREFIXES(PlatformEventBuilderXTest, SingleClickRightLeft); | |
46 | |
47 // Resets the last_click_event_ for unit tests. | |
48 static void ResetLastClickForTest(); | |
49 | |
50 // Takes data from |native_event| and fills the per class details on |event|. | |
51 static void FillEventFrom(const base::NativeEvent& native_event, | |
52 Event* event); | |
53 static void FillLocatedEventFrom(const base::NativeEvent& native_event, | |
54 LocatedEvent* located_event); | |
55 static void FillMouseEventFrom(const base::NativeEvent& native_event, | |
56 MouseEvent* mouse_event); | |
57 static void FillMouseWheelEventFrom(const base::NativeEvent& native_event, | |
58 MouseWheelEvent* mouse_wheel_event); | |
59 static void FillTouchEventFrom(const base::NativeEvent& native_event, | |
60 TouchEvent* touch_event); | |
61 static void FillKeyEventFrom(const base::NativeEvent& native_event, | |
62 KeyEvent* key_event); | |
63 static void FillScrollEventFrom(const base::NativeEvent& native_event, | |
64 ScrollEvent* scroll_event); | |
65 }; | |
sky
2015/01/21 22:46:46
DISALLOW_IMPLICIT_CONSTRUCTORS?
| |
66 | |
67 } // namespace ui | |
68 | |
69 #endif // UI_EVENTS_PLATFORM_EVENT_PLATFORM_EVENT_BUILDER_H_ | |
OLD | NEW |