diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index b6ef3e2e3b7a..f37bcf701a68 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -346,8 +346,32 @@ impl Window { GlRequest::Specific(Api::OpenGlEs, (3, 0)) } + /// Detect if given char is default ignorable in unicode + /// http://www.unicode.org/L2/L2002/02368-default-ignorable.pdf + fn is_identifier_ignorable(&self, ch: &char) -> bool { + match *ch { + '\u{0000}'...'\u{0008}' | '\u{000E}'...'\u{001F}' | + '\u{007F}'...'\u{0084}' | '\u{0086}'...'\u{009F}' | + '\u{06DD}' | '\u{070F}' | + '\u{180B}'...'\u{180D}' | '\u{180E}' | + '\u{200C}'...'\u{200F}' | + '\u{202A}'...'\u{202E}' | '\u{2060}'...'\u{2063}' | + '\u{2064}'...'\u{2069}' | '\u{206A}'...'\u{206F}' | + '\u{FE00}'...'\u{FE0F}' | '\u{FEFF}' | + '\u{FFF0}'...'\u{FFF8}' | '\u{FFF9}'...'\u{FFFB}' | + '\u{1D173}'...'\u{1D17A}' | '\u{E0000}' | + '\u{E0001}' | + '\u{E0002}'...'\u{E001F}' | '\u{E0020}'...'\u{E007F}' | + '\u{E0080}'...'\u{E0FFF}' => true, + _ => false + } + } + fn handle_received_character(&self, ch: char) { let modifiers = Window::glutin_mods_to_script_mods(self.key_modifiers.get()); + if self.is_identifier_ignorable(&ch) { + return + } if let Some(last_pressed_key) = self.last_pressed_key.get() { let event = WindowEvent::KeyEvent(Some(ch), last_pressed_key, KeyState::Pressed, modifiers); self.event_queue.borrow_mut().push(event);