blob: 63eb227b1822cdab032a3979d8e169b83c35ebe0 [file] [log] [blame]
[email protected]f751653a92014-02-18 16:32:551// Use of this source code is governed by a BSD-style license that can be
2// found in the LICENSE file.
3
Scott Violetfdda96d2018-07-27 20:17:234#include "content/shell/test_runner/text_input_controller.h"
[email protected]f751653a92014-02-18 16:32:555
avi5dd91f82015-12-25 22:30:466#include "base/macros.h"
danakj27e4ebe2020-04-15 18:48:277#include "content/shell/renderer/web_test/blink_test_runner.h"
Scott Violetfdda96d2018-07-27 20:17:238#include "content/shell/test_runner/web_view_test_proxy.h"
[email protected]f751653a92014-02-18 16:32:559#include "gin/arguments.h"
10#include "gin/handle.h"
11#include "gin/object_template_builder.h"
12#include "gin/wrappable.h"
Dave Tapuska129cef82019-12-19 16:36:4813#include "third_party/blink/public/common/input/web_keyboard_event.h"
Blink Reformata30d4232018-04-07 15:31:0614#include "third_party/blink/public/platform/web_coalesced_input_event.h"
15#include "third_party/blink/public/platform/web_input_event_result.h"
Blink Reformata30d4232018-04-07 15:31:0616#include "third_party/blink/public/web/blink.h"
17#include "third_party/blink/public/web/web_frame_widget.h"
18#include "third_party/blink/public/web/web_ime_text_span.h"
19#include "third_party/blink/public/web/web_input_method_controller.h"
20#include "third_party/blink/public/web/web_local_frame.h"
21#include "third_party/blink/public/web/web_range.h"
22#include "third_party/blink/public/web/web_view.h"
changwan9bdc18f02015-11-20 02:43:5223#include "third_party/skia/include/core/SkColor.h"
dtapuska899ac222017-01-03 18:09:1624#include "ui/events/base_event_utils.h"
[email protected]f751653a92014-02-18 16:32:5525#include "v8/include/v8.h"
26
danakj741848a2020-04-07 22:48:0627namespace content {
[email protected]f751653a92014-02-18 16:32:5528
29class TextInputControllerBindings
30 : public gin::Wrappable<TextInputControllerBindings> {
31 public:
32 static gin::WrapperInfo kWrapperInfo;
33
34 static void Install(base::WeakPtr<TextInputController> controller,
lukasza8b6d5f32016-04-22 16:56:3135 blink::WebLocalFrame* frame);
[email protected]f751653a92014-02-18 16:32:5536
37 private:
38 explicit TextInputControllerBindings(
39 base::WeakPtr<TextInputController> controller);
dchenge933b3e2014-10-21 11:44:0940 ~TextInputControllerBindings() override;
[email protected]f751653a92014-02-18 16:32:5541
42 // gin::Wrappable:
dchenge933b3e2014-10-21 11:44:0943 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
anand.ratn449f39a42014-10-06 13:45:5744 v8::Isolate* isolate) override;
[email protected]f751653a92014-02-18 16:32:5545
46 void InsertText(const std::string& text);
47 void UnmarkText();
Ryan Landay7b5dbd52018-01-11 19:05:5948 void UnmarkAndUnselectText();
[email protected]f751653a92014-02-18 16:32:5549 void DoCommand(const std::string& text);
Ryan Landay9c6809422018-01-17 07:04:1550 void ExtendSelectionAndDelete(int before, int after);
Ryan Landay6d163ae2018-01-17 06:58:0651 void DeleteSurroundingText(int before, int after);
[email protected]f751653a92014-02-18 16:32:5552 void SetMarkedText(const std::string& text, int start, int length);
Ryan Landayd2034672018-01-12 22:22:3253 void SetMarkedTextFromExistingText(int start, int length);
[email protected]f751653a92014-02-18 16:32:5554 bool HasMarkedText();
55 std::vector<int> MarkedRange();
56 std::vector<int> SelectedRange();
57 std::vector<int> FirstRectForCharacterRange(unsigned location,
58 unsigned length);
59 void SetComposition(const std::string& text);
ekaramad2daaf672016-11-10 20:29:0160 void ForceTextInputStateUpdate();
[email protected]f751653a92014-02-18 16:32:5561
62 base::WeakPtr<TextInputController> controller_;
63
64 DISALLOW_COPY_AND_ASSIGN(TextInputControllerBindings);
65};
66
67gin::WrapperInfo TextInputControllerBindings::kWrapperInfo = {
68 gin::kEmbedderNativeGin};
69
70// static
71void TextInputControllerBindings::Install(
72 base::WeakPtr<TextInputController> controller,
lukasza8b6d5f32016-04-22 16:56:3173 blink::WebLocalFrame* frame) {
Blink Reformat1c4d759e2017-04-09 16:34:5474 v8::Isolate* isolate = blink::MainThreadIsolate();
[email protected]f751653a92014-02-18 16:32:5575 v8::HandleScope handle_scope(isolate);
Blink Reformat1c4d759e2017-04-09 16:34:5476 v8::Local<v8::Context> context = frame->MainWorldScriptContext();
[email protected]f751653a92014-02-18 16:32:5577 if (context.IsEmpty())
78 return;
79
80 v8::Context::Scope context_scope(context);
81
82 gin::Handle<TextInputControllerBindings> bindings =
83 gin::CreateHandle(isolate, new TextInputControllerBindings(controller));
[email protected]ad4d2032014-04-28 13:50:5984 if (bindings.IsEmpty())
85 return;
deepak.s750d68f2015-04-30 07:32:4186 v8::Local<v8::Object> global = context->Global();
Dan Elphicka83be512019-02-05 15:57:2387 global
88 ->Set(context, gin::StringToV8(isolate, "textInputController"),
89 bindings.ToV8())
90 .Check();
[email protected]f751653a92014-02-18 16:32:5591}
92
93TextInputControllerBindings::TextInputControllerBindings(
94 base::WeakPtr<TextInputController> controller)
95 : controller_(controller) {}
96
97TextInputControllerBindings::~TextInputControllerBindings() {}
98
99gin::ObjectTemplateBuilder
100TextInputControllerBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) {
101 return gin::Wrappable<TextInputControllerBindings>::GetObjectTemplateBuilder(
102 isolate)
103 .SetMethod("insertText", &TextInputControllerBindings::InsertText)
104 .SetMethod("unmarkText", &TextInputControllerBindings::UnmarkText)
Ryan Landay7b5dbd52018-01-11 19:05:59105 .SetMethod("unmarkAndUnselectText",
106 &TextInputControllerBindings::UnmarkAndUnselectText)
[email protected]f751653a92014-02-18 16:32:55107 .SetMethod("doCommand", &TextInputControllerBindings::DoCommand)
Ryan Landay9c6809422018-01-17 07:04:15108 .SetMethod("extendSelectionAndDelete",
109 &TextInputControllerBindings::ExtendSelectionAndDelete)
Ryan Landay6d163ae2018-01-17 06:58:06110 .SetMethod("deleteSurroundingText",
111 &TextInputControllerBindings::DeleteSurroundingText)
[email protected]f751653a92014-02-18 16:32:55112 .SetMethod("setMarkedText", &TextInputControllerBindings::SetMarkedText)
Ryan Landayd2034672018-01-12 22:22:32113 .SetMethod("setMarkedTextFromExistingText",
114 &TextInputControllerBindings::SetMarkedTextFromExistingText)
[email protected]f751653a92014-02-18 16:32:55115 .SetMethod("hasMarkedText", &TextInputControllerBindings::HasMarkedText)
116 .SetMethod("markedRange", &TextInputControllerBindings::MarkedRange)
117 .SetMethod("selectedRange", &TextInputControllerBindings::SelectedRange)
118 .SetMethod("firstRectForCharacterRange",
119 &TextInputControllerBindings::FirstRectForCharacterRange)
ekaramad2daaf672016-11-10 20:29:01120 .SetMethod("setComposition", &TextInputControllerBindings::SetComposition)
121 .SetMethod("forceTextInputStateUpdate",
122 &TextInputControllerBindings::ForceTextInputStateUpdate);
[email protected]f751653a92014-02-18 16:32:55123}
124
125void TextInputControllerBindings::InsertText(const std::string& text) {
126 if (controller_)
127 controller_->InsertText(text);
128}
129
130void TextInputControllerBindings::UnmarkText() {
131 if (controller_)
132 controller_->UnmarkText();
133}
134
Ryan Landay7b5dbd52018-01-11 19:05:59135void TextInputControllerBindings::UnmarkAndUnselectText() {
136 if (controller_)
137 controller_->UnmarkAndUnselectText();
138}
139
[email protected]f751653a92014-02-18 16:32:55140void TextInputControllerBindings::DoCommand(const std::string& text) {
141 if (controller_)
142 controller_->DoCommand(text);
143}
144
Ryan Landay9c6809422018-01-17 07:04:15145void TextInputControllerBindings::ExtendSelectionAndDelete(int before,
146 int after) {
147 if (controller_)
148 controller_->ExtendSelectionAndDelete(before, after);
149}
150
Ryan Landay6d163ae2018-01-17 06:58:06151void TextInputControllerBindings::DeleteSurroundingText(int before, int after) {
152 if (controller_)
153 controller_->DeleteSurroundingText(before, after);
154}
155
[email protected]f751653a92014-02-18 16:32:55156void TextInputControllerBindings::SetMarkedText(const std::string& text,
157 int start,
158 int length) {
159 if (controller_)
160 controller_->SetMarkedText(text, start, length);
161}
162
Ryan Landayd2034672018-01-12 22:22:32163void TextInputControllerBindings::SetMarkedTextFromExistingText(int start,
164 int end) {
165 if (controller_)
166 controller_->SetMarkedTextFromExistingText(start, end);
167}
168
[email protected]f751653a92014-02-18 16:32:55169bool TextInputControllerBindings::HasMarkedText() {
170 return controller_ ? controller_->HasMarkedText() : false;
171}
172
173std::vector<int> TextInputControllerBindings::MarkedRange() {
174 return controller_ ? controller_->MarkedRange() : std::vector<int>();
175}
176
177std::vector<int> TextInputControllerBindings::SelectedRange() {
178 return controller_ ? controller_->SelectedRange() : std::vector<int>();
179}
180
181std::vector<int> TextInputControllerBindings::FirstRectForCharacterRange(
182 unsigned location,
183 unsigned length) {
184 return controller_ ? controller_->FirstRectForCharacterRange(location, length)
185 : std::vector<int>();
186}
187
188void TextInputControllerBindings::SetComposition(const std::string& text) {
189 if (controller_)
190 controller_->SetComposition(text);
191}
ekaramad2daaf672016-11-10 20:29:01192void TextInputControllerBindings::ForceTextInputStateUpdate() {
193 if (controller_)
194 controller_->ForceTextInputStateUpdate();
195}
[email protected]f751653a92014-02-18 16:32:55196// TextInputController ---------------------------------------------------------
197
Albert J. Wong2727e8a82019-02-15 16:56:11198TextInputController::TextInputController(WebViewTestProxy* web_view_test_proxy)
Jeremy Roman3bca4bf2019-07-11 03:41:25199 : web_view_test_proxy_(web_view_test_proxy) {}
[email protected]f751653a92014-02-18 16:32:55200
201TextInputController::~TextInputController() {}
202
lukasza8b6d5f32016-04-22 16:56:31203void TextInputController::Install(blink::WebLocalFrame* frame) {
[email protected]f751653a92014-02-18 16:32:55204 TextInputControllerBindings::Install(weak_factory_.GetWeakPtr(), frame);
205}
206
[email protected]f751653a92014-02-18 16:32:55207void TextInputController::InsertText(const std::string& text) {
ekaramadc75b1b3b32016-12-02 03:57:52208 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54209 controller->CommitText(blink::WebString::FromUTF8(text),
Ryan Landay9e42fd742017-08-12 01:59:11210 std::vector<blink::WebImeTextSpan>(),
ekaramadce32ef9f2017-02-09 17:33:56211 blink::WebRange(), 0);
ekaramadc75b1b3b32016-12-02 03:57:52212 }
[email protected]f751653a92014-02-18 16:32:55213}
214
215void TextInputController::UnmarkText() {
ekaramadc75b1b3b32016-12-02 03:57:52216 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54217 controller->FinishComposingText(
218 blink::WebInputMethodController::kKeepSelection);
ekaramadc75b1b3b32016-12-02 03:57:52219 }
[email protected]f751653a92014-02-18 16:32:55220}
221
Ryan Landay7b5dbd52018-01-11 19:05:59222void TextInputController::UnmarkAndUnselectText() {
223 if (auto* controller = GetInputMethodController()) {
224 controller->FinishComposingText(
225 blink::WebInputMethodController::kDoNotKeepSelection);
226 }
227}
228
[email protected]f751653a92014-02-18 16:32:55229void TextInputController::DoCommand(const std::string& text) {
Blink Reformat1c4d759e2017-04-09 16:34:54230 if (view()->MainFrame()) {
Ryan Landayd2034672018-01-12 22:22:32231 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
232 "called if the main frame "
233 "is not a local frame.";
Blink Reformat1c4d759e2017-04-09 16:34:54234 view()->MainFrame()->ToWebLocalFrame()->ExecuteCommand(
235 blink::WebString::FromUTF8(text));
yabinh8204efc2016-07-08 13:58:57236 }
[email protected]f751653a92014-02-18 16:32:55237}
238
Ryan Landay9c6809422018-01-17 07:04:15239void TextInputController::ExtendSelectionAndDelete(int before, int after) {
240 if (view()->MainFrame()) {
241 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
242 "called if the main frame "
243 "is not a local frame.";
244 view()->MainFrame()->ToWebLocalFrame()->ExtendSelectionAndDelete(before,
245 after);
246 }
247}
248
Ryan Landay6d163ae2018-01-17 06:58:06249void TextInputController::DeleteSurroundingText(int before, int after) {
250 if (view()->MainFrame()) {
251 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
252 "called if the main frame "
253 "is not a local frame.";
254 view()->MainFrame()->ToWebLocalFrame()->DeleteSurroundingText(before,
255 after);
256 }
257}
258
[email protected]f751653a92014-02-18 16:32:55259void TextInputController::SetMarkedText(const std::string& text,
260 int start,
261 int length) {
Blink Reformat1c4d759e2017-04-09 16:34:54262 blink::WebString web_text(blink::WebString::FromUTF8(text));
[email protected]f751653a92014-02-18 16:32:55263
264 // Split underline into up to 3 elements (before, selection, and after).
Ryan Landay9e42fd742017-08-12 01:59:11265 std::vector<blink::WebImeTextSpan> ime_text_spans;
266 blink::WebImeTextSpan ime_text_span;
[email protected]f751653a92014-02-18 16:32:55267 if (!start) {
Ryan Landay9e42fd742017-08-12 01:59:11268 ime_text_span.end_offset = length;
[email protected]f751653a92014-02-18 16:32:55269 } else {
Ryan Landay9e42fd742017-08-12 01:59:11270 ime_text_span.end_offset = start;
271 ime_text_spans.push_back(ime_text_span);
272 ime_text_span.start_offset = start;
273 ime_text_span.end_offset = start + length;
[email protected]f751653a92014-02-18 16:32:55274 }
Shu Chen855e1dc2019-03-22 00:27:03275 ime_text_span.thickness = ui::mojom::ImeTextSpanThickness::kThick;
Anupam Snigdha614b7ad2020-01-16 06:09:27276 ime_text_span.underline_style = ui::mojom::ImeTextSpanUnderlineStyle::kSolid;
Ryan Landay9e42fd742017-08-12 01:59:11277 ime_text_spans.push_back(ime_text_span);
[email protected]f751653a92014-02-18 16:32:55278 if (start + length < static_cast<int>(web_text.length())) {
Ryan Landay9e42fd742017-08-12 01:59:11279 ime_text_span.start_offset = ime_text_span.end_offset;
280 ime_text_span.end_offset = web_text.length();
Shu Chen855e1dc2019-03-22 00:27:03281 ime_text_span.thickness = ui::mojom::ImeTextSpanThickness::kThin;
Anupam Snigdha614b7ad2020-01-16 06:09:27282 ime_text_span.underline_style =
283 ui::mojom::ImeTextSpanUnderlineStyle::kSolid;
Ryan Landay9e42fd742017-08-12 01:59:11284 ime_text_spans.push_back(ime_text_span);
[email protected]f751653a92014-02-18 16:32:55285 }
286
ekaramadc75b1b3b32016-12-02 03:57:52287 if (auto* controller = GetInputMethodController()) {
Ryan Landay9e42fd742017-08-12 01:59:11288 controller->SetComposition(web_text, ime_text_spans, blink::WebRange(),
289 start, start + length);
ekaramadc75b1b3b32016-12-02 03:57:52290 }
[email protected]f751653a92014-02-18 16:32:55291}
292
Ryan Landayd2034672018-01-12 22:22:32293void TextInputController::SetMarkedTextFromExistingText(int start, int end) {
294 if (!view()->MainFrame())
295 return;
296
297 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
298 "called if the main frame "
299 "is not a local frame.";
300
301 view()->MainFrame()->ToWebLocalFrame()->SetCompositionFromExistingText(
302 start, end, std::vector<blink::WebImeTextSpan>());
303}
304
[email protected]f751653a92014-02-18 16:32:55305bool TextInputController::HasMarkedText() {
Blink Reformat1c4d759e2017-04-09 16:34:54306 if (!view()->MainFrame())
yabinh8204efc2016-07-08 13:58:57307 return false;
308
Ryan Landayd2034672018-01-12 22:22:32309 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
310 "called if the main frame "
311 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57312
Blink Reformat1c4d759e2017-04-09 16:34:54313 return view()->MainFrame()->ToWebLocalFrame()->HasMarkedText();
[email protected]f751653a92014-02-18 16:32:55314}
315
316std::vector<int> TextInputController::MarkedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54317 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50318 return std::vector<int>();
319
Ryan Landayd2034672018-01-12 22:22:32320 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
321 "called if the main frame "
322 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57323
Blink Reformat1c4d759e2017-04-09 16:34:54324 blink::WebRange range = view()->MainFrame()->ToWebLocalFrame()->MarkedRange();
[email protected]f751653a92014-02-18 16:32:55325 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54326 int_array[0] = range.StartOffset();
327 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55328
329 return int_array;
330}
331
332std::vector<int> TextInputController::SelectedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54333 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50334 return std::vector<int>();
335
Ryan Landayd2034672018-01-12 22:22:32336 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
337 "called if the main frame "
338 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57339
340 blink::WebRange range =
Blink Reformat1c4d759e2017-04-09 16:34:54341 view()->MainFrame()->ToWebLocalFrame()->SelectionRange();
342 if (range.IsNull())
yosin702c78a32016-06-13 08:39:13343 return std::vector<int>();
[email protected]f751653a92014-02-18 16:32:55344 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54345 int_array[0] = range.StartOffset();
346 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55347
348 return int_array;
349}
350
351std::vector<int> TextInputController::FirstRectForCharacterRange(
352 unsigned location,
353 unsigned length) {
354 blink::WebRect rect;
Blink Reformat1c4d759e2017-04-09 16:34:54355 if (!view()->FocusedFrame() ||
356 !view()->FocusedFrame()->FirstRectForCharacterRange(location, length,
lukasza8b6d5f32016-04-22 16:56:31357 rect)) {
[email protected]f751653a92014-02-18 16:32:55358 return std::vector<int>();
[email protected]6f9397122014-02-25 09:30:50359 }
[email protected]f751653a92014-02-18 16:32:55360
361 std::vector<int> int_array(4);
362 int_array[0] = rect.x;
363 int_array[1] = rect.y;
364 int_array[2] = rect.width;
365 int_array[3] = rect.height;
366
367 return int_array;
368}
369
370void TextInputController::SetComposition(const std::string& text) {
371 // Sends a keydown event with key code = 0xE5 to emulate input method
372 // behavior.
Dave Tapuska347d60a2020-04-21 23:55:47373 blink::WebKeyboardEvent key_down(blink::WebInputEvent::Type::kRawKeyDown,
Daniel Cheng224569ee2018-04-25 05:45:06374 blink::WebInputEvent::kNoModifiers,
375 ui::EventTimeForNow());
dtapuska899ac222017-01-03 18:09:16376
Blink Reformat1c4d759e2017-04-09 16:34:54377 key_down.windows_key_code = 0xE5; // VKEY_PROCESSKEY
danakj763c2402018-11-09 02:46:22378 view()->MainFrameWidget()->HandleInputEvent(
379 blink::WebCoalescedInputEvent(key_down));
[email protected]f751653a92014-02-18 16:32:55380
yabinhdd6d1b62016-08-23 07:09:02381 // The value returned by std::string::length() may not correspond to the
382 // actual number of encoded characters in sequences of multi-byte or
383 // variable-length characters.
Blink Reformat1c4d759e2017-04-09 16:34:54384 blink::WebString newText = blink::WebString::FromUTF8(text);
yabinhdd6d1b62016-08-23 07:09:02385 size_t textLength = newText.length();
386
Ryan Landay9e42fd742017-08-12 01:59:11387 std::vector<blink::WebImeTextSpan> ime_text_spans;
Ryan Landay9387aa92017-08-16 23:16:52388 ime_text_spans.push_back(blink::WebImeTextSpan(
Manuel Rego Casasnovas6743b452018-03-22 20:42:39389 blink::WebImeTextSpan::Type::kComposition, 0, textLength,
Anupam Snigdha614b7ad2020-01-16 06:09:27390 ui::mojom::ImeTextSpanThickness::kThin,
391 ui::mojom::ImeTextSpanUnderlineStyle::kSolid, SK_ColorTRANSPARENT));
ekaramadc75b1b3b32016-12-02 03:57:52392 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54393 controller->SetComposition(
Ryan Landay9e42fd742017-08-12 01:59:11394 newText, blink::WebVector<blink::WebImeTextSpan>(ime_text_spans),
ekaramadce32ef9f2017-02-09 17:33:56395 blink::WebRange(), textLength, textLength);
ekaramadc75b1b3b32016-12-02 03:57:52396 }
lukasza8b6d5f32016-04-22 16:56:31397}
398
ekaramad2daaf672016-11-10 20:29:01399void TextInputController::ForceTextInputStateUpdate() {
Kent Tamura21d1de62018-12-10 04:45:20400 // TODO(lukasza): Finish adding OOPIF support to the web tests harness.
danakje3e48d42020-05-01 23:47:33401 RenderFrameImpl* main_frame = web_view_test_proxy_->GetMainRenderFrame();
402 CHECK(main_frame) << "WebView does not have a local main frame and"
403 << " cannot handle input method controller tasks.";
404 RenderWidget* main_widget = main_frame->GetLocalRootRenderWidget();
405 main_widget->ShowVirtualKeyboard();
ekaramad2daaf672016-11-10 20:29:01406}
407
lukasza8b6d5f32016-04-22 16:56:31408blink::WebView* TextInputController::view() {
Antonio Gomes778a0f72020-02-24 13:52:44409 return web_view_test_proxy_->GetWebView();
[email protected]f751653a92014-02-18 16:32:55410}
411
ekaramadc75b1b3b32016-12-02 03:57:52412blink::WebInputMethodController*
413TextInputController::GetInputMethodController() {
Blink Reformat1c4d759e2017-04-09 16:34:54414 if (!view()->MainFrame())
ekaramadc75b1b3b32016-12-02 03:57:52415 return nullptr;
416
Kent Tamura21d1de62018-12-10 04:45:20417 // TODO(lukasza): Finish adding OOPIF support to the web tests harness.
Daniel Cheng3c829432017-06-19 03:42:31418 CHECK(view()->MainFrame()->IsWebLocalFrame())
419 << "WebView does not have a local main frame and"
420 " cannot handle input method controller tasks.";
421
danakje3e48d42020-05-01 23:47:33422 return view()->MainFrameWidget()->GetActiveWebInputMethodController();
ekaramad2daaf672016-11-10 20:29:01423}
424
danakj741848a2020-04-07 22:48:06425} // namespace content