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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2387353004: Delay Input.dispatchKeyEvent response until after key event ack. (Closed)
Patch Set: add test, address review comments about docs Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 ui::LatencyInfo* latency) { 1947 ui::LatencyInfo* latency) {
1948 latency_tracker_.OnInputEvent(event, latency); 1948 latency_tracker_.OnInputEvent(event, latency);
1949 for (auto& observer : input_event_observers_) 1949 for (auto& observer : input_event_observers_)
1950 observer.OnInputEvent(event); 1950 observer.OnInputEvent(event);
1951 } 1951 }
1952 1952
1953 void RenderWidgetHostImpl::OnKeyboardEventAck( 1953 void RenderWidgetHostImpl::OnKeyboardEventAck(
1954 const NativeWebKeyboardEventWithLatencyInfo& event, 1954 const NativeWebKeyboardEventWithLatencyInfo& event,
1955 InputEventAckState ack_result) { 1955 InputEventAckState ack_result) {
1956 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 1956 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
1957 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1958 OnInputEventAck(event.event, event.event.is_synthetic));
1957 1959
1958 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 1960 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
1959 1961
1960 // We only send unprocessed key event upwards if we are not hidden, 1962 // We only send unprocessed key event upwards if we are not hidden,
1961 // because the user has moved away from us and no longer expect any effect 1963 // because the user has moved away from us and no longer expect any effect
1962 // of this key event. 1964 // of this key event.
1963 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) { 1965 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) {
1964 delegate_->HandleKeyboardEvent(event.event); 1966 delegate_->HandleKeyboardEvent(event.event);
1965 1967
1966 // WARNING: This RenderWidgetHostImpl can be deallocated at this point 1968 // WARNING: This RenderWidgetHostImpl can be deallocated at this point
1967 // (i.e. in the case of Ctrl+W, where the call to 1969 // (i.e. in the case of Ctrl+W, where the call to
1968 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). 1970 // HandleKeyboardEvent destroys this RenderWidgetHostImpl).
1969 } 1971 }
1970 } 1972 }
1971 1973
1972 void RenderWidgetHostImpl::OnMouseEventAck( 1974 void RenderWidgetHostImpl::OnMouseEventAck(
1973 const MouseEventWithLatencyInfo& mouse_event, 1975 const MouseEventWithLatencyInfo& mouse_event,
1974 InputEventAckState ack_result) { 1976 InputEventAckState ack_result) {
1975 latency_tracker_.OnInputEventAck(mouse_event.event, &mouse_event.latency, 1977 latency_tracker_.OnInputEventAck(mouse_event.event, &mouse_event.latency,
1976 ack_result); 1978 ack_result);
1979 // TOOD(samuong): keep track of synthetic mouse events
1980 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1981 OnInputEventAck(mouse_event.event, true));
samuong 2016/10/20 23:36:18 Right now I'm setting is_synthetic to true for *al
1977 } 1982 }
1978 1983
1979 void RenderWidgetHostImpl::OnWheelEventAck( 1984 void RenderWidgetHostImpl::OnWheelEventAck(
1980 const MouseWheelEventWithLatencyInfo& wheel_event, 1985 const MouseWheelEventWithLatencyInfo& wheel_event,
1981 InputEventAckState ack_result) { 1986 InputEventAckState ack_result) {
1982 latency_tracker_.OnInputEventAck(wheel_event.event, &wheel_event.latency, 1987 latency_tracker_.OnInputEventAck(wheel_event.event, &wheel_event.latency,
1983 ack_result); 1988 ack_result);
1989 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1990 OnInputEventAck(wheel_event.event, false));
1984 1991
1985 if (!is_hidden() && view_) { 1992 if (!is_hidden() && view_) {
1986 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED && 1993 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED &&
1987 delegate_ && delegate_->HandleWheelEvent(wheel_event.event)) { 1994 delegate_ && delegate_->HandleWheelEvent(wheel_event.event)) {
1988 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED; 1995 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED;
1989 } 1996 }
1990 view_->WheelEventAck(wheel_event.event, ack_result); 1997 view_->WheelEventAck(wheel_event.event, ack_result);
1991 } 1998 }
1992 } 1999 }
1993 2000
1994 void RenderWidgetHostImpl::OnGestureEventAck( 2001 void RenderWidgetHostImpl::OnGestureEventAck(
1995 const GestureEventWithLatencyInfo& event, 2002 const GestureEventWithLatencyInfo& event,
1996 InputEventAckState ack_result) { 2003 InputEventAckState ack_result) {
1997 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 2004 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
2005 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
2006 OnInputEventAck(event.event, false));
1998 2007
1999 if (view_) 2008 if (view_)
2000 view_->GestureEventAck(event.event, ack_result); 2009 view_->GestureEventAck(event.event, ack_result);
2001 } 2010 }
2002 2011
2003 void RenderWidgetHostImpl::OnTouchEventAck( 2012 void RenderWidgetHostImpl::OnTouchEventAck(
2004 const TouchEventWithLatencyInfo& event, 2013 const TouchEventWithLatencyInfo& event,
2005 InputEventAckState ack_result) { 2014 InputEventAckState ack_result) {
2006 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 2015 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
2016 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
2017 OnInputEventAck(event.event, false));
2007 2018
2008 if (touch_emulator_ && 2019 if (touch_emulator_ &&
2009 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { 2020 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) {
2010 return; 2021 return;
2011 } 2022 }
2012 2023
2013 if (view_) 2024 if (view_)
2014 view_->ProcessAckedTouchEvent(event, ack_result); 2025 view_->ProcessAckedTouchEvent(event, ack_result);
2015 } 2026 }
2016 2027
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2233 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2223 } 2234 }
2224 2235
2225 BrowserAccessibilityManager* 2236 BrowserAccessibilityManager*
2226 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2237 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2227 return delegate_ ? 2238 return delegate_ ?
2228 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2239 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2229 } 2240 }
2230 2241
2231 } // namespace content 2242 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/native_web_keyboard_event_mac.mm ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698