Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: Source/web/WebInputEventConversion.cpp

Issue 933323002: Add experimental Support for DOM3 KeyboardEvent key value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated comments, and change API name to domKeyEnumFromString Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 { 312 {
313 m_type = toPlatformKeyboardEventType(e.type); 313 m_type = toPlatformKeyboardEventType(e.type);
314 m_text = String(e.text); 314 m_text = String(e.text);
315 m_unmodifiedText = String(e.unmodifiedText); 315 m_unmodifiedText = String(e.unmodifiedText);
316 m_keyIdentifier = String(e.keyIdentifier); 316 m_keyIdentifier = String(e.keyIdentifier);
317 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); 317 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat);
318 m_nativeVirtualKeyCode = e.nativeKeyCode; 318 m_nativeVirtualKeyCode = e.nativeKeyCode;
319 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); 319 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
320 m_isSystemKey = e.isSystemKey; 320 m_isSystemKey = e.isSystemKey;
321 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); 321 m_code = Platform::current()->domCodeStringFromEnum(e.domCode);
322 m_key = Platform::current()->domKeyStringFromEnum(e.domKey);
Rick Byers 2015/04/20 19:49:46 Wow, I'm surprised we do this every time we create
Habib Virji 2015/04/29 16:00:50 I agree this is not the best use of the embedded A
Rick Byers 2015/04/29 17:34:27 Yes, please do. Maybe add a TODO comment here ref
Habib Virji 2015/04/30 09:07:24 Done.
322 323
323 m_modifiers = toPlatformEventModifiers(e.modifiers); 324 m_modifiers = toPlatformEventModifiers(e.modifiers);
324 325
325 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT 326 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT
326 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately, 327 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately,
327 // as in other places in the code. 328 // as in other places in the code.
328 m_windowsVirtualKeyCode = e.windowsKeyCode; 329 m_windowsVirtualKeyCode = e.windowsKeyCode;
329 if (e.windowsKeyCode == VK_SHIFT) { 330 if (e.windowsKeyCode == VK_SHIFT) {
330 if (e.modifiers & WebInputEvent::IsLeft) 331 if (e.modifiers & WebInputEvent::IsLeft)
331 m_windowsVirtualKeyCode = VK_LSHIFT; 332 m_windowsVirtualKeyCode = VK_LSHIFT;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 672
672 timeStampSeconds = event.timeStamp() / millisPerSecond; 673 timeStampSeconds = event.timeStamp() / millisPerSecond;
673 windowsKeyCode = event.keyCode(); 674 windowsKeyCode = event.keyCode();
674 675
675 // The platform keyevent does not exist if the event was created using 676 // The platform keyevent does not exist if the event was created using
676 // initKeyboardEvent. 677 // initKeyboardEvent.
677 if (!event.keyEvent()) 678 if (!event.keyEvent())
678 return; 679 return;
679 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); 680 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
680 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code( )); 681 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code( ));
682 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key());
681 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap)); 683 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap));
682 for (unsigned i = 0; i < numberOfCharacters; ++i) { 684 for (unsigned i = 0; i < numberOfCharacters; ++i) {
683 text[i] = event.keyEvent()->text()[i]; 685 text[i] = event.keyEvent()->text()[i];
684 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; 686 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
685 } 687 }
686 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length()); 688 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length());
687 } 689 }
688 690
689 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) 691 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type)
690 { 692 {
(...skipping 15 matching lines...) Expand all
706 { 708 {
707 type = toWebKeyboardEventType(event.type()); 709 type = toWebKeyboardEventType(event.type());
708 modifiers = toWebEventModifiers(event.modifiers()); 710 modifiers = toWebEventModifiers(event.modifiers());
709 if (event.isAutoRepeat()) 711 if (event.isAutoRepeat())
710 modifiers |= WebInputEvent::IsAutoRepeat; 712 modifiers |= WebInputEvent::IsAutoRepeat;
711 if (event.isKeypad()) 713 if (event.isKeypad())
712 modifiers |= WebInputEvent::IsKeyPad; 714 modifiers |= WebInputEvent::IsKeyPad;
713 isSystemKey = event.isSystemKey(); 715 isSystemKey = event.isSystemKey();
714 nativeKeyCode = event.nativeVirtualKeyCode(); 716 nativeKeyCode = event.nativeVirtualKeyCode();
715 domCode = Platform::current()->domEnumFromCodeString(event.code()); 717 domCode = Platform::current()->domEnumFromCodeString(event.code());
718 domKey = Platform::current()->domKeyEnumFromString(event.key());
716 719
717 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() ); 720 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() );
718 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ()); 721 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ());
719 722
720 event.text().copyTo(text, 0, textLengthCap); 723 event.text().copyTo(text, 0, textLengthCap);
721 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); 724 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap);
722 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); 725 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
723 } 726 }
724 727
725 static WebTouchPoint toWebTouchPoint(const Touch* touch, const LayoutObject* lay outObject, WebTouchPoint::State state) 728 static WebTouchPoint toWebTouchPoint(const Touch* touch, const LayoutObject* lay outObject, WebTouchPoint::State state)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 modifiers = getWebInputModifiers(event); 813 modifiers = getWebInputModifiers(event);
811 814
812 globalX = event.screenX(); 815 globalX = event.screenX();
813 globalY = event.screenY(); 816 globalY = event.screenY();
814 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL ocation(), *layoutObject); 817 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL ocation(), *layoutObject);
815 x = localPoint.x(); 818 x = localPoint.x();
816 y = localPoint.y(); 819 y = localPoint.y();
817 } 820 }
818 821
819 } // namespace blink 822 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698