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

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

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