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

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

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Set dependency correctly Created 4 years, 10 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 ignore_ack_for_mouse_move_from_debugger_(false) { 184 ignore_ack_for_mouse_move_from_debugger_(false) {
185 DCHECK(delegate); 185 DCHECK(delegate);
186 DCHECK(widget); 186 DCHECK(widget);
187 delegate->SetInputHandler(this); 187 delegate->SetInputHandler(this);
188 } 188 }
189 189
190 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} 190 RenderWidgetInputHandler::~RenderWidgetInputHandler() {}
191 191
192 void RenderWidgetInputHandler::HandleInputEvent( 192 void RenderWidgetInputHandler::HandleInputEvent(
193 const WebInputEvent& input_event, 193 const WebInputEvent& input_event,
194 const ui::LatencyInfo& latency_info) { 194 const ui::LatencyInfo& latency_info,
195 // TODO(dtapuska): Passive support not implemented yet crbug.com/489802 195 bool passive) {
196 bool passive = false;
197 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, 196 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
198 true); 197 true);
199 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( 198 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter(
200 &handling_event_type_, input_event.type); 199 &handling_event_type_, input_event.type);
201 200
202 // Calls into |didOverscroll()| while handling this event will populate 201 // Calls into |didOverscroll()| while handling this event will populate
203 // |event_overscroll|, which in turn will be bundled with the event ack. 202 // |event_overscroll|, which in turn will be bundled with the event ack.
204 scoped_ptr<DidOverscrollParams> event_overscroll; 203 scoped_ptr<DidOverscrollParams> event_overscroll;
205 base::AutoReset<scoped_ptr<DidOverscrollParams>*> 204 base::AutoReset<scoped_ptr<DidOverscrollParams>*>
206 handling_event_overscroll_resetter(&handling_event_overscroll_, 205 handling_event_overscroll_resetter(&handling_event_overscroll_,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 gfx::ToFlooredPoint(touch_event.touches[i].position))) { 348 gfx::ToFlooredPoint(touch_event.touches[i].position))) {
350 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 349 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
351 break; 350 break;
352 } 351 }
353 } 352 }
354 } 353 }
355 354
356 // Send mouse wheel events and their disposition to the compositor thread, so 355 // Send mouse wheel events and their disposition to the compositor thread, so
357 // that they can be used to produce the elastic overscroll effect on Mac. 356 // that they can be used to produce the elastic overscroll effect on Mac.
358 if (input_event.type == WebInputEvent::MouseWheel) { 357 if (input_event.type == WebInputEvent::MouseWheel) {
359 delegate_->ObserveWheelEventAndResult( 358 const WebMouseWheelEvent& wheel_event =
360 static_cast<const WebMouseWheelEvent&>(input_event), 359 static_cast<const WebMouseWheelEvent&>(input_event);
361 event_overscroll ? event_overscroll->latest_overscroll_delta 360 if (wheel_event.canScroll) {
tdresser 2016/01/26 16:34:37 The canScroll check is unrelated to the rest of yo
dtapuska 2016/01/26 16:53:15 Ultimately yes; for passive wheel listeners; canSc
tdresser 2016/01/26 18:45:42 Acknowledged.
362 : gfx::Vector2dF(), 361 delegate_->ObserveWheelEventAndResult(
363 processed != WebInputEventResult::NotHandled); 362 wheel_event,
363 event_overscroll ? event_overscroll->latest_overscroll_delta
364 : gfx::Vector2dF(),
365 processed != WebInputEventResult::NotHandled);
366 }
364 } 367 }
365 368
366 bool frame_pending = 369 bool frame_pending =
367 widget_->compositor() && widget_->compositor()->BeginMainFrameRequested(); 370 widget_->compositor() && widget_->compositor()->BeginMainFrameRequested();
368 371
369 // If we don't have a fast and accurate Now(), we assume the input handlers 372 // If we don't have a fast and accurate Now(), we assume the input handlers
370 // are heavy and rate limit them. 373 // are heavy and rate limit them.
371 bool rate_limiting_wanted = input_event.type == WebInputEvent::MouseMove || 374 bool rate_limiting_wanted = input_event.type == WebInputEvent::MouseMove ||
372 input_event.type == WebInputEvent::MouseWheel; 375 input_event.type == WebInputEvent::MouseWheel;
373 if (rate_limiting_wanted && !start_time.is_null()) { 376 if (rate_limiting_wanted && !start_time.is_null()) {
374 base::TimeTicks end_time = base::TimeTicks::Now(); 377 base::TimeTicks end_time = base::TimeTicks::Now();
375 total_input_handling_time_this_frame_ += (end_time - start_time); 378 total_input_handling_time_this_frame_ += (end_time - start_time);
376 rate_limiting_wanted = 379 rate_limiting_wanted =
377 total_input_handling_time_this_frame_.InMicroseconds() > 380 total_input_handling_time_this_frame_.InMicroseconds() >
378 kInputHandlingTimeThrottlingThresholdMicroseconds; 381 kInputHandlingTimeThrottlingThresholdMicroseconds;
379 } 382 }
380 383
381 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); 384 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent");
382 385
383 // Note that we can't use handling_event_type_ here since it will be overriden 386 // Note that we can't use handling_event_type_ here since it will be overriden
384 // by reentrant calls for events after the paused one. 387 // by reentrant calls for events after the paused one.
385 bool no_ack = ignore_ack_for_mouse_move_from_debugger_ && 388 bool no_ack = ignore_ack_for_mouse_move_from_debugger_ &&
386 input_event.type == WebInputEvent::MouseMove; 389 input_event.type == WebInputEvent::MouseMove;
387 if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event) && !no_ack) { 390 if (passive) {
391 // Passive means it was ack'd already by the InputHandlerProxy
392 // so let the delegate know the passive event has been handled.
393 delegate_->PassiveInputEventHandled(input_event.type);
394 } else if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event) &&
395 !no_ack) {
tdresser 2016/01/26 16:34:37 Is this indentation correct?
dtapuska 2016/01/26 16:53:15 Done.
388 scoped_ptr<InputEventAck> response(new InputEventAck( 396 scoped_ptr<InputEventAck> response(new InputEventAck(
389 input_event.type, ack_result, swap_latency_info, 397 input_event.type, ack_result, swap_latency_info,
390 std::move(event_overscroll), 398 std::move(event_overscroll),
391 WebInputEventTraits::GetUniqueTouchEventId(input_event))); 399 WebInputEventTraits::GetUniqueTouchEventId(input_event)));
392 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { 400 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) {
393 // We want to rate limit the input events in this case, so we'll wait for 401 // We want to rate limit the input events in this case, so we'll wait for
394 // painting to finish before ACKing this message. 402 // painting to finish before ACKing this message.
395 TRACE_EVENT_INSTANT0( 403 TRACE_EVENT_INSTANT0(
396 "renderer", 404 "renderer",
397 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", 405 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled",
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 if (pending_input_event_ack_) { 514 if (pending_input_event_ack_) {
507 TRACE_EVENT_ASYNC_END0("input", 515 TRACE_EVENT_ASYNC_END0("input",
508 "RenderWidgetInputHandler::ThrottledInputEventAck", 516 "RenderWidgetInputHandler::ThrottledInputEventAck",
509 pending_input_event_ack_.get()); 517 pending_input_event_ack_.get());
510 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); 518 delegate_->OnInputEventAck(std::move(pending_input_event_ack_));
511 } 519 }
512 total_input_handling_time_this_frame_ = base::TimeDelta(); 520 total_input_handling_time_this_frame_ = base::TimeDelta();
513 } 521 }
514 522
515 } // namespace content 523 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698