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

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

Issue 2637403012: Suppress ET_MOUSE_MOVE when the mouse hasn't moved on Windows. (Closed)
Patch Set: Move to render_host_widget Created 3 years, 11 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver); 210 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver);
211 }; 211 };
212 #endif // defined(OS_WIN) 212 #endif // defined(OS_WIN)
213 213
214 // Callback from embedding the renderer. 214 // Callback from embedding the renderer.
215 void EmbedCallback(bool result) { 215 void EmbedCallback(bool result) {
216 if (!result) 216 if (!result)
217 DVLOG(1) << "embed failed"; 217 DVLOG(1) << "embed failed";
218 } 218 }
219 219
220 // We need to watch for mouse events outside a Web Popup or its parent
221 // and dismiss the popup for certain events.
222 class EventFilterForMouseMove : public ui::EventHandler {
223 public:
224 EventFilterForMouseMove() {
225 aura::Env::GetInstance()->AddPreTargetHandler(this);
sadrul 2017/01/27 00:22:03 This should install the event-handler on the RWHVA
226 }
227
228 ~EventFilterForMouseMove() override {
229 aura::Env::GetInstance()->RemovePreTargetHandler(this);
230 }
231
232 // Overridden from ui::EventHandler
233 void OnMouseEvent(ui::MouseEvent* event) override {
234 if (event->type() != ui::ET_MOUSE_MOVED)
235 return;
236 if (event->location() == last_location_) {
237 event->SetHandled();
238 return;
239 }
240 last_location_ = event->location();
241 }
242
243 private:
244 gfx::Point last_location_;
245 DISALLOW_COPY_AND_ASSIGN(EventFilterForMouseMove);
246 };
247
220 } // namespace 248 } // namespace
221 249
222 // We need to watch for mouse events outside a Web Popup or its parent 250 // We need to watch for mouse events outside a Web Popup or its parent
223 // and dismiss the popup for certain events. 251 // and dismiss the popup for certain events.
224 class RenderWidgetHostViewAura::EventFilterForPopupExit 252 class RenderWidgetHostViewAura::EventFilterForPopupExit
225 : public ui::EventHandler { 253 : public ui::EventHandler {
226 public: 254 public:
227 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 255 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
228 : rwhva_(rwhva) { 256 : rwhva_(rwhva) {
229 DCHECK(rwhva_); 257 DCHECK(rwhva_);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 selection_controller_client_.reset( 441 selection_controller_client_.reset(
414 new TouchSelectionControllerClientAura(this)); 442 new TouchSelectionControllerClientAura(this));
415 CreateSelectionController(); 443 CreateSelectionController();
416 444
417 RenderViewHost* rvh = RenderViewHost::From(host_); 445 RenderViewHost* rvh = RenderViewHost::From(host_);
418 if (rvh) { 446 if (rvh) {
419 // TODO(mostynb): actually use prefs. Landing this as a separate CL 447 // TODO(mostynb): actually use prefs. Landing this as a separate CL
420 // first to rebaseline some unreliable layout tests. 448 // first to rebaseline some unreliable layout tests.
421 ignore_result(rvh->GetWebkitPreferences()); 449 ignore_result(rvh->GetWebkitPreferences());
422 } 450 }
451
452 #if defined(OS_WIN)
453 // Windows will post a WM_MOUSEMOVE after a click event. Other platforms
454 // do not do this so we filter out mouse moves where the position doesn't
455 // change from the last event.
456 event_filter_for_mouse_move_.reset(new EventFilterForMouseMove());
457 #endif
423 } 458 }
424 459
425 //////////////////////////////////////////////////////////////////////////////// 460 ////////////////////////////////////////////////////////////////////////////////
426 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 461 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
427 462
428 void RenderWidgetHostViewAura::InitAsChild( 463 void RenderWidgetHostViewAura::InitAsChild(
429 gfx::NativeView parent_view) { 464 gfx::NativeView parent_view) {
430 CreateDelegatedFrameHostClient(); 465 CreateDelegatedFrameHostClient();
431 466
432 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL); 467 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL);
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 popup_parent_host_view_->SetPopupChild(nullptr); 1881 popup_parent_host_view_->SetPopupChild(nullptr);
1847 } 1882 }
1848 if (popup_child_host_view_) { 1883 if (popup_child_host_view_) {
1849 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL || 1884 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL ||
1850 popup_child_host_view_->popup_parent_host_view_ == this); 1885 popup_child_host_view_->popup_parent_host_view_ == this);
1851 popup_child_host_view_->popup_parent_host_view_ = NULL; 1886 popup_child_host_view_->popup_parent_host_view_ = NULL;
1852 } 1887 }
1853 event_filter_for_popup_exit_.reset(); 1888 event_filter_for_popup_exit_.reset();
1854 1889
1855 #if defined(OS_WIN) 1890 #if defined(OS_WIN)
1891 event_filter_for_mouse_move_.reset();
1892
1856 // The LegacyRenderWidgetHostHWND window should have been destroyed in 1893 // The LegacyRenderWidgetHostHWND window should have been destroyed in
1857 // RenderWidgetHostViewAura::OnWindowDestroying and the pointer should 1894 // RenderWidgetHostViewAura::OnWindowDestroying and the pointer should
1858 // be set to NULL. 1895 // be set to NULL.
1859 DCHECK(!legacy_render_widget_host_HWND_); 1896 DCHECK(!legacy_render_widget_host_HWND_);
1860 if (virtual_keyboard_requested_) { 1897 if (virtual_keyboard_requested_) {
1861 DCHECK(keyboard_observer_.get()); 1898 DCHECK(keyboard_observer_.get());
1862 ui::OnScreenKeyboardDisplayManager* osk_display_manager = 1899 ui::OnScreenKeyboardDisplayManager* osk_display_manager =
1863 ui::OnScreenKeyboardDisplayManager::GetInstance(); 1900 ui::OnScreenKeyboardDisplayManager::GetInstance();
1864 DCHECK(osk_display_manager); 1901 DCHECK(osk_display_manager);
1865 osk_display_manager->RemoveObserver(keyboard_observer_.get()); 1902 osk_display_manager->RemoveObserver(keyboard_observer_.get());
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 2418
2382 void RenderWidgetHostViewAura::SetPopupChild( 2419 void RenderWidgetHostViewAura::SetPopupChild(
2383 RenderWidgetHostViewAura* popup_child_host_view) { 2420 RenderWidgetHostViewAura* popup_child_host_view) {
2384 popup_child_host_view_ = popup_child_host_view; 2421 popup_child_host_view_ = popup_child_host_view;
2385 event_handler_->SetPopupChild( 2422 event_handler_->SetPopupChild(
2386 popup_child_host_view, 2423 popup_child_host_view,
2387 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2424 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2388 } 2425 }
2389 2426
2390 } // namespace content 2427 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698