 Chromium Code Reviews
 Chromium Code Reviews Issue 663523002:
  Adding support for DOM3 KeyboardEvents Code in KeyboardEvents  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 663523002:
  Adding support for DOM3 KeyboardEvents Code in KeyboardEvents  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/web/WebInputEventConversion.cpp | 
| diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp | 
| index 05362ad51cead37f99e912c696d5e67a2e63c626..6d51e6d3acc3c9b0b7a1279e430dddcac75c4aa5 100644 | 
| --- a/Source/web/WebInputEventConversion.cpp | 
| +++ b/Source/web/WebInputEventConversion.cpp | 
| @@ -45,6 +45,8 @@ | 
| #include "core/rendering/RenderObject.h" | 
| #include "platform/KeyboardCodes.h" | 
| #include "platform/Widget.h" | 
| +#include "public/web/WebViewClient.h" | 
| +#include "web/WebViewImpl.h" | 
| namespace blink { | 
| @@ -305,7 +307,28 @@ inline PlatformEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type) | 
| return PlatformEvent::KeyDown; | 
| } | 
| -PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEvent& e) | 
| +static void getDomCodeStringFromEnum(Widget* widget, String& code, long domCode) | 
| 
bokan
2015/01/20 17:05:58
Can we return the string, rather than using an out
 
Habib Virji
2015/01/22 16:01:30
Done.
 | 
| +{ | 
| + FrameView* view = toFrameView(widget->root()); | 
| + if (view) { | 
| + WebViewImpl* webView = WebViewImpl::fromPage(view->page()); | 
| + if (webView) | 
| + code = webView->client()->domCodeStringFromEnum(domCode); | 
| + } | 
| 
Wez
2015/01/17 02:35:10
This leaves the |code| empty, which is also the st
 
Habib Virji
2015/01/22 16:01:30
I have sent mail to Gary with the questions. 
For
 | 
| +} | 
| + | 
| +static long getDomEnumFromCodeString(const Widget* widget, const String& code) | 
| +{ | 
| + FrameView* view = toFrameView(widget->root()); | 
| + if (view) { | 
| + WebViewImpl* webView = WebViewImpl::fromPage(view->page()); | 
| + if (webView) | 
| + return webView->client()->domEnumFromCodeString(code.utf8().data()); | 
| + } | 
| + return 0; | 
| 
Wez
2015/01/17 02:35:10
This means that the embedder cannot use zero as on
 | 
| +} | 
| + | 
| +PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(Widget* widget, const WebKeyboardEvent& e) | 
| { | 
| m_type = toPlatformKeyboardEventType(e.type); | 
| m_text = String(e.text); | 
| @@ -315,6 +338,7 @@ PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven | 
| m_nativeVirtualKeyCode = e.nativeKeyCode; | 
| m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); | 
| m_isSystemKey = e.isSystemKey; | 
| + getDomCodeStringFromEnum(widget, m_code, e.domCode); | 
| m_modifiers = toPlatformEventModifiers(e.modifiers); | 
| @@ -645,7 +669,7 @@ WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const | 
| canScroll = event.canScroll(); | 
| } | 
| -WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) | 
| +WebKeyboardEventBuilder::WebKeyboardEventBuilder(const Widget* widget, const KeyboardEvent& event) | 
| { | 
| if (event.type() == EventTypeNames::keydown) | 
| type = KeyDown; | 
| @@ -672,6 +696,7 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) | 
| if (!event.keyEvent()) | 
| return; | 
| nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 
| + domCode = getDomEnumFromCodeString(widget, event.keyEvent()->code()); | 
| unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), static_cast<unsigned>(textLengthCap)); | 
| for (unsigned i = 0; i < numberOfCharacters; ++i) { | 
| text[i] = event.keyEvent()->text()[i]; | 
| @@ -696,7 +721,7 @@ WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) | 
| } | 
| } | 
| -WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& event) | 
| +WebKeyboardEventBuilder::WebKeyboardEventBuilder(const Widget* widget, const PlatformKeyboardEvent& event) | 
| { | 
| type = toWebKeyboardEventType(event.type()); | 
| modifiers = toWebEventModifiers(event.modifiers()); | 
| @@ -706,6 +731,7 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev | 
| modifiers |= WebInputEvent::IsKeyPad; | 
| isSystemKey = event.isSystemKey(); | 
| nativeKeyCode = event.nativeVirtualKeyCode(); | 
| + domCode = getDomEnumFromCodeString(widget, event.code()); | 
| windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode()); | 
| modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode()); |