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"
49 class WebMouseWheelEvent
;
50 class WebKeyboardEvent
;
52 class WebGestureEvent
;
56 // These classes are used to convert from WebInputEvent subclasses to
57 // corresponding WebCore events.
59 class PlatformMouseEventBuilder
: public PlatformMouseEvent
{
61 PlatformMouseEventBuilder(Widget
*, const WebMouseEvent
&);
64 class PlatformWheelEventBuilder
: public PlatformWheelEvent
{
66 PlatformWheelEventBuilder(Widget
*, const WebMouseWheelEvent
&);
69 class PlatformGestureEventBuilder
: public PlatformGestureEvent
{
71 PlatformGestureEventBuilder(Widget
*, const WebGestureEvent
&);
74 class PlatformKeyboardEventBuilder
: public PlatformKeyboardEvent
{
76 PlatformKeyboardEventBuilder(const WebKeyboardEvent
&);
77 void setKeyType(Type
);
78 bool isCharacterKey() const;
81 // Converts a WebTouchPoint to a PlatformTouchPoint.
82 class PlatformTouchPointBuilder
: public PlatformTouchPoint
{
84 PlatformTouchPointBuilder(Widget
*, const WebTouchPoint
&);
87 // Converts a WebTouchEvent to a PlatformTouchEvent.
88 class PlatformTouchEventBuilder
: public PlatformTouchEvent
{
90 PlatformTouchEventBuilder(Widget
*, const WebTouchEvent
&);
93 class WebMouseEventBuilder
: public WebMouseEvent
{
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
{
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
115 class WebKeyboardEventBuilder
: public WebKeyboardEvent
{
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
{
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
{
132 WebGestureEventBuilder(const LayoutObject
*, const GestureEvent
&);
135 unsigned toPlatformMouseEventModifiers(int webModifiers
);