| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 namespace content { | 50 namespace content { |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 int64_t GetEventLatencyMicros(double event_timestamp, base::TimeTicks now) { | 54 int64_t GetEventLatencyMicros(double event_timestamp, base::TimeTicks now) { |
| 55 return (now - base::TimeDelta::FromSecondsD(event_timestamp)) | 55 return (now - base::TimeDelta::FromSecondsD(event_timestamp)) |
| 56 .ToInternalValue(); | 56 .ToInternalValue(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void LogInputEventLatencyUma(const WebInputEvent& event, base::TimeTicks now) { | 59 void LogInputEventLatencyUma(const WebInputEvent& event, base::TimeTicks now) { |
| 60 WebInputEvent::Type event_type = event.type; | 60 WebInputEvent::Type event_type = event.type(); |
| 61 UMA_HISTOGRAM_CUSTOM_COUNTS( | 61 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 62 "Event.AggregatedLatency.Renderer2", | 62 "Event.AggregatedLatency.Renderer2", |
| 63 GetEventLatencyMicros(event.timeStampSeconds, now), 1, 10000000, 100); | 63 GetEventLatencyMicros(event.timeStampSeconds(), now), 1, 10000000, 100); |
| 64 | 64 |
| 65 #define CASE_TYPE(t) \ | 65 #define CASE_TYPE(t) \ |
| 66 case WebInputEvent::t: \ | 66 case WebInputEvent::t: \ |
| 67 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 67 UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 68 "Event.Latency.Renderer2." #t, \ | 68 "Event.Latency.Renderer2." #t, \ |
| 69 GetEventLatencyMicros(event.timeStampSeconds, now), 1, 10000000, 100); \ | 69 GetEventLatencyMicros(event.timeStampSeconds(), now), 1, 10000000, \ |
| 70 100); \ |
| 70 break; | 71 break; |
| 71 | 72 |
| 72 switch (event_type) { | 73 switch (event_type) { |
| 73 CASE_TYPE(Undefined); | 74 CASE_TYPE(Undefined); |
| 74 CASE_TYPE(MouseDown); | 75 CASE_TYPE(MouseDown); |
| 75 CASE_TYPE(MouseUp); | 76 CASE_TYPE(MouseUp); |
| 76 CASE_TYPE(MouseMove); | 77 CASE_TYPE(MouseMove); |
| 77 CASE_TYPE(MouseEnter); | 78 CASE_TYPE(MouseEnter); |
| 78 CASE_TYPE(MouseLeave); | 79 CASE_TYPE(MouseLeave); |
| 79 CASE_TYPE(ContextMenu); | 80 CASE_TYPE(ContextMenu); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 204 |
| 204 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} | 205 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} |
| 205 | 206 |
| 206 void RenderWidgetInputHandler::HandleInputEvent( | 207 void RenderWidgetInputHandler::HandleInputEvent( |
| 207 const WebInputEvent& input_event, | 208 const WebInputEvent& input_event, |
| 208 const ui::LatencyInfo& latency_info, | 209 const ui::LatencyInfo& latency_info, |
| 209 InputEventDispatchType dispatch_type) { | 210 InputEventDispatchType dispatch_type) { |
| 210 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, | 211 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, |
| 211 true); | 212 true); |
| 212 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( | 213 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( |
| 213 &handling_event_type_, input_event.type); | 214 &handling_event_type_, input_event.type()); |
| 214 | 215 |
| 215 // Calls into |didOverscroll()| while handling this event will populate | 216 // Calls into |didOverscroll()| while handling this event will populate |
| 216 // |event_overscroll|, which in turn will be bundled with the event ack. | 217 // |event_overscroll|, which in turn will be bundled with the event ack. |
| 217 std::unique_ptr<DidOverscrollParams> event_overscroll; | 218 std::unique_ptr<DidOverscrollParams> event_overscroll; |
| 218 base::AutoReset<std::unique_ptr<DidOverscrollParams>*> | 219 base::AutoReset<std::unique_ptr<DidOverscrollParams>*> |
| 219 handling_event_overscroll_resetter(&handling_event_overscroll_, | 220 handling_event_overscroll_resetter(&handling_event_overscroll_, |
| 220 &event_overscroll); | 221 &event_overscroll); |
| 221 | 222 |
| 222 #if defined(OS_ANDROID) | 223 #if defined(OS_ANDROID) |
| 223 ImeEventGuard guard(widget_); | 224 ImeEventGuard guard(widget_); |
| 224 #endif | 225 #endif |
| 225 | 226 |
| 226 base::TimeTicks start_time; | 227 base::TimeTicks start_time; |
| 227 if (base::TimeTicks::IsHighResolution()) | 228 if (base::TimeTicks::IsHighResolution()) |
| 228 start_time = base::TimeTicks::Now(); | 229 start_time = base::TimeTicks::Now(); |
| 229 | 230 |
| 230 TRACE_EVENT1("renderer,benchmark,rail", | 231 TRACE_EVENT1("renderer,benchmark,rail", |
| 231 "RenderWidgetInputHandler::OnHandleInputEvent", "event", | 232 "RenderWidgetInputHandler::OnHandleInputEvent", "event", |
| 232 WebInputEvent::GetName(input_event.type)); | 233 WebInputEvent::GetName(input_event.type())); |
| 233 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 234 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
| 234 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", | 235 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", |
| 235 TRACE_ID_DONT_MANGLE(latency_info.trace_id()), | 236 TRACE_ID_DONT_MANGLE(latency_info.trace_id()), |
| 236 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 237 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
| 237 "step", "HandleInputEventMain"); | 238 "step", "HandleInputEventMain"); |
| 238 | 239 |
| 239 // If we don't have a high res timer, these metrics won't be accurate enough | 240 // If we don't have a high res timer, these metrics won't be accurate enough |
| 240 // to be worth collecting. Note that this does introduce some sampling bias. | 241 // to be worth collecting. Note that this does introduce some sampling bias. |
| 241 if (!start_time.is_null()) | 242 if (!start_time.is_null()) |
| 242 LogInputEventLatencyUma(input_event, start_time); | 243 LogInputEventLatencyUma(input_event, start_time); |
| 243 | 244 |
| 244 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; | 245 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
| 245 ui::LatencyInfo swap_latency_info(latency_info); | 246 ui::LatencyInfo swap_latency_info(latency_info); |
| 246 swap_latency_info.AddLatencyNumber( | 247 swap_latency_info.AddLatencyNumber( |
| 247 ui::LatencyComponentType::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, | 248 ui::LatencyComponentType::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, |
| 248 0); | 249 0); |
| 249 if (widget_->compositor()) { | 250 if (widget_->compositor()) { |
| 250 latency_info_swap_promise_monitor = | 251 latency_info_swap_promise_monitor = |
| 251 widget_->compositor()->CreateLatencyInfoSwapPromiseMonitor( | 252 widget_->compositor()->CreateLatencyInfoSwapPromiseMonitor( |
| 252 &swap_latency_info); | 253 &swap_latency_info); |
| 253 } | 254 } |
| 254 | 255 |
| 255 bool prevent_default = false; | 256 bool prevent_default = false; |
| 256 if (WebInputEvent::isMouseEventType(input_event.type)) { | 257 if (WebInputEvent::isMouseEventType(input_event.type())) { |
| 257 const WebMouseEvent& mouse_event = | 258 const WebMouseEvent& mouse_event = |
| 258 static_cast<const WebMouseEvent&>(input_event); | 259 static_cast<const WebMouseEvent&>(input_event); |
| 259 TRACE_EVENT2("renderer", "HandleMouseMove", "x", mouse_event.x, "y", | 260 TRACE_EVENT2("renderer", "HandleMouseMove", "x", mouse_event.x, "y", |
| 260 mouse_event.y); | 261 mouse_event.y); |
| 261 context_menu_source_type_ = ui::MENU_SOURCE_MOUSE; | 262 context_menu_source_type_ = ui::MENU_SOURCE_MOUSE; |
| 262 prevent_default = delegate_->WillHandleMouseEvent(mouse_event); | 263 prevent_default = delegate_->WillHandleMouseEvent(mouse_event); |
| 263 } | 264 } |
| 264 | 265 |
| 265 if (WebInputEvent::isKeyboardEventType(input_event.type)) { | 266 if (WebInputEvent::isKeyboardEventType(input_event.type())) { |
| 266 context_menu_source_type_ = ui::MENU_SOURCE_KEYBOARD; | 267 context_menu_source_type_ = ui::MENU_SOURCE_KEYBOARD; |
| 267 #if defined(OS_ANDROID) | 268 #if defined(OS_ANDROID) |
| 268 // The DPAD_CENTER key on Android has a dual semantic: (1) in the general | 269 // The DPAD_CENTER key on Android has a dual semantic: (1) in the general |
| 269 // case it should behave like a select key (i.e. causing a click if a button | 270 // case it should behave like a select key (i.e. causing a click if a button |
| 270 // is focused). However, if a text field is focused (2), its intended | 271 // is focused). However, if a text field is focused (2), its intended |
| 271 // behavior is to just show the IME and don't propagate the key. | 272 // behavior is to just show the IME and don't propagate the key. |
| 272 // A typical use case is a web form: the DPAD_CENTER should bring up the IME | 273 // A typical use case is a web form: the DPAD_CENTER should bring up the IME |
| 273 // when clicked on an input text field and cause the form submit if clicked | 274 // when clicked on an input text field and cause the form submit if clicked |
| 274 // when the submit button is focused, but not vice-versa. | 275 // when the submit button is focused, but not vice-versa. |
| 275 // The UI layer takes care of translating DPAD_CENTER into a RETURN key, | 276 // The UI layer takes care of translating DPAD_CENTER into a RETURN key, |
| 276 // but at this point we have to swallow the event for the scenario (2). | 277 // but at this point we have to swallow the event for the scenario (2). |
| 277 const WebKeyboardEvent& key_event = | 278 const WebKeyboardEvent& key_event = |
| 278 static_cast<const WebKeyboardEvent&>(input_event); | 279 static_cast<const WebKeyboardEvent&>(input_event); |
| 279 if (key_event.nativeKeyCode == AKEYCODE_DPAD_CENTER && | 280 if (key_event.nativeKeyCode == AKEYCODE_DPAD_CENTER && |
| 280 widget_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { | 281 widget_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { |
| 281 widget_->showImeIfNeeded(); | 282 widget_->showImeIfNeeded(); |
| 282 prevent_default = true; | 283 prevent_default = true; |
| 283 } | 284 } |
| 284 #endif | 285 #endif |
| 285 } | 286 } |
| 286 | 287 |
| 287 if (WebInputEvent::isGestureEventType(input_event.type)) { | 288 if (WebInputEvent::isGestureEventType(input_event.type())) { |
| 288 const WebGestureEvent& gesture_event = | 289 const WebGestureEvent& gesture_event = |
| 289 static_cast<const WebGestureEvent&>(input_event); | 290 static_cast<const WebGestureEvent&>(input_event); |
| 290 if (input_event.type == WebInputEvent::GestureLongPress) { | 291 if (input_event.type() == WebInputEvent::GestureLongPress) { |
| 291 context_menu_source_type_ = ui::MENU_SOURCE_LONG_PRESS; | 292 context_menu_source_type_ = ui::MENU_SOURCE_LONG_PRESS; |
| 292 } else if (input_event.type == WebInputEvent::GestureLongTap) { | 293 } else if (input_event.type() == WebInputEvent::GestureLongTap) { |
| 293 context_menu_source_type_ = ui::MENU_SOURCE_LONG_TAP; | 294 context_menu_source_type_ = ui::MENU_SOURCE_LONG_TAP; |
| 294 } else { | 295 } else { |
| 295 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH; | 296 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH; |
| 296 } | 297 } |
| 297 prevent_default = | 298 prevent_default = |
| 298 prevent_default || delegate_->WillHandleGestureEvent(gesture_event); | 299 prevent_default || delegate_->WillHandleGestureEvent(gesture_event); |
| 299 } | 300 } |
| 300 | 301 |
| 301 WebInputEventResult processed = prevent_default | 302 WebInputEventResult processed = prevent_default |
| 302 ? WebInputEventResult::HandledSuppressed | 303 ? WebInputEventResult::HandledSuppressed |
| 303 : WebInputEventResult::NotHandled; | 304 : WebInputEventResult::NotHandled; |
| 304 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) { | 305 if (input_event.type() != WebInputEvent::Char || |
| 306 !suppress_next_char_events_) { |
| 305 suppress_next_char_events_ = false; | 307 suppress_next_char_events_ = false; |
| 306 if (processed == WebInputEventResult::NotHandled && widget_->GetWebWidget()) | 308 if (processed == WebInputEventResult::NotHandled && widget_->GetWebWidget()) |
| 307 processed = widget_->GetWebWidget()->handleInputEvent(input_event); | 309 processed = widget_->GetWebWidget()->handleInputEvent(input_event); |
| 308 } | 310 } |
| 309 | 311 |
| 310 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start | 312 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start |
| 311 // ideally this should be when the event was sent by the compositor to the | 313 // ideally this should be when the event was sent by the compositor to the |
| 312 // renderer. crbug.com/565348 | 314 // renderer. crbug.com/565348 |
| 313 if (input_event.type == WebInputEvent::TouchStart || | 315 if (input_event.type() == WebInputEvent::TouchStart || |
| 314 input_event.type == WebInputEvent::TouchMove || | 316 input_event.type() == WebInputEvent::TouchMove || |
| 315 input_event.type == WebInputEvent::TouchEnd) { | 317 input_event.type() == WebInputEvent::TouchEnd) { |
| 316 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 318 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
| 317 | 319 |
| 318 LogPassiveEventListenersUma(processed, touch.dispatchType, | 320 LogPassiveEventListenersUma(processed, touch.dispatchType, |
| 319 input_event.timeStampSeconds, latency_info); | 321 input_event.timeStampSeconds(), latency_info); |
| 320 | 322 |
| 321 // TODO(lanwei): Remove this metric for event latency outside fling in M56, | 323 // TODO(lanwei): Remove this metric for event latency outside fling in M56, |
| 322 // once we've gathered enough data to decide if we want to ship the passive | 324 // once we've gathered enough data to decide if we want to ship the passive |
| 323 // event listener for fling, see https://crbug.com/638661. | 325 // event listener for fling, see https://crbug.com/638661. |
| 324 if (touch.dispatchType == WebInputEvent::Blocking && | 326 if (touch.dispatchType == WebInputEvent::Blocking && |
| 325 touch.touchStartOrFirstTouchMove && | 327 touch.touchStartOrFirstTouchMove && |
| 326 base::TimeTicks::IsHighResolution()) { | 328 base::TimeTicks::IsHighResolution()) { |
| 327 base::TimeTicks now = base::TimeTicks::Now(); | 329 base::TimeTicks now = base::TimeTicks::Now(); |
| 328 UMA_HISTOGRAM_CUSTOM_COUNTS( | 330 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 329 "Event.Touch.TouchLatencyOutsideFling", | 331 "Event.Touch.TouchLatencyOutsideFling", |
| 330 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, | 332 GetEventLatencyMicros(input_event.timeStampSeconds(), now), 1, |
| 331 100000000, 50); | 333 100000000, 50); |
| 332 } | 334 } |
| 333 } else if (input_event.type == WebInputEvent::MouseWheel) { | 335 } else if (input_event.type() == WebInputEvent::MouseWheel) { |
| 334 LogPassiveEventListenersUma( | 336 LogPassiveEventListenersUma( |
| 335 processed, | 337 processed, |
| 336 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, | 338 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, |
| 337 input_event.timeStampSeconds, latency_info); | 339 input_event.timeStampSeconds(), latency_info); |
| 338 } | 340 } |
| 339 | 341 |
| 340 // If this RawKeyDown event corresponds to a browser keyboard shortcut and | 342 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
| 341 // it's not processed by webkit, then we need to suppress the upcoming Char | 343 // it's not processed by webkit, then we need to suppress the upcoming Char |
| 342 // events. | 344 // events. |
| 343 bool is_keyboard_shortcut = | 345 bool is_keyboard_shortcut = |
| 344 input_event.type == WebInputEvent::RawKeyDown && | 346 input_event.type() == WebInputEvent::RawKeyDown && |
| 345 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut; | 347 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut; |
| 346 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut) | 348 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut) |
| 347 suppress_next_char_events_ = true; | 349 suppress_next_char_events_ = true; |
| 348 | 350 |
| 349 InputEventAckState ack_result = processed == WebInputEventResult::NotHandled | 351 InputEventAckState ack_result = processed == WebInputEventResult::NotHandled |
| 350 ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED | 352 ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED |
| 351 : INPUT_EVENT_ACK_STATE_CONSUMED; | 353 : INPUT_EVENT_ACK_STATE_CONSUMED; |
| 352 if (processed == WebInputEventResult::NotHandled && | 354 if (processed == WebInputEventResult::NotHandled && |
| 353 input_event.type == WebInputEvent::TouchStart) { | 355 input_event.type() == WebInputEvent::TouchStart) { |
| 354 const WebTouchEvent& touch_event = | 356 const WebTouchEvent& touch_event = |
| 355 static_cast<const WebTouchEvent&>(input_event); | 357 static_cast<const WebTouchEvent&>(input_event); |
| 356 // Hit-test for all the pressed touch points. If there is a touch-handler | 358 // Hit-test for all the pressed touch points. If there is a touch-handler |
| 357 // for any of the touch points, then the renderer should continue to receive | 359 // for any of the touch points, then the renderer should continue to receive |
| 358 // touch events. | 360 // touch events. |
| 359 ack_result = INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 361 ack_result = INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 360 for (size_t i = 0; i < touch_event.touchesLength; ++i) { | 362 for (size_t i = 0; i < touch_event.touchesLength; ++i) { |
| 361 if (touch_event.touches[i].state == WebTouchPoint::StatePressed && | 363 if (touch_event.touches[i].state == WebTouchPoint::StatePressed && |
| 362 delegate_->HasTouchEventHandlersAt( | 364 delegate_->HasTouchEventHandlersAt( |
| 363 gfx::ToFlooredPoint(touch_event.touches[i].position))) { | 365 gfx::ToFlooredPoint(touch_event.touches[i].position))) { |
| 364 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 366 ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 365 break; | 367 break; |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 | 371 |
| 370 // Send gesture scroll events and their dispositions to the compositor thread, | 372 // Send gesture scroll events and their dispositions to the compositor thread, |
| 371 // so that they can be used to produce the elastic overscroll effect on Mac. | 373 // so that they can be used to produce the elastic overscroll effect on Mac. |
| 372 if (input_event.type == WebInputEvent::GestureScrollBegin || | 374 if (input_event.type() == WebInputEvent::GestureScrollBegin || |
| 373 input_event.type == WebInputEvent::GestureScrollEnd || | 375 input_event.type() == WebInputEvent::GestureScrollEnd || |
| 374 input_event.type == WebInputEvent::GestureScrollUpdate) { | 376 input_event.type() == WebInputEvent::GestureScrollUpdate) { |
| 375 const WebGestureEvent& gesture_event = | 377 const WebGestureEvent& gesture_event = |
| 376 static_cast<const WebGestureEvent&>(input_event); | 378 static_cast<const WebGestureEvent&>(input_event); |
| 377 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { | 379 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { |
| 378 delegate_->ObserveGestureEventAndResult( | 380 delegate_->ObserveGestureEventAndResult( |
| 379 gesture_event, | 381 gesture_event, |
| 380 event_overscroll ? event_overscroll->latest_overscroll_delta | 382 event_overscroll ? event_overscroll->latest_overscroll_delta |
| 381 : gfx::Vector2dF(), | 383 : gfx::Vector2dF(), |
| 382 processed != WebInputEventResult::NotHandled); | 384 processed != WebInputEventResult::NotHandled); |
| 383 } | 385 } |
| 384 } | 386 } |
| 385 | 387 |
| 386 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); | 388 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); |
| 387 | 389 |
| 388 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN || | 390 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN || |
| 389 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) { | 391 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) { |
| 390 // |non_blocking| means it was ack'd already by the InputHandlerProxy | 392 // |non_blocking| means it was ack'd already by the InputHandlerProxy |
| 391 // so let the delegate know the event has been handled. | 393 // so let the delegate know the event has been handled. |
| 392 delegate_->NotifyInputEventHandled(input_event.type, ack_result); | 394 delegate_->NotifyInputEventHandled(input_event.type(), ack_result); |
| 393 } | 395 } |
| 394 | 396 |
| 395 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || | 397 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 396 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN)) { | 398 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN)) { |
| 397 std::unique_ptr<InputEventAck> response(new InputEventAck( | 399 std::unique_ptr<InputEventAck> response(new InputEventAck( |
| 398 InputEventAckSource::MAIN_THREAD, input_event.type, ack_result, | 400 InputEventAckSource::MAIN_THREAD, input_event.type(), ack_result, |
| 399 swap_latency_info, std::move(event_overscroll), | 401 swap_latency_info, std::move(event_overscroll), |
| 400 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event))); | 402 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event))); |
| 401 delegate_->OnInputEventAck(std::move(response)); | 403 delegate_->OnInputEventAck(std::move(response)); |
| 402 } else { | 404 } else { |
| 403 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; | 405 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; |
| 404 } | 406 } |
| 405 if (RenderThreadImpl::current()) { | 407 if (RenderThreadImpl::current()) { |
| 406 RenderThreadImpl::current() | 408 RenderThreadImpl::current() |
| 407 ->GetRendererScheduler() | 409 ->GetRendererScheduler() |
| 408 ->DidHandleInputEventOnMainThread(input_event); | 410 ->DidHandleInputEventOnMainThread(input_event); |
| 409 } | 411 } |
| 410 | 412 |
| 411 #if defined(OS_ANDROID) | 413 #if defined(OS_ANDROID) |
| 412 // Allow the IME to be shown when the focus changes as a consequence | 414 // Allow the IME to be shown when the focus changes as a consequence |
| 413 // of a processed touch end event. | 415 // of a processed touch end event. |
| 414 if (input_event.type == WebInputEvent::TouchEnd && | 416 if (input_event.type() == WebInputEvent::TouchEnd && |
| 415 processed != WebInputEventResult::NotHandled) { | 417 processed != WebInputEventResult::NotHandled) { |
| 416 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, | 418 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, |
| 417 ChangeSource::FROM_NON_IME); | 419 ChangeSource::FROM_NON_IME); |
| 418 } | 420 } |
| 419 #elif defined(USE_AURA) | 421 #elif defined(USE_AURA) |
| 420 // Show the virtual keyboard if enabled and a user gesture triggers a focus | 422 // Show the virtual keyboard if enabled and a user gesture triggers a focus |
| 421 // change. | 423 // change. |
| 422 if (processed != WebInputEventResult::NotHandled && | 424 if (processed != WebInputEventResult::NotHandled && |
| 423 (input_event.type == WebInputEvent::TouchEnd || | 425 (input_event.type() == WebInputEvent::TouchEnd || |
| 424 input_event.type == WebInputEvent::MouseUp)) { | 426 input_event.type() == WebInputEvent::MouseUp)) { |
| 425 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_IME); | 427 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_IME); |
| 426 } | 428 } |
| 427 #endif | 429 #endif |
| 428 | 430 |
| 429 if (!prevent_default && WebInputEvent::isKeyboardEventType(input_event.type)) | 431 if (!prevent_default && |
| 432 WebInputEvent::isKeyboardEventType(input_event.type())) |
| 430 delegate_->OnDidHandleKeyEvent(); | 433 delegate_->OnDidHandleKeyEvent(); |
| 431 | 434 |
| 432 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with | 435 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with |
| 433 // virtual keyboard. | 436 // virtual keyboard. |
| 434 #if !defined(OS_ANDROID) | 437 #if !defined(OS_ANDROID) |
| 435 // Virtual keyboard is not supported, so react to focus change immediately. | 438 // Virtual keyboard is not supported, so react to focus change immediately. |
| 436 if (processed != WebInputEventResult::NotHandled && | 439 if (processed != WebInputEventResult::NotHandled && |
| 437 (input_event.type == WebInputEvent::TouchEnd || | 440 (input_event.type() == WebInputEvent::TouchEnd || |
| 438 input_event.type == WebInputEvent::MouseUp)) { | 441 input_event.type() == WebInputEvent::MouseUp)) { |
| 439 delegate_->FocusChangeComplete(); | 442 delegate_->FocusChangeComplete(); |
| 440 } | 443 } |
| 441 #endif | 444 #endif |
| 442 } | 445 } |
| 443 | 446 |
| 444 void RenderWidgetInputHandler::DidOverscrollFromBlink( | 447 void RenderWidgetInputHandler::DidOverscrollFromBlink( |
| 445 const WebFloatSize& overscrollDelta, | 448 const WebFloatSize& overscrollDelta, |
| 446 const WebFloatSize& accumulatedOverscroll, | 449 const WebFloatSize& accumulatedOverscroll, |
| 447 const WebFloatPoint& position, | 450 const WebFloatPoint& position, |
| 448 const WebFloatSize& velocity) { | 451 const WebFloatSize& velocity) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 459 // it can be bundled in the event ack. | 462 // it can be bundled in the event ack. |
| 460 if (handling_event_overscroll_) { | 463 if (handling_event_overscroll_) { |
| 461 *handling_event_overscroll_ = std::move(params); | 464 *handling_event_overscroll_ = std::move(params); |
| 462 return; | 465 return; |
| 463 } | 466 } |
| 464 | 467 |
| 465 delegate_->OnDidOverscroll(*params); | 468 delegate_->OnDidOverscroll(*params); |
| 466 } | 469 } |
| 467 | 470 |
| 468 } // namespace content | 471 } // namespace content |
| OLD | NEW |