diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 73f6159a9a0..6213b1ef511 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -998,6 +998,9 @@ impl TextInput { self.insert_string(c.as_str()); return KeyReaction::DispatchInput; } + if matches!(key, Key::Process) { + return KeyReaction::DispatchInput; + } KeyReaction::Nothing }) .unwrap() diff --git a/ports/servoshell/egl/app_state.rs b/ports/servoshell/egl/app_state.rs index 486b01060e8..c0890e2d36a 100644 --- a/ports/servoshell/egl/app_state.rs +++ b/ports/servoshell/egl/app_state.rs @@ -620,11 +620,27 @@ impl RunningAppState { } pub fn ime_insert_text(&self, text: String) { - self.active_webview() - .notify_input_event(InputEvent::Ime(ImeEvent::Composition(CompositionEvent { + // In OHOS, we get empty text after the intended text. + if text.is_empty() { + return; + } + let active_webview = self.active_webview(); + active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent { + state: KeyState::Down, + key: Key::Process, + ..KeyboardEvent::default() + })); + active_webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition( + CompositionEvent { state: CompositionState::End, data: text, - }))); + }, + ))); + active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent { + state: KeyState::Up, + key: Key::Process, + ..KeyboardEvent::default() + })); self.perform_updates(); }