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

Side by Side Diff: content/browser/devtools/protocol/input_handler.cc

Issue 2656903005: ChromeDriver: Handle key events properly on Mac (Closed)
Patch Set: fixes Created 3 years, 5 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 "content/browser/devtools/protocol/input_handler.h" 5 #include "content/browser/devtools/protocol/input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "cc/output/compositor_frame_metadata.h" 13 #include "cc/output/compositor_frame_metadata.h"
14 #include "content/browser/devtools/devtools_session.h" 14 #include "content/browser/devtools/devtools_session.h"
15 #include "content/browser/devtools/protocol/native_input_event_builder.h"
15 #include "content/browser/frame_host/render_frame_host_impl.h" 16 #include "content/browser/frame_host/render_frame_host_impl.h"
16 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
17 #include "content/common/input/synthetic_pinch_gesture_params.h" 18 #include "content/common/input/synthetic_pinch_gesture_params.h"
18 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 19 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
19 #include "content/common/input/synthetic_tap_gesture_params.h" 20 #include "content/common/input/synthetic_tap_gesture_params.h"
20 #include "third_party/WebKit/public/platform/WebInputEvent.h" 21 #include "third_party/WebKit/public/platform/WebInputEvent.h"
21 #include "ui/events/blink/web_input_event_traits.h" 22 #include "ui/events/blink/web_input_event_traits.h"
22 #include "ui/events/keycodes/dom/keycode_converter.h" 23 #include "ui/events/keycodes/dom/keycode_converter.h"
23 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
24 25
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 base::StringPrintf("Unexpected event type '%s'", type.c_str()))); 292 base::StringPrintf("Unexpected event type '%s'", type.c_str())));
292 return; 293 return;
293 } 294 }
294 295
295 NativeWebKeyboardEvent event( 296 NativeWebKeyboardEvent event(
296 web_event_type, 297 web_event_type,
297 GetEventModifiers(modifiers.fromMaybe(blink::WebInputEvent::kNoModifiers), 298 GetEventModifiers(modifiers.fromMaybe(blink::WebInputEvent::kNoModifiers),
298 auto_repeat.fromMaybe(false), 299 auto_repeat.fromMaybe(false),
299 is_keypad.fromMaybe(false)), 300 is_keypad.fromMaybe(false)),
300 GetEventTimeTicks(std::move(timestamp))); 301 GetEventTimeTicks(std::move(timestamp)));
301 event.skip_in_browser = true; 302
302 if (!SetKeyboardEventText(event.text, std::move(text))) { 303 if (!SetKeyboardEventText(event.text, std::move(text))) {
303 callback->sendFailure(Response::InvalidParams("Invalid 'text' parameter")); 304 callback->sendFailure(Response::InvalidParams("Invalid 'text' parameter"));
304 return; 305 return;
305 } 306 }
306 if (!SetKeyboardEventText(event.unmodified_text, 307 if (!SetKeyboardEventText(event.unmodified_text,
307 std::move(unmodified_text))) { 308 std::move(unmodified_text))) {
308 callback->sendFailure( 309 callback->sendFailure(
309 Response::InvalidParams("Invalid 'unmodifiedText' parameter")); 310 Response::InvalidParams("Invalid 'unmodifiedText' parameter"));
310 return; 311 return;
311 } 312 }
(...skipping 12 matching lines...) Expand all
324 325
325 if (key.isJust()) { 326 if (key.isJust()) {
326 event.dom_key = static_cast<int>( 327 event.dom_key = static_cast<int>(
327 ui::KeycodeConverter::KeyStringToDomKey(key.fromJust())); 328 ui::KeycodeConverter::KeyStringToDomKey(key.fromJust()));
328 } 329 }
329 330
330 if (!host_ || !host_->GetRenderWidgetHost()) { 331 if (!host_ || !host_->GetRenderWidgetHost()) {
331 callback->sendFailure(Response::InternalError()); 332 callback->sendFailure(Response::InternalError());
332 return; 333 return;
333 } 334 }
334 335 event.os_event = NativeInputEventBuilder::CreateEvent(event);
335 host_->GetRenderWidgetHost()->Focus(); 336 host_->GetRenderWidgetHost()->Focus();
336 input_queued_ = false; 337 input_queued_ = false;
337 pending_key_callbacks_.push_back(std::move(callback)); 338 pending_key_callbacks_.push_back(std::move(callback));
338 host_->GetRenderWidgetHost()->ForwardKeyboardEvent(event); 339 host_->GetRenderWidgetHost()->ForwardKeyboardEvent(event);
339 if (!input_queued_) { 340 if (!input_queued_) {
340 pending_key_callbacks_.back()->sendSuccess(); 341 pending_key_callbacks_.back()->sendSuccess();
341 pending_key_callbacks_.pop_back(); 342 pending_key_callbacks_.pop_back();
342 } 343 }
343 } 344 }
344 345
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 679 }
679 680
680 bool InputHandler::PointIsWithinContents(gfx::PointF point) const { 681 bool InputHandler::PointIsWithinContents(gfx::PointF point) const {
681 gfx::Rect bounds = host_->GetView()->GetViewBounds(); 682 gfx::Rect bounds = host_->GetView()->GetViewBounds();
682 bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0). 683 bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0).
683 return bounds.Contains(point.x(), point.y()); 684 return bounds.Contains(point.x(), point.y());
684 } 685 }
685 686
686 } // namespace protocol 687 } // namespace protocol
687 } // namespace content 688 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/devtools/protocol/native_input_event_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698