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