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
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
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"
55 class WebMouseWheelEvent;
56 class WebKeyboardEvent;
58 class WebGestureEvent;
60 // These classes are used to convert from WebInputEvent subclasses to
61 // corresponding WebCore events.
63 class PlatformMouseEventBuilder : public WebCore::PlatformMouseEvent {
65 PlatformMouseEventBuilder(WebCore::Widget*, const WebMouseEvent&);
68 class PlatformWheelEventBuilder : public WebCore::PlatformWheelEvent {
70 PlatformWheelEventBuilder(WebCore::Widget*, const WebMouseWheelEvent&);
73 class PlatformGestureEventBuilder : public WebCore::PlatformGestureEvent {
75 PlatformGestureEventBuilder(WebCore::Widget*, const WebGestureEvent&);
78 class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent {
80 PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
81 void setKeyType(Type);
82 bool isCharacterKey() const;
85 // Converts a WebTouchPoint to a WebCore::PlatformTouchPoint.
86 class PlatformTouchPointBuilder : public WebCore::PlatformTouchPoint {
88 PlatformTouchPointBuilder(WebCore::Widget*, const WebTouchPoint&);
91 // Converts a WebTouchEvent to a WebCore::PlatformTouchEvent.
92 class PlatformTouchEventBuilder : public WebCore::PlatformTouchEvent {
94 PlatformTouchEventBuilder(WebCore::Widget*, const WebTouchEvent&);
97 class WebMouseEventBuilder : public WebMouseEvent {
99 // Converts a WebCore::MouseEvent to a corresponding WebMouseEvent.
100 // NOTE: This is only implemented for mousemove, mouseover, mouseout,
101 // mousedown and mouseup. If the event mapping fails, the event type will
102 // be set to Undefined.
103 WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::MouseEvent&);
104 WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
106 // Converts a WebCore::PlatformMouseEvent to a corresponding WebMouseEvent.
107 // NOTE: This is only implemented for mousepressed, mousereleased, and
108 // mousemoved. If the event mapping fails, the event type will be set to
110 WebMouseEventBuilder(const WebCore::Widget*, const WebCore::PlatformMouseEvent&);
113 // Converts a WebCore::WheelEvent to a corresponding WebMouseWheelEvent.
114 // If the event mapping fails, the event type will be set to Undefined.
115 class WebMouseWheelEventBuilder : public WebMouseWheelEvent {
117 WebMouseWheelEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::WheelEvent&);
120 // Converts a WebCore::KeyboardEvent or WebCore::PlatformKeyboardEvent to a
121 // corresponding WebKeyboardEvent.
122 // NOTE: For WebCore::KeyboardEvent, this is only implemented for keydown,
123 // keyup, and keypress. If the event mapping fails, the event type will be set
125 class WebKeyboardEventBuilder : public WebKeyboardEvent {
127 WebKeyboardEventBuilder(const WebCore::KeyboardEvent&);
128 WebKeyboardEventBuilder(const WebCore::PlatformKeyboardEvent&);
131 // Converts a WebCore::TouchEvent to a corresponding WebTouchEvent.
132 // NOTE: WebTouchEvents have a cap on the number of WebTouchPoints. Any points
133 // exceeding that cap will be dropped.
134 class WebTouchEventBuilder : public WebTouchEvent {
136 WebTouchEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
139 // Converts WebCore::GestureEvent to a corresponding WebGestureEvent.
140 // NOTE: If event mapping fails, the type will be set to Undefined.
141 class WebGestureEventBuilder : public WebGestureEvent {
143 WebGestureEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::GestureEvent&);