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

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

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 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
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"
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/WebInputEvent.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 "v8/include/v8.h" 25 #include "v8/include/v8.h"
25 26
26 namespace test_runner { 27 namespace test_runner {
27 28
28 class TextInputControllerBindings 29 class TextInputControllerBindings
29 : public gin::Wrappable<TextInputControllerBindings> { 30 : public gin::Wrappable<TextInputControllerBindings> {
30 public: 31 public:
31 static gin::WrapperInfo kWrapperInfo; 32 static gin::WrapperInfo kWrapperInfo;
32 33
33 static void Install(base::WeakPtr<TextInputController> controller, 34 static void Install(base::WeakPtr<TextInputController> controller,
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 int_array[1] = rect.y; 287 int_array[1] = rect.y;
287 int_array[2] = rect.width; 288 int_array[2] = rect.width;
288 int_array[3] = rect.height; 289 int_array[3] = rect.height;
289 290
290 return int_array; 291 return int_array;
291 } 292 }
292 293
293 void TextInputController::SetComposition(const std::string& text) { 294 void TextInputController::SetComposition(const std::string& text) {
294 // Sends a keydown event with key code = 0xE5 to emulate input method 295 // Sends a keydown event with key code = 0xE5 to emulate input method
295 // behavior. 296 // behavior.
296 blink::WebKeyboardEvent key_down; 297 blink::WebKeyboardEvent key_down(
297 key_down.type = blink::WebInputEvent::RawKeyDown; 298 blink::WebInputEvent::RawKeyDown, blink::WebInputEvent::NoModifiers,
298 key_down.modifiers = 0; 299 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
300
299 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY 301 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY
300 view()->handleInputEvent(key_down); 302 view()->handleInputEvent(key_down);
301 303
302 // The value returned by std::string::length() may not correspond to the 304 // The value returned by std::string::length() may not correspond to the
303 // actual number of encoded characters in sequences of multi-byte or 305 // actual number of encoded characters in sequences of multi-byte or
304 // variable-length characters. 306 // variable-length characters.
305 blink::WebString newText = blink::WebString::fromUTF8(text); 307 blink::WebString newText = blink::WebString::fromUTF8(text);
306 size_t textLength = newText.length(); 308 size_t textLength = newText.length();
307 309
308 std::vector<blink::WebCompositionUnderline> underlines; 310 std::vector<blink::WebCompositionUnderline> underlines;
(...skipping 22 matching lines...) Expand all
331 333
332 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame(); 334 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame();
333 if (!mainFrame) { 335 if (!mainFrame) {
334 CHECK(false) << "WebView does not have a local main frame and" 336 CHECK(false) << "WebView does not have a local main frame and"
335 " cannot handle input method controller tasks."; 337 " cannot handle input method controller tasks.";
336 } 338 }
337 return mainFrame->frameWidget()->getActiveWebInputMethodController(); 339 return mainFrame->frameWidget()->getActiveWebInputMethodController();
338 } 340 }
339 341
340 } // namespace test_runner 342 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698