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

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

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

Powered by Google App Engine
This is Rietveld 408576698