OLD | NEW |
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 /* eslint-disable indent */ | 5 /* eslint-disable indent */ |
6 (function(window) { | 6 (function(window) { |
7 | 7 |
8 // DevToolsAPI ---------------------------------------------------------------- | 8 // DevToolsAPI ---------------------------------------------------------------- |
9 | 9 |
10 /** | 10 /** |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 /** | 222 /** |
223 * @param {number} requestId | 223 * @param {number} requestId |
224 * @param {string} fileSystemPath | 224 * @param {string} fileSystemPath |
225 */ | 225 */ |
226 indexingDone: function(requestId, fileSystemPath) | 226 indexingDone: function(requestId, fileSystemPath) |
227 { | 227 { |
228 this._dispatchOnInspectorFrontendAPI("indexingDone", [requestId, fileSys
temPath]); | 228 this._dispatchOnInspectorFrontendAPI("indexingDone", [requestId, fileSys
temPath]); |
229 }, | 229 }, |
230 | 230 |
231 /** | 231 /** |
232 * @param {{type: string, keyIdentifier: string, keyCode: number, modifiers:
number}} event | 232 * @param {{type: string, key: string, code: string, keyCode: number, modifi
ers: number}} event |
233 */ | 233 */ |
234 keyEventUnhandled: function(event) | 234 keyEventUnhandled: function(event) |
235 { | 235 { |
| 236 event.keyIdentifier = keyCodeToKeyIdentifier(event.keyCode); |
236 this._dispatchOnInspectorFrontendAPI("keyEventUnhandled", [event]); | 237 this._dispatchOnInspectorFrontendAPI("keyEventUnhandled", [event]); |
237 }, | 238 }, |
238 | 239 |
239 /** | 240 /** |
240 * @param {boolean} hard | 241 * @param {boolean} hard |
241 */ | 242 */ |
242 reloadInspectedPage: function(hard) | 243 reloadInspectedPage: function(hard) |
243 { | 244 { |
244 this._dispatchOnInspectorFrontendAPI("reloadInspectedPage", [hard]); | 245 this._dispatchOnInspectorFrontendAPI("reloadInspectedPage", [hard]); |
245 }, | 246 }, |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 var pair = params[i].split("="); | 996 var pair = params[i].split("="); |
996 var name = pair.shift(); | 997 var name = pair.shift(); |
997 var value = pair.join("="); | 998 var value = pair.join("="); |
998 if (name === "remoteFrontendUrl" && !remoteFrontendUrlRegexp.test(value)
) | 999 if (name === "remoteFrontendUrl" && !remoteFrontendUrlRegexp.test(value)
) |
999 location.search = ""; | 1000 location.search = ""; |
1000 if (name === "remoteBase" && !remoteBaseRegexp.test(value)) | 1001 if (name === "remoteBase" && !remoteBaseRegexp.test(value)) |
1001 location.search = ""; | 1002 location.search = ""; |
1002 } | 1003 } |
1003 } | 1004 } |
1004 | 1005 |
| 1006 var staticKeyIdentifiers = new Map([ |
| 1007 [0x12, "Alt"], |
| 1008 [0x11, "Control"], |
| 1009 [0x10, "Shift"], |
| 1010 [0x14, "CapsLock"], |
| 1011 [0x5b, "Win"], |
| 1012 [0x5c, "Win"], |
| 1013 [0x0c, "Clear"], |
| 1014 [0x28, "Down"], |
| 1015 [0x23, "End"], |
| 1016 [0x0a, "Enter"], |
| 1017 [0x0d, "Enter"], |
| 1018 [0x2b, "Execute"], |
| 1019 [0x70, "F1"], |
| 1020 [0x71, "F2"], |
| 1021 [0x72, "F3"], |
| 1022 [0x73, "F4"], |
| 1023 [0x74, "F5"], |
| 1024 [0x75, "F6"], |
| 1025 [0x76, "F7"], |
| 1026 [0x77, "F8"], |
| 1027 [0x78, "F9"], |
| 1028 [0x79, "F10"], |
| 1029 [0x7a, "F11"], |
| 1030 [0x7b, "F12"], |
| 1031 [0x7c, "F13"], |
| 1032 [0x7d, "F14"], |
| 1033 [0x7e, "F15"], |
| 1034 [0x7f, "F16"], |
| 1035 [0x80, "F17"], |
| 1036 [0x81, "F18"], |
| 1037 [0x82, "F19"], |
| 1038 [0x83, "F20"], |
| 1039 [0x84, "F21"], |
| 1040 [0x85, "F22"], |
| 1041 [0x86, "F23"], |
| 1042 [0x87, "F24"], |
| 1043 [0x2f, "Help"], |
| 1044 [0x24, "Home"], |
| 1045 [0x2d, "Insert"], |
| 1046 [0x25, "Left"], |
| 1047 [0x22, "PageDown"], |
| 1048 [0x21, "PageUp"], |
| 1049 [0x13, "Pause"], |
| 1050 [0x2c, "PrintScreen"], |
| 1051 [0x27, "Right"], |
| 1052 [0x91, "Scroll"], |
| 1053 [0x29, "Select"], |
| 1054 [0x26, "Up"], |
| 1055 [0x2e, "U+007F"], // Standard says that DEL becomes U+007F. |
| 1056 [0xb0, "MediaNextTrack"], |
| 1057 [0xb1, "MediaPreviousTrack"], |
| 1058 [0xb2, "MediaStop"], |
| 1059 [0xb3, "MediaPlayPause"], |
| 1060 [0xad, "VolumeMute"], |
| 1061 [0xae, "VolumeDown"], |
| 1062 [0xaf, "VolumeUp"], |
| 1063 ]); |
| 1064 |
| 1065 function keyCodeToKeyIdentifier(keyCode) |
| 1066 { |
| 1067 var result = staticKeyIdentifiers.get(keyCode); |
| 1068 if (result !== undefined) |
| 1069 return result; |
| 1070 result = "U+"; |
| 1071 var hexString = keyCode.toString(16).toUpperCase(); |
| 1072 for (var i = hexString.length; i < 4; ++i) |
| 1073 result += "0"; |
| 1074 result += hexString; |
| 1075 return result; |
| 1076 } |
| 1077 |
1005 /** | 1078 /** |
1006 * @suppressGlobalPropertiesCheck | 1079 * @suppressGlobalPropertiesCheck |
1007 */ | 1080 */ |
1008 function installBackwardsCompatibility() | 1081 function installBackwardsCompatibility() |
1009 { | 1082 { |
1010 sanitizeRemoteFrontendUrl(); | 1083 sanitizeRemoteFrontendUrl(); |
1011 | 1084 |
1012 if (window.location.search.indexOf("remoteFrontend") === -1) | 1085 if (window.location.search.indexOf("remoteFrontend") === -1) |
1013 return; | 1086 return; |
1014 | 1087 |
| 1088 // Support for legacy (<M53) frontends. |
| 1089 if (!window.KeyboardEvent.prototype.hasOwnProperty("keyIdentifier")) { |
| 1090 Object.defineProperty(window.KeyboardEvent.prototype, "keyIdentifier", { |
| 1091 get: function() |
| 1092 { |
| 1093 return keyCodeToKeyIdentifier(this.keyCode); |
| 1094 } |
| 1095 }); |
| 1096 } |
| 1097 |
1015 // Support for legacy (<M50) frontends. | 1098 // Support for legacy (<M50) frontends. |
1016 installObjectObserve(); | 1099 installObjectObserve(); |
1017 | 1100 |
1018 /** | 1101 /** |
1019 * @this {CSSStyleDeclaration} | 1102 * @this {CSSStyleDeclaration} |
1020 */ | 1103 */ |
1021 function getValue(property) | 1104 function getValue(property) |
1022 { | 1105 { |
1023 // Note that |property| comes from another context, so we can't use ===
here. | 1106 // Note that |property| comes from another context, so we can't use ===
here. |
1024 // eslint-disable-next-line eqeqeq | 1107 // eslint-disable-next-line eqeqeq |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 | 1158 |
1076 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { | 1159 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { |
1077 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; | 1160 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; |
1078 DOMTokenList.prototype.toggle = function(token, force) | 1161 DOMTokenList.prototype.toggle = function(token, force) |
1079 { | 1162 { |
1080 if (arguments.length === 1) | 1163 if (arguments.length === 1) |
1081 force = !this.contains(token); | 1164 force = !this.contains(token); |
1082 return this.__originalDOMTokenListToggle(token, !!force); | 1165 return this.__originalDOMTokenListToggle(token, !!force); |
1083 } | 1166 } |
1084 } | 1167 } |
OLD | NEW |