| OLD | NEW |
| 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" |
| 11 #include "gin/handle.h" | 11 #include "gin/handle.h" |
| 12 #include "gin/object_template_builder.h" | 12 #include "gin/object_template_builder.h" |
| 13 #include "gin/wrappable.h" | 13 #include "gin/wrappable.h" |
| 14 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 14 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h" |
| 15 #include "third_party/WebKit/public/platform/WebInputEventResult.h" | 15 #include "third_party/WebKit/public/platform/WebInputEventResult.h" |
| 16 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" | 16 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" |
| 17 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 17 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 18 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 18 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 19 #include "third_party/WebKit/public/web/WebInputMethodController.h" | 19 #include "third_party/WebKit/public/web/WebInputMethodController.h" |
| 20 #include "third_party/WebKit/public/web/WebKit.h" | 20 #include "third_party/WebKit/public/web/WebKit.h" |
| 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 22 #include "third_party/WebKit/public/web/WebRange.h" | 22 #include "third_party/WebKit/public/web/WebRange.h" |
| 23 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
| 24 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 void TextInputController::SetComposition(const std::string& text) { | 296 void TextInputController::SetComposition(const std::string& text) { |
| 297 // Sends a keydown event with key code = 0xE5 to emulate input method | 297 // Sends a keydown event with key code = 0xE5 to emulate input method |
| 298 // behavior. | 298 // behavior. |
| 299 blink::WebKeyboardEvent key_down( | 299 blink::WebKeyboardEvent key_down( |
| 300 blink::WebInputEvent::RawKeyDown, blink::WebInputEvent::NoModifiers, | 300 blink::WebInputEvent::RawKeyDown, blink::WebInputEvent::NoModifiers, |
| 301 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 301 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 302 | 302 |
| 303 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY | 303 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY |
| 304 view()->handleInputEvent(key_down); | 304 view()->handleInputEvent(blink::WebCoalescedInputEvent(key_down)); |
| 305 | 305 |
| 306 // The value returned by std::string::length() may not correspond to the | 306 // The value returned by std::string::length() may not correspond to the |
| 307 // actual number of encoded characters in sequences of multi-byte or | 307 // actual number of encoded characters in sequences of multi-byte or |
| 308 // variable-length characters. | 308 // variable-length characters. |
| 309 blink::WebString newText = blink::WebString::fromUTF8(text); | 309 blink::WebString newText = blink::WebString::fromUTF8(text); |
| 310 size_t textLength = newText.length(); | 310 size_t textLength = newText.length(); |
| 311 | 311 |
| 312 std::vector<blink::WebCompositionUnderline> underlines; | 312 std::vector<blink::WebCompositionUnderline> underlines; |
| 313 underlines.push_back(blink::WebCompositionUnderline( | 313 underlines.push_back(blink::WebCompositionUnderline( |
| 314 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); | 314 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 335 | 335 |
| 336 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame(); | 336 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame(); |
| 337 if (!mainFrame) { | 337 if (!mainFrame) { |
| 338 CHECK(false) << "WebView does not have a local main frame and" | 338 CHECK(false) << "WebView does not have a local main frame and" |
| 339 " cannot handle input method controller tasks."; | 339 " cannot handle input method controller tasks."; |
| 340 } | 340 } |
| 341 return mainFrame->frameWidget()->getActiveWebInputMethodController(); | 341 return mainFrame->frameWidget()->getActiveWebInputMethodController(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace test_runner | 344 } // namespace test_runner |
| OLD | NEW |