Skip to content

Commit 85bfba5

Browse files
browser(webkit): properly specifiy keyIdentifier (#2149)
1 parent 436bc5c commit 85bfba5

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1223
1+
1224

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10901,10 +10901,10 @@ index 0000000000000000000000000000000000000000..5ae0ce152f06b8316dbfbbbb2efd1990
1090110901
+} // namespace WebKit
1090210902
diff --git a/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp
1090310903
new file mode 100644
10904-
index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a233649878
10904+
index 0000000000000000000000000000000000000000..5d19607e019489b33318be50ccdc94c2fcfae914
1090510905
--- /dev/null
1090610906
+++ b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.cpp
10907-
@@ -0,0 +1,253 @@
10907+
@@ -0,0 +1,282 @@
1090810908
+/*
1090910909
+ * Copyright (C) 2019 Microsoft Corporation.
1091010910
+ *
@@ -10937,6 +10937,7 @@ index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a2
1093710937
+#include "NativeWebMouseEvent.h"
1093810938
+#include "WebPageProxy.h"
1093910939
+#include <wtf/MathExtras.h>
10940+
+#include <wtf/HexNumber.h>
1094010941
+
1094110942
+namespace WebKit {
1094210943
+
@@ -11009,6 +11010,31 @@ index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a2
1100911010
+ m_mouseCallbacks = nullptr;
1101011011
+}
1101111012
+
11013+
+static String keyIdentifierForKey(const String& key)
11014+
+{
11015+
+ if (key.length() == 1)
11016+
+ return makeString("U+", hex(toASCIIUpper(key.characterAt(0)), 4));
11017+
+ if (key == "Delete")
11018+
+ return "U+007F";
11019+
+ if (key == "Backspace")
11020+
+ return "U+0008";
11021+
+ if (key == "ArrowUp")
11022+
+ return "Up";
11023+
+ if (key == "ArrowDown")
11024+
+ return "Down";
11025+
+ if (key == "ArrowLeft")
11026+
+ return "Left";
11027+
+ if (key == "ArrowRight")
11028+
+ return "Right";
11029+
+ if (key == "Tab")
11030+
+ return "U+0009";
11031+
+ if (key == "Pause")
11032+
+ return "Pause";
11033+
+ if (key == "ScrollLock")
11034+
+ return "Scroll";
11035+
+ return key;
11036+
+}
11037+
+
1101211038
+void WebPageInspectorInputAgent::dispatchKeyEvent(const String& type, const int* modifiers, const String* text, const String* unmodifiedText, const String* code, const String* key, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey, const JSON::Array* commands, Ref<Inspector::InputBackendDispatcherHandler::DispatchKeyEventCallback>&& callback)
1101311039
+{
1101411040
+ WebKit::WebEvent::Type eventType;
@@ -11053,6 +11079,8 @@ index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a2
1105311079
+ }
1105411080
+ }
1105511081
+
11082+
+ String keyIdentifier = keyIdentifierForKey(eventKey);
11083+
+
1105611084
+ bool eventIsAutoRepeat = false;
1105711085
+ if (autoRepeat)
1105811086
+ eventIsAutoRepeat = *autoRepeat;
@@ -11071,6 +11099,7 @@ index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a2
1107111099
+ eventUnmodifiedText,
1107211100
+ eventKey,
1107311101
+ eventCode,
11102+
+ keyIdentifier,
1107411103
+ eventWindowsVirtualKeyCode,
1107511104
+ eventNativeVirtualKeyCode,
1107611105
+ eventIsAutoRepeat,
@@ -11160,7 +11189,7 @@ index 0000000000000000000000000000000000000000..5043224bbd6378175c9ca7dce63fc5a2
1116011189
+} // namespace WebKit
1116111190
diff --git a/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h
1116211191
new file mode 100644
11163-
index 0000000000000000000000000000000000000000..76290475097e756e3d932d22be4d8c797be4aa0c
11192+
index 0000000000000000000000000000000000000000..20311d530090b0229010957a96fc60f44b4823fe
1116411193
--- /dev/null
1116511194
+++ b/Source/WebKit/UIProcess/WebPageInspectorInputAgent.h
1116611195
@@ -0,0 +1,84 @@
@@ -11228,7 +11257,7 @@ index 0000000000000000000000000000000000000000..76290475097e756e3d932d22be4d8c79
1122811257
+ void dispatchMouseEvent(const String& type, int x, int y, const int* modifiers, const String* button, const int* buttons, const int* clickCount, const int* deltaX, const int* deltaY, Ref<DispatchMouseEventCallback>&& callback) override;
1122911258
+
1123011259
+private:
11231-
+ void platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp);
11260+
+ void platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp);
1123211261
+#if PLATFORM(WPE)
1123311262
+ void platformDispatchMouseEvent(WebMouseEvent::Type type, int x, int y, WebMouseEvent::Button button, OptionSet<WebEvent::Modifier> modifiers);
1123411263
+#endif
@@ -12132,10 +12161,10 @@ index 0000000000000000000000000000000000000000..e5e25acebabb76a05a77db02a99f1267
1213212161
+} // namespace WebKit
1213312162
diff --git a/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp b/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp
1213412163
new file mode 100644
12135-
index 0000000000000000000000000000000000000000..7ad3fe416c5c747eaad8c6948c3549a3984223ea
12164+
index 0000000000000000000000000000000000000000..d0f9827544994e450e24e3f7a427c35eeff94d67
1213612165
--- /dev/null
1213712166
+++ b/Source/WebKit/UIProcess/gtk/WebPageInspectorInputAgentGtk.cpp
12138-
@@ -0,0 +1,107 @@
12167+
@@ -0,0 +1,105 @@
1213912168
+/*
1214012169
+ * Copyright (C) 2019 Microsoft Corporation.
1214112170
+ *
@@ -12201,11 +12230,10 @@ index 0000000000000000000000000000000000000000..7ad3fe416c5c747eaad8c6948c3549a3
1220112230
+ return state;
1220212231
+}
1220312232
+
12204-
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
12233+
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
1220512234
+{
1220612235
+ Vector<String> commands;
1220712236
+ const guint keyVal = WebCore::PlatformKeyboardEvent::gdkKeyCodeForWindowsKeyCode(windowsVirtualKeyCode);
12208-
+ String keyIdentifier;
1220912237
+ if (keyVal) {
1221012238
+ GdkEventType event = GDK_NOTHING;
1221112239
+ switch (type)
@@ -12222,7 +12250,6 @@ index 0000000000000000000000000000000000000000..7ad3fe416c5c747eaad8c6948c3549a3
1222212250
+ }
1222312251
+ unsigned state = modifiersToEventState(modifiers);
1222412252
+ commands = commandsForKeyEvent(event, keyVal, state);
12225-
+ keyIdentifier = WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyVal);
1222612253
+ }
1222712254
+ NativeWebKeyboardEvent event(
1222812255
+ type,
@@ -12642,10 +12669,10 @@ index 0000000000000000000000000000000000000000..6113f4cd60a5d72b8ead61176cb43200
1264212669
+} // namespace WebKit
1264312670
diff --git a/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm b/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm
1264412671
new file mode 100644
12645-
index 0000000000000000000000000000000000000000..30e6ae3bdc8c1695189885afae949071add54c4e
12672+
index 0000000000000000000000000000000000000000..832e52038cf42ea73246e036a66ad9e1fc87fa78
1264612673
--- /dev/null
1264712674
+++ b/Source/WebKit/UIProcess/mac/WebPageInspectorInputAgentMac.mm
12648-
@@ -0,0 +1,124 @@
12675+
@@ -0,0 +1,122 @@
1264912676
+/*
1265012677
+ * Copyright (C) 2019 Microsoft Corporation.
1265112678
+ *
@@ -12678,7 +12705,6 @@ index 0000000000000000000000000000000000000000..30e6ae3bdc8c1695189885afae949071
1267812705
+#import <WebCore/IntPoint.h>
1267912706
+#import <WebCore/IntSize.h>
1268012707
+#import "NativeWebKeyboardEvent.h"
12681-
+#import <wtf/HexNumber.h>
1268212708
+
1268312709
+namespace WebKit {
1268412710
+
@@ -12743,9 +12769,8 @@ index 0000000000000000000000000000000000000000..30e6ae3bdc8c1695189885afae949071
1274312769
+ }
1274412770
+}
1274512771
+
12746-
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp)
12772+
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& commands, WallTime timestamp)
1274712773
+{
12748-
+ String keyIdentifier = key.length() == 1 ? makeString("U+", hex(toASCIIUpper(key.characterAt(0)), 4)) : key;
1274912774
+ Vector<WebCore::KeypressCommand> macCommands;
1275012775
+ for (const String& command : commands)
1275112776
+ macCommands.append(WebCore::KeypressCommand(command.utf8().data()));
@@ -13030,7 +13055,7 @@ index 0000000000000000000000000000000000000000..62b841fe1d0de2296e1c61e328cff564
1303013055
+} // namespace WebKit
1303113056
diff --git a/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp b/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp
1303213057
new file mode 100644
13033-
index 0000000000000000000000000000000000000000..a299240b1fea96694cb47fa11fc6a6411ffdaf70
13058+
index 0000000000000000000000000000000000000000..5cf8a010e9809e6a95741cdb7c2cbeb445ab638b
1303413059
--- /dev/null
1303513060
+++ b/Source/WebKit/UIProcess/win/WebPageInspectorInputAgentWin.cpp
1303613061
@@ -0,0 +1,55 @@
@@ -13069,15 +13094,15 @@ index 0000000000000000000000000000000000000000..a299240b1fea96694cb47fa11fc6a641
1306913094
+
1307013095
+namespace WebKit {
1307113096
+
13072-
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
13097+
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
1307313098
+{
1307413099
+ NativeWebKeyboardEvent event(
1307513100
+ type,
1307613101
+ text,
1307713102
+ unmodifiedText,
1307813103
+ key,
1307913104
+ code,
13080-
+ "",
13105+
+ keyIdentifier,
1308113106
+ windowsVirtualKeyCode,
1308213107
+ nativeVirtualKeyCode,
1308313108
+ isAutoRepeat,
@@ -13220,10 +13245,10 @@ index 0000000000000000000000000000000000000000..5dc76aa302cb574307059e66a1b73730
1322013245
+} // namespace WebKit
1322113246
diff --git a/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp
1322213247
new file mode 100644
13223-
index 0000000000000000000000000000000000000000..585fb151f302e4b376c705ed0d0974d518733605
13248+
index 0000000000000000000000000000000000000000..c3d7cacea987ba2b094d5022c670705ef6ced129
1322413249
--- /dev/null
1322513250
+++ b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp
13226-
@@ -0,0 +1,59 @@
13251+
@@ -0,0 +1,55 @@
1322713252
+/*
1322813253
+ * Copyright (C) 2019 Microsoft Corporation.
1322913254
+ *
@@ -13259,12 +13284,8 @@ index 0000000000000000000000000000000000000000..585fb151f302e4b376c705ed0d0974d5
1325913284
+
1326013285
+namespace WebKit {
1326113286
+
13262-
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
13287+
+void WebPageInspectorInputAgent::platformDispatchKeyEvent(WebKeyboardEvent::Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<WebEvent::Modifier> modifiers, Vector<String>& macCommands, WallTime timestamp)
1326313288
+{
13264-
+ unsigned keyCode = WebCore::PlatformKeyboardEvent::WPEKeyCodeForWindowsKeyCode(windowsVirtualKeyCode);
13265-
+ String keyIdentifier;
13266-
+ if (keyCode)
13267-
+ keyIdentifier = WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode(keyCode);
1326813289
+ NativeWebKeyboardEvent event(
1326913290
+ type,
1327013291
+ text,

0 commit comments

Comments
 (0)