Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebInputEventConversion.h
blobef3c1874bcb9b5b0ab44c882f9958feb0d691957
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebInputEventConversion_h
32 #define WebInputEventConversion_h
34 #include "platform/PlatformGestureEvent.h"
35 #include "platform/PlatformKeyboardEvent.h"
36 #include "platform/PlatformMouseEvent.h"
37 #include "platform/PlatformTouchEvent.h"
38 #include "platform/PlatformWheelEvent.h"
39 #include "public/web/WebInputEvent.h"
41 namespace blink {
43 class GestureEvent;
44 class KeyboardEvent;
45 class MouseEvent;
46 class LayoutObject;
47 class TouchEvent;
48 class WebMouseEvent;
49 class WebMouseWheelEvent;
50 class WebKeyboardEvent;
51 class WebTouchEvent;
52 class WebGestureEvent;
53 class WheelEvent;
54 class Widget;
56 // These classes are used to convert from WebInputEvent subclasses to
57 // corresponding WebCore events.
59 class PlatformMouseEventBuilder : public PlatformMouseEvent {
60 public:
61 PlatformMouseEventBuilder(Widget*, const WebMouseEvent&);
64 class PlatformWheelEventBuilder : public PlatformWheelEvent {
65 public:
66 PlatformWheelEventBuilder(Widget*, const WebMouseWheelEvent&);
69 class PlatformGestureEventBuilder : public PlatformGestureEvent {
70 public:
71 PlatformGestureEventBuilder(Widget*, const WebGestureEvent&);
74 class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent {
75 public:
76 PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
77 void setKeyType(Type);
78 bool isCharacterKey() const;
81 // Converts a WebTouchPoint to a PlatformTouchPoint.
82 class PlatformTouchPointBuilder : public PlatformTouchPoint {
83 public:
84 PlatformTouchPointBuilder(Widget*, const WebTouchPoint&);
87 // Converts a WebTouchEvent to a PlatformTouchEvent.
88 class PlatformTouchEventBuilder : public PlatformTouchEvent {
89 public:
90 PlatformTouchEventBuilder(Widget*, const WebTouchEvent&);
93 class WebMouseEventBuilder : public WebMouseEvent {
94 public:
95 // Converts a MouseEvent to a corresponding WebMouseEvent.
96 // NOTE: This is only implemented for mousemove, mouseover, mouseout,
97 // mousedown and mouseup. If the event mapping fails, the event type will
98 // be set to Undefined.
99 WebMouseEventBuilder(const Widget*, const LayoutObject*, const MouseEvent&);
100 WebMouseEventBuilder(const Widget*, const LayoutObject*, const TouchEvent&);
103 // Converts a WheelEvent to a corresponding WebMouseWheelEvent.
104 // If the event mapping fails, the event type will be set to Undefined.
105 class WebMouseWheelEventBuilder : public WebMouseWheelEvent {
106 public:
107 WebMouseWheelEventBuilder(const Widget*, const LayoutObject*, const WheelEvent&);
110 // Converts a KeyboardEvent or PlatformKeyboardEvent to a
111 // corresponding WebKeyboardEvent.
112 // NOTE: For KeyboardEvent, this is only implemented for keydown,
113 // keyup, and keypress. If the event mapping fails, the event type will be set
114 // to Undefined.
115 class WebKeyboardEventBuilder : public WebKeyboardEvent {
116 public:
117 WebKeyboardEventBuilder(const KeyboardEvent&);
120 // Converts a TouchEvent to a corresponding WebTouchEvent.
121 // NOTE: WebTouchEvents have a cap on the number of WebTouchPoints. Any points
122 // exceeding that cap will be dropped.
123 class WebTouchEventBuilder : public WebTouchEvent {
124 public:
125 WebTouchEventBuilder(const LayoutObject*, const TouchEvent&);
128 // Converts GestureEvent to a corresponding WebGestureEvent.
129 // NOTE: If event mapping fails, the type will be set to Undefined.
130 class WebGestureEventBuilder : public WebGestureEvent {
131 public:
132 WebGestureEventBuilder(const LayoutObject*, const GestureEvent&);
135 unsigned toPlatformMouseEventModifiers(int webModifiers);
137 } // namespace blink
139 #endif