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

Unified Diff: Source/devtools/front_end/ExtensionServer.js

Issue 212573006: DevTools: Implement batch event forwarding from extension panels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/KeyboardShortcut.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ExtensionServer.js
diff --git a/Source/devtools/front_end/ExtensionServer.js b/Source/devtools/front_end/ExtensionServer.js
index de286159b2d51a12050f80b838bdf1afc68dda18..7f3601b0e8c3812a7143e3a38627cfef1ce0291f 100644
--- a/Source/devtools/front_end/ExtensionServer.js
+++ b/Source/devtools/front_end/ExtensionServer.js
@@ -618,20 +618,37 @@ WebInspector.ExtensionServer.prototype = {
_onForwardKeyboardEvent: function(message)
{
const Esc = "U+001B";
+ message.entries.forEach(handleEventEntry);
- if (!message.ctrlKey && !message.altKey && !message.metaKey && !/^F\d+$/.test(message.keyIdentifier) && message.keyIdentifier !== Esc)
- return;
- // Fool around closure compiler -- it has its own notion of both KeyboardEvent constructor
- // and initKeyboardEvent methods and overriding these in externs.js does not have effect.
- var event = new window.KeyboardEvent(message.eventType, {
- keyIdentifier: message.keyIdentifier,
- location: message.location,
- ctrlKey: message.ctrlKey,
- altKey: message.altKey,
- shiftKey: message.shiftKey,
- metaKey: message.metaKey
- });
- document.dispatchEvent(event);
+ function handleEventEntry(entry)
+ {
+ if (!entry.ctrlKey && !entry.altKey && !entry.metaKey && !/^F\d+$/.test(entry.keyIdentifier) && entry.keyIdentifier !== Esc)
+ return;
+ // Fool around closure compiler -- it has its own notion of both KeyboardEvent constructor
+ // and initKeyboardEvent methods and overriding these in externs.js does not have effect.
+ var event = new window.KeyboardEvent(entry.eventType, {
+ keyIdentifier: entry.keyIdentifier,
+ location: entry.location,
+ ctrlKey: entry.ctrlKey,
+ altKey: entry.altKey,
+ shiftKey: entry.shiftKey,
+ metaKey: entry.metaKey
+ });
+ event.__keyCode = keyCodeForEntry(entry);
+ document.dispatchEvent(event);
+ }
+
+ function keyCodeForEntry(entry)
+ {
+ var keyCode = entry.keyCode;
+ if (!keyCode) {
+ // This is required only for synthetic events (e.g. dispatched in tests).
+ var match = entry.keyIdentifier.match(/^U\+([\dA-Fa-f]+)$/);
+ if (match)
+ keyCode = parseInt(match[1], 16);
+ }
+ return keyCode || 0;
+ }
},
_dispatchCallback: function(requestId, port, result)
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/KeyboardShortcut.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698