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 41 namespace blink { 42 43 class GestureEvent; 44 class KeyboardEvent; 45 class MouseEvent; 46 class RenderObject; 47 class ScrollView; 48 class TouchEvent; 49 class WebMouseEvent; 50 class WebMouseWheelEvent; 51 class WebKeyboardEvent; 52 class WebTouchEvent; 53 class WebGestureEvent; 54 class WheelEvent; 55 class Widget; 56 57 // These classes are used to convert from WebInputEvent subclasses to 58 // corresponding WebCore events. 59 60 class PlatformMouseEventBuilder : public PlatformMouseEvent { 61 public: 62 PlatformMouseEventBuilder(Widget*, const WebMouseEvent&); 63 }; 64 65 class PlatformWheelEventBuilder : public PlatformWheelEvent { 66 public: 67 PlatformWheelEventBuilder(Widget*, const WebMouseWheelEvent&); 68 }; 69 70 class PlatformGestureEventBuilder : public PlatformGestureEvent { 71 public: 72 PlatformGestureEventBuilder(Widget*, const WebGestureEvent&); 73 }; 74 75 class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent { 76 public: 77 PlatformKeyboardEventBuilder(const WebKeyboardEvent&); 78 void setKeyType(Type); 79 bool isCharacterKey() const; 80 }; 81 82 // Converts a WebTouchPoint to a PlatformTouchPoint. 83 class PlatformTouchPointBuilder : public PlatformTouchPoint { 84 public: 85 PlatformTouchPointBuilder(Widget*, const WebTouchPoint&); 86 }; 87 88 // Converts a WebTouchEvent to a PlatformTouchEvent. 89 class PlatformTouchEventBuilder : public PlatformTouchEvent { 90 public: 91 PlatformTouchEventBuilder(Widget*, const WebTouchEvent&); 92 }; 93 94 class WebMouseEventBuilder : public WebMouseEvent { 95 public: 96 // Converts a MouseEvent to a corresponding WebMouseEvent. 97 // NOTE: This is only implemented for mousemove, mouseover, mouseout, 98 // mousedown and mouseup. If the event mapping fails, the event type will 99 // be set to Undefined. 100 WebMouseEventBuilder(const Widget*, const RenderObject*, const MouseEvent&); 101 WebMouseEventBuilder(const Widget*, const RenderObject*, const TouchEvent&); 102 103 // Converts a PlatformMouseEvent to a corresponding WebMouseEvent. 104 // NOTE: This is only implemented for mousepressed, mousereleased, and 105 // mousemoved. If the event mapping fails, the event type will be set to 106 // Undefined. 107 WebMouseEventBuilder(const Widget*, const PlatformMouseEvent&); 108 }; 109 110 // Converts a WheelEvent to a corresponding WebMouseWheelEvent. 111 // If the event mapping fails, the event type will be set to Undefined. 112 class WebMouseWheelEventBuilder : public WebMouseWheelEvent { 113 public: 114 WebMouseWheelEventBuilder(const Widget*, const RenderObject*, const WheelEvent&); 115 }; 116 117 // Converts a KeyboardEvent or PlatformKeyboardEvent to a 118 // corresponding WebKeyboardEvent. 119 // NOTE: For KeyboardEvent, this is only implemented for keydown, 120 // keyup, and keypress. If the event mapping fails, the event type will be set 121 // to Undefined. 122 class WebKeyboardEventBuilder : public WebKeyboardEvent { 123 public: 124 WebKeyboardEventBuilder(const KeyboardEvent&); 125 WebKeyboardEventBuilder(const PlatformKeyboardEvent&); 126 }; 127 128 // Converts a TouchEvent to a corresponding WebTouchEvent. 129 // NOTE: WebTouchEvents have a cap on the number of WebTouchPoints. Any points 130 // exceeding that cap will be dropped. 131 class WebTouchEventBuilder : public WebTouchEvent { 132 public: 133 WebTouchEventBuilder(const Widget*, const RenderObject*, const TouchEvent&); 134 }; 135 136 // Converts GestureEvent to a corresponding WebGestureEvent. 137 // NOTE: If event mapping fails, the type will be set to Undefined. 138 class WebGestureEventBuilder : public WebGestureEvent { 139 public: 140 WebGestureEventBuilder(const Widget*, const RenderObject*, const GestureEvent&); 141 }; 142 143 } // namespace blink 144 145 #endif 146