Commit d1bac2b8 authored by skobes@chromium.org's avatar skobes@chromium.org

Make RendererExited reset the InputRouter after destroying the window.

Destroying an Aura window generates a synthetic mouse move event if the mouse
is inside the window.  This causes the InputRouter to get stuck in a state
where it is waiting for the renderer to ack the mouse move.

BUG=395737
R=sky@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285040 0039d316-1c4b-4281-b951-d872f2087c98
parent b2984ae8
......@@ -63,6 +63,8 @@ class InputRouter : public IPC::Listener {
MOBILE_VIEWPORT = 1 << 1
};
virtual void OnViewUpdated(int view_flags) = 0;
virtual bool HasPendingEvents() const = 0;
};
} // namespace content
......
......@@ -74,6 +74,7 @@ class CONTENT_EXPORT InputRouterImpl
virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE;
virtual bool ShouldForwardTouchEvent() const OVERRIDE;
virtual void OnViewUpdated(int view_flags) OVERRIDE;
virtual bool HasPendingEvents() const OVERRIDE;
// IPC::Listener
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
......@@ -205,8 +206,6 @@ private:
// all events have been dispatched (i.e., |HasPendingEvents()| is false).
void SignalFlushedIfNecessary();
bool HasPendingEvents() const;
bool IsInOverscrollGesture() const;
int routing_id() const { return routing_id_; }
......
......@@ -1208,10 +1208,6 @@ void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
waiting_for_screen_rects_ack_ = false;
// Reset to ensure that input routing works with a new renderer.
input_router_.reset(new InputRouterImpl(
process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
// Must reset these to ensure that keyboard events work with a new renderer.
suppress_next_char_events_ = false;
......@@ -1230,6 +1226,13 @@ void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
view_ = NULL; // The View should be deleted by RenderProcessGone.
}
// Reconstruct the input router to ensure that it has fresh state for a new
// renderer. Otherwise it may be stuck waiting for the old renderer to ack an
// event. (In particular, the above call to view_->RenderProcessGone will
// destroy the aura window, which may dispatch a synthetic mouse move.)
input_router_.reset(new InputRouterImpl(
process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
synthetic_gesture_controller_.reset();
}
......
......@@ -107,6 +107,7 @@ class MockInputRouter : public InputRouter {
}
virtual bool ShouldForwardTouchEvent() const OVERRIDE { return true; }
virtual void OnViewUpdated(int view_flags) OVERRIDE {}
virtual bool HasPendingEvents() const OVERRIDE { return false; }
// IPC::Listener
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
......@@ -302,6 +303,17 @@ class TestView : public TestRenderWidgetHostView {
return mock_physical_backing_size_;
return TestRenderWidgetHostView::GetPhysicalBackingSize();
}
#if defined(USE_AURA)
virtual ~TestView() {
// Simulate the mouse exit event dispatched when an aura window is
// destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED
// into WebInputEvent::MouseMove.)
rwh_->input_router()->SendMouseEvent(
MouseEventWithLatencyInfo(
SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove),
ui::LatencyInfo()));
}
#endif
protected:
WebMouseWheelEvent unhandled_wheel_event_;
......@@ -1399,4 +1411,13 @@ TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) {
SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
}
TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) {
// RendererExited will delete the view.
host_->SetView(new TestView(host_.get()));
host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
// Make sure the input router is in a fresh state.
ASSERT_FALSE(host_->input_router()->HasPendingEvents());
}
} // namespace content
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