| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Apple 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 | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #include "config.h" | |
| 27 #include "PlatformEventFactoryMac.h" | |
| 28 | |
| 29 #import "KeyEventCocoa.h" | |
| 30 #import "Logging.h" | |
| 31 #import "PlatformScreen.h" | |
| 32 #import "Scrollbar.h" | |
| 33 #import "WebCoreSystemInterface.h" | |
| 34 #import "WindowsKeyboardCodes.h" | |
| 35 #import <wtf/ASCIICType.h> | |
| 36 | |
| 37 namespace WebCore { | |
| 38 | |
| 39 IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *window) | |
| 40 { | |
| 41 return IntPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], sc
reenForWindow(window))); | |
| 42 } | |
| 43 | |
| 44 static IntPoint globalPointForEvent(NSEvent *event) | |
| 45 { | |
| 46 switch ([event type]) { | |
| 47 case NSLeftMouseDown: | |
| 48 case NSLeftMouseDragged: | |
| 49 case NSLeftMouseUp: | |
| 50 case NSMouseEntered: | |
| 51 case NSMouseExited: | |
| 52 case NSMouseMoved: | |
| 53 case NSOtherMouseDown: | |
| 54 case NSOtherMouseDragged: | |
| 55 case NSOtherMouseUp: | |
| 56 case NSRightMouseDown: | |
| 57 case NSRightMouseDragged: | |
| 58 case NSRightMouseUp: | |
| 59 case NSScrollWheel: | |
| 60 return globalPoint([event locationInWindow], [event window]); | |
| 61 default: | |
| 62 return IntPoint(); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 static IntPoint pointForEvent(NSEvent *event, NSView *windowView) | |
| 67 { | |
| 68 switch ([event type]) { | |
| 69 case NSLeftMouseDown: | |
| 70 case NSLeftMouseDragged: | |
| 71 case NSLeftMouseUp: | |
| 72 case NSMouseEntered: | |
| 73 case NSMouseExited: | |
| 74 case NSMouseMoved: | |
| 75 case NSOtherMouseDown: | |
| 76 case NSOtherMouseDragged: | |
| 77 case NSOtherMouseUp: | |
| 78 case NSRightMouseDown: | |
| 79 case NSRightMouseDragged: | |
| 80 case NSRightMouseUp: | |
| 81 case NSScrollWheel: { | |
| 82 // Note: This will have its origin at the bottom left of the window
unless windowView is flipped. | |
| 83 // In those cases, the Y coordinate gets flipped by Widget::convertF
romContainingWindow. | |
| 84 NSPoint location = [event locationInWindow]; | |
| 85 if (windowView) | |
| 86 location = [windowView convertPoint:location fromView:nil]; | |
| 87 return IntPoint(location); | |
| 88 } | |
| 89 default: | |
| 90 return IntPoint(); | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 static MouseButton mouseButtonForEvent(NSEvent *event) | |
| 95 { | |
| 96 switch ([event type]) { | |
| 97 case NSLeftMouseDown: | |
| 98 case NSLeftMouseUp: | |
| 99 case NSLeftMouseDragged: | |
| 100 return LeftButton; | |
| 101 case NSRightMouseDown: | |
| 102 case NSRightMouseUp: | |
| 103 case NSRightMouseDragged: | |
| 104 return RightButton; | |
| 105 case NSOtherMouseDown: | |
| 106 case NSOtherMouseUp: | |
| 107 case NSOtherMouseDragged: | |
| 108 return MiddleButton; | |
| 109 default: | |
| 110 return NoButton; | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 static PlatformEvent::Type mouseEventTypeForEvent(NSEvent* event) | |
| 115 { | |
| 116 switch ([event type]) { | |
| 117 case NSLeftMouseDragged: | |
| 118 case NSMouseEntered: | |
| 119 case NSMouseExited: | |
| 120 case NSMouseMoved: | |
| 121 case NSOtherMouseDragged: | |
| 122 case NSRightMouseDragged: | |
| 123 return PlatformEvent::MouseMoved; | |
| 124 case NSLeftMouseDown: | |
| 125 case NSRightMouseDown: | |
| 126 case NSOtherMouseDown: | |
| 127 return PlatformEvent::MousePressed; | |
| 128 case NSLeftMouseUp: | |
| 129 case NSRightMouseUp: | |
| 130 case NSOtherMouseUp: | |
| 131 return PlatformEvent::MouseReleased; | |
| 132 default: | |
| 133 return PlatformEvent::MouseMoved; | |
| 134 } | |
| 135 } | |
| 136 | |
| 137 static int clickCountForEvent(NSEvent *event) | |
| 138 { | |
| 139 switch ([event type]) { | |
| 140 case NSLeftMouseDown: | |
| 141 case NSLeftMouseUp: | |
| 142 case NSLeftMouseDragged: | |
| 143 case NSRightMouseDown: | |
| 144 case NSRightMouseUp: | |
| 145 case NSRightMouseDragged: | |
| 146 case NSOtherMouseDown: | |
| 147 case NSOtherMouseUp: | |
| 148 case NSOtherMouseDragged: | |
| 149 return [event clickCount]; | |
| 150 default: | |
| 151 return 0; | |
| 152 } | |
| 153 } | |
| 154 | |
| 155 static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event) | |
| 156 { | |
| 157 uint32_t phase = PlatformWheelEventPhaseNone; | |
| 158 | |
| 159 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
| 160 if ([event momentumPhase] & NSEventPhaseBegan) | |
| 161 phase |= PlatformWheelEventPhaseBegan; | |
| 162 if ([event momentumPhase] & NSEventPhaseStationary) | |
| 163 phase |= PlatformWheelEventPhaseStationary; | |
| 164 if ([event momentumPhase] & NSEventPhaseChanged) | |
| 165 phase |= PlatformWheelEventPhaseChanged; | |
| 166 if ([event momentumPhase] & NSEventPhaseEnded) | |
| 167 phase |= PlatformWheelEventPhaseEnded; | |
| 168 if ([event momentumPhase] & NSEventPhaseCancelled) | |
| 169 phase |= PlatformWheelEventPhaseCancelled; | |
| 170 #else | |
| 171 switch (wkGetNSEventMomentumPhase(event)) { | |
| 172 case wkEventPhaseNone: | |
| 173 phase = PlatformWheelEventPhaseNone; | |
| 174 break; | |
| 175 case wkEventPhaseBegan: | |
| 176 phase = PlatformWheelEventPhaseBegan; | |
| 177 break; | |
| 178 case wkEventPhaseChanged: | |
| 179 phase = PlatformWheelEventPhaseChanged; | |
| 180 break; | |
| 181 case wkEventPhaseEnded: | |
| 182 phase = PlatformWheelEventPhaseEnded; | |
| 183 break; | |
| 184 } | |
| 185 #endif | |
| 186 | |
| 187 return static_cast<PlatformWheelEventPhase>(phase); | |
| 188 } | |
| 189 | |
| 190 static PlatformWheelEventPhase phaseForEvent(NSEvent *event) | |
| 191 { | |
| 192 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
| 193 uint32_t phase = PlatformWheelEventPhaseNone; | |
| 194 if ([event phase] & NSEventPhaseBegan) | |
| 195 phase |= PlatformWheelEventPhaseBegan; | |
| 196 if ([event phase] & NSEventPhaseStationary) | |
| 197 phase |= PlatformWheelEventPhaseStationary; | |
| 198 if ([event phase] & NSEventPhaseChanged) | |
| 199 phase |= PlatformWheelEventPhaseChanged; | |
| 200 if ([event phase] & NSEventPhaseEnded) | |
| 201 phase |= PlatformWheelEventPhaseEnded; | |
| 202 if ([event phase] & NSEventPhaseCancelled) | |
| 203 phase |= PlatformWheelEventPhaseCancelled; | |
| 204 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 | |
| 205 if ([event momentumPhase] & NSEventPhaseMayBegin) | |
| 206 phase |= PlatformWheelEventPhaseMayBegin; | |
| 207 #endif | |
| 208 | |
| 209 return static_cast<PlatformWheelEventPhase>(phase); | |
| 210 #else | |
| 211 UNUSED_PARAM(event); | |
| 212 return PlatformWheelEventPhaseNone; | |
| 213 #endif | |
| 214 } | |
| 215 | |
| 216 #if ENABLE(GESTURE_EVENTS) | |
| 217 static PlatformEvent::Type gestureEventTypeForEvent(NSEvent *event) | |
| 218 { | |
| 219 switch ([event type]) { | |
| 220 case NSEventTypeBeginGesture: | |
| 221 return PlatformEvent::GestureScrollBegin; | |
| 222 case NSEventTypeEndGesture: | |
| 223 return PlatformEvent::GestureScrollEnd; | |
| 224 default: | |
| 225 ASSERT_NOT_REACHED(); | |
| 226 return PlatformEvent::GestureScrollEnd; | |
| 227 } | |
| 228 } | |
| 229 #endif | |
| 230 | |
| 231 static inline String textFromEvent(NSEvent* event) | |
| 232 { | |
| 233 if ([event type] == NSFlagsChanged) | |
| 234 return String(""); | |
| 235 return String([event characters]); | |
| 236 } | |
| 237 | |
| 238 static inline String unmodifiedTextFromEvent(NSEvent* event) | |
| 239 { | |
| 240 if ([event type] == NSFlagsChanged) | |
| 241 return String(""); | |
| 242 return String([event charactersIgnoringModifiers]); | |
| 243 } | |
| 244 | |
| 245 String keyIdentifierForKeyEvent(NSEvent* event) | |
| 246 { | |
| 247 if ([event type] == NSFlagsChanged) | |
| 248 switch ([event keyCode]) { | |
| 249 case 54: // Right Command | |
| 250 case 55: // Left Command | |
| 251 return String("Meta"); | |
| 252 | |
| 253 case 57: // Capslock | |
| 254 return String("CapsLock"); | |
| 255 | |
| 256 case 56: // Left Shift | |
| 257 case 60: // Right Shift | |
| 258 return String("Shift"); | |
| 259 | |
| 260 case 58: // Left Alt | |
| 261 case 61: // Right Alt | |
| 262 return String("Alt"); | |
| 263 | |
| 264 case 59: // Left Ctrl | |
| 265 case 62: // Right Ctrl | |
| 266 return String("Control"); | |
| 267 | |
| 268 default: | |
| 269 ASSERT_NOT_REACHED(); | |
| 270 return String(""); | |
| 271 } | |
| 272 | |
| 273 NSString *s = [event charactersIgnoringModifiers]; | |
| 274 if ([s length] != 1) { | |
| 275 LOG(Events, "received an unexpected number of characters in key event: %
u", [s length]); | |
| 276 return "Unidentified"; | |
| 277 } | |
| 278 return keyIdentifierForCharCode([s characterAtIndex:0]); | |
| 279 } | |
| 280 | |
| 281 static bool isKeypadEvent(NSEvent* event) | |
| 282 { | |
| 283 // Check that this is the type of event that has a keyCode. | |
| 284 switch ([event type]) { | |
| 285 case NSKeyDown: | |
| 286 case NSKeyUp: | |
| 287 case NSFlagsChanged: | |
| 288 break; | |
| 289 default: | |
| 290 return false; | |
| 291 } | |
| 292 | |
| 293 if ([event modifierFlags] & NSNumericPadKeyMask) | |
| 294 return true; | |
| 295 | |
| 296 switch ([event keyCode]) { | |
| 297 case 71: // Clear | |
| 298 case 81: // = | |
| 299 case 75: // / | |
| 300 case 67: // * | |
| 301 case 78: // - | |
| 302 case 69: // + | |
| 303 case 76: // Enter | |
| 304 case 65: // . | |
| 305 case 82: // 0 | |
| 306 case 83: // 1 | |
| 307 case 84: // 2 | |
| 308 case 85: // 3 | |
| 309 case 86: // 4 | |
| 310 case 87: // 5 | |
| 311 case 88: // 6 | |
| 312 case 89: // 7 | |
| 313 case 91: // 8 | |
| 314 case 92: // 9 | |
| 315 return true; | |
| 316 } | |
| 317 | |
| 318 return false; | |
| 319 } | |
| 320 | |
| 321 int windowsKeyCodeForKeyEvent(NSEvent* event) | |
| 322 { | |
| 323 int code = 0; | |
| 324 // There are several kinds of characters for which we produce key code from
char code: | |
| 325 // 1. Roman letters. Windows keyboard layouts affect both virtual key codes
and character codes for these, | |
| 326 // so e.g. 'A' gets the same keyCode on QWERTY, AZERTY or Dvorak layouts. | |
| 327 // 2. Keys for which there is no known Mac virtual key codes, like PrintScre
en. | |
| 328 // 3. Certain punctuation keys. On Windows, these are also remapped dependin
g on current keyboard layout, | |
| 329 // but see comment in windowsKeyCodeForCharCode(). | |
| 330 if (!isKeypadEvent(event) && ([event type] == NSKeyDown || [event type] == N
SKeyUp)) { | |
| 331 // Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified
characters first. | |
| 332 NSString* s = [event characters]; | |
| 333 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]
) : 0; | |
| 334 if (code) | |
| 335 return code; | |
| 336 | |
| 337 // Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on -
[NSEvent keyCode] below. | |
| 338 s = [event charactersIgnoringModifiers]; | |
| 339 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]
) : 0; | |
| 340 if (code) | |
| 341 return code; | |
| 342 } | |
| 343 | |
| 344 // Map Mac virtual key code directly to Windows one for any keys not handled
above. | |
| 345 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboar
d ('A') and on Russian keyboard (CYRILLIC LETTER EF). | |
| 346 return windowsKeyCodeForKeyCode([event keyCode]); | |
| 347 } | |
| 348 | |
| 349 static inline bool isKeyUpEvent(NSEvent *event) | |
| 350 { | |
| 351 if ([event type] != NSFlagsChanged) | |
| 352 return [event type] == NSKeyUp; | |
| 353 // FIXME: This logic fails if the user presses both Shift keys at once, for
example: | |
| 354 // we treat releasing one of them as keyDown. | |
| 355 switch ([event keyCode]) { | |
| 356 case 54: // Right Command | |
| 357 case 55: // Left Command | |
| 358 return ([event modifierFlags] & NSCommandKeyMask) == 0; | |
| 359 | |
| 360 case 57: // Capslock | |
| 361 return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0; | |
| 362 | |
| 363 case 56: // Left Shift | |
| 364 case 60: // Right Shift | |
| 365 return ([event modifierFlags] & NSShiftKeyMask) == 0; | |
| 366 | |
| 367 case 58: // Left Alt | |
| 368 case 61: // Right Alt | |
| 369 return ([event modifierFlags] & NSAlternateKeyMask) == 0; | |
| 370 | |
| 371 case 59: // Left Ctrl | |
| 372 case 62: // Right Ctrl | |
| 373 return ([event modifierFlags] & NSControlKeyMask) == 0; | |
| 374 | |
| 375 case 63: // Function | |
| 376 return ([event modifierFlags] & NSFunctionKeyMask) == 0; | |
| 377 } | |
| 378 return false; | |
| 379 } | |
| 380 | |
| 381 static inline PlatformEvent::Modifiers modifiersForEvent(NSEvent *event) | |
| 382 { | |
| 383 unsigned modifiers = 0; | |
| 384 if ([event modifierFlags] & NSShiftKeyMask) | |
| 385 modifiers |= PlatformEvent::ShiftKey; | |
| 386 if ([event modifierFlags] & NSControlKeyMask) | |
| 387 modifiers |= PlatformEvent::CtrlKey; | |
| 388 if ([event modifierFlags] & NSAlternateKeyMask) | |
| 389 modifiers |= PlatformEvent::AltKey; | |
| 390 if ([event modifierFlags] & NSCommandKeyMask) | |
| 391 modifiers |= PlatformEvent::MetaKey; | |
| 392 return (PlatformEvent::Modifiers)modifiers; | |
| 393 } | |
| 394 | |
| 395 | |
| 396 class PlatformMouseEventBuilder : public PlatformMouseEvent { | |
| 397 public: | |
| 398 PlatformMouseEventBuilder(NSEvent *event, NSView *windowView) | |
| 399 { | |
| 400 // PlatformEvent | |
| 401 m_type = mouseEventTypeForEvent(event); | |
| 402 m_modifiers = modifiersForEvent(event); | |
| 403 m_timestamp = [event timestamp]; | |
| 404 | |
| 405 // PlatformMouseEvent | |
| 406 m_position = pointForEvent(event, windowView); | |
| 407 m_globalPosition = globalPointForEvent(event); | |
| 408 m_button = mouseButtonForEvent(event); | |
| 409 m_clickCount = clickCountForEvent(event); | |
| 410 | |
| 411 // Mac specific | |
| 412 m_modifierFlags = [event modifierFlags]; | |
| 413 m_eventNumber = [event eventNumber]; | |
| 414 } | |
| 415 }; | |
| 416 | |
| 417 PlatformMouseEvent PlatformEventFactory::createPlatformMouseEvent(NSEvent *event
, NSView *windowView) | |
| 418 { | |
| 419 return PlatformMouseEventBuilder(event, windowView); | |
| 420 } | |
| 421 | |
| 422 | |
| 423 class PlatformWheelEventBuilder : public PlatformWheelEvent { | |
| 424 public: | |
| 425 PlatformWheelEventBuilder(NSEvent *event, NSView *windowView) | |
| 426 { | |
| 427 // PlatformEvent | |
| 428 m_type = PlatformEvent::Wheel; | |
| 429 m_modifiers = modifiersForEvent(event); | |
| 430 m_timestamp = [event timestamp]; | |
| 431 | |
| 432 // PlatformWheelEvent | |
| 433 m_position = pointForEvent(event, windowView); | |
| 434 m_globalPosition = globalPointForEvent(event); | |
| 435 m_granularity = ScrollByPixelWheelEvent; | |
| 436 | |
| 437 BOOL continuous; | |
| 438 wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous); | |
| 439 if (continuous) { | |
| 440 m_wheelTicksX = m_deltaX / static_cast<float>(Scrollbar::pixelsPerLi
neStep()); | |
| 441 m_wheelTicksY = m_deltaY / static_cast<float>(Scrollbar::pixelsPerLi
neStep()); | |
| 442 } else { | |
| 443 m_wheelTicksX = m_deltaX; | |
| 444 m_wheelTicksY = m_deltaY; | |
| 445 m_deltaX *= static_cast<float>(Scrollbar::pixelsPerLineStep()); | |
| 446 m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep()); | |
| 447 } | |
| 448 | |
| 449 m_phase = phaseForEvent(event); | |
| 450 m_momentumPhase = momentumPhaseForEvent(event); | |
| 451 m_hasPreciseScrollingDeltas = continuous; | |
| 452 | |
| 453 #if HAVE(INVERTED_WHEEL_EVENTS) | |
| 454 m_directionInvertedFromDevice = [event isDirectionInvertedFromDevi
ce]; | |
| 455 #else | |
| 456 m_directionInvertedFromDevice = false; | |
| 457 #endif | |
| 458 } | |
| 459 }; | |
| 460 | |
| 461 PlatformWheelEvent PlatformEventFactory::createPlatformWheelEvent(NSEvent *event
, NSView *windowView) | |
| 462 { | |
| 463 return PlatformWheelEventBuilder(event, windowView); | |
| 464 } | |
| 465 | |
| 466 | |
| 467 class PlatformKeyboardEventBuilder : public PlatformKeyboardEvent { | |
| 468 public: | |
| 469 PlatformKeyboardEventBuilder(NSEvent *event) | |
| 470 { | |
| 471 // PlatformEvent | |
| 472 m_type = isKeyUpEvent(event) ? PlatformEven
t::KeyUp : PlatformEvent::KeyDown; | |
| 473 m_modifiers = modifiersForEvent(event); | |
| 474 m_timestamp = [event timestamp]; | |
| 475 | |
| 476 // PlatformKeyboardEvent | |
| 477 m_text = textFromEvent(event); | |
| 478 m_unmodifiedText = unmodifiedTextFromEvent(event); | |
| 479 m_keyIdentifier = keyIdentifierForKeyEvent(event); | |
| 480 m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event); | |
| 481 m_nativeVirtualKeyCode = [event keyCode]; | |
| 482 m_macCharCode = wkGetNSEventKeyChar(event); | |
| 483 m_autoRepeat = ([event type] != NSFlagsChanged) &
& [event isARepeat]; | |
| 484 m_isKeypad = isKeypadEvent(event); | |
| 485 m_isSystemKey = false; // SystemKey is always fals
e on the Mac. | |
| 486 | |
| 487 // Always use 13 for Enter/Return -- we don't want to use AppKit's diffe
rent character for Enter. | |
| 488 if (m_windowsVirtualKeyCode == VK_RETURN) { | |
| 489 m_text = "\r"; | |
| 490 m_unmodifiedText = "\r"; | |
| 491 } | |
| 492 | |
| 493 // AppKit sets text to "\x7F" for backspace, but the correct KeyboardEve
nt character code is 8. | |
| 494 if (m_windowsVirtualKeyCode == VK_BACK) { | |
| 495 m_text = "\x8"; | |
| 496 m_unmodifiedText = "\x8"; | |
| 497 } | |
| 498 | |
| 499 // Always use 9 for Tab -- we don't want to use AppKit's different chara
cter for shift-tab. | |
| 500 if (m_windowsVirtualKeyCode == VK_TAB) { | |
| 501 m_text = "\x9"; | |
| 502 m_unmodifiedText = "\x9"; | |
| 503 } | |
| 504 | |
| 505 // Mac specific. | |
| 506 m_macEvent = event; | |
| 507 } | |
| 508 }; | |
| 509 | |
| 510 PlatformKeyboardEvent PlatformEventFactory::createPlatformKeyboardEvent(NSEvent
*event) | |
| 511 { | |
| 512 return PlatformKeyboardEventBuilder(event); | |
| 513 } | |
| 514 | |
| 515 #if ENABLE(GESTURE_EVENTS) | |
| 516 class PlatformGestureEventBuilder : public PlatformGestureEvent { | |
| 517 public: | |
| 518 PlatformGestureEventBuilder(NSEvent *event, NSView *windowView) | |
| 519 { | |
| 520 // PlatformEvent | |
| 521 m_type = gestureEventTypeForEvent(event); | |
| 522 m_modifiers = modifiersForEvent(event); | |
| 523 m_timestamp = [event timestamp]; | |
| 524 | |
| 525 // PlatformGestureEvent | |
| 526 m_position = pointForEvent(event, windowView); | |
| 527 m_globalPosition = globalPointForEvent(event); | |
| 528 m_deltaX = 0; | |
| 529 m_deltaY = 0; | |
| 530 } | |
| 531 }; | |
| 532 | |
| 533 PlatformGestureEvent PlatformEventFactory::createPlatformGestureEvent(NSEvent *e
vent, NSView *windowView) | |
| 534 { | |
| 535 return PlatformGestureEventBuilder(event, windowView); | |
| 536 } | |
| 537 #endif | |
| 538 | |
| 539 } // namespace WebCore | |
| OLD | NEW |