1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
10 #include "content/public/browser/native_web_keyboard_event.h"
11 #include "content/browser/renderer_host/web_event_factory_efl.h"
12 #include "ui/base/ime/composition_text.h"
13 #include "ui/gfx/geometry/rect.h"
15 typedef struct _Ecore_IMF_Context Ecore_IMF_Context;
19 class RenderWidgetHostViewEfl;
23 // Returns NULL if there is no available backend.
24 static IMContextEfl* Create(RenderWidgetHostViewEfl*);
28 void HandleKeyDownEvent(const Evas_Event_Key_Down* event, bool* was_filtered);
29 void HandleKeyUpEvent(const Evas_Event_Key_Up* event, bool* was_filtered);
31 void UpdateInputMethodType(ui::TextInputType, ui::TextInputMode,
32 bool can_compose_inline);
33 void UpdateInputMethodState(ui::TextInputType, bool can_compose_inline,
35 void UpdateCaretBounds(const gfx::Rect& caret_bounds);
42 void DoNotShowAfterResume();
47 void ResetIMFContext();
48 void CancelComposition();
49 void ConfirmComposition();
50 void SetSurroundingText(std::string value);
51 void SetIsInFormTag(bool is_in_form_tag);
52 void SetCaretPosition(int position);
54 // Return visible state based on ecore_imf API.
56 bool WebViewWillBeResized();
58 bool IsPreeditQueueEmpty() const { return preedit_queue_.empty(); }
59 bool IsCommitQueueEmpty() const { return commit_queue_.empty(); }
60 bool IsKeyUpQueueEmpty() const { return keyup_event_queue_.empty(); }
61 bool IsKeyDownQueueEmpty() const { return keydown_event_queue_.empty(); }
62 void PreeditQueuePop() { preedit_queue_.pop(); }
64 void HandleKeyEvent(bool processed, blink::WebInputEvent::Type);
66 void PushToKeyUpEventQueue(int key);
67 void PushToKeyDownEventQueue(NativeWebKeyboardEvent key);
69 void SendFakeCompositionKeyEvent(const base::string16& buf);
71 void UpdateLayoutVariation(bool is_minimum_negative, bool is_step_integer);
72 bool IsDefaultReturnKeyType();
73 #if defined(OS_TIZEN_MOBILE_PRODUCT)
74 void PrevNextButtonUpdate(bool prev_state, bool next_state);
76 bool ShouldHandleImmediately(const char* key);
77 void SetIMERecommendedWords(const std::string&);
78 void SetIMERecommendedWordsType(bool should_enable);
80 void SetDefaultViewSize(const gfx::Size& size) { default_view_size_ = size; }
83 IMContextEfl(RenderWidgetHostViewEfl*, Ecore_IMF_Context*);
85 void InitializeIMFContext(Ecore_IMF_Context*);
88 static Eina_Bool IMFRetrieveSurroundingCallback(void* data,
92 static void IMFCandidatePanelGeometryChangedCallback(void* data,
95 static void IMFCandidatePanelLanguageChangedCallback(
97 Ecore_IMF_Context* context,
99 static void IMFCandidatePanelStateChangedCallback(void* data,
102 static void IMFCommitCallback(void* data,
105 static void IMFDeleteSurroundingCallback(void* data,
108 #if defined(OS_TIZEN_TV_PRODUCT)
109 static void IMFEventPrivateCommandCallback(void* data,
110 Ecore_IMF_Context* context,
113 static void IMFInputPanelStateChangedCallback(void* data,
116 static void IMFInputPanelGeometryChangedCallback(void* data,
119 static void IMFPreeditChangedCallback(void* data,
120 Ecore_IMF_Context* context,
122 static void IMFTransactionPrivateCommandSendCallback(
124 Ecore_IMF_Context* context,
126 #if defined(OS_TIZEN_MOBILE_PRODUCT)
127 static void IMFEventPrivateCmdCallback(void* data,
128 Ecore_IMF_Context* context,
132 void OnCommit(void* event_info);
133 void OnPreeditChanged(void* data,
134 Ecore_IMF_Context* context,
136 #if defined(OS_TIZEN_MOBILE_PRODUCT)
137 void OnIMFPrevNextButtonPressedCallback(std::string command);
139 void OnInputPanelStateChanged(int state);
140 void OnInputPanelGeometryChanged();
142 void OnCandidateInputPanelStateChanged(int state);
143 void OnCandidateInputPanelGeometryChanged();
145 bool OnRetrieveSurrounding(char** text, int* offset);
146 void OnDeleteSurrounding(void* event_info);
147 void OnCandidateInputPanelLanguageChanged(Ecore_IMF_Context* context,
149 #if defined(OS_TIZEN_TV_PRODUCT)
150 void OnIMFEventPrivateCommand(std::string command);
153 void ProcessNextCommitText(bool processed);
154 void ProcessNextPreeditText(bool processed);
155 void ProcessNextKeyDownEvent();
156 void ProcessNextKeyUpEvent();
157 void SendCompositionKeyUpEvent(int windowsKeyCode);
159 RenderWidgetHostImpl* GetRenderWidgetHostImpl() const;
161 RenderWidgetHostViewEfl* view_;
163 Ecore_IMF_Context* context_;
165 // Whether or not the associated widget is focused.
168 // Whether or not is in form tag.
169 bool is_in_form_tag_;
171 // The current soft keyboard mode and layout
172 ui::TextInputMode current_mode_;
173 ui::TextInputType current_type_;
174 bool can_compose_inline_;
176 ui::CompositionText composition_;
178 // View size when IME isn't shown.
179 gfx::Size default_view_size_;
181 typedef std::queue<base::string16> CommitQueue;
182 typedef std::queue<ui::CompositionText> PreeditQueue;
183 typedef std::queue<int> KeyUpEventQueue;
184 typedef std::queue<NativeWebKeyboardEvent> KeyDownEventQueue;
186 CommitQueue commit_queue_;
187 PreeditQueue preedit_queue_;
188 KeyUpEventQueue keyup_event_queue_;
189 KeyDownEventQueue keydown_event_queue_;
191 bool is_ime_ctx_reset_;
193 bool should_show_on_resume_;
195 bool is_get_lookup_table_from_app_;
199 std::string surrounding_text_;
200 bool is_surrounding_text_change_in_progress_;
202 bool is_keyevent_processing_;
203 bool is_transaction_finished_;
206 } // namespace content