From 76c1a2b3581e9df09e3b524470ca9faf1195796b Mon Sep 17 00:00:00 2001 From: "ananta@chromium.org" Date: Tue, 24 Jun 2014 01:58:19 +0000 Subject: Updated the WindowEventTarget interface in ui\base to return a bool from all its methods which indicates whether the message was handled. This is to ensure that the default handling on the Windows message is performed by the caller (LegacyRenderWidgetHostHWND). Most of the changes in this patch are around passing a bool flag to the methods in the WindowEventTarget interface and passing that information from the LegacyRenderWidgetHostHWND to the message crackers in ATL. The changes apart from those are as below:- 1. Added a handler for WM_SYSCOMMAND in the LegacyRenderWidgetHostHWND class. This forwards the message to the parent. This is needed because there are cases when the LegacyRenderWidgetHostHWND class is of the same size as the parent. For e.g. App windows etc. In these cases the LegacyRenderWidgetHostHWND window receives non client mouse messages which when defproced result in the WM_SYSCOMMAND message coming in. 2. There are cases when the LegacyRenderWidgetHostHWND is created after the parent is made visible and the associated RenderWidget is visible. Added code to make the LegacyRenderWidgetHostHWND hwnd visible. 3. Added a Destroy method to the LegacyRenderWidgetHostHWND class. This method destroys the window. The instance is destroyed in OnFinalMessage. This ensures that we don't have issues with the LegacyRenderWidgetHostHWND instance getting deleted in the context of a message and crashes due to us calling SetMsgHandled which dereferences members in the ATL base class. BUG=381609 R=sky Review URL: https://codereview.chromium.org/349563002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279269 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser_accessibility_manager_win.cc | 2 +- .../browser_accessibility_win_unittest.cc | 48 +++++++++-- .../renderer_host/legacy_render_widget_host_win.cc | 96 +++++++++++++++------- .../renderer_host/legacy_render_widget_host_win.h | 11 ++- .../renderer_host/render_widget_host_view_aura.cc | 42 ++++++++-- .../renderer_host/render_widget_host_view_aura.h | 6 +- ui/base/win/window_event_target.h | 36 ++++++-- ui/views/win/hwnd_message_handler.cc | 45 +++++++--- ui/views/win/hwnd_message_handler.h | 22 +++-- 9 files changed, 234 insertions(+), 74 deletions(-) diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index 4e7153a..62c87e3 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc @@ -21,7 +21,7 @@ BrowserAccessibilityManager* BrowserAccessibilityManager::Create( BrowserAccessibilityDelegate* delegate, BrowserAccessibilityFactory* factory) { return new BrowserAccessibilityManagerWin( - content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow()).get(), + content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow()), NULL, initial_tree, delegate, factory); } diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index eca0d91..ac5b58f 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -79,6 +79,34 @@ BrowserAccessibility* CountedBrowserAccessibilityFactory::Create() { return instance; } +// Provides functionality for creating the accessible hwnd and ensures that +// the hwnd along with the LegacyRenderWidgetHostHWND instance is destroyed +// when this instance is destroyed. +class TestLegacyRenderWidgetHostHWND { + public: + TestLegacyRenderWidgetHostHWND() + : accessible_hwnd_(NULL) {} + + ~TestLegacyRenderWidgetHostHWND() { + if (accessible_hwnd()) + ::DestroyWindow(accessible_hwnd()->hwnd()); + } + + bool Initialize(HWND parent) { + accessible_hwnd_ = LegacyRenderWidgetHostHWND::Create(parent); + EXPECT_NE(accessible_hwnd_, + static_cast(NULL)); + return accessible_hwnd_ != NULL; + } + + LegacyRenderWidgetHostHWND* accessible_hwnd() { + return accessible_hwnd_; + } + + private: + LegacyRenderWidgetHostHWND* accessible_hwnd_; +}; + } // namespace @@ -605,11 +633,12 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { const int32 busy_state = 1 << ui::AX_STATE_BUSY; const int32 readonly_state = 1 << ui::AX_STATE_READ_ONLY; const int32 enabled_state = 1 << ui::AX_STATE_ENABLED; - scoped_ptr accessible_hwnd( - content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow())); + scoped_ptr accessibility_test + (new TestLegacyRenderWidgetHostHWND); + EXPECT_EQ(accessibility_test->Initialize(GetDesktopWindow()), true); scoped_ptr manager( new BrowserAccessibilityManagerWin( - accessible_hwnd.get(), + accessibility_test->accessible_hwnd(), NULL, BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL, @@ -691,12 +720,13 @@ TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { IID_IAccessible, reinterpret_cast(desktop_hwnd_iaccessible.Receive()))); - scoped_ptr accessible_hwnd( - content::LegacyRenderWidgetHostHWND::Create(GetDesktopWindow())); + scoped_ptr accessibility_test + (new TestLegacyRenderWidgetHostHWND); + EXPECT_EQ(accessibility_test->Initialize(GetDesktopWindow()), true); scoped_ptr manager( new BrowserAccessibilityManagerWin( - accessible_hwnd.get(), + accessibility_test->accessible_hwnd(), desktop_hwnd_iaccessible, BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL)); @@ -719,11 +749,11 @@ TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) { ASSERT_EQ(NULL, manager->parent_hwnd()); // Now create it again. - accessible_hwnd = content::LegacyRenderWidgetHostHWND::Create( - GetDesktopWindow()); + accessibility_test.reset(new TestLegacyRenderWidgetHostHWND); + EXPECT_EQ(accessibility_test->Initialize(::GetDesktopWindow()), true); manager.reset( new BrowserAccessibilityManagerWin( - accessible_hwnd.get(), + accessibility_test->accessible_hwnd(), desktop_hwnd_iaccessible, BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL)); diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc index 86799c9..6cdf237 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.cc +++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc @@ -25,12 +25,8 @@ namespace content { // accessibility support. const int kIdScreenReaderHoneyPot = 1; -LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { - ::DestroyWindow(hwnd()); -} - // static -scoped_ptr LegacyRenderWidgetHostHWND::Create( +LegacyRenderWidgetHostHWND* LegacyRenderWidgetHostHWND::Create( HWND parent) { // content_unittests passes in the desktop window as the parent. We allow // the LegacyRenderWidgetHostHWND instance to be created in this case for @@ -38,17 +34,23 @@ scoped_ptr LegacyRenderWidgetHostHWND::Create( if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableLegacyIntermediateWindow) || (!GetWindowEventTarget(parent) && parent != ::GetDesktopWindow())) - return scoped_ptr(); + return NULL; - scoped_ptr legacy_window_instance; - legacy_window_instance.reset(new LegacyRenderWidgetHostHWND(parent)); + LegacyRenderWidgetHostHWND* legacy_window_instance = + new LegacyRenderWidgetHostHWND(parent); // If we failed to create the child, or if the switch to disable the legacy // window is passed in, then return NULL. - if (!::IsWindow(legacy_window_instance->hwnd())) - return scoped_ptr(); - + if (!::IsWindow(legacy_window_instance->hwnd())) { + delete legacy_window_instance; + return NULL; + } legacy_window_instance->Init(); - return legacy_window_instance.Pass(); + return legacy_window_instance; +} + +void LegacyRenderWidgetHostHWND::Destroy() { + if (::IsWindow(hwnd())) + ::DestroyWindow(hwnd()); } void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { @@ -88,6 +90,7 @@ void LegacyRenderWidgetHostHWND::SetBounds(const gfx::Rect& bounds) { void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) { if (manager_) manager_->OnAccessibleHwndDeleted(); + delete this; } LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) @@ -99,6 +102,10 @@ LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent) WS_EX_TRANSPARENT); } +LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { + DCHECK(!::IsWindow(hwnd())); +} + bool LegacyRenderWidgetHostHWND::Init() { if (base::win::GetVersion() >= base::win::VERSION_WIN7 && ui::AreTouchEventsEnabled()) @@ -167,11 +174,14 @@ LRESULT LegacyRenderWidgetHostHWND::OnKeyboardRange(UINT message, WPARAM w_param, LPARAM l_param, BOOL& handled) { + LRESULT ret = 0; if (GetWindowEventTarget(GetParent())) { - return GetWindowEventTarget(GetParent())->HandleKeyboardMessage( - message, w_param, l_param); + bool msg_handled = false; + ret = GetWindowEventTarget(GetParent())->HandleKeyboardMessage( + message, w_param, l_param, &msg_handled); + handled = msg_handled; } - return 0; + return ret; } LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message, @@ -200,28 +210,36 @@ LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message, ::MapWindowPoints(hwnd(), GetParent(), &mouse_coords, 1); l_param = MAKELPARAM(mouse_coords.x, mouse_coords.y); } + + LRESULT ret = 0; + if (GetWindowEventTarget(GetParent())) { - return GetWindowEventTarget(GetParent())->HandleMouseMessage( - message, w_param, l_param); + bool msg_handled = false; + ret = GetWindowEventTarget(GetParent())->HandleMouseMessage( + message, w_param, l_param, &msg_handled); + handled = msg_handled; } - return 0; + return ret; } LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { mouse_tracking_enabled_ = false; + LRESULT ret = 0; if ((::GetCapture() != GetParent()) && GetWindowEventTarget(GetParent())) { // We should send a WM_MOUSELEAVE to the parent window only if the mouse // has moved outside the bounds of the parent. POINT cursor_pos; ::GetCursorPos(&cursor_pos); if (::WindowFromPoint(cursor_pos) != GetParent()) { - return GetWindowEventTarget(GetParent())->HandleMouseMessage( - message, w_param, l_param); + bool msg_handled = false; + ret = GetWindowEventTarget(GetParent())->HandleMouseMessage( + message, w_param, l_param, &msg_handled); + SetMsgHandled(msg_handled); } } - return 0; + return ret; } LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message, @@ -254,29 +272,37 @@ LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message, LRESULT LegacyRenderWidgetHostHWND::OnTouch(UINT message, WPARAM w_param, LPARAM l_param) { + LRESULT ret = 0; if (GetWindowEventTarget(GetParent())) { - return GetWindowEventTarget(GetParent())->HandleTouchMessage( - message, w_param, l_param); + bool msg_handled = false; + ret = GetWindowEventTarget(GetParent())->HandleTouchMessage( + message, w_param, l_param, &msg_handled); + SetMsgHandled(msg_handled); } - return 0; + return ret; } LRESULT LegacyRenderWidgetHostHWND::OnScroll(UINT message, WPARAM w_param, LPARAM l_param) { + LRESULT ret = 0; if (GetWindowEventTarget(GetParent())) { - return GetWindowEventTarget(GetParent())->HandleScrollMessage( - message, w_param, l_param); + bool msg_handled = false; + ret = GetWindowEventTarget(GetParent())->HandleScrollMessage( + message, w_param, l_param, &msg_handled); + SetMsgHandled(msg_handled); } - return 0; + return ret; } LRESULT LegacyRenderWidgetHostHWND::OnNCHitTest(UINT message, WPARAM w_param, LPARAM l_param) { if (GetWindowEventTarget(GetParent())) { + bool msg_handled = false; LRESULT hit_test = GetWindowEventTarget( - GetParent())->HandleNcHitTestMessage(message, w_param, l_param); + GetParent())->HandleNcHitTestMessage(message, w_param, l_param, + &msg_handled); // If the parent returns HTNOWHERE which can happen for popup windows, etc // we return HTCLIENT. if (hit_test == HTNOWHERE) @@ -330,4 +356,18 @@ LRESULT LegacyRenderWidgetHostHWND::OnSize(UINT message, return 0; } +LRESULT LegacyRenderWidgetHostHWND::OnSysCommand(UINT message, + WPARAM w_param, + LPARAM l_param) { + LRESULT ret = 0; + if (GetWindowEventTarget(GetParent())) { + bool msg_handled = false; + ret = GetWindowEventTarget( + GetParent())->HandleSysCommand(message, w_param, l_param, + &msg_handled); + SetMsgHandled(msg_handled); + } + return ret; +} + } // namespace content diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.h b/content/browser/renderer_host/legacy_render_widget_host_win.h index 814c200..6c525df 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.h +++ b/content/browser/renderer_host/legacy_render_widget_host_win.h @@ -11,7 +11,6 @@ #include #include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" #include "base/win/scoped_comptr.h" #include "content/common/content_export.h" #include "ui/gfx/rect.h" @@ -57,12 +56,13 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND NON_EXPORTED_BASE(ATL::CWindow), ATL::CWinTraits > Base; - ~LegacyRenderWidgetHostHWND(); - // Creates and returns an instance of the LegacyRenderWidgetHostHWND class on // successful creation of a child window parented to the parent window passed // in. - static scoped_ptr Create(HWND parent); + static LegacyRenderWidgetHostHWND* Create(HWND parent); + + // Destroys the HWND managed by this class. + void Destroy(); BEGIN_MSG_MAP_EX(LegacyRenderWidgetHostHWND) MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) @@ -82,6 +82,7 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND OnMouseRange) MESSAGE_HANDLER_EX(WM_NCCALCSIZE, OnNCCalcSize) MESSAGE_HANDLER_EX(WM_SIZE, OnSize) + MESSAGE_HANDLER_EX(WM_SYSCOMMAND, OnSysCommand) END_MSG_MAP() HWND hwnd() { return m_hWnd; } @@ -112,6 +113,7 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND private: LegacyRenderWidgetHostHWND(HWND parent); + ~LegacyRenderWidgetHostHWND(); bool Init(); @@ -135,6 +137,7 @@ class CONTENT_EXPORT LegacyRenderWidgetHostHWND LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnNCCalcSize(UINT message, WPARAM w_param, LPARAM l_param); LRESULT OnSize(UINT message, WPARAM w_param, LPARAM l_param); + LRESULT OnSysCommand(UINT message, WPARAM w_param, LPARAM l_param); content::BrowserAccessibilityManagerWin* manager_; base::win::ScopedComPtr window_accessible_; 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 3c10f51..16a4e76 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -453,6 +453,9 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) bool overscroll_enabled = CommandLine::ForCurrentProcess()-> GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; SetOverscrollControllerEnabled(overscroll_enabled); +#if defined(OS_WIN) + legacy_render_widget_host_HWND_ = NULL; +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -1008,15 +1011,22 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { if (!legacy_render_widget_host_HWND_) { legacy_render_widget_host_HWND_ = LegacyRenderWidgetHostHWND::Create( reinterpret_cast(GetNativeViewId())); - BrowserAccessibilityManagerWin* manager = - static_cast( - GetBrowserAccessibilityManager()); - if (manager) - manager->SetAccessibleHWND(legacy_render_widget_host_HWND_.get()); } if (legacy_render_widget_host_HWND_) { legacy_render_widget_host_HWND_->SetBounds( window_->GetBoundsInRootWindow()); + // There are cases where the parent window is created, made visible and + // the associated RenderWidget is also visible before the + // LegacyRenderWidgetHostHWND instace is created. Ensure that it is shown + // here. + if (!host_->is_hidden()) + legacy_render_widget_host_HWND_->Show(); + + BrowserAccessibilityManagerWin* manager = + static_cast( + GetBrowserAccessibilityManager()); + if (manager) + manager->SetAccessibleHWND(legacy_render_widget_host_HWND_); } } @@ -1244,10 +1254,8 @@ void RenderWidgetHostViewAura::CreateBrowserAccessibilityManagerIfNeeded() { if (!GetBrowserAccessibilityManager()) { gfx::NativeViewAccessible accessible_parent = host_->GetParentNativeViewAccessible(); - LegacyRenderWidgetHostHWND* parent_hwnd = - legacy_render_widget_host_HWND_.get(); SetBrowserAccessibilityManager(new BrowserAccessibilityManagerWin( - legacy_render_widget_host_HWND_.get(), accessible_parent, + legacy_render_widget_host_HWND_, accessible_parent, BrowserAccessibilityManagerWin::GetEmptyDocument(), host_)); } #else @@ -1683,6 +1691,19 @@ void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { } LPARAM lparam = reinterpret_cast(this); EnumChildWindows(parent, WindowDestroyingCallback, lparam); + + // The LegacyRenderWidgetHostHWND instance is destroyed when its window is + // destroyed. Normally we control when that happens via the Destroy call + // in the dtor. However there may be cases where the window is destroyed + // by Windows, i.e. the parent window is destroyed before the + // RenderWidgetHostViewAura instance goes away etc. To avoid that we + // destroy the LegacyRenderWidgetHostHWND instance here. + if (legacy_render_widget_host_HWND_) { + legacy_render_widget_host_HWND_->Destroy(); + // The Destroy call above will delete the LegacyRenderWidgetHostHWND + // instance. + legacy_render_widget_host_HWND_ = NULL; + } #endif // Make sure that the input method no longer references to this object before @@ -2172,7 +2193,10 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { DetachFromInputMethod(); #if defined(OS_WIN) - legacy_render_widget_host_HWND_.reset(NULL); + // The LegacyRenderWidgetHostHWND window should have been destroyed in + // RenderWidgetHostViewAura::OnWindowDestroying and the pointer should + // be set to NULL. + DCHECK(!legacy_render_widget_host_HWND_); #endif } diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 8eab68b..6623b60 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -580,8 +580,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura // for accessibility, as the container for windowless plugins like // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, // etc. - scoped_ptr - legacy_render_widget_host_HWND_; + // The LegacyRenderWidgetHostHWND instance is created during the first call + // to RenderWidgetHostViewAura::InternalSetBounds. The instance is destroyed + // when the LegacyRenderWidgetHostHWND hwnd is destroyed. + content::LegacyRenderWidgetHostHWND* legacy_render_widget_host_HWND_; #endif DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); }; diff --git a/ui/base/win/window_event_target.h b/ui/base/win/window_event_target.h index c7bb670..2c74522 100644 --- a/ui/base/win/window_event_target.h +++ b/ui/base/win/window_event_target.h @@ -23,42 +23,68 @@ class UI_BASE_EXPORT WindowEventTarget { // The |message| parameter identifies the message. // The |w_param| and |l_param| values are dependent on the type of the // message. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. // Returns the result of processing the message. virtual LRESULT HandleMouseMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) = 0; + LPARAM l_param, + bool* handled) = 0; // Handles keyboard events like WM_KEYDOWN/WM_KEYUP, etc. // The |message| parameter identifies the message. // The |w_param| and |l_param| values are dependent on the type of the // message. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. // Returns the result of processing the message. virtual LRESULT HandleKeyboardMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) = 0; + LPARAM l_param, + bool* handled) = 0; // Handles WM_TOUCH events. // The |message| parameter identifies the message. // The |w_param| and |l_param| values are as per MSDN docs. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. // Returns the result of processing the message. virtual LRESULT HandleTouchMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) = 0; + LPARAM l_param, + bool* handled) = 0; // Handles scroll messages like WM_VSCROLL and WM_HSCROLL. // The |message| parameter identifies the scroll message. // The |w_param| and |l_param| values are dependent on the type of scroll. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. virtual LRESULT HandleScrollMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) = 0; + LPARAM l_param, + bool* handled) = 0; // Handles the WM_NCHITTEST message // The |message| parameter identifies the message. // The |w_param| and |l_param| values are as per MSDN docs. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. // Returns the result of processing the message. virtual LRESULT HandleNcHitTestMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) = 0; + LPARAM l_param, + bool* handled) = 0; + + // Handles the WM_SYSCOMMAND message + // The |message| parameter identifies the message. + // The |w_param| and |l_param| values are as per MSDN docs. + // The |handled| parameter is an output parameter which when set to false + // indicates that the message should be DefProc'ed. + // Returns the result of processing the message. + virtual LRESULT HandleSysCommand(unsigned int message, + WPARAM w_param, + LPARAM l_param, + bool* handled) = 0; protected: WindowEventTarget(); virtual ~WindowEventTarget(); diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index adbe4fa..cc2ea86 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -935,35 +935,60 @@ LRESULT HWNDMessageHandler::OnWndProc(UINT message, LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) { + LPARAM l_param, + bool* handled) { // Don't track forwarded mouse messages. We expect the caller to track the // mouse. - return HandleMouseEventInternal(message, w_param, l_param, false); + LRESULT ret = HandleMouseEventInternal(message, w_param, l_param, false); + *handled = IsMsgHandled(); + return ret; } LRESULT HWNDMessageHandler::HandleTouchMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) { - return OnTouchEvent(message, w_param, l_param); + LPARAM l_param, + bool* handled) { + LRESULT ret = OnTouchEvent(message, w_param, l_param); + *handled = IsMsgHandled(); + return ret; } LRESULT HWNDMessageHandler::HandleKeyboardMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) { - return OnKeyEvent(message, w_param, l_param); + LPARAM l_param, + bool* handled) { + LRESULT ret = OnKeyEvent(message, w_param, l_param); + *handled = IsMsgHandled(); + return ret; } LRESULT HWNDMessageHandler::HandleScrollMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) { - return OnScrollMessage(message, w_param, l_param); + LPARAM l_param, + bool* handled) { + LRESULT ret = OnScrollMessage(message, w_param, l_param); + *handled = IsMsgHandled(); + return ret; } LRESULT HWNDMessageHandler::HandleNcHitTestMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) { - return OnNCHitTest( + LPARAM l_param, + bool* handled) { + LRESULT ret = OnNCHitTest( gfx::Point(CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param))); + *handled = IsMsgHandled(); + return ret; +} + +LRESULT HWNDMessageHandler::HandleSysCommand(unsigned int message, + WPARAM w_param, + LPARAM l_param, + bool* handled) { + OnSysCommand(static_cast(w_param), + gfx::Point(CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param))); + *handled = IsMsgHandled(); + return 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index fbc0581..9e42ef9 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h @@ -60,7 +60,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; // IsMsgHandled() from a member function to a define that checks if the weak // factory is still valid in addition to the member. Together these allow for // |this| to be deleted during dispatch. -#define IsMsgHandled() !ref.get() || msg_handled_ +#define IsMsgHandled() !weak_factory_.GetWeakPtr().get() || msg_handled_ #define BEGIN_SAFE_MSG_MAP_EX(the_class) \ private: \ @@ -218,21 +218,31 @@ class VIEWS_EXPORT HWNDMessageHandler : // Overridden from WindowEventTarget virtual LRESULT HandleMouseMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) OVERRIDE; + LPARAM l_param, + bool* handled) OVERRIDE; virtual LRESULT HandleKeyboardMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) OVERRIDE; + LPARAM l_param, + bool* handled) OVERRIDE; virtual LRESULT HandleTouchMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) OVERRIDE; + LPARAM l_param, + bool* handled) OVERRIDE; virtual LRESULT HandleScrollMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) OVERRIDE; + LPARAM l_param, + bool* handled) OVERRIDE; virtual LRESULT HandleNcHitTestMessage(unsigned int message, WPARAM w_param, - LPARAM l_param) OVERRIDE; + LPARAM l_param, + bool* handled) OVERRIDE; + + virtual LRESULT HandleSysCommand(unsigned int message, + WPARAM w_param, + LPARAM l_param, + bool* handled); // Returns the auto-hide edges of the appbar. See // ViewsDelegate::GetAppbarAutohideEdges() for details. If the edges change, -- cgit v1.1