Fixup! Use the Aura path to |TextInputClient| 43/321043/3
authorhyoputer <hyoputer.kim@samsung.com>
Thu, 14 Nov 2024 08:22:40 +0000 (17:22 +0900)
committerBot Blink <blinkbot@samsung.com>
Thu, 28 Nov 2024 09:17:51 +0000 (09:17 +0000)
This patch fixes the key event issues, inversion of the keyup and
keydown event and duplicated keypress events. You could test them in
[0].
First, move processing the keyUp event from inside processing the
keyDown event where the reversion caused to after the keyDown event to
make them in order.
And, process fake key event of keycode 229 from |IMContextEfl| according
to the web spec [1]. Then we could prevent the duplicated KeyPress
event. And we could match the key event logic with TV WebApps and
the browser.

This patch is based on [2].

[0] https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html

[1] https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html

[2] fd69b69446bce97d8dc100d81276d29d614da3fe

Change-Id: I87c95bdc84d3923a949d3fd9e06dc01ca7f8eeeb
Signed-off-by: hyoputer <hyoputer.kim@samsung.com>
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_input_method_context.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h

index f7968d5b0d7bd9d4ef6adf02c031bf443df7b5f5..aeecdf9ecdc359e7402bc5c490833f57a6c64eff 100644 (file)
@@ -78,10 +78,6 @@ void EflInputMethodContext::Reset() {
 }
 
 bool EflInputMethodContext::DispatchKeyEvent(const ui::KeyEvent& key_event) {
-  if (key_event.is_system_key) {
-    im_context_->ProcessKeyUpEvent(key_event.key_code());
-  }
-
   return false;
 }
 
index e4fc84ccd758aebd85d2a06a2693e3e3c7c5b49c..0c11855b5331394a03fafbfb2ac9d354899dd35f 100644 (file)
@@ -496,52 +496,15 @@ void IMContextEfl::OnCommit(void* event_info) {
   char* text = static_cast<char*>(event_info);
   std::u16string text16 = base::UTF8ToUTF16(text);
 
-  SendFakeCompositionKeyEvent(text16);
-
+  SendFakeKeyDownEvent();
   LOG(INFO) << "OnCommit, text: " << text16;
   ime_delegate_->OnCommit(text16);
+  SendFakeKeyUpEvent();
 }
 
-void IMContextEfl::SendFakeCompositionKeyEvent(const std::u16string& buf) {
-  std::string str = base::UTF16ToUTF8(buf);
-
-#if BUILDFLAG(IS_TIZEN_TV)
-  // We should process both " " and "space" which IME sends.
-  // Otherwise " " would be received by engine and cause unnecessary page
-  // scroll.
-  if (str == " ")
-    str = "space";
-#endif
-
-  Evas_Event_Key_Down downEvent;
-  memset(&downEvent, 0, sizeof(Evas_Event_Key_Down));
-  downEvent.key = str.c_str();
-  downEvent.string = str.c_str();
-
-  KeyEvent event = MakeWebKeyEvent(true, &downEvent);
-  event.is_system_key = true;
-
-  // Key code should be '229' except ASCII key event about key down/up event.
-  // It is according to Web spec about key code [1].
-  // On TV WebAPPs case, key code should be '229' including ASCII key event
-  // about key down/up event.
-  // [1] https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/
-  // keyCode-spec.html
-  // [2] http://developer.samsung.com/tv/develop/tutorials/user-input/
-  // text-input-ime-external-keyboard
-  if (event.key_code() == 0)
-    event.set_key_code(static_cast<KeyboardCode>(229));
-
-#if BUILDFLAG(IS_TIZEN_TV)
-  if (blink::IsTIZENWRT()) {
-    // a-z, A-Z, 0-9
-    int key_code = event.key_code();
-    if ((key_code >= 65 && key_code <= 90) ||
-        (key_code >= 48 && key_code <= 57)) {
-      event.set_key_code(static_cast<KeyboardCode>(229));
-    }
-  }
-#endif
+void IMContextEfl::SendFakeKeyDownEvent() {
+  KeyEvent event(ET_KEY_PRESSED, static_cast<KeyboardCode>(229), EF_NONE,
+                 base::TimeTicks());
 
 #if BUILDFLAG(IS_TIZEN_TV)
   // Needed for HBBTV single window, multiwebview scenario.
@@ -550,8 +513,9 @@ void IMContextEfl::SendFakeCompositionKeyEvent(const std::u16string& buf) {
   EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event);
 }
 
-void IMContextEfl::ProcessKeyUpEvent(KeyboardCode code) {
-  KeyEvent event(ET_KEY_RELEASED, code, EF_NONE, base::TimeTicks());
+void IMContextEfl::SendFakeKeyUpEvent() {
+  KeyEvent event(ET_KEY_RELEASED, static_cast<KeyboardCode>(229), EF_NONE,
+                 base::TimeTicks());
 
 #if BUILDFLAG(IS_TIZEN_TV)
   // Needed for HBBTV single window, multiwebview scenario.
@@ -563,10 +527,7 @@ void IMContextEfl::ProcessKeyUpEvent(KeyboardCode code) {
 void IMContextEfl::SetComposition(const char* buffer) {
   std::u16string text16 = base::UTF8ToUTF16(buffer);
 
-  if (!text16.empty())
-    SendFakeCompositionKeyEvent(text16.substr(text16.length() - 1));
-  else
-    SendFakeCompositionKeyEvent(text16);
+  SendFakeKeyDownEvent();
 
   composition_ = CompositionText();
   composition_.text = text16;
@@ -624,6 +585,8 @@ void IMContextEfl::OnPreeditChanged(void* data,
   free(buffer);
 
   ime_delegate_->OnPreeditChanged(composition_);
+
+  SendFakeKeyUpEvent();
 }
 
 // TODO(kbalazs): figure out what do we need from these callbacks.
index ce2867e51697840b19e5dd425c0eac08728a662e..4fe930cca3a37a4b6b61514e29ba6462320e1991 100644 (file)
@@ -69,7 +69,6 @@ class IMContextEfl {
   bool IsShow();
   void UpdateLayoutVariation(bool is_minimum_negative, bool is_step_integer);
   void RequestHide();
-  void ProcessKeyUpEvent(KeyboardCode code);
 
   // To forward RenderWidgetHostImpl calls.
   void SetRWHHelper(content::RenderWidgetHostHelper* rwh_helper) {
@@ -157,7 +156,8 @@ class IMContextEfl {
 
   bool HasRenderWidgetHostImpl() const;
 
-  void SendFakeCompositionKeyEvent(const std::u16string& buf);
+  void SendFakeKeyDownEvent();
+  void SendFakeKeyUpEvent();
 
   Ecore_IMF_Context* context_;