Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| index eb6449f0c8996436534491c40ce5542f4c6c6d3e..5b940bfb9ceb5b5485fc6385e917062afb5724ce 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| @@ -217,6 +217,34 @@ void EmbedCallback(bool result) { |
| DVLOG(1) << "embed failed"; |
| } |
| +// We need to watch for mouse events outside a Web Popup or its parent |
| +// and dismiss the popup for certain events. |
| +class EventFilterForMouseMove : public ui::EventHandler { |
| + public: |
| + EventFilterForMouseMove() { |
| + aura::Env::GetInstance()->AddPreTargetHandler(this); |
|
sadrul
2017/01/27 00:22:03
This should install the event-handler on the RWHVA
|
| + } |
| + |
| + ~EventFilterForMouseMove() override { |
| + aura::Env::GetInstance()->RemovePreTargetHandler(this); |
| + } |
| + |
| + // Overridden from ui::EventHandler |
| + void OnMouseEvent(ui::MouseEvent* event) override { |
| + if (event->type() != ui::ET_MOUSE_MOVED) |
| + return; |
| + if (event->location() == last_location_) { |
| + event->SetHandled(); |
| + return; |
| + } |
| + last_location_ = event->location(); |
| + } |
| + |
| + private: |
| + gfx::Point last_location_; |
| + DISALLOW_COPY_AND_ASSIGN(EventFilterForMouseMove); |
| +}; |
| + |
| } // namespace |
| // We need to watch for mouse events outside a Web Popup or its parent |
| @@ -420,6 +448,13 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
| // first to rebaseline some unreliable layout tests. |
| ignore_result(rvh->GetWebkitPreferences()); |
| } |
| + |
| +#if defined(OS_WIN) |
| + // Windows will post a WM_MOUSEMOVE after a click event. Other platforms |
| + // do not do this so we filter out mouse moves where the position doesn't |
| + // change from the last event. |
| + event_filter_for_mouse_move_.reset(new EventFilterForMouseMove()); |
| +#endif |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -1853,6 +1888,8 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
| event_filter_for_popup_exit_.reset(); |
| #if defined(OS_WIN) |
| + event_filter_for_mouse_move_.reset(); |
| + |
| // The LegacyRenderWidgetHostHWND window should have been destroyed in |
| // RenderWidgetHostViewAura::OnWindowDestroying and the pointer should |
| // be set to NULL. |