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

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

Issue 663523002: Adding support for DOM3 KeyboardEvents Code in KeyboardEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to use domCode instead of native domCode Created 5 years, 11 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e) 308 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e)
309 { 309 {
310 m_type = toPlatformKeyboardEventType(e.type); 310 m_type = toPlatformKeyboardEventType(e.type);
311 m_text = String(e.text); 311 m_text = String(e.text);
312 m_unmodifiedText = String(e.unmodifiedText); 312 m_unmodifiedText = String(e.unmodifiedText);
313 m_keyIdentifier = String(e.keyIdentifier); 313 m_keyIdentifier = String(e.keyIdentifier);
314 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); 314 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat);
315 m_nativeVirtualKeyCode = e.nativeKeyCode; 315 m_nativeVirtualKeyCode = e.nativeKeyCode;
316 m_domCode = e.domCode;
Wez 2015/01/08 01:14:48 Is there any point in storing the numeric form of
Habib Virji 2015/01/12 15:34:17 The only reason I was saving this is, as I did not
316 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); 317 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
317 m_isSystemKey = e.isSystemKey; 318 m_isSystemKey = e.isSystemKey;
318 319
319 m_modifiers = toPlatformEventModifiers(e.modifiers); 320 m_modifiers = toPlatformEventModifiers(e.modifiers);
320 321
321 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT 322 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT
322 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately, 323 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately,
323 // as in other places in the code. 324 // as in other places in the code.
324 m_windowsVirtualKeyCode = e.windowsKeyCode; 325 m_windowsVirtualKeyCode = e.windowsKeyCode;
325 if (e.windowsKeyCode == VK_SHIFT) { 326 if (e.windowsKeyCode == VK_SHIFT) {
(...skipping 26 matching lines...) Expand all
352 353
353 if (type == RawKeyDown) { 354 if (type == RawKeyDown) {
354 m_text = String(); 355 m_text = String();
355 m_unmodifiedText = String(); 356 m_unmodifiedText = String();
356 } else { 357 } else {
357 m_keyIdentifier = String(); 358 m_keyIdentifier = String();
358 m_windowsVirtualKeyCode = 0; 359 m_windowsVirtualKeyCode = 0;
359 } 360 }
360 } 361 }
361 362
363 void PlatformKeyboardEventBuilder::setKeyboardEventDOMCodeValue(const char* code )
364 {
365 m_code = String(code);
366 }
Habib Virji 2015/01/12 15:34:17 This code is now removed.
367
362 // Please refer to bug http://b/issue?id=961192, which talks about Webkit 368 // Please refer to bug http://b/issue?id=961192, which talks about Webkit
363 // keyboard event handling changes. It also mentions the list of keys 369 // keyboard event handling changes. It also mentions the list of keys
364 // which don't have associated character events. 370 // which don't have associated character events.
365 bool PlatformKeyboardEventBuilder::isCharacterKey() const 371 bool PlatformKeyboardEventBuilder::isCharacterKey() const
366 { 372 {
367 switch (windowsVirtualKeyCode()) { 373 switch (windowsVirtualKeyCode()) {
368 case VKEY_BACK: 374 case VKEY_BACK:
369 case VKEY_ESCAPE: 375 case VKEY_ESCAPE:
370 return false; 376 return false;
371 } 377 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 modifiers |= WebInputEvent::IsRight; 671 modifiers |= WebInputEvent::IsRight;
666 672
667 timeStampSeconds = event.timeStamp() / millisPerSecond; 673 timeStampSeconds = event.timeStamp() / millisPerSecond;
668 windowsKeyCode = event.keyCode(); 674 windowsKeyCode = event.keyCode();
669 675
670 // 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
671 // initKeyboardEvent. 677 // initKeyboardEvent.
672 if (!event.keyEvent()) 678 if (!event.keyEvent())
673 return; 679 return;
674 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); 680 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
681 domCode = event.keyEvent()->domCode();
Wez 2015/01/08 01:14:48 Similarly to above, can we arrange this translatio
Habib Virji 2015/01/12 15:34:17 New code has embedder API for this purpose.
675 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap)); 682 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap));
676 for (unsigned i = 0; i < numberOfCharacters; ++i) { 683 for (unsigned i = 0; i < numberOfCharacters; ++i) {
677 text[i] = event.keyEvent()->text()[i]; 684 text[i] = event.keyEvent()->text()[i];
678 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; 685 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
679 } 686 }
680 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length()); 687 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length());
681 } 688 }
682 689
683 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) 690 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type)
684 { 691 {
(...skipping 14 matching lines...) Expand all
699 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev ent) 706 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev ent)
700 { 707 {
701 type = toWebKeyboardEventType(event.type()); 708 type = toWebKeyboardEventType(event.type());
702 modifiers = toWebEventModifiers(event.modifiers()); 709 modifiers = toWebEventModifiers(event.modifiers());
703 if (event.isAutoRepeat()) 710 if (event.isAutoRepeat())
704 modifiers |= WebInputEvent::IsAutoRepeat; 711 modifiers |= WebInputEvent::IsAutoRepeat;
705 if (event.isKeypad()) 712 if (event.isKeypad())
706 modifiers |= WebInputEvent::IsKeyPad; 713 modifiers |= WebInputEvent::IsKeyPad;
707 isSystemKey = event.isSystemKey(); 714 isSystemKey = event.isSystemKey();
708 nativeKeyCode = event.nativeVirtualKeyCode(); 715 nativeKeyCode = event.nativeVirtualKeyCode();
716 domCode = event.domCode();
709 717
710 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() ); 718 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() );
711 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ()); 719 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ());
712 720
713 event.text().copyTo(text, 0, textLengthCap); 721 event.text().copyTo(text, 0, textLengthCap);
714 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); 722 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap);
715 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); 723 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
716 } 724 }
717 725
718 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren derObject, WebTouchPoint::State state) 726 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren derObject, WebTouchPoint::State state)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 modifiers = getWebInputModifiers(event); 810 modifiers = getWebInputModifiers(event);
803 811
804 globalX = event.screenX(); 812 globalX = event.screenX();
805 globalY = event.screenY(); 813 globalY = event.screenY();
806 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject); 814 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject);
807 x = localPoint.x(); 815 x = localPoint.x();
808 y = localPoint.y(); 816 y = localPoint.y();
809 } 817 }
810 818
811 } // namespace blink 819 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698