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

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: undo weakptr change, rebase to pull in dgozman's fix (crrev.com/437658) 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 (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 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 ui::LatencyInfo* latency) { 2146 ui::LatencyInfo* latency) {
2147 latency_tracker_.OnInputEvent(event, latency); 2147 latency_tracker_.OnInputEvent(event, latency);
2148 for (auto& observer : input_event_observers_) 2148 for (auto& observer : input_event_observers_)
2149 observer.OnInputEvent(event); 2149 observer.OnInputEvent(event);
2150 } 2150 }
2151 2151
2152 void RenderWidgetHostImpl::OnKeyboardEventAck( 2152 void RenderWidgetHostImpl::OnKeyboardEventAck(
2153 const NativeWebKeyboardEventWithLatencyInfo& event, 2153 const NativeWebKeyboardEventWithLatencyInfo& event,
2154 InputEventAckState ack_result) { 2154 InputEventAckState ack_result) {
2155 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 2155 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
2156 for (auto& input_event_observer : input_event_observers_)
2157 input_event_observer.OnInputEventAck(event.event);
2156 2158
2157 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 2159 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
2158 2160
2159 // We only send unprocessed key event upwards if we are not hidden, 2161 // We only send unprocessed key event upwards if we are not hidden,
2160 // because the user has moved away from us and no longer expect any effect 2162 // because the user has moved away from us and no longer expect any effect
2161 // of this key event. 2163 // of this key event.
2162 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) { 2164 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) {
2163 delegate_->HandleKeyboardEvent(event.event); 2165 delegate_->HandleKeyboardEvent(event.event);
2164 2166
2165 // WARNING: This RenderWidgetHostImpl can be deallocated at this point 2167 // WARNING: This RenderWidgetHostImpl can be deallocated at this point
2166 // (i.e. in the case of Ctrl+W, where the call to 2168 // (i.e. in the case of Ctrl+W, where the call to
2167 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). 2169 // HandleKeyboardEvent destroys this RenderWidgetHostImpl).
2168 } 2170 }
2169 } 2171 }
2170 2172
2171 void RenderWidgetHostImpl::OnMouseEventAck( 2173 void RenderWidgetHostImpl::OnMouseEventAck(
2172 const MouseEventWithLatencyInfo& mouse_event, 2174 const MouseEventWithLatencyInfo& mouse_event,
2173 InputEventAckState ack_result) { 2175 InputEventAckState ack_result) {
2174 latency_tracker_.OnInputEventAck(mouse_event.event, &mouse_event.latency, 2176 latency_tracker_.OnInputEventAck(mouse_event.event, &mouse_event.latency,
2175 ack_result); 2177 ack_result);
2178 for (auto& input_event_observer : input_event_observers_)
2179 input_event_observer.OnInputEventAck(mouse_event.event);
2176 } 2180 }
2177 2181
2178 void RenderWidgetHostImpl::OnWheelEventAck( 2182 void RenderWidgetHostImpl::OnWheelEventAck(
2179 const MouseWheelEventWithLatencyInfo& wheel_event, 2183 const MouseWheelEventWithLatencyInfo& wheel_event,
2180 InputEventAckState ack_result) { 2184 InputEventAckState ack_result) {
2181 latency_tracker_.OnInputEventAck(wheel_event.event, &wheel_event.latency, 2185 latency_tracker_.OnInputEventAck(wheel_event.event, &wheel_event.latency,
2182 ack_result); 2186 ack_result);
2187 for (auto& input_event_observer : input_event_observers_)
2188 input_event_observer.OnInputEventAck(wheel_event.event);
2183 2189
2184 if (!is_hidden() && view_) { 2190 if (!is_hidden() && view_) {
2185 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED && 2191 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED &&
2186 delegate_ && delegate_->HandleWheelEvent(wheel_event.event)) { 2192 delegate_ && delegate_->HandleWheelEvent(wheel_event.event)) {
2187 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED; 2193 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED;
2188 } 2194 }
2189 view_->WheelEventAck(wheel_event.event, ack_result); 2195 view_->WheelEventAck(wheel_event.event, ack_result);
2190 } 2196 }
2191 } 2197 }
2192 2198
2193 void RenderWidgetHostImpl::OnGestureEventAck( 2199 void RenderWidgetHostImpl::OnGestureEventAck(
2194 const GestureEventWithLatencyInfo& event, 2200 const GestureEventWithLatencyInfo& event,
2195 InputEventAckState ack_result) { 2201 InputEventAckState ack_result) {
2196 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 2202 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
2203 for (auto& input_event_observer : input_event_observers_)
2204 input_event_observer.OnInputEventAck(event.event);
2197 2205
2198 if (view_) 2206 if (view_)
2199 view_->GestureEventAck(event.event, ack_result); 2207 view_->GestureEventAck(event.event, ack_result);
2200 } 2208 }
2201 2209
2202 void RenderWidgetHostImpl::OnTouchEventAck( 2210 void RenderWidgetHostImpl::OnTouchEventAck(
2203 const TouchEventWithLatencyInfo& event, 2211 const TouchEventWithLatencyInfo& event,
2204 InputEventAckState ack_result) { 2212 InputEventAckState ack_result) {
2205 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); 2213 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result);
2214 for (auto& input_event_observer : input_event_observers_)
2215 input_event_observer.OnInputEventAck(event.event);
2206 2216
2207 if (touch_emulator_ && 2217 if (touch_emulator_ &&
2208 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { 2218 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) {
2209 return; 2219 return;
2210 } 2220 }
2211 2221
2212 if (view_) 2222 if (view_)
2213 view_->ProcessAckedTouchEvent(event, ack_result); 2223 view_->ProcessAckedTouchEvent(event, ack_result);
2214 } 2224 }
2215 2225
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 // Note: We are using the origin URL provided by the sender here. It may be 2513 // Note: We are using the origin URL provided by the sender here. It may be
2504 // different from the receiver's. 2514 // different from the receiver's.
2505 file_system_file.url = 2515 file_system_file.url =
2506 GURL(storage::GetIsolatedFileSystemRootURIString( 2516 GURL(storage::GetIsolatedFileSystemRootURIString(
2507 file_system_url.origin(), filesystem_id, std::string()) 2517 file_system_url.origin(), filesystem_id, std::string())
2508 .append(register_name)); 2518 .append(register_name));
2509 } 2519 }
2510 } 2520 }
2511 2521
2512 } // namespace content 2522 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | content/public/browser/render_widget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698