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

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

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Creating CoalescedWebInputEvent Created 4 years, 1 month 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/CoalescedWebInputEvent.h"
15 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 15 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
16 #include "third_party/WebKit/public/web/WebFrameWidget.h" 16 #include "third_party/WebKit/public/web/WebFrameWidget.h"
17 #include "third_party/WebKit/public/web/WebInputMethodController.h" 17 #include "third_party/WebKit/public/web/WebInputMethodController.h"
18 #include "third_party/WebKit/public/web/WebKit.h" 18 #include "third_party/WebKit/public/web/WebKit.h"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
20 #include "third_party/WebKit/public/web/WebRange.h" 20 #include "third_party/WebKit/public/web/WebRange.h"
21 #include "third_party/WebKit/public/web/WebView.h" 21 #include "third_party/WebKit/public/web/WebView.h"
22 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
23 #include "v8/include/v8.h" 23 #include "v8/include/v8.h"
24 24
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return int_array; 284 return int_array;
285 } 285 }
286 286
287 void TextInputController::SetComposition(const std::string& text) { 287 void TextInputController::SetComposition(const std::string& text) {
288 // Sends a keydown event with key code = 0xE5 to emulate input method 288 // Sends a keydown event with key code = 0xE5 to emulate input method
289 // behavior. 289 // behavior.
290 blink::WebKeyboardEvent key_down; 290 blink::WebKeyboardEvent key_down;
291 key_down.type = blink::WebInputEvent::RawKeyDown; 291 key_down.type = blink::WebInputEvent::RawKeyDown;
292 key_down.modifiers = 0; 292 key_down.modifiers = 0;
293 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY 293 key_down.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY
294 view()->handleInputEvent(key_down); 294 view()->handleInputEvent(CoalescedWebInputEvent(key_down));
295 295
296 // The value returned by std::string::length() may not correspond to the 296 // The value returned by std::string::length() may not correspond to the
297 // actual number of encoded characters in sequences of multi-byte or 297 // actual number of encoded characters in sequences of multi-byte or
298 // variable-length characters. 298 // variable-length characters.
299 blink::WebString newText = blink::WebString::fromUTF8(text); 299 blink::WebString newText = blink::WebString::fromUTF8(text);
300 size_t textLength = newText.length(); 300 size_t textLength = newText.length();
301 301
302 std::vector<blink::WebCompositionUnderline> underlines; 302 std::vector<blink::WebCompositionUnderline> underlines;
303 underlines.push_back(blink::WebCompositionUnderline( 303 underlines.push_back(blink::WebCompositionUnderline(
304 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); 304 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT));
(...skipping 14 matching lines...) Expand all
319 blink::WebInputMethodController* TextInputController::inputMethodController() { 319 blink::WebInputMethodController* TextInputController::inputMethodController() {
320 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame(); 320 blink::WebLocalFrame* mainFrame = view()->mainFrame()->toWebLocalFrame();
321 if (!mainFrame) { 321 if (!mainFrame) {
322 CHECK(false) << "WebView does not have a local main frame and" 322 CHECK(false) << "WebView does not have a local main frame and"
323 " cannot handle input method controller tasks."; 323 " cannot handle input method controller tasks.";
324 } 324 }
325 return mainFrame->frameWidget()->getActiveWebInputMethodController(); 325 return mainFrame->frameWidget()->getActiveWebInputMethodController();
326 } 326 }
327 327
328 } // namespace test_runner 328 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698