blob: c393efccbe7f1e9d6a185fa27369c674c3b0a90f [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"
Dave Tapuska13da016a2021-02-04 21:51:588#include "content/web_test/renderer/web_frame_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
Peter Boström9b036532021-10-28 23:37:2834 TextInputControllerBindings(const TextInputControllerBindings&) = delete;
35 TextInputControllerBindings& operator=(const TextInputControllerBindings&) =
36 delete;
37
[email protected]f751653a92014-02-18 16:32:5538 static void Install(base::WeakPtr<TextInputController> controller,
lukasza8b6d5f32016-04-22 16:56:3139 blink::WebLocalFrame* frame);
[email protected]f751653a92014-02-18 16:32:5540
41 private:
42 explicit TextInputControllerBindings(
43 base::WeakPtr<TextInputController> controller);
dchenge933b3e2014-10-21 11:44:0944 ~TextInputControllerBindings() override;
[email protected]f751653a92014-02-18 16:32:5545
46 // gin::Wrappable:
dchenge933b3e2014-10-21 11:44:0947 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
anand.ratn449f39a42014-10-06 13:45:5748 v8::Isolate* isolate) override;
[email protected]f751653a92014-02-18 16:32:5549
50 void InsertText(const std::string& text);
51 void UnmarkText();
Ryan Landay7b5dbd52018-01-11 19:05:5952 void UnmarkAndUnselectText();
[email protected]f751653a92014-02-18 16:32:5553 void DoCommand(const std::string& text);
Ryan Landay9c6809422018-01-17 07:04:1554 void ExtendSelectionAndDelete(int before, int after);
Ryan Landay6d163ae2018-01-17 06:58:0655 void DeleteSurroundingText(int before, int after);
[email protected]f751653a92014-02-18 16:32:5556 void SetMarkedText(const std::string& text, int start, int length);
Ryan Landayd2034672018-01-12 22:22:3257 void SetMarkedTextFromExistingText(int start, int length);
[email protected]f751653a92014-02-18 16:32:5558 bool HasMarkedText();
59 std::vector<int> MarkedRange();
60 std::vector<int> SelectedRange();
61 std::vector<int> FirstRectForCharacterRange(unsigned location,
62 unsigned length);
63 void SetComposition(const std::string& text);
ekaramad2daaf672016-11-10 20:29:0164 void ForceTextInputStateUpdate();
[email protected]f751653a92014-02-18 16:32:5565
66 base::WeakPtr<TextInputController> controller_;
[email protected]f751653a92014-02-18 16:32:5567};
68
69gin::WrapperInfo TextInputControllerBindings::kWrapperInfo = {
70 gin::kEmbedderNativeGin};
71
72// static
73void TextInputControllerBindings::Install(
74 base::WeakPtr<TextInputController> controller,
lukasza8b6d5f32016-04-22 16:56:3175 blink::WebLocalFrame* frame) {
Blink Reformat1c4d759e2017-04-09 16:34:5476 v8::Isolate* isolate = blink::MainThreadIsolate();
[email protected]f751653a92014-02-18 16:32:5577 v8::HandleScope handle_scope(isolate);
Blink Reformat1c4d759e2017-04-09 16:34:5478 v8::Local<v8::Context> context = frame->MainWorldScriptContext();
[email protected]f751653a92014-02-18 16:32:5579 if (context.IsEmpty())
80 return;
81
82 v8::Context::Scope context_scope(context);
83
84 gin::Handle<TextInputControllerBindings> bindings =
85 gin::CreateHandle(isolate, new TextInputControllerBindings(controller));
[email protected]ad4d2032014-04-28 13:50:5986 if (bindings.IsEmpty())
87 return;
deepak.s750d68f2015-04-30 07:32:4188 v8::Local<v8::Object> global = context->Global();
Dan Elphicka83be512019-02-05 15:57:2389 global
90 ->Set(context, gin::StringToV8(isolate, "textInputController"),
91 bindings.ToV8())
92 .Check();
[email protected]f751653a92014-02-18 16:32:5593}
94
95TextInputControllerBindings::TextInputControllerBindings(
96 base::WeakPtr<TextInputController> controller)
97 : controller_(controller) {}
98
99TextInputControllerBindings::~TextInputControllerBindings() {}
100
101gin::ObjectTemplateBuilder
102TextInputControllerBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) {
103 return gin::Wrappable<TextInputControllerBindings>::GetObjectTemplateBuilder(
104 isolate)
105 .SetMethod("insertText", &TextInputControllerBindings::InsertText)
106 .SetMethod("unmarkText", &TextInputControllerBindings::UnmarkText)
Ryan Landay7b5dbd52018-01-11 19:05:59107 .SetMethod("unmarkAndUnselectText",
108 &TextInputControllerBindings::UnmarkAndUnselectText)
[email protected]f751653a92014-02-18 16:32:55109 .SetMethod("doCommand", &TextInputControllerBindings::DoCommand)
Ryan Landay9c6809422018-01-17 07:04:15110 .SetMethod("extendSelectionAndDelete",
111 &TextInputControllerBindings::ExtendSelectionAndDelete)
Ryan Landay6d163ae2018-01-17 06:58:06112 .SetMethod("deleteSurroundingText",
113 &TextInputControllerBindings::DeleteSurroundingText)
[email protected]f751653a92014-02-18 16:32:55114 .SetMethod("setMarkedText", &TextInputControllerBindings::SetMarkedText)
Ryan Landayd2034672018-01-12 22:22:32115 .SetMethod("setMarkedTextFromExistingText",
116 &TextInputControllerBindings::SetMarkedTextFromExistingText)
[email protected]f751653a92014-02-18 16:32:55117 .SetMethod("hasMarkedText", &TextInputControllerBindings::HasMarkedText)
118 .SetMethod("markedRange", &TextInputControllerBindings::MarkedRange)
119 .SetMethod("selectedRange", &TextInputControllerBindings::SelectedRange)
120 .SetMethod("firstRectForCharacterRange",
121 &TextInputControllerBindings::FirstRectForCharacterRange)
ekaramad2daaf672016-11-10 20:29:01122 .SetMethod("setComposition", &TextInputControllerBindings::SetComposition)
123 .SetMethod("forceTextInputStateUpdate",
124 &TextInputControllerBindings::ForceTextInputStateUpdate);
[email protected]f751653a92014-02-18 16:32:55125}
126
127void TextInputControllerBindings::InsertText(const std::string& text) {
128 if (controller_)
129 controller_->InsertText(text);
130}
131
132void TextInputControllerBindings::UnmarkText() {
133 if (controller_)
134 controller_->UnmarkText();
135}
136
Ryan Landay7b5dbd52018-01-11 19:05:59137void TextInputControllerBindings::UnmarkAndUnselectText() {
138 if (controller_)
139 controller_->UnmarkAndUnselectText();
140}
141
[email protected]f751653a92014-02-18 16:32:55142void TextInputControllerBindings::DoCommand(const std::string& text) {
143 if (controller_)
144 controller_->DoCommand(text);
145}
146
Ryan Landay9c6809422018-01-17 07:04:15147void TextInputControllerBindings::ExtendSelectionAndDelete(int before,
148 int after) {
149 if (controller_)
150 controller_->ExtendSelectionAndDelete(before, after);
151}
152
Ryan Landay6d163ae2018-01-17 06:58:06153void TextInputControllerBindings::DeleteSurroundingText(int before, int after) {
154 if (controller_)
155 controller_->DeleteSurroundingText(before, after);
156}
157
[email protected]f751653a92014-02-18 16:32:55158void TextInputControllerBindings::SetMarkedText(const std::string& text,
159 int start,
160 int length) {
161 if (controller_)
162 controller_->SetMarkedText(text, start, length);
163}
164
Ryan Landayd2034672018-01-12 22:22:32165void TextInputControllerBindings::SetMarkedTextFromExistingText(int start,
166 int end) {
167 if (controller_)
168 controller_->SetMarkedTextFromExistingText(start, end);
169}
170
[email protected]f751653a92014-02-18 16:32:55171bool TextInputControllerBindings::HasMarkedText() {
172 return controller_ ? controller_->HasMarkedText() : false;
173}
174
175std::vector<int> TextInputControllerBindings::MarkedRange() {
176 return controller_ ? controller_->MarkedRange() : std::vector<int>();
177}
178
179std::vector<int> TextInputControllerBindings::SelectedRange() {
180 return controller_ ? controller_->SelectedRange() : std::vector<int>();
181}
182
183std::vector<int> TextInputControllerBindings::FirstRectForCharacterRange(
184 unsigned location,
185 unsigned length) {
186 return controller_ ? controller_->FirstRectForCharacterRange(location, length)
187 : std::vector<int>();
188}
189
190void TextInputControllerBindings::SetComposition(const std::string& text) {
191 if (controller_)
192 controller_->SetComposition(text);
193}
ekaramad2daaf672016-11-10 20:29:01194void TextInputControllerBindings::ForceTextInputStateUpdate() {
195 if (controller_)
196 controller_->ForceTextInputStateUpdate();
197}
[email protected]f751653a92014-02-18 16:32:55198// TextInputController ---------------------------------------------------------
199
Dave Tapuska13da016a2021-02-04 21:51:58200TextInputController::TextInputController(
201 WebFrameTestProxy* web_frame_test_proxy)
202 : web_frame_test_proxy_(web_frame_test_proxy) {}
[email protected]f751653a92014-02-18 16:32:55203
204TextInputController::~TextInputController() {}
205
lukasza8b6d5f32016-04-22 16:56:31206void TextInputController::Install(blink::WebLocalFrame* frame) {
[email protected]f751653a92014-02-18 16:32:55207 TextInputControllerBindings::Install(weak_factory_.GetWeakPtr(), frame);
208}
209
[email protected]f751653a92014-02-18 16:32:55210void TextInputController::InsertText(const std::string& text) {
ekaramadc75b1b3b32016-12-02 03:57:52211 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54212 controller->CommitText(blink::WebString::FromUTF8(text),
Dave Tapuska7fa75212020-06-04 17:46:11213 std::vector<ui::ImeTextSpan>(), blink::WebRange(),
214 0);
ekaramadc75b1b3b32016-12-02 03:57:52215 }
[email protected]f751653a92014-02-18 16:32:55216}
217
218void TextInputController::UnmarkText() {
ekaramadc75b1b3b32016-12-02 03:57:52219 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54220 controller->FinishComposingText(
221 blink::WebInputMethodController::kKeepSelection);
ekaramadc75b1b3b32016-12-02 03:57:52222 }
[email protected]f751653a92014-02-18 16:32:55223}
224
Ryan Landay7b5dbd52018-01-11 19:05:59225void TextInputController::UnmarkAndUnselectText() {
226 if (auto* controller = GetInputMethodController()) {
227 controller->FinishComposingText(
228 blink::WebInputMethodController::kDoNotKeepSelection);
229 }
230}
231
[email protected]f751653a92014-02-18 16:32:55232void TextInputController::DoCommand(const std::string& text) {
Blink Reformat1c4d759e2017-04-09 16:34:54233 if (view()->MainFrame()) {
Ryan Landayd2034672018-01-12 22:22:32234 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
235 "called if the main frame "
236 "is not a local frame.";
Blink Reformat1c4d759e2017-04-09 16:34:54237 view()->MainFrame()->ToWebLocalFrame()->ExecuteCommand(
238 blink::WebString::FromUTF8(text));
yabinh8204efc2016-07-08 13:58:57239 }
[email protected]f751653a92014-02-18 16:32:55240}
241
Ryan Landay9c6809422018-01-17 07:04:15242void TextInputController::ExtendSelectionAndDelete(int before, int after) {
243 if (view()->MainFrame()) {
244 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
245 "called if the main frame "
246 "is not a local frame.";
247 view()->MainFrame()->ToWebLocalFrame()->ExtendSelectionAndDelete(before,
248 after);
249 }
250}
251
Ryan Landay6d163ae2018-01-17 06:58:06252void TextInputController::DeleteSurroundingText(int before, int after) {
253 if (view()->MainFrame()) {
254 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
255 "called if the main frame "
256 "is not a local frame.";
257 view()->MainFrame()->ToWebLocalFrame()->DeleteSurroundingText(before,
258 after);
259 }
260}
261
[email protected]f751653a92014-02-18 16:32:55262void TextInputController::SetMarkedText(const std::string& text,
263 int start,
264 int length) {
Blink Reformat1c4d759e2017-04-09 16:34:54265 blink::WebString web_text(blink::WebString::FromUTF8(text));
[email protected]f751653a92014-02-18 16:32:55266
267 // Split underline into up to 3 elements (before, selection, and after).
Dave Tapuska7fa75212020-06-04 17:46:11268 std::vector<ui::ImeTextSpan> ime_text_spans;
269 ui::ImeTextSpan ime_text_span;
[email protected]f751653a92014-02-18 16:32:55270 if (!start) {
Ryan Landay9e42fd742017-08-12 01:59:11271 ime_text_span.end_offset = length;
[email protected]f751653a92014-02-18 16:32:55272 } else {
Ryan Landay9e42fd742017-08-12 01:59:11273 ime_text_span.end_offset = start;
274 ime_text_spans.push_back(ime_text_span);
275 ime_text_span.start_offset = start;
276 ime_text_span.end_offset = start + length;
[email protected]f751653a92014-02-18 16:32:55277 }
Dave Tapuska7fa75212020-06-04 17:46:11278 ime_text_span.thickness = ui::ImeTextSpan::Thickness::kThick;
279 ime_text_span.underline_style = ui::ImeTextSpan::UnderlineStyle::kSolid;
Ryan Landay9e42fd742017-08-12 01:59:11280 ime_text_spans.push_back(ime_text_span);
[email protected]f751653a92014-02-18 16:32:55281 if (start + length < static_cast<int>(web_text.length())) {
Ryan Landay9e42fd742017-08-12 01:59:11282 ime_text_span.start_offset = ime_text_span.end_offset;
283 ime_text_span.end_offset = web_text.length();
Dave Tapuska7fa75212020-06-04 17:46:11284 ime_text_span.thickness = ui::ImeTextSpan::Thickness::kThin;
285 ime_text_span.underline_style = ui::ImeTextSpan::UnderlineStyle::kSolid;
Ryan Landay9e42fd742017-08-12 01:59:11286 ime_text_spans.push_back(ime_text_span);
[email protected]f751653a92014-02-18 16:32:55287 }
288
ekaramadc75b1b3b32016-12-02 03:57:52289 if (auto* controller = GetInputMethodController()) {
Ryan Landay9e42fd742017-08-12 01:59:11290 controller->SetComposition(web_text, ime_text_spans, blink::WebRange(),
291 start, start + length);
ekaramadc75b1b3b32016-12-02 03:57:52292 }
[email protected]f751653a92014-02-18 16:32:55293}
294
Ryan Landayd2034672018-01-12 22:22:32295void TextInputController::SetMarkedTextFromExistingText(int start, int end) {
296 if (!view()->MainFrame())
297 return;
298
299 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
300 "called if the main frame "
301 "is not a local frame.";
302
303 view()->MainFrame()->ToWebLocalFrame()->SetCompositionFromExistingText(
Dave Tapuska7fa75212020-06-04 17:46:11304 start, end, std::vector<ui::ImeTextSpan>());
Ryan Landayd2034672018-01-12 22:22:32305}
306
[email protected]f751653a92014-02-18 16:32:55307bool TextInputController::HasMarkedText() {
Blink Reformat1c4d759e2017-04-09 16:34:54308 if (!view()->MainFrame())
yabinh8204efc2016-07-08 13:58:57309 return false;
310
Ryan Landayd2034672018-01-12 22:22:32311 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
312 "called if the main frame "
313 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57314
Blink Reformat1c4d759e2017-04-09 16:34:54315 return view()->MainFrame()->ToWebLocalFrame()->HasMarkedText();
[email protected]f751653a92014-02-18 16:32:55316}
317
318std::vector<int> TextInputController::MarkedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54319 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50320 return std::vector<int>();
321
Ryan Landayd2034672018-01-12 22:22:32322 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
323 "called if the main frame "
324 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57325
Blink Reformat1c4d759e2017-04-09 16:34:54326 blink::WebRange range = view()->MainFrame()->ToWebLocalFrame()->MarkedRange();
[email protected]f751653a92014-02-18 16:32:55327 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54328 int_array[0] = range.StartOffset();
329 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55330
331 return int_array;
332}
333
334std::vector<int> TextInputController::SelectedRange() {
Blink Reformat1c4d759e2017-04-09 16:34:54335 if (!view()->MainFrame())
[email protected]6f9397122014-02-25 09:30:50336 return std::vector<int>();
337
Ryan Landayd2034672018-01-12 22:22:32338 CHECK(view()->MainFrame()->ToWebLocalFrame()) << "This function cannot be "
339 "called if the main frame "
340 "is not a local frame.";
yabinh8204efc2016-07-08 13:58:57341
342 blink::WebRange range =
Blink Reformat1c4d759e2017-04-09 16:34:54343 view()->MainFrame()->ToWebLocalFrame()->SelectionRange();
344 if (range.IsNull())
yosin702c78a32016-06-13 08:39:13345 return std::vector<int>();
[email protected]f751653a92014-02-18 16:32:55346 std::vector<int> int_array(2);
Blink Reformat1c4d759e2017-04-09 16:34:54347 int_array[0] = range.StartOffset();
348 int_array[1] = range.EndOffset();
[email protected]f751653a92014-02-18 16:32:55349
350 return int_array;
351}
352
353std::vector<int> TextInputController::FirstRectForCharacterRange(
354 unsigned location,
355 unsigned length) {
Dave Tapuskae8fe9b22021-01-21 20:38:21356 gfx::Rect rect;
Blink Reformat1c4d759e2017-04-09 16:34:54357 if (!view()->FocusedFrame() ||
358 !view()->FocusedFrame()->FirstRectForCharacterRange(location, length,
lukasza8b6d5f32016-04-22 16:56:31359 rect)) {
[email protected]f751653a92014-02-18 16:32:55360 return std::vector<int>();
[email protected]6f9397122014-02-25 09:30:50361 }
[email protected]f751653a92014-02-18 16:32:55362
363 std::vector<int> int_array(4);
Dave Tapuskae8fe9b22021-01-21 20:38:21364 int_array[0] = rect.x();
365 int_array[1] = rect.y();
366 int_array[2] = rect.width();
367 int_array[3] = rect.height();
[email protected]f751653a92014-02-18 16:32:55368
369 return int_array;
370}
371
372void TextInputController::SetComposition(const std::string& text) {
373 // Sends a keydown event with key code = 0xE5 to emulate input method
374 // behavior.
Dave Tapuska347d60a2020-04-21 23:55:47375 blink::WebKeyboardEvent key_down(blink::WebInputEvent::Type::kRawKeyDown,
Daniel Cheng224569ee2018-04-25 05:45:06376 blink::WebInputEvent::kNoModifiers,
377 ui::EventTimeForNow());
dtapuska899ac222017-01-03 18:09:16378
Blink Reformat1c4d759e2017-04-09 16:34:54379 key_down.windows_key_code = 0xE5; // VKEY_PROCESSKEY
danakj763c2402018-11-09 02:46:22380 view()->MainFrameWidget()->HandleInputEvent(
Dave Tapuskacc788dd2020-05-11 22:33:56381 blink::WebCoalescedInputEvent(key_down, ui::LatencyInfo()));
[email protected]f751653a92014-02-18 16:32:55382
yabinhdd6d1b62016-08-23 07:09:02383 // The value returned by std::string::length() may not correspond to the
384 // actual number of encoded characters in sequences of multi-byte or
385 // variable-length characters.
Blink Reformat1c4d759e2017-04-09 16:34:54386 blink::WebString newText = blink::WebString::FromUTF8(text);
yabinhdd6d1b62016-08-23 07:09:02387 size_t textLength = newText.length();
388
Dave Tapuska7fa75212020-06-04 17:46:11389 std::vector<ui::ImeTextSpan> ime_text_spans;
390 ime_text_spans.push_back(ui::ImeTextSpan(
391 ui::ImeTextSpan::Type::kComposition, 0, textLength,
392 ui::ImeTextSpan::Thickness::kThin,
393 ui::ImeTextSpan::UnderlineStyle::kSolid, SK_ColorTRANSPARENT));
ekaramadc75b1b3b32016-12-02 03:57:52394 if (auto* controller = GetInputMethodController()) {
Blink Reformat1c4d759e2017-04-09 16:34:54395 controller->SetComposition(
Dave Tapuska7fa75212020-06-04 17:46:11396 newText, blink::WebVector<ui::ImeTextSpan>(std::move(ime_text_spans)),
ekaramadce32ef9f2017-02-09 17:33:56397 blink::WebRange(), textLength, textLength);
ekaramadc75b1b3b32016-12-02 03:57:52398 }
lukasza8b6d5f32016-04-22 16:56:31399}
400
ekaramad2daaf672016-11-10 20:29:01401void TextInputController::ForceTextInputStateUpdate() {
Dave Tapuskaa5c53485102020-12-01 21:31:02402 blink::WebFrameWidget* frame_widget =
Dave Tapuska13da016a2021-02-04 21:51:58403 web_frame_test_proxy_->GetLocalRootWebFrameWidget();
Dave Tapuskaa5c53485102020-12-01 21:31:02404 frame_widget->ShowVirtualKeyboard();
ekaramad2daaf672016-11-10 20:29:01405}
406
lukasza8b6d5f32016-04-22 16:56:31407blink::WebView* TextInputController::view() {
Dave Tapuska13da016a2021-02-04 21:51:58408 return web_frame_test_proxy_->GetWebFrame()->View();
[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