Commit c27dd4f7 authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Send ack early when paused in mouse move to keep events coming.

When paused in debugger on mouse move, we can send ack as it has
no side effects apart from new mouse moves being sent to renderer.

Debugger already causes nested input events handling (because of
different event types don't wait for each other's ack). This, and mouse
move being the event without side effects, means there should be
no harm in allowing nested mouse moves.

BUG=374183

Review URL: https://codereview.chromium.org/288393004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272230 0039d316-1c4b-4281-b951-d872f2087c98
parent bb7f2f2a
...@@ -625,6 +625,7 @@ void InputRouterImpl::ProcessMouseAck(blink::WebInputEvent::Type type, ...@@ -625,6 +625,7 @@ void InputRouterImpl::ProcessMouseAck(blink::WebInputEvent::Type type,
if (type != WebInputEvent::MouseMove) if (type != WebInputEvent::MouseMove)
return; return;
DCHECK(mouse_move_pending_);
mouse_move_pending_ = false; mouse_move_pending_ = false;
if (next_mouse_move_) { if (next_mouse_move_) {
......
...@@ -77,7 +77,8 @@ DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view) ...@@ -77,7 +77,8 @@ DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view)
: RenderViewObserver(render_view), : RenderViewObserver(render_view),
is_attached_(false), is_attached_(false),
is_devtools_client_(false), is_devtools_client_(false),
gpu_route_id_(MSG_ROUTING_NONE) { gpu_route_id_(MSG_ROUTING_NONE),
paused_in_mouse_move_(false) {
g_agent_for_routing_id.Get()[routing_id()] = this; g_agent_for_routing_id.Get()[routing_id()] = this;
render_view->webview()->setDevToolsAgentClient(this); render_view->webview()->setDevToolsAgentClient(this);
...@@ -134,6 +135,19 @@ blink::WebDevToolsAgentClient::WebKitClientMessageLoop* ...@@ -134,6 +135,19 @@ blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
return new WebKitClientMessageLoopImpl(); return new WebKitClientMessageLoopImpl();
} }
void DevToolsAgent::willEnterDebugLoop() {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
paused_in_mouse_move_ = impl->SendAckForMouseMoveFromDebugger();
}
void DevToolsAgent::didExitDebugLoop() {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
if (paused_in_mouse_move_) {
impl->IgnoreAckForMouseMoveFromDebugger();
paused_in_mouse_move_ = false;
}
}
void DevToolsAgent::resetTraceEventCallback() void DevToolsAgent::resetTraceEventCallback()
{ {
TraceLog::GetInstance()->SetEventCallbackDisabled(); TraceLog::GetInstance()->SetEventCallbackDisabled();
......
...@@ -54,6 +54,8 @@ class DevToolsAgent : public RenderViewObserver, ...@@ -54,6 +54,8 @@ class DevToolsAgent : public RenderViewObserver,
virtual void saveAgentRuntimeState(const blink::WebString& state) OVERRIDE; virtual void saveAgentRuntimeState(const blink::WebString& state) OVERRIDE;
virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop* virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
createClientMessageLoop() OVERRIDE; createClientMessageLoop() OVERRIDE;
virtual void willEnterDebugLoop() OVERRIDE;
virtual void didExitDebugLoop() OVERRIDE;
virtual void visitAllocatedObjects(AllocatedObjectVisitor* visitor) OVERRIDE; virtual void visitAllocatedObjects(AllocatedObjectVisitor* visitor) OVERRIDE;
typedef void (*TraceEventCallback)( typedef void (*TraceEventCallback)(
...@@ -101,6 +103,7 @@ class DevToolsAgent : public RenderViewObserver, ...@@ -101,6 +103,7 @@ class DevToolsAgent : public RenderViewObserver,
bool is_attached_; bool is_attached_;
bool is_devtools_client_; bool is_devtools_client_;
int32 gpu_route_id_; int32 gpu_route_id_;
bool paused_in_mouse_move_;
static base::subtle::AtomicWord /* TraceEventCallback */ event_callback_; static base::subtle::AtomicWord /* TraceEventCallback */ event_callback_;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "content/renderer/render_widget.h" #include "content/renderer/render_widget.h"
#include "base/auto_reset.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
...@@ -373,7 +374,8 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type, ...@@ -373,7 +374,8 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type,
has_focus_(false), has_focus_(false),
handling_input_event_(false), handling_input_event_(false),
handling_ime_event_(false), handling_ime_event_(false),
handling_touchstart_event_(false), handling_event_type_(WebInputEvent::Undefined),
ignore_ack_for_mouse_move_from_debugger_(false),
closing_(false), closing_(false),
is_swapped_out_(swapped_out), is_swapped_out_(swapped_out),
input_method_is_active_(false), input_method_is_active_(false),
...@@ -903,11 +905,12 @@ void RenderWidget::OnSwapBuffersComplete() { ...@@ -903,11 +905,12 @@ void RenderWidget::OnSwapBuffersComplete() {
void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
const ui::LatencyInfo& latency_info, const ui::LatencyInfo& latency_info,
bool is_keyboard_shortcut) { bool is_keyboard_shortcut) {
handling_input_event_ = true; base::AutoReset<bool> handling_input_event_resetter(
if (!input_event) { &handling_input_event_, true);
handling_input_event_ = false; if (!input_event)
return; return;
} base::AutoReset<WebInputEvent::Type> handling_event_type_resetter(
&handling_event_type_, input_event->type);
base::TimeTicks start_time; base::TimeTicks start_time;
if (base::TimeTicks::IsHighResNowFastAndReliable()) if (base::TimeTicks::IsHighResNowFastAndReliable())
...@@ -993,9 +996,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, ...@@ -993,9 +996,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
} }
if (input_event->type == WebInputEvent::TouchStart)
handling_touchstart_event_ = true;
bool processed = prevent_default; bool processed = prevent_default;
if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
suppress_next_char_events_ = false; suppress_next_char_events_ = false;
...@@ -1003,8 +1003,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, ...@@ -1003,8 +1003,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
processed = webwidget_->handleInputEvent(*input_event); processed = webwidget_->handleInputEvent(*input_event);
} }
handling_touchstart_event_ = false;
// If this RawKeyDown event corresponds to a browser keyboard shortcut and // If this RawKeyDown event corresponds to a browser keyboard shortcut and
// it's not processed by webkit, then we need to suppress the upcoming Char // it's not processed by webkit, then we need to suppress the upcoming Char
// events. // events.
...@@ -1053,7 +1051,11 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, ...@@ -1053,7 +1051,11 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent");
if (!WebInputEventTraits::IgnoresAckDisposition(*input_event)) { // Note that we can't use handling_event_type_ here since it will be overriden
// by reentrant calls for events after the paused one.
bool no_ack = ignore_ack_for_mouse_move_from_debugger_ &&
input_event->type == WebInputEvent::MouseMove;
if (!WebInputEventTraits::IgnoresAckDisposition(*input_event) && !no_ack) {
InputHostMsg_HandleInputEvent_ACK_Params ack; InputHostMsg_HandleInputEvent_ACK_Params ack;
ack.type = input_event->type; ack.type = input_event->type;
ack.state = ack_result; ack.state = ack_result;
...@@ -1080,6 +1082,7 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, ...@@ -1080,6 +1082,7 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
Send(response.release()); Send(response.release());
} }
} }
ignore_ack_for_mouse_move_from_debugger_ = false;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Allow the IME to be shown when the focus changes as a consequence // Allow the IME to be shown when the focus changes as a consequence
...@@ -1094,8 +1097,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, ...@@ -1094,8 +1097,6 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_IME); UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_IME);
#endif #endif
handling_input_event_ = false;
if (!prevent_default) { if (!prevent_default) {
if (WebInputEvent::isKeyboardEventType(input_event->type)) if (WebInputEvent::isKeyboardEventType(input_event->type))
DidHandleKeyEvent(); DidHandleKeyEvent();
...@@ -1517,6 +1518,21 @@ bool RenderWidget::ShouldHandleImeEvent() { ...@@ -1517,6 +1518,21 @@ bool RenderWidget::ShouldHandleImeEvent() {
#endif #endif
} }
bool RenderWidget::SendAckForMouseMoveFromDebugger() {
if (handling_event_type_ == WebInputEvent::MouseMove) {
InputHostMsg_HandleInputEvent_ACK_Params ack;
ack.type = handling_event_type_;
ack.state = INPUT_EVENT_ACK_STATE_CONSUMED;
Send(new InputHostMsg_HandleInputEvent_ACK(routing_id_, ack));
return true;
}
return false;
}
void RenderWidget::IgnoreAckForMouseMoveFromDebugger() {
ignore_ack_for_mouse_move_from_debugger_ = true;
}
void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
if (device_scale_factor_ == device_scale_factor) if (device_scale_factor_ == device_scale_factor)
return; return;
...@@ -1963,7 +1979,7 @@ void RenderWidget::setTouchAction( ...@@ -1963,7 +1979,7 @@ void RenderWidget::setTouchAction(
// Ignore setTouchAction calls that result from synthetic touch events (eg. // Ignore setTouchAction calls that result from synthetic touch events (eg.
// when blink is emulating touch with mouse). // when blink is emulating touch with mouse).
if (!handling_touchstart_event_) if (handling_event_type_ != WebInputEvent::TouchStart)
return; return;
// Verify the same values are used by the types so we can cast between them. // Verify the same values are used by the types so we can cast between them.
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ipc/ipc_sender.h" #include "ipc/ipc_sender.h"
#include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/WebKit/public/web/WebCompositionUnderline.h" #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebPopupType.h" #include "third_party/WebKit/public/web/WebPopupType.h"
#include "third_party/WebKit/public/web/WebTextDirection.h" #include "third_party/WebKit/public/web/WebTextDirection.h"
#include "third_party/WebKit/public/web/WebTextInputInfo.h" #include "third_party/WebKit/public/web/WebTextInputInfo.h"
...@@ -52,7 +53,6 @@ class SyncMessage; ...@@ -52,7 +53,6 @@ class SyncMessage;
namespace blink { namespace blink {
struct WebDeviceEmulationParams; struct WebDeviceEmulationParams;
class WebGestureEvent; class WebGestureEvent;
class WebInputEvent;
class WebKeyboardEvent; class WebKeyboardEvent;
class WebMouseEvent; class WebMouseEvent;
class WebTouchEvent; class WebTouchEvent;
...@@ -188,6 +188,15 @@ class CONTENT_EXPORT RenderWidget ...@@ -188,6 +188,15 @@ class CONTENT_EXPORT RenderWidget
virtual void InstrumentDidCancelFrame() {} virtual void InstrumentDidCancelFrame() {}
virtual void InstrumentWillComposite() {} virtual void InstrumentWillComposite() {}
// When paused in debugger, we send ack for mouse event early. This ensures
// that we continue receiving mouse moves and pass them to debugger. Returns
// whether we are paused in mouse move event and have sent the ack.
bool SendAckForMouseMoveFromDebugger();
// When resumed from pause in debugger while handling mouse move,
// we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
void IgnoreAckForMouseMoveFromDebugger();
bool UsingSynchronousRendererCompositor() const; bool UsingSynchronousRendererCompositor() const;
// ScreenMetricsEmulator class manages screen emulation inside a render // ScreenMetricsEmulator class manages screen emulation inside a render
...@@ -573,8 +582,11 @@ class CONTENT_EXPORT RenderWidget ...@@ -573,8 +582,11 @@ class CONTENT_EXPORT RenderWidget
// Are we currently handling an ime event? // Are we currently handling an ime event?
bool handling_ime_event_; bool handling_ime_event_;
// Are we currently handling a touchstart event? // Type of the input event we are currently handling.
bool handling_touchstart_event_; blink::WebInputEvent::Type handling_event_type_;
// Whether we should not send ack for the current mouse move.
bool ignore_ack_for_mouse_move_from_debugger_;
// True if we have requested this widget be closed. No more messages will // True if we have requested this widget be closed. No more messages will
// be sent, except for a Close. // be sent, except for a Close.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment