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

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: Added keyboardTest failure for virtual/slimmingpaint Created 5 years, 10 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
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 #include "core/events/MouseEvent.h" 38 #include "core/events/MouseEvent.h"
39 #include "core/events/TouchEvent.h" 39 #include "core/events/TouchEvent.h"
40 #include "core/events/WheelEvent.h" 40 #include "core/events/WheelEvent.h"
41 #include "core/frame/FrameHost.h" 41 #include "core/frame/FrameHost.h"
42 #include "core/frame/FrameView.h" 42 #include "core/frame/FrameView.h"
43 #include "core/frame/PinchViewport.h" 43 #include "core/frame/PinchViewport.h"
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "core/rendering/RenderObject.h" 45 #include "core/rendering/RenderObject.h"
46 #include "platform/KeyboardCodes.h" 46 #include "platform/KeyboardCodes.h"
47 #include "platform/Widget.h" 47 #include "platform/Widget.h"
48 #include "public/platform/Platform.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 static const double millisPerSecond = 1000.0; 52 static const double millisPerSecond = 1000.0;
52 53
53 static float scaleDeltaToWindow(const Widget* widget, float delta) 54 static float scaleDeltaToWindow(const Widget* widget, float delta)
54 { 55 {
55 float scale = 1; 56 float scale = 1;
56 if (widget) { 57 if (widget) {
57 FrameView* rootView = toFrameView(widget->root()); 58 FrameView* rootView = toFrameView(widget->root());
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e) 311 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e)
311 { 312 {
312 m_type = toPlatformKeyboardEventType(e.type); 313 m_type = toPlatformKeyboardEventType(e.type);
313 m_text = String(e.text); 314 m_text = String(e.text);
314 m_unmodifiedText = String(e.unmodifiedText); 315 m_unmodifiedText = String(e.unmodifiedText);
315 m_keyIdentifier = String(e.keyIdentifier); 316 m_keyIdentifier = String(e.keyIdentifier);
316 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); 317 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat);
317 m_nativeVirtualKeyCode = e.nativeKeyCode; 318 m_nativeVirtualKeyCode = e.nativeKeyCode;
318 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); 319 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
319 m_isSystemKey = e.isSystemKey; 320 m_isSystemKey = e.isSystemKey;
321 m_code = Platform::current()->domCodeStringFromEnum(e.domCode);
320 322
321 m_modifiers = toPlatformEventModifiers(e.modifiers); 323 m_modifiers = toPlatformEventModifiers(e.modifiers);
322 324
323 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT 325 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT
324 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately, 326 // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately,
325 // as in other places in the code. 327 // as in other places in the code.
326 m_windowsVirtualKeyCode = e.windowsKeyCode; 328 m_windowsVirtualKeyCode = e.windowsKeyCode;
327 if (e.windowsKeyCode == VK_SHIFT) { 329 if (e.windowsKeyCode == VK_SHIFT) {
328 if (e.modifiers & WebInputEvent::IsLeft) 330 if (e.modifiers & WebInputEvent::IsLeft)
329 m_windowsVirtualKeyCode = VK_LSHIFT; 331 m_windowsVirtualKeyCode = VK_LSHIFT;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 modifiers |= WebInputEvent::IsRight; 669 modifiers |= WebInputEvent::IsRight;
668 670
669 timeStampSeconds = event.timeStamp() / millisPerSecond; 671 timeStampSeconds = event.timeStamp() / millisPerSecond;
670 windowsKeyCode = event.keyCode(); 672 windowsKeyCode = event.keyCode();
671 673
672 // The platform keyevent does not exist if the event was created using 674 // The platform keyevent does not exist if the event was created using
673 // initKeyboardEvent. 675 // initKeyboardEvent.
674 if (!event.keyEvent()) 676 if (!event.keyEvent())
675 return; 677 return;
676 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); 678 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
679 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code( ));
677 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap)); 680 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st atic_cast<unsigned>(textLengthCap));
678 for (unsigned i = 0; i < numberOfCharacters; ++i) { 681 for (unsigned i = 0; i < numberOfCharacters; ++i) {
679 text[i] = event.keyEvent()->text()[i]; 682 text[i] = event.keyEvent()->text()[i];
680 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; 683 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
681 } 684 }
682 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length()); 685 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif ier().length());
683 } 686 }
684 687
685 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) 688 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type)
686 { 689 {
(...skipping 14 matching lines...) Expand all
701 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev ent) 704 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev ent)
702 { 705 {
703 type = toWebKeyboardEventType(event.type()); 706 type = toWebKeyboardEventType(event.type());
704 modifiers = toWebEventModifiers(event.modifiers()); 707 modifiers = toWebEventModifiers(event.modifiers());
705 if (event.isAutoRepeat()) 708 if (event.isAutoRepeat())
706 modifiers |= WebInputEvent::IsAutoRepeat; 709 modifiers |= WebInputEvent::IsAutoRepeat;
707 if (event.isKeypad()) 710 if (event.isKeypad())
708 modifiers |= WebInputEvent::IsKeyPad; 711 modifiers |= WebInputEvent::IsKeyPad;
709 isSystemKey = event.isSystemKey(); 712 isSystemKey = event.isSystemKey();
710 nativeKeyCode = event.nativeVirtualKeyCode(); 713 nativeKeyCode = event.nativeVirtualKeyCode();
714 domCode = Platform::current()->domEnumFromCodeString(event.code());
711 715
712 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() ); 716 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() );
713 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ()); 717 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ());
714 718
715 event.text().copyTo(text, 0, textLengthCap); 719 event.text().copyTo(text, 0, textLengthCap);
716 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); 720 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap);
717 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); 721 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
718 } 722 }
719 723
720 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren derObject, WebTouchPoint::State state) 724 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
804 modifiers = getWebInputModifiers(event); 808 modifiers = getWebInputModifiers(event);
805 809
806 globalX = event.screenX(); 810 globalX = event.screenX();
807 globalY = event.screenY(); 811 globalY = event.screenY();
808 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject); 812 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject);
809 x = localPoint.x(); 813 x = localPoint.x();
810 y = localPoint.y(); 814 y = localPoint.y();
811 } 815 }
812 816
813 } // namespace blink 817 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698