Commit bd2c1ba9 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Remove KeyboardEvent.key polyfil for iOS, no longer needed.

The polyfil was added 4 years ago at r403715. It is now supported by
iOS Safari for quite a few versions (10.3+), based on [1]

[1] https://caniuse.com/?search=KeyboardEvent.Key

Bug: None
Change-Id: I7e16c08b5f18f70342d69c270da4ec2f8a96aacd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509929Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824098}
parent 54dd7c3a
...@@ -322,110 +322,6 @@ ...@@ -322,110 +322,6 @@
}); });
} }
// <if expr="is_ios">
// Polyfill 'key' in KeyboardEvent for iOS.
// This function is not intended to be complete but should
// be sufficient enough to have iOS work correctly while
// it does not support key yet.
if (!('key' in KeyboardEvent.prototype)) {
Object.defineProperty(KeyboardEvent.prototype, 'key', {
/** @this {KeyboardEvent} */
get() {
// 0-9
if (this.keyCode >= 0x30 && this.keyCode <= 0x39) {
return String.fromCharCode(this.keyCode);
}
// A-Z
if (this.keyCode >= 0x41 && this.keyCode <= 0x5a) {
let result = String.fromCharCode(this.keyCode).toLowerCase();
if (this.shiftKey) {
result = result.toUpperCase();
}
return result;
}
// Special characters
switch (this.keyCode) {
case 0x08:
return 'Backspace';
case 0x09:
return 'Tab';
case 0x0d:
return 'Enter';
case 0x10:
return 'Shift';
case 0x11:
return 'Control';
case 0x12:
return 'Alt';
case 0x1b:
return 'Escape';
case 0x20:
return ' ';
case 0x21:
return 'PageUp';
case 0x22:
return 'PageDown';
case 0x23:
return 'End';
case 0x24:
return 'Home';
case 0x25:
return 'ArrowLeft';
case 0x26:
return 'ArrowUp';
case 0x27:
return 'ArrowRight';
case 0x28:
return 'ArrowDown';
case 0x2d:
return 'Insert';
case 0x2e:
return 'Delete';
case 0x5b:
return 'Meta';
case 0x70:
return 'F1';
case 0x71:
return 'F2';
case 0x72:
return 'F3';
case 0x73:
return 'F4';
case 0x74:
return 'F5';
case 0x75:
return 'F6';
case 0x76:
return 'F7';
case 0x77:
return 'F8';
case 0x78:
return 'F9';
case 0x79:
return 'F10';
case 0x7a:
return 'F11';
case 0x7b:
return 'F12';
case 0xbb:
return '=';
case 0xbd:
return '-';
case 0xdb:
return '[';
case 0xdd:
return ']';
}
return 'Unidentified';
}
});
} else {
window.console.log('KeyboardEvent.Key polyfill not required');
}
// </if> /* is_ios */
/** /**
* @param {!Event} e * @param {!Event} e
* @return {boolean} Whether a modifier key was down when processing |e|. * @return {boolean} Whether a modifier key was down when processing |e|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment