1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 // Regression test for #29740. Inefficient MIR matching algorithms
14 // generated way too much code for this sort of case, leading to OOM.
15 #![allow(non_snake_case)]
17 pub mod KeyboardEventConstants {
18 pub const DOM_KEY_LOCATION_STANDARD: u32 = 0;
19 pub const DOM_KEY_LOCATION_LEFT: u32 = 1;
20 pub const DOM_KEY_LOCATION_RIGHT: u32 = 2;
21 pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3;
22 } // mod KeyboardEventConstants
148 fn key_from_string(key_string: &str, location: u32) -> Option<Key> {
150 " " => Some(Key::Space),
151 "\"" => Some(Key::Apostrophe),
152 "'" => Some(Key::Apostrophe),
153 "<" => Some(Key::Comma),
154 "," => Some(Key::Comma),
155 "_" => Some(Key::Minus),
156 "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Minus),
157 ">" => Some(Key::Period),
158 "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Period),
159 "?" => Some(Key::Slash),
160 "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Slash),
161 "~" => Some(Key::GraveAccent),
162 "`" => Some(Key::GraveAccent),
163 ")" => Some(Key::Num0),
164 "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num0),
165 "!" => Some(Key::Num1),
166 "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num1),
167 "@" => Some(Key::Num2),
168 "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num2),
169 "#" => Some(Key::Num3),
170 "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num3),
171 "$" => Some(Key::Num4),
172 "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num4),
173 "%" => Some(Key::Num5),
174 "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num5),
175 "^" => Some(Key::Num6),
176 "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num6),
177 "&" => Some(Key::Num7),
178 "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num7),
179 "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
180 "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
181 "(" => Some(Key::Num9),
182 "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num9),
183 ":" => Some(Key::Semicolon),
184 ";" => Some(Key::Semicolon),
185 "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
186 "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
239 "{" => Some(Key::LeftBracket),
240 "[" => Some(Key::LeftBracket),
241 "|" => Some(Key::Backslash),
242 "\\" => Some(Key::Backslash),
243 "}" => Some(Key::RightBracket),
244 "]" => Some(Key::RightBracket),
245 "Escape" => Some(Key::Escape),
246 "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD
248 "Tab" => Some(Key::Tab),
249 "Backspace" => Some(Key::Backspace),
250 "Insert" => Some(Key::Insert),
251 "Delete" => Some(Key::Delete),
252 "ArrowRight" => Some(Key::Right),
253 "ArrowLeft" => Some(Key::Left),
254 "ArrowDown" => Some(Key::Down),
255 "ArrowUp" => Some(Key::Up),
256 "PageUp" => Some(Key::PageUp),
257 "PageDown" => Some(Key::PageDown),
258 "Home" => Some(Key::Home),
259 "End" => Some(Key::End),
260 "CapsLock" => Some(Key::CapsLock),
261 "ScrollLock" => Some(Key::ScrollLock),
262 "NumLock" => Some(Key::NumLock),
263 "PrintScreen" => Some(Key::PrintScreen),
264 "Pause" => Some(Key::Pause),
265 "F1" => Some(Key::F1),
266 "F2" => Some(Key::F2),
267 "F3" => Some(Key::F3),
268 "F4" => Some(Key::F4),
269 "F5" => Some(Key::F5),
270 "F6" => Some(Key::F6),
271 "F7" => Some(Key::F7),
272 "F8" => Some(Key::F8),
273 "F9" => Some(Key::F9),
274 "F10" => Some(Key::F10),
275 "F11" => Some(Key::F11),
276 "F12" => Some(Key::F12),
277 "F13" => Some(Key::F13),
278 "F14" => Some(Key::F14),
279 "F15" => Some(Key::F15),
280 "F16" => Some(Key::F16),
281 "F17" => Some(Key::F17),
282 "F18" => Some(Key::F18),
283 "F19" => Some(Key::F19),
284 "F20" => Some(Key::F20),
285 "F21" => Some(Key::F21),
286 "F22" => Some(Key::F22),
287 "F23" => Some(Key::F23),
288 "F24" => Some(Key::F24),
289 "F25" => Some(Key::F25),
290 "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp0),
291 "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp1),
292 "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp2),
293 "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp3),
294 "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp4),
295 "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp5),
296 "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp6),
297 "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp7),
298 "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp8),
299 "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp9),
300 "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDecimal),
301 "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDivide),
302 "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpMultiply),
303 "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpSubtract),
304 "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpAdd),
305 "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD
306 => Some(Key::KpEnter),
307 "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpEqual),
308 "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
309 => Some(Key::LeftShift),
310 "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
311 => Some(Key::LeftControl),
312 "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT => Some(Key::LeftAlt),
313 "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
314 => Some(Key::LeftSuper),
315 "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
316 => Some(Key::RightShift),
317 "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
318 => Some(Key::RightControl),
319 "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt),
320 "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
321 => Some(Key::RightSuper),
322 "ContextMenu" => Some(Key::Menu),