Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: components/test_runner/text_input_controller.cc

Issue 2674253004: [refactor] Remove WebWidget::applyReplacementRange (Closed)
Patch Set: Rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/text_input_controller.h" 5 #include "components/test_runner/text_input_controller.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/test_runner/web_test_delegate.h" 8 #include "components/test_runner/web_test_delegate.h"
9 #include "components/test_runner/web_view_test_proxy.h" 9 #include "components/test_runner/web_view_test_proxy.h"
10 #include "gin/arguments.h" 10 #include "gin/arguments.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 TextInputController::~TextInputController() {} 167 TextInputController::~TextInputController() {}
168 168
169 void TextInputController::Install(blink::WebLocalFrame* frame) { 169 void TextInputController::Install(blink::WebLocalFrame* frame) {
170 TextInputControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); 170 TextInputControllerBindings::Install(weak_factory_.GetWeakPtr(), frame);
171 } 171 }
172 172
173 void TextInputController::InsertText(const std::string& text) { 173 void TextInputController::InsertText(const std::string& text) {
174 if (auto* controller = GetInputMethodController()) { 174 if (auto* controller = GetInputMethodController()) {
175 controller->commitText(blink::WebString::fromUTF8(text), 175 controller->commitText(blink::WebString::fromUTF8(text),
176 std::vector<blink::WebCompositionUnderline>(), 0); 176 std::vector<blink::WebCompositionUnderline>(),
177 blink::WebRange(), 0);
177 } 178 }
178 } 179 }
179 180
180 void TextInputController::UnmarkText() { 181 void TextInputController::UnmarkText() {
181 if (auto* controller = GetInputMethodController()) { 182 if (auto* controller = GetInputMethodController()) {
182 controller->finishComposingText( 183 controller->finishComposingText(
183 blink::WebInputMethodController::KeepSelection); 184 blink::WebInputMethodController::KeepSelection);
184 } 185 }
185 } 186 }
186 187
(...skipping 27 matching lines...) Expand all
214 underline.thick = true; 215 underline.thick = true;
215 underlines.push_back(underline); 216 underlines.push_back(underline);
216 if (start + length < static_cast<int>(web_text.length())) { 217 if (start + length < static_cast<int>(web_text.length())) {
217 underline.startOffset = underline.endOffset; 218 underline.startOffset = underline.endOffset;
218 underline.endOffset = web_text.length(); 219 underline.endOffset = web_text.length();
219 underline.thick = false; 220 underline.thick = false;
220 underlines.push_back(underline); 221 underlines.push_back(underline);
221 } 222 }
222 223
223 if (auto* controller = GetInputMethodController()) { 224 if (auto* controller = GetInputMethodController()) {
224 controller->setComposition(web_text, underlines, start, start + length); 225 controller->setComposition(web_text, underlines, blink::WebRange(), start,
226 start + length);
225 } 227 }
226 } 228 }
227 229
228 bool TextInputController::HasMarkedText() { 230 bool TextInputController::HasMarkedText() {
229 if (!view()->mainFrame()) 231 if (!view()->mainFrame())
230 return false; 232 return false;
231 233
232 if (!view()->mainFrame()->toWebLocalFrame()) { 234 if (!view()->mainFrame()->toWebLocalFrame()) {
233 CHECK(false) << "This function cannot be called if the main frame is not" 235 CHECK(false) << "This function cannot be called if the main frame is not"
234 "a local frame."; 236 "a local frame.";
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // variable-length characters. 310 // variable-length characters.
309 blink::WebString newText = blink::WebString::fromUTF8(text); 311 blink::WebString newText = blink::WebString::fromUTF8(text);
310 size_t textLength = newText.length(); 312 size_t textLength = newText.length();
311 313
312 std::vector<blink::WebCompositionUnderline> underlines; 314 std::vector<blink::WebCompositionUnderline> underlines;
313 underlines.push_back(blink::WebCompositionUnderline( 315 underlines.push_back(blink::WebCompositionUnderline(
314 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); 316 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT));
315 if (auto* controller = GetInputMethodController()) { 317 if (auto* controller = GetInputMethodController()) {
316 controller->setComposition( 318 controller->setComposition(
317 newText, blink::WebVector<blink::WebCompositionUnderline>(underlines), 319 newText, blink::WebVector<blink::WebCompositionUnderline>(underlines),
318 textLength, textLength); 320 blink::WebRange(), textLength, textLength);
319 } 321 }
320 } 322 }
321 323
322 void TextInputController::ForceTextInputStateUpdate() { 324 void TextInputController::ForceTextInputStateUpdate() {
323 web_view_test_proxy_base_->delegate()->ForceTextInputStateUpdate( 325 web_view_test_proxy_base_->delegate()->ForceTextInputStateUpdate(
324 view()->mainFrame()); 326 view()->mainFrame());
325 } 327 }
326 328
327 blink::WebView* TextInputController::view() { 329 blink::WebView* TextInputController::view() {
328 return web_view_test_proxy_base_->web_view(); 330 return web_view_test_proxy_base_->web_view();
329 } 331 }
330 332
331 blink::WebInputMethodController* 333 blink::WebInputMethodController*
332 TextInputController::GetInputMethodController() { 334 TextInputController::GetInputMethodController() {
333 if (!view()->mainFrame()) 335 if (!view()->mainFrame())
334 return nullptr; 336 return nullptr;
335 337
336 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame(); 338 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame();
337 if (!mainFrame) { 339 if (!mainFrame) {
338 CHECK(false) << "WebView does not have a local main frame and" 340 CHECK(false) << "WebView does not have a local main frame and"
339 " cannot handle input method controller tasks."; 341 " cannot handle input method controller tasks.";
340 } 342 }
341 return mainFrame->frameWidget()->getActiveWebInputMethodController(); 343 return mainFrame->frameWidget()->getActiveWebInputMethodController();
342 } 344 }
343 345
344 } // namespace test_runner 346 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698