mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 696918 - Restrict key input in DOM full-screen mode to explicit whitelist. r=smaug
This commit is contained in:
parent
677ba8894d
commit
0aa08286eb
@ -13,19 +13,18 @@
|
||||
// List of key codes, and whether they should cause a warning in full-screen mode.
|
||||
var keyList = [
|
||||
// Allowed: DOM_VK_CANCEL to DOM_VK_CAPS_LOCK, inclusive
|
||||
{ code: "VK_CANCEL", warn: false},
|
||||
{ code: "VK_HELP", warn: false},
|
||||
{ code: "VK_BACK_SPACE", warn: false},
|
||||
{ code: "VK_CANCEL", warn: true},
|
||||
{ code: "VK_HELP", warn: true},
|
||||
{ code: "VK_BACK_SPACE", warn: true},
|
||||
{ code: "VK_TAB", warn: false},
|
||||
{ code: "VK_CLEAR", warn: false},
|
||||
{ code: "VK_RETURN", warn: false},
|
||||
{ code: "VK_ENTER", warn: false},
|
||||
{ code: "VK_CLEAR", warn: true},
|
||||
{ code: "VK_RETURN", warn: true},
|
||||
{ code: "VK_ENTER", warn: true},
|
||||
{ code: "VK_SHIFT", warn: false},
|
||||
{ code: "VK_CONTROL", warn: false},
|
||||
{ code: "VK_ALT", warn: false},
|
||||
{ code: "VK_PAUSE", warn: false},
|
||||
{ code: "VK_CAPS_LOCK", warn: false},
|
||||
|
||||
{ code: "VK_PAUSE", warn: true},
|
||||
{ code: "VK_CAPS_LOCK", warn: true},
|
||||
{ code: "VK_KANA", warn: true},
|
||||
{ code: "VK_HANGUL", warn: true},
|
||||
{ code: "VK_JUNJA", warn: true},
|
||||
@ -37,8 +36,6 @@ var keyList = [
|
||||
{ code: "VK_NONCONVERT", warn: true},
|
||||
{ code: "VK_ACCEPT", warn: true},
|
||||
{ code: "VK_MODECHANGE", warn: true},
|
||||
|
||||
// Allowed: DOM_VK_SPACE to DOM_VK_DELETE, inclusive
|
||||
{ code: "VK_SPACE", warn: false},
|
||||
{ code: "VK_PAGE_UP", warn: false},
|
||||
{ code: "VK_PAGE_DOWN", warn: false},
|
||||
@ -48,13 +45,12 @@ var keyList = [
|
||||
{ code: "VK_UP", warn: false},
|
||||
{ code: "VK_RIGHT", warn: false},
|
||||
{ code: "VK_DOWN", warn: false},
|
||||
{ code: "VK_SELECT", warn: false},
|
||||
{ code: "VK_PRINT", warn: false},
|
||||
{ code: "VK_EXECUTE", warn: false},
|
||||
{ code: "VK_PRINTSCREEN", warn: false},
|
||||
{ code: "VK_INSERT", warn: false},
|
||||
{ code: "VK_DELETE", warn: false},
|
||||
|
||||
{ code: "VK_SELECT", warn: true},
|
||||
{ code: "VK_PRINT", warn: true},
|
||||
{ code: "VK_EXECUTE", warn: true},
|
||||
{ code: "VK_PRINTSCREEN", warn: true},
|
||||
{ code: "VK_INSERT", warn: true},
|
||||
{ code: "VK_DELETE", warn: true},
|
||||
{ code: "VK_0", warn: true},
|
||||
{ code: "VK_1", warn: true},
|
||||
{ code: "VK_2", warn: true},
|
||||
@ -65,11 +61,8 @@ var keyList = [
|
||||
{ code: "VK_7", warn: true},
|
||||
{ code: "VK_8", warn: true},
|
||||
{ code: "VK_9", warn: true},
|
||||
|
||||
// Allowed: DOM_VK_SPACE to DOM_VK_DELETE, inclusive
|
||||
{ code: "VK_SEMICOLON", warn: false},
|
||||
{ code: "VK_EQUALS", warn: false},
|
||||
|
||||
{ code: "VK_SEMICOLON", warn: true},
|
||||
{ code: "VK_EQUALS", warn: true},
|
||||
{ code: "VK_A", warn: true},
|
||||
{ code: "VK_B", warn: true},
|
||||
{ code: "VK_C", warn: true},
|
||||
@ -108,48 +101,46 @@ var keyList = [
|
||||
{ code: "VK_NUMPAD7", warn: true},
|
||||
{ code: "VK_NUMPAD8", warn: true},
|
||||
{ code: "VK_NUMPAD9", warn: true},
|
||||
|
||||
// Allowed: DOM_VK_MULTIPLY to DOM_VK_META, inclusive
|
||||
{ code: "VK_MULTIPLY", warn: false},
|
||||
{ code: "VK_ADD", warn: false},
|
||||
{ code: "VK_SEPARATOR", warn: false},
|
||||
{ code: "VK_SUBTRACT", warn: false},
|
||||
{ code: "VK_DECIMAL", warn: false},
|
||||
{ code: "VK_DIVIDE", warn: false},
|
||||
{ code: "VK_F1", warn: false},
|
||||
{ code: "VK_F2", warn: false},
|
||||
{ code: "VK_F3", warn: false},
|
||||
{ code: "VK_F4", warn: false},
|
||||
{ code: "VK_F5", warn: false},
|
||||
{ code: "VK_F6", warn: false},
|
||||
{ code: "VK_F7", warn: false},
|
||||
{ code: "VK_F8", warn: false},
|
||||
{ code: "VK_F9", warn: false},
|
||||
{ code: "VK_F10", warn: false},
|
||||
{ code: "VK_F11", warn: false}, // F11 exit full-screen handler is in browser.js, so won't cause exit here.
|
||||
{ code: "VK_F12", warn: false},
|
||||
{ code: "VK_F13", warn: false},
|
||||
{ code: "VK_F14", warn: false},
|
||||
{ code: "VK_F15", warn: false},
|
||||
{ code: "VK_F16", warn: false},
|
||||
{ code: "VK_F17", warn: false},
|
||||
{ code: "VK_F18", warn: false},
|
||||
{ code: "VK_F19", warn: false},
|
||||
{ code: "VK_F20", warn: false},
|
||||
{ code: "VK_F21", warn: false},
|
||||
{ code: "VK_F22", warn: false},
|
||||
{ code: "VK_F23", warn: false},
|
||||
{ code: "VK_F24", warn: false},
|
||||
{ code: "VK_NUM_LOCK", warn: false},
|
||||
{ code: "VK_SCROLL_LOCK", warn: false},
|
||||
{ code: "VK_COMMA", warn: false},
|
||||
{ code: "VK_PERIOD", warn: false},
|
||||
{ code: "VK_SLASH", warn: false},
|
||||
{ code: "VK_BACK_QUOTE", warn: false},
|
||||
{ code: "VK_OPEN_BRACKET", warn: false},
|
||||
{ code: "VK_BACK_SLASH", warn: false},
|
||||
{ code: "VK_CLOSE_BRACKET", warn: false},
|
||||
{ code: "VK_QUOTE", warn: false},
|
||||
{ code: "VK_MULTIPLY", warn: true},
|
||||
{ code: "VK_ADD", warn: true},
|
||||
{ code: "VK_SEPARATOR", warn: true},
|
||||
{ code: "VK_SUBTRACT", warn: true},
|
||||
{ code: "VK_DECIMAL", warn: true},
|
||||
{ code: "VK_DIVIDE", warn: true},
|
||||
{ code: "VK_F1", warn: true},
|
||||
{ code: "VK_F2", warn: true},
|
||||
{ code: "VK_F3", warn: true},
|
||||
{ code: "VK_F4", warn: true},
|
||||
{ code: "VK_F5", warn: true},
|
||||
{ code: "VK_F6", warn: true},
|
||||
{ code: "VK_F7", warn: true},
|
||||
{ code: "VK_F8", warn: true},
|
||||
{ code: "VK_F9", warn: true},
|
||||
{ code: "VK_F10", warn: true},
|
||||
{ code: "VK_F11", warn: true}, // F11 exit full-screen handler is in browser.js, so won't cause exit here.
|
||||
{ code: "VK_F12", warn: true},
|
||||
{ code: "VK_F13", warn: true},
|
||||
{ code: "VK_F14", warn: true},
|
||||
{ code: "VK_F15", warn: true},
|
||||
{ code: "VK_F16", warn: true},
|
||||
{ code: "VK_F17", warn: true},
|
||||
{ code: "VK_F18", warn: true},
|
||||
{ code: "VK_F19", warn: true},
|
||||
{ code: "VK_F20", warn: true},
|
||||
{ code: "VK_F21", warn: true},
|
||||
{ code: "VK_F22", warn: true},
|
||||
{ code: "VK_F23", warn: true},
|
||||
{ code: "VK_F24", warn: true},
|
||||
{ code: "VK_NUM_LOCK", warn: true},
|
||||
{ code: "VK_SCROLL_LOCK", warn: true},
|
||||
{ code: "VK_COMMA", warn: true},
|
||||
{ code: "VK_PERIOD", warn: true},
|
||||
{ code: "VK_SLASH", warn: true},
|
||||
{ code: "VK_BACK_QUOTE", warn: true},
|
||||
{ code: "VK_OPEN_BRACKET", warn: true},
|
||||
{ code: "VK_BACK_SLASH", warn: true},
|
||||
{ code: "VK_CLOSE_BRACKET", warn: true},
|
||||
{ code: "VK_QUOTE", warn: true},
|
||||
{ code: "VK_META", warn: false},
|
||||
];
|
||||
|
||||
|
@ -6302,23 +6302,32 @@ IsFullScreenAndRestrictedKeyEvent(nsIContent* aTarget, const nsEvent* aEvent)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Key input is restricted. Determine if the key event has a restricted
|
||||
// key code. Non-restricted codes are:
|
||||
// DOM_VK_CANCEL to DOM_VK_CAPS_LOCK, inclusive
|
||||
// DOM_VK_SPACE to DOM_VK_DELETE, inclusive
|
||||
// DOM_VK_SEMICOLON to DOM_VK_EQUALS, inclusive
|
||||
// DOM_VK_MULTIPLY to DOM_VK_META, inclusive
|
||||
int key = static_cast<const nsKeyEvent*>(aEvent)->keyCode;
|
||||
if ((key >= NS_VK_CANCEL && key <= NS_VK_CAPS_LOCK) ||
|
||||
(key >= NS_VK_SPACE && key <= NS_VK_DELETE) ||
|
||||
(key >= NS_VK_SEMICOLON && key <= NS_VK_EQUALS) ||
|
||||
(key >= NS_VK_MULTIPLY && key <= NS_VK_META)) {
|
||||
return false;
|
||||
// We're in full-screen mode. We whitelist key codes, and we will
|
||||
// show a warning when keys not in this list are pressed.
|
||||
const nsKeyEvent* keyEvent = static_cast<const nsKeyEvent*>(aEvent);
|
||||
int key = keyEvent->keyCode ? keyEvent->keyCode : keyEvent->charCode;
|
||||
switch (key) {
|
||||
case NS_VK_TAB:
|
||||
case NS_VK_SPACE:
|
||||
case NS_VK_PAGE_UP:
|
||||
case NS_VK_PAGE_DOWN:
|
||||
case NS_VK_END:
|
||||
case NS_VK_HOME:
|
||||
case NS_VK_LEFT:
|
||||
case NS_VK_UP:
|
||||
case NS_VK_RIGHT:
|
||||
case NS_VK_DOWN:
|
||||
case NS_VK_SHIFT:
|
||||
case NS_VK_CONTROL:
|
||||
case NS_VK_ALT:
|
||||
case NS_VK_META:
|
||||
// Unrestricted key code.
|
||||
return false;
|
||||
default:
|
||||
// Otherwise, fullscreen is enabled, key input is restricted, and the key
|
||||
// code is not an allowed key code.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, fullscreen is enabled, key input is restricted, and the key
|
||||
// code is not an allowed key code.
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user