1/*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
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.
17 *
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.
29 */
30
31#ifndef WebInputEventConversion_h
32#define WebInputEventConversion_h
33
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"
40
41namespace WebCore {
42class GestureEvent;
43class KeyboardEvent;
44class MouseEvent;
45class RenderObject;
46class ScrollView;
47class TouchEvent;
48class WheelEvent;
49class Widget;
50}
51
52namespace blink {
53
54class WebMouseEvent;
55class WebMouseWheelEvent;
56class WebKeyboardEvent;
57class WebTouchEvent;
58class WebGestureEvent;
59
60// These classes are used to convert from WebInputEvent subclasses to
61// corresponding WebCore events.
62
63class PlatformMouseEventBuilder : public WebCore::PlatformMouseEvent {
64public:
65    PlatformMouseEventBuilder(WebCore::Widget*, const WebMouseEvent&);
66};
67
68class PlatformWheelEventBuilder : public WebCore::PlatformWheelEvent {
69public:
70    PlatformWheelEventBuilder(WebCore::Widget*, const WebMouseWheelEvent&);
71};
72
73class PlatformGestureEventBuilder : public WebCore::PlatformGestureEvent {
74public:
75    PlatformGestureEventBuilder(WebCore::Widget*, const WebGestureEvent&);
76};
77
78class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent {
79public:
80    PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
81    void setKeyType(Type);
82    bool isCharacterKey() const;
83};
84
85// Converts a WebTouchPoint to a WebCore::PlatformTouchPoint.
86class PlatformTouchPointBuilder : public WebCore::PlatformTouchPoint {
87public:
88    PlatformTouchPointBuilder(WebCore::Widget*, const WebTouchPoint&);
89};
90
91// Converts a WebTouchEvent to a WebCore::PlatformTouchEvent.
92class PlatformTouchEventBuilder : public WebCore::PlatformTouchEvent {
93public:
94    PlatformTouchEventBuilder(WebCore::Widget*, const WebTouchEvent&);
95};
96
97class WebMouseEventBuilder : public WebMouseEvent {
98public:
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&);
105
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
109    // Undefined.
110    WebMouseEventBuilder(const WebCore::Widget*, const WebCore::PlatformMouseEvent&);
111};
112
113// Converts a WebCore::WheelEvent to a corresponding WebMouseWheelEvent.
114// If the event mapping fails, the event type will be set to Undefined.
115class WebMouseWheelEventBuilder : public WebMouseWheelEvent {
116public:
117    WebMouseWheelEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::WheelEvent&);
118};
119
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
124// to Undefined.
125class WebKeyboardEventBuilder : public WebKeyboardEvent {
126public:
127    WebKeyboardEventBuilder(const WebCore::KeyboardEvent&);
128    WebKeyboardEventBuilder(const WebCore::PlatformKeyboardEvent&);
129};
130
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.
134class WebTouchEventBuilder : public WebTouchEvent {
135public:
136    WebTouchEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
137};
138
139// Converts WebCore::GestureEvent to a corresponding WebGestureEvent.
140// NOTE: If event mapping fails, the type will be set to Undefined.
141class WebGestureEventBuilder : public WebGestureEvent {
142public:
143    WebGestureEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::GestureEvent&);
144};
145
146} // namespace blink
147
148#endif
149