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