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