| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 NOTREACHED(); | 365 NOTREACHED(); |
| 366 } | 366 } |
| 367 return PlatformEvent::KeyDown; | 367 return PlatformEvent::KeyDown; |
| 368 } | 368 } |
| 369 | 369 |
| 370 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven
t& e) | 370 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven
t& e) |
| 371 { | 371 { |
| 372 m_type = toPlatformKeyboardEventType(e.type); | 372 m_type = toPlatformKeyboardEventType(e.type); |
| 373 m_text = String(e.text); | 373 m_text = String(e.text); |
| 374 m_unmodifiedText = String(e.unmodifiedText); | 374 m_unmodifiedText = String(e.unmodifiedText); |
| 375 m_keyIdentifier = String(e.keyIdentifier); | |
| 376 m_nativeVirtualKeyCode = e.nativeKeyCode; | 375 m_nativeVirtualKeyCode = e.nativeKeyCode; |
| 377 m_isSystemKey = e.isSystemKey; | 376 m_isSystemKey = e.isSystemKey; |
| 378 // TODO: BUG482880 Fix this initialization to lazy initialization. | 377 // TODO: BUG482880 Fix this initialization to lazy initialization. |
| 379 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); | 378 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); |
| 380 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); | 379 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); |
| 381 | 380 |
| 382 m_modifiers = e.modifiers; | 381 m_modifiers = e.modifiers; |
| 383 m_timestamp = e.timeStampSeconds; | 382 m_timestamp = e.timeStampSeconds; |
| 384 m_windowsVirtualKeyCode = e.windowsKeyCode; | 383 m_windowsVirtualKeyCode = e.windowsKeyCode; |
| 385 } | 384 } |
| 386 | 385 |
| 387 void PlatformKeyboardEventBuilder::setKeyType(EventType type) | 386 void PlatformKeyboardEventBuilder::setKeyType(EventType type) |
| 388 { | 387 { |
| 389 // According to the behavior of Webkit in Windows platform, | 388 // According to the behavior of Webkit in Windows platform, |
| 390 // we need to convert KeyDown to RawKeydown and Char events | 389 // we need to convert KeyDown to RawKeydown and Char events |
| 391 // See WebKit/WebKit/Win/WebView.cpp | 390 // See WebKit/WebKit/Win/WebView.cpp |
| 392 DCHECK(m_type == KeyDown); | 391 DCHECK(m_type == KeyDown); |
| 393 DCHECK(type == RawKeyDown || type == Char); | 392 DCHECK(type == RawKeyDown || type == Char); |
| 394 m_type = type; | 393 m_type = type; |
| 395 | 394 |
| 396 if (type == RawKeyDown) { | 395 if (type == RawKeyDown) { |
| 397 m_text = String(); | 396 m_text = String(); |
| 398 m_unmodifiedText = String(); | 397 m_unmodifiedText = String(); |
| 399 } else { | 398 } else { |
| 400 m_keyIdentifier = String(); | |
| 401 m_windowsVirtualKeyCode = 0; | 399 m_windowsVirtualKeyCode = 0; |
| 402 } | 400 } |
| 403 } | 401 } |
| 404 | 402 |
| 405 // Please refer to bug http://b/issue?id=961192, which talks about Webkit | 403 // Please refer to bug http://b/issue?id=961192, which talks about Webkit |
| 406 // keyboard event handling changes. It also mentions the list of keys | 404 // keyboard event handling changes. It also mentions the list of keys |
| 407 // which don't have associated character events. | 405 // which don't have associated character events. |
| 408 bool PlatformKeyboardEventBuilder::isCharacterKey() const | 406 bool PlatformKeyboardEventBuilder::isCharacterKey() const |
| 409 { | 407 { |
| 410 switch (windowsVirtualKeyCode()) { | 408 switch (windowsVirtualKeyCode()) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 if (!event.keyEvent()) | 664 if (!event.keyEvent()) |
| 667 return; | 665 return; |
| 668 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 666 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); |
| 669 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); | 667 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); |
| 670 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); | 668 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); |
| 671 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); | 669 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); |
| 672 for (unsigned i = 0; i < numberOfCharacters; ++i) { | 670 for (unsigned i = 0; i < numberOfCharacters; ++i) { |
| 673 text[i] = event.keyEvent()->text()[i]; | 671 text[i] = event.keyEvent()->text()[i]; |
| 674 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; | 672 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; |
| 675 } | 673 } |
| 676 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); | |
| 677 } | 674 } |
| 678 | 675 |
| 679 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::EventType type) | 676 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::EventType type) |
| 680 { | 677 { |
| 681 switch (type) { | 678 switch (type) { |
| 682 case PlatformEvent::KeyUp: | 679 case PlatformEvent::KeyUp: |
| 683 return WebInputEvent::KeyUp; | 680 return WebInputEvent::KeyUp; |
| 684 case PlatformEvent::KeyDown: | 681 case PlatformEvent::KeyDown: |
| 685 return WebInputEvent::KeyDown; | 682 return WebInputEvent::KeyDown; |
| 686 case PlatformEvent::RawKeyDown: | 683 case PlatformEvent::RawKeyDown: |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 break; | 816 break; |
| 820 case GestureSourceTouchscreen: | 817 case GestureSourceTouchscreen: |
| 821 sourceDevice = WebGestureDeviceTouchscreen; | 818 sourceDevice = WebGestureDeviceTouchscreen; |
| 822 break; | 819 break; |
| 823 case GestureSourceUninitialized: | 820 case GestureSourceUninitialized: |
| 824 NOTREACHED(); | 821 NOTREACHED(); |
| 825 } | 822 } |
| 826 } | 823 } |
| 827 | 824 |
| 828 } // namespace blink | 825 } // namespace blink |
| OLD | NEW |