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

Side by Side Diff: content/renderer/input/render_widget_input_handler.cc

Issue 2813683002: Allow MainThreadEventQueue to call the RenderWidget directly. (Closed)
Patch Set: Fix style nits Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/input/render_widget_input_handler.h" 5 #include "content/renderer/input/render_widget_input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 handling_event_type_(WebInputEvent::kUndefined), 200 handling_event_type_(WebInputEvent::kUndefined),
201 context_menu_source_type_(ui::MENU_SOURCE_MOUSE), 201 context_menu_source_type_(ui::MENU_SOURCE_MOUSE),
202 suppress_next_char_events_(false) { 202 suppress_next_char_events_(false) {
203 DCHECK(delegate); 203 DCHECK(delegate);
204 DCHECK(widget); 204 DCHECK(widget);
205 delegate->SetInputHandler(this); 205 delegate->SetInputHandler(this);
206 } 206 }
207 207
208 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} 208 RenderWidgetInputHandler::~RenderWidgetInputHandler() {}
209 209
210 void RenderWidgetInputHandler::HandleInputEvent( 210 InputEventAckState RenderWidgetInputHandler::HandleInputEvent(
211 const blink::WebCoalescedInputEvent& coalesced_event, 211 const blink::WebCoalescedInputEvent& coalesced_event,
212 const ui::LatencyInfo& latency_info, 212 const ui::LatencyInfo& latency_info,
213 InputEventDispatchType dispatch_type) { 213 InputEventDispatchType dispatch_type) {
214 const WebInputEvent& input_event = coalesced_event.Event(); 214 const WebInputEvent& input_event = coalesced_event.Event();
215 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, 215 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
216 true); 216 true);
217 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( 217 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter(
218 &handling_event_type_, input_event.GetType()); 218 &handling_event_type_, input_event.GetType());
219 219
220 // Calls into |didOverscroll()| while handling this event will populate 220 // Calls into |didOverscroll()| while handling this event will populate
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 delegate_->ObserveGestureEventAndResult( 386 delegate_->ObserveGestureEventAndResult(
387 gesture_event, 387 gesture_event,
388 event_overscroll ? event_overscroll->latest_overscroll_delta 388 event_overscroll ? event_overscroll->latest_overscroll_delta
389 : gfx::Vector2dF(), 389 : gfx::Vector2dF(),
390 processed != WebInputEventResult::kNotHandled); 390 processed != WebInputEventResult::kNotHandled);
391 } 391 }
392 } 392 }
393 393
394 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); 394 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent");
395 395
396 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN || 396 if (dispatch_type == DISPATCH_TYPE_BLOCKING) {
397 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) {
398 // |non_blocking| means it was ack'd already by the InputHandlerProxy
399 // so let the delegate know the event has been handled.
400 delegate_->NotifyInputEventHandled(input_event.GetType(), processed,
401 ack_result);
402 }
403
404 if ((dispatch_type == DISPATCH_TYPE_BLOCKING ||
405 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN)) {
406 std::unique_ptr<InputEventAck> response(new InputEventAck( 397 std::unique_ptr<InputEventAck> response(new InputEventAck(
407 InputEventAckSource::MAIN_THREAD, input_event.GetType(), ack_result, 398 InputEventAckSource::MAIN_THREAD, input_event.GetType(), ack_result,
408 swap_latency_info, std::move(event_overscroll), 399 swap_latency_info, std::move(event_overscroll),
409 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event))); 400 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event)));
410 delegate_->OnInputEventAck(std::move(response)); 401 delegate_->OnInputEventAck(std::move(response));
411 } else { 402 } else {
412 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; 403 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event";
413 } 404 }
414 if (RenderThreadImpl::current()) { 405 if (RenderThreadImpl::current()) {
415 RenderThreadImpl::current() 406 RenderThreadImpl::current()
(...skipping 25 matching lines...) Expand all
441 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with 432 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
442 // virtual keyboard. 433 // virtual keyboard.
443 #if !defined(OS_ANDROID) 434 #if !defined(OS_ANDROID)
444 // Virtual keyboard is not supported, so react to focus change immediately. 435 // Virtual keyboard is not supported, so react to focus change immediately.
445 if (processed != WebInputEventResult::kNotHandled && 436 if (processed != WebInputEventResult::kNotHandled &&
446 (input_event.GetType() == WebInputEvent::kTouchEnd || 437 (input_event.GetType() == WebInputEvent::kTouchEnd ||
447 input_event.GetType() == WebInputEvent::kMouseUp)) { 438 input_event.GetType() == WebInputEvent::kMouseUp)) {
448 delegate_->FocusChangeComplete(); 439 delegate_->FocusChangeComplete();
449 } 440 }
450 #endif 441 #endif
442 return ack_result;
451 } 443 }
452 444
453 void RenderWidgetInputHandler::DidOverscrollFromBlink( 445 void RenderWidgetInputHandler::DidOverscrollFromBlink(
454 const WebFloatSize& overscrollDelta, 446 const WebFloatSize& overscrollDelta,
455 const WebFloatSize& accumulatedOverscroll, 447 const WebFloatSize& accumulatedOverscroll,
456 const WebFloatPoint& position, 448 const WebFloatPoint& position,
457 const WebFloatSize& velocity) { 449 const WebFloatSize& velocity) {
458 std::unique_ptr<DidOverscrollParams> params(new DidOverscrollParams()); 450 std::unique_ptr<DidOverscrollParams> params(new DidOverscrollParams());
459 params->accumulated_overscroll = gfx::Vector2dF( 451 params->accumulated_overscroll = gfx::Vector2dF(
460 accumulatedOverscroll.width, accumulatedOverscroll.height); 452 accumulatedOverscroll.width, accumulatedOverscroll.height);
461 params->latest_overscroll_delta = 453 params->latest_overscroll_delta =
462 gfx::Vector2dF(overscrollDelta.width, overscrollDelta.height); 454 gfx::Vector2dF(overscrollDelta.width, overscrollDelta.height);
463 params->current_fling_velocity = 455 params->current_fling_velocity =
464 gfx::Vector2dF(velocity.width, velocity.height); 456 gfx::Vector2dF(velocity.width, velocity.height);
465 params->causal_event_viewport_point = gfx::PointF(position.x, position.y); 457 params->causal_event_viewport_point = gfx::PointF(position.x, position.y);
466 458
467 // If we're currently handling an event, stash the overscroll data such that 459 // If we're currently handling an event, stash the overscroll data such that
468 // it can be bundled in the event ack. 460 // it can be bundled in the event ack.
469 if (handling_event_overscroll_) { 461 if (handling_event_overscroll_) {
470 *handling_event_overscroll_ = std::move(params); 462 *handling_event_overscroll_ = std::move(params);
471 return; 463 return;
472 } 464 }
473 465
474 delegate_->OnDidOverscroll(*params); 466 delegate_->OnDidOverscroll(*params);
475 } 467 }
476 468
477 } // namespace content 469 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/render_widget_input_handler.h ('k') | content/renderer/input/render_widget_input_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698