blob: c40d88dbad89e6863ddc3de21805dd3a7d8cb5e0 [file] [log] [blame]
danakjb0092062020-05-04 19:53:061// Copyright 2020 The Chromium Authors. All rights reserved.
[email protected]f751653a92014-02-18 16:32:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
danakj89f47082020-09-02 17:53:435#include "content/web_test/renderer/text_input_controller.h"
[email protected]f751653a92014-02-18 16:32:556
avi5dd91f82015-12-25 22:30:467#include "base/macros.h"
danakj89f47082020-09-02 17:53:438#include "content/web_test/renderer/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 Tapuska0dd120b2020-05-08 17:06:5213#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
Dave Tapuska129cef82019-12-19 16:36:4814#include "third_party/blink/public/common/input/web_keyboard_event.h"
Blink Reformata30d4232018-04-07 15:31:0615#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"
Blink Reformata30d4232018-04-07 15:31:0618#include "third_party/blink/public/web/web_input_method_controller.h"
19#include "third_party/blink/public/web/web_local_frame.h"
20#include "third_party/blink/public/web/web_range.h"
21#include "third_party/blink/public/web/web_view.h"
changwan9bdc18f02015-11-20 02:43:5222#include "third_party/skia/include/core/SkColor.h"
Dave Tapuska7fa75212020-06-04 17:46:1123#include "ui/base/ime/ime_text_span.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),
Dave Tapuska7fa75212020-06-04 17:46:11210 std::vector<ui::ImeTextSpan>(), blink::WebRange(),
211 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).
Dave Tapuska7fa75212020-06-04 17:46:11265 std::vector<ui::ImeTextSpan> ime_text_spans;
266 ui::ImeTextSpan 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 }
Dave Tapuska7fa75212020-06-04 17:46:11275 ime_text_span.thickness = ui::ImeTextSpan::Thickness::kThick;
276 ime_text_span.underline_style = ui::ImeTextSpan::UnderlineStyle::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();
Dave Tapuska7fa75212020-06-04 17:46:11281 ime_text_span.thickness = ui::ImeTextSpan::Thickness::kThin;
282 ime_text_span.underline_style = ui::ImeTextSpan::UnderlineStyle::kSolid;
Ryan Landay9e42fd742017-08-12 01:59:11283 ime_text_spans.push_back(ime_text_span);
[email protected]f751653a92014-02-18 16:32:55284 }
285
ekaramadc75b1b3b32016-12-02 03:57:52286 if (auto* controller = GetInputMethodController()) {
Ryan Landay9e42fd742017-08-12 01:59:11287 controller->SetComposition(web_text, ime_text_spans, blink::WebRange(),
288 start, start + length);
ekaramadc75b1b3b32016-12-02 03:57:52289 }
[email protected]f751653a92014-02-18 16:32:55290}
291
Ryan Landayd2034672018-01-12 22:22:32292void TextInputController::SetMarkedTextFromExistingText(int start, int end) {
293 if (!view()->MainFrame())
294 return;
295
296 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
297 "called if the main frame "
298 "is not a local frame.";
299
300 view()->MainFrame()->ToWebLocalFrame()->SetCompositionFromExistingText(
Dave Tapuska7fa75212020-06-04 17:46:11301 start, end, std::vector<ui::ImeTextSpan>());
Ryan Landayd2034672018-01-12 22:22:32302}
303
[email protected]f751653a92014-02-18 16:32:55304bool TextInputController::HasMarkedText() {
Blink Reformat1c4d759e2017-04-09 16:34:54305 if (!view()->MainFrame())
yabinh8204efc2016-07-08 13:58:57306 return false;
307
Ryan Landayd2034672018-01-12 22:22:32308 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
309 "called if the main frame "
310 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57311
Blink Reformat1c4d759e2017-04-09 16:34:54312 return view()->MainFrame()->ToWebLocalFrame()->HasMarkedText();
[email protected]f751653a92014-02-18 16:32:55313}
314
315std::vector<int> TextInputController::MarkedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54316 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50317 return std::vector<int>();
318
Ryan Landayd2034672018-01-12 22:22:32319 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
320 "called if the main frame "
321 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57322
Blink Reformat1c4d759e2017-04-09 16:34:54323 blink::WebRange range = view()->MainFrame()->ToWebLocalFrame()->MarkedRange();
[email protected]f751653a92014-02-18 16:32:55324 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54325 int_array[0] = range.StartOffset();
326 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55327
328 return int_array;
329}
330
331std::vector<int> TextInputController::SelectedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54332 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50333 return std::vector<int>();
334
Ryan Landayd2034672018-01-12 22:22:32335 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
336 "called if the main frame "
337 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57338
339 blink::WebRange range =
Blink Reformat1c4d759e2017-04-09 16:34:54340 view()->MainFrame()->ToWebLocalFrame()->SelectionRange();
341 if (range.IsNull())
yosin702c78a32016-06-13 08:39:13342 return std::vector<int>();
[email protected]f751653a92014-02-18 16:32:55343 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54344 int_array[0] = range.StartOffset();
345 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55346
347 return int_array;
348}
349
350std::vector<int> TextInputController::FirstRectForCharacterRange(
351 unsigned location,
352 unsigned length) {
353 blink::WebRect rect;
Blink Reformat1c4d759e2017-04-09 16:34:54354 if (!view()->FocusedFrame() ||
355 !view()->FocusedFrame()->FirstRectForCharacterRange(location, length,
lukasza8b6d5f32016-04-22 16:56:31356 rect)) {
[email protected]f751653a92014-02-18 16:32:55357 return std::vector<int>();
[email protected]6f9397122014-02-25 09:30:50358 }
[email protected]f751653a92014-02-18 16:32:55359
360 std::vector<int> int_array(4);
361 int_array[0] = rect.x;
362 int_array[1] = rect.y;
363 int_array[2] = rect.width;
364 int_array[3] = rect.height;
365
366 return int_array;
367}
368
369void TextInputController::SetComposition(const std::string& text) {
370 // Sends a keydown event with key code = 0xE5 to emulate input method
371 // behavior.
Dave Tapuska347d60a2020-04-21 23:55:47372 blink::WebKeyboardEvent key_down(blink::WebInputEvent::Type::kRawKeyDown,
Daniel Cheng224569ee2018-04-25 05:45:06373 blink::WebInputEvent::kNoModifiers,
374 ui::EventTimeForNow());
dtapuska899ac222017-01-03 18:09:16375
Blink Reformat1c4d759e2017-04-09 16:34:54376 key_down.windows_key_code = 0xE5; // VKEY_PROCESSKEY
danakj763c2402018-11-09 02:46:22377 view()->MainFrameWidget()->HandleInputEvent(
Dave Tapuskacc788dd2020-05-11 22:33:56378 blink::WebCoalescedInputEvent(key_down, ui::LatencyInfo()));
[email protected]f751653a92014-02-18 16:32:55379
yabinhdd6d1b62016-08-23 07:09:02380 // The value returned by std::string::length() may not correspond to the
381 // actual number of encoded characters in sequences of multi-byte or
382 // variable-length characters.
Blink Reformat1c4d759e2017-04-09 16:34:54383 blink::WebString newText = blink::WebString::FromUTF8(text);
yabinhdd6d1b62016-08-23 07:09:02384 size_t textLength = newText.length();
385
Dave Tapuska7fa75212020-06-04 17:46:11386 std::vector<ui::ImeTextSpan> ime_text_spans;
387 ime_text_spans.push_back(ui::ImeTextSpan(
388 ui::ImeTextSpan::Type::kComposition, 0, textLength,
389 ui::ImeTextSpan::Thickness::kThin,
390 ui::ImeTextSpan::UnderlineStyle::kSolid, SK_ColorTRANSPARENT));
ekaramadc75b1b3b32016-12-02 03:57:52391 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54392 controller->SetComposition(
Dave Tapuska7fa75212020-06-04 17:46:11393 newText, blink::WebVector<ui::ImeTextSpan>(std::move(ime_text_spans)),
ekaramadce32ef9f2017-02-09 17:33:56394 blink::WebRange(), textLength, textLength);
ekaramadc75b1b3b32016-12-02 03:57:52395 }
lukasza8b6d5f32016-04-22 16:56:31396}
397
ekaramad2daaf672016-11-10 20:29:01398void TextInputController::ForceTextInputStateUpdate() {
Kent Tamura21d1de62018-12-10 04:45:20399 // TODO(lukasza): Finish adding OOPIF support to the web tests harness.
danakje3e48d42020-05-01 23:47:33400 RenderFrameImpl* main_frame = web_view_test_proxy_->GetMainRenderFrame();
401 CHECK(main_frame) << "WebView does not have a local main frame and"
402 << " cannot handle input method controller tasks.";
403 RenderWidget* main_widget = main_frame->GetLocalRootRenderWidget();
Dave Tapuskac135bf12020-06-19 17:37:53404 main_widget->GetWebWidget()->ShowVirtualKeyboard();
ekaramad2daaf672016-11-10 20:29:01405}
406
lukasza8b6d5f32016-04-22 16:56:31407blink::WebView* TextInputController::view() {
Antonio Gomes778a0f72020-02-24 13:52:44408 return web_view_test_proxy_->GetWebView();
[email protected]f751653a92014-02-18 16:32:55409}
410
ekaramadc75b1b3b32016-12-02 03:57:52411blink::WebInputMethodController*
412TextInputController::GetInputMethodController() {
Blink Reformat1c4d759e2017-04-09 16:34:54413 if (!view()->MainFrame())
ekaramadc75b1b3b32016-12-02 03:57:52414 return nullptr;
415
Kent Tamura21d1de62018-12-10 04:45:20416 // TODO(lukasza): Finish adding OOPIF support to the web tests harness.
Daniel Cheng3c829432017-06-19 03:42:31417 CHECK(view()->MainFrame()->IsWebLocalFrame())
418 << "WebView does not have a local main frame and"
419 " cannot handle input method controller tasks.";
420
danakje3e48d42020-05-01 23:47:33421 return view()->MainFrameWidget()->GetActiveWebInputMethodController();
ekaramad2daaf672016-11-10 20:29:01422}
423
danakj741848a2020-04-07 22:48:06424} // namespace content