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

Side by Side Diff: chrome/browser/resources/pdf/pdf_scripting_api.js

Issue 2358553002: PDF: Use KeyboardEvent.code instead of keyCode.
Patch Set: Created 4 years, 3 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 | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Turn a dictionary received from postMessage into a key event. 6 * Turn a dictionary received from postMessage into a key event.
7 * @param {Object} dict A dictionary representing the key event. 7 * @param {Object} dict A dictionary representing the key event.
8 * @return {Event} A key event. 8 * @return {Event} A key event.
9 */ 9 */
10 function DeserializeKeyEvent(dict) { 10 function DeserializeKeyEvent(dict) {
11 var e = document.createEvent('Event'); 11 var e = document.createEvent('Event');
12 e.initEvent('keydown'); 12 e.initEvent('keydown');
13 // TODO(thestig): Remove this once setKeyEventCallback() callers have been
14 // converted to event.code. Ditto below in SerializeKeyEvent().
13 e.keyCode = dict.keyCode; 15 e.keyCode = dict.keyCode;
16 e.code = dict.code;
14 e.shiftKey = dict.shiftKey; 17 e.shiftKey = dict.shiftKey;
15 e.ctrlKey = dict.ctrlKey; 18 e.ctrlKey = dict.ctrlKey;
16 e.altKey = dict.altKey; 19 e.altKey = dict.altKey;
17 e.metaKey = dict.metaKey; 20 e.metaKey = dict.metaKey;
18 e.fromScriptingAPI = true; 21 e.fromScriptingAPI = true;
19 return e; 22 return e;
20 } 23 }
21 24
22 /** 25 /**
23 * Turn a key event into a dictionary which can be sent over postMessage. 26 * Turn a key event into a dictionary which can be sent over postMessage.
24 * @param {Event} event A key event. 27 * @param {Event} event A key event.
25 * @return {Object} A dictionary representing the key event. 28 * @return {Object} A dictionary representing the key event.
26 */ 29 */
27 function SerializeKeyEvent(event) { 30 function SerializeKeyEvent(event) {
28 return { 31 return {
29 keyCode: event.keyCode, 32 keyCode: event.keyCode,
33 code: event.code,
30 shiftKey: event.shiftKey, 34 shiftKey: event.shiftKey,
31 ctrlKey: event.ctrlKey, 35 ctrlKey: event.ctrlKey,
32 altKey: event.altKey, 36 altKey: event.altKey,
33 metaKey: event.metaKey 37 metaKey: event.metaKey
34 }; 38 };
35 } 39 }
36 40
37 /** 41 /**
38 * An enum containing a value specifying whether the PDF is currently loading, 42 * An enum containing a value specifying whether the PDF is currently loading,
39 * has finished loading or failed to load. 43 * has finished loading or failed to load.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Add the functions to the iframe so that they can be called directly. 257 // Add the functions to the iframe so that they can be called directly.
254 iframe.setViewportChangedCallback = 258 iframe.setViewportChangedCallback =
255 client.setViewportChangedCallback.bind(client); 259 client.setViewportChangedCallback.bind(client);
256 iframe.setLoadCallback = client.setLoadCallback.bind(client); 260 iframe.setLoadCallback = client.setLoadCallback.bind(client);
257 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); 261 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client);
258 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); 262 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client);
259 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); 263 iframe.loadPreviewPage = client.loadPreviewPage.bind(client);
260 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); 264 iframe.sendKeyEvent = client.sendKeyEvent.bind(client);
261 return iframe; 265 return iframe;
262 } 266 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698