| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // platform and correspond closely to WebCore's Platform*Event classes. | 42 // platform and correspond closely to WebCore's Platform*Event classes. |
| 43 // | 43 // |
| 44 // WARNING! These classes must remain PODs (plain old data). They are | 44 // WARNING! These classes must remain PODs (plain old data). They are |
| 45 // intended to be "serializable" by copying their raw bytes, so they must | 45 // intended to be "serializable" by copying their raw bytes, so they must |
| 46 // not contain any non-bit-copyable member variables! | 46 // not contain any non-bit-copyable member variables! |
| 47 | 47 |
| 48 // WebInputEvent -------------------------------------------------------------- | 48 // WebInputEvent -------------------------------------------------------------- |
| 49 | 49 |
| 50 class WebInputEvent { | 50 class WebInputEvent { |
| 51 public: | 51 public: |
| 52 WebInputEvent() : type(None), modifiers(0) { } | 52 WebInputEvent(unsigned sizeParam = sizeof(WebInputEvent)) |
| 53 : size(sizeParam) |
| 54 , type(Undefined) |
| 55 , modifiers(0) |
| 56 , timeStampSeconds(0.0) { } |
| 53 | 57 |
| 54 // There are two schemes used for keyboard input. On Windows (and, | 58 // There are two schemes used for keyboard input. On Windows (and, |
| 55 // interestingly enough, on Mac Carbon) there are two events for a | 59 // interestingly enough, on Mac Carbon) there are two events for a |
| 56 // keypress. One is a raw keydown, which provides the keycode only. | 60 // keypress. One is a raw keydown, which provides the keycode only. |
| 57 // If the app doesn't handle that, then the system runs key translation | 61 // If the app doesn't handle that, then the system runs key translation |
| 58 // to create an event containing the generated character and pumps that | 62 // to create an event containing the generated character and pumps that |
| 59 // event. In such a scheme, those two events are translated to | 63 // event. In such a scheme, those two events are translated to |
| 60 // RAW_KEY_DOWN and CHAR events respectively. In Cocoa and Gtk, key | 64 // RAW_KEY_DOWN and CHAR events respectively. In Cocoa and Gtk, key |
| 61 // events contain both the keycode and any translation into actual | 65 // events contain both the keycode and any translation into actual |
| 62 // text. In such a case, WebCore will eventually need to split the | 66 // text. In such a case, WebCore will eventually need to split the |
| 63 // events (see disambiguateKeyDownEvent and its callers) but we don't | 67 // events (see disambiguateKeyDownEvent and its callers) but we don't |
| 64 // worry about that here. We just use a different type (KEY_DOWN) to | 68 // worry about that here. We just use a different type (KEY_DOWN) to |
| 65 // indicate this. | 69 // indicate this. |
| 66 | 70 |
| 67 enum Type { | 71 enum Type { |
| 68 None = -1, | 72 Undefined = -1, |
| 69 | 73 |
| 70 // WebMouseEvent | 74 // WebMouseEvent |
| 71 MouseDown, | 75 MouseDown, |
| 72 MouseUp, | 76 MouseUp, |
| 73 MouseMove, | 77 MouseMove, |
| 78 MouseEnter, |
| 74 MouseLeave, | 79 MouseLeave, |
| 75 | 80 |
| 76 // WebMouseWheelEvent | 81 // WebMouseWheelEvent |
| 77 MouseWheel, | 82 MouseWheel, |
| 78 | 83 |
| 79 // WebKeyboardEvent | 84 // WebKeyboardEvent |
| 80 RawKeyDown, | 85 RawKeyDown, |
| 81 KeyDown, | 86 KeyDown, |
| 82 KeyUp, | 87 KeyUp, |
| 83 Char | 88 Char |
| 84 }; | 89 }; |
| 85 | 90 |
| 86 enum Modifiers { | 91 enum Modifiers { |
| 87 // modifiers for all events: | 92 // modifiers for all events: |
| 88 ShiftKey = 1 << 0, | 93 ShiftKey = 1 << 0, |
| 89 ControlKey = 1 << 1, | 94 ControlKey = 1 << 1, |
| 90 AltKey = 1 << 2, | 95 AltKey = 1 << 2, |
| 91 MetaKey = 1 << 3, | 96 MetaKey = 1 << 3, |
| 92 | 97 |
| 93 // modifiers for keyboard events: | 98 // modifiers for keyboard events: |
| 94 IsKeyPad = 1 << 4, | 99 IsKeyPad = 1 << 4, |
| 95 IsAutoRepeat = 1 << 5 | 100 IsAutoRepeat = 1 << 5, |
| 101 |
| 102 // modifiers for mouse events: |
| 103 LeftButtonDown = 1 << 6, |
| 104 MiddleButtonDown = 1 << 7, |
| 105 RightButtonDown = 1 << 8, |
| 96 }; | 106 }; |
| 97 | 107 |
| 108 unsigned size; // The size of this structure, for serialization. |
| 98 Type type; | 109 Type type; |
| 99 int modifiers; | 110 int modifiers; |
| 111 double timeStampSeconds; // Seconds since epoch. |
| 100 | 112 |
| 101 // Returns true if the WebInputEvent |type| is a keyboard event. | 113 // Returns true if the WebInputEvent |type| is a keyboard event. |
| 102 static bool isKeyboardEventType(int type) | 114 static bool isKeyboardEventType(int type) |
| 103 { | 115 { |
| 104 return type == RawKeyDown | 116 return type == RawKeyDown |
| 105 || type == KeyDown | 117 || type == KeyDown |
| 106 || type == KeyUp | 118 || type == KeyUp |
| 107 || type == Char; | 119 || type == Char; |
| 108 } | 120 } |
| 109 }; | 121 }; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // This is a string identifying the key pressed. | 156 // This is a string identifying the key pressed. |
| 145 char keyIdentifier[keyIdentifierLengthCap]; | 157 char keyIdentifier[keyIdentifierLengthCap]; |
| 146 | 158 |
| 147 // This identifies whether this event was tagged by the system as being | 159 // This identifies whether this event was tagged by the system as being |
| 148 // a "system key" event (see | 160 // a "system key" event (see |
| 149 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for | 161 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for |
| 150 // details). Other platforms don't have this concept, but it's just | 162 // details). Other platforms don't have this concept, but it's just |
| 151 // easier to leave it always false than ifdef. | 163 // easier to leave it always false than ifdef. |
| 152 bool isSystemKey; | 164 bool isSystemKey; |
| 153 | 165 |
| 154 WebKeyboardEvent() | 166 WebKeyboardEvent(unsigned sizeParam = sizeof(WebKeyboardEvent)) |
| 155 : windowsKeyCode(0) | 167 : WebInputEvent(sizeParam) |
| 168 , windowsKeyCode(0) |
| 156 , nativeKeyCode(0) | 169 , nativeKeyCode(0) |
| 157 , isSystemKey(false) | 170 , isSystemKey(false) |
| 158 { | 171 { |
| 159 memset(&text, 0, sizeof(text)); | 172 memset(&text, 0, sizeof(text)); |
| 160 memset(&unmodifiedText, 0, sizeof(unmodifiedText)); | 173 memset(&unmodifiedText, 0, sizeof(unmodifiedText)); |
| 161 memset(&keyIdentifier, 0, sizeof(keyIdentifier)); | 174 memset(&keyIdentifier, 0, sizeof(keyIdentifier)); |
| 162 } | 175 } |
| 163 | 176 |
| 164 // Sets keyIdentifier based on the value of windowsKeyCode. This is | 177 // Sets keyIdentifier based on the value of windowsKeyCode. This is |
| 165 // handy for generating synthetic keyboard events. | 178 // handy for generating synthetic keyboard events. |
| 166 WEBKIT_API void setKeyIdentifierFromWindowsKeyCode(); | 179 WEBKIT_API void setKeyIdentifierFromWindowsKeyCode(); |
| 167 }; | 180 }; |
| 168 | 181 |
| 169 // WebMouseEvent -------------------------------------------------------------- | 182 // WebMouseEvent -------------------------------------------------------------- |
| 170 | 183 |
| 171 class WebMouseEvent : public WebInputEvent { | 184 class WebMouseEvent : public WebInputEvent { |
| 172 public: | 185 public: |
| 173 // These values defined for WebCore::MouseButton | 186 // These values defined for WebCore::MouseButton |
| 174 enum Button { | 187 enum Button { |
| 175 ButtonNone = -1, | 188 ButtonNone = -1, |
| 176 ButtonLeft, | 189 ButtonLeft, |
| 177 ButtonMiddle, | 190 ButtonMiddle, |
| 178 ButtonRight | 191 ButtonRight |
| 179 }; | 192 }; |
| 180 | 193 |
| 181 Button button; | 194 Button button; |
| 182 int x; | 195 int x; |
| 183 int y; | 196 int y; |
| 197 int windowX; |
| 198 int windowY; |
| 184 int globalX; | 199 int globalX; |
| 185 int globalY; | 200 int globalY; |
| 186 double timeStampSeconds; // Seconds since epoch. | |
| 187 int clickCount; | 201 int clickCount; |
| 188 | 202 |
| 189 WebMouseEvent() | 203 WebMouseEvent(unsigned sizeParam = sizeof(WebMouseEvent)) |
| 190 : button(ButtonNone) | 204 : WebInputEvent(sizeParam) |
| 205 , button(ButtonNone) |
| 191 , x(0) | 206 , x(0) |
| 192 , y(0) | 207 , y(0) |
| 208 , windowX(0) |
| 209 , windowY(0) |
| 193 , globalX(0) | 210 , globalX(0) |
| 194 , globalY(0) | 211 , globalY(0) |
| 195 , timeStampSeconds(0.0) | |
| 196 , clickCount(0) | 212 , clickCount(0) |
| 197 { | 213 { |
| 198 } | 214 } |
| 199 }; | 215 }; |
| 200 | 216 |
| 201 // WebMouseWheelEvent --------------------------------------------------------- | 217 // WebMouseWheelEvent --------------------------------------------------------- |
| 202 | 218 |
| 203 class WebMouseWheelEvent : public WebMouseEvent { | 219 class WebMouseWheelEvent : public WebMouseEvent { |
| 204 public: | 220 public: |
| 205 float deltaX; | 221 float deltaX; |
| 206 float deltaY; | 222 float deltaY; |
| 207 float wheelTicksX; | 223 float wheelTicksX; |
| 208 float wheelTicksY; | 224 float wheelTicksY; |
| 209 bool scrollByPage; | 225 bool scrollByPage; |
| 210 | 226 |
| 211 WebMouseWheelEvent() | 227 WebMouseWheelEvent(unsigned sizeParam = sizeof(WebMouseWheelEvent)) |
| 212 : deltaX(0.0f) | 228 : WebMouseEvent(sizeParam) |
| 229 , deltaX(0.0f) |
| 213 , deltaY(0.0f) | 230 , deltaY(0.0f) |
| 214 , wheelTicksX(0.0f) | 231 , wheelTicksX(0.0f) |
| 215 , wheelTicksY(0.0f) | 232 , wheelTicksY(0.0f) |
| 216 , scrollByPage(false) | 233 , scrollByPage(false) |
| 217 { | 234 { |
| 218 } | 235 } |
| 219 }; | 236 }; |
| 220 | 237 |
| 221 } // namespace WebKit | 238 } // namespace WebKit |
| 222 | 239 |
| 223 #endif | 240 #endif |
| OLD | NEW |