diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:50:20 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:50:20 +0000 |
commit | f1aadb738b716d2e32392023b9eb7b75eac59f07 (patch) | |
tree | c6ceb922e8cc99fe4195a2adbd8f938f03c8f72e | |
parent | 0182232cfb9425caab261ddd470e2fe3c6f94193 (diff) | |
download | chromium_src-f1aadb738b716d2e32392023b9eb7b75eac59f07.zip chromium_src-f1aadb738b716d2e32392023b9eb7b75eac59f07.tar.gz chromium_src-f1aadb738b716d2e32392023b9eb7b75eac59f07.tar.bz2 |
Reverting 23645.
Crashing the reliability bot.
Review URL: http://codereview.chromium.org/174029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23674 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/window_impl.cc | 9 | ||||
-rw-r--r-- | base/window_impl.h | 3 | ||||
-rw-r--r-- | views/controls/native_control.cc | 51 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 6 | ||||
-rw-r--r-- | views/widget/widget_win.h | 10 |
5 files changed, 40 insertions, 39 deletions
diff --git a/base/window_impl.cc b/base/window_impl.cc index 7438bd9..c3b3ad4 100644 --- a/base/window_impl.cc +++ b/base/window_impl.cc @@ -155,14 +155,7 @@ LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { // Handle the message if it's in our message map; otherwise, let the system // handle it. if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result)) - result = DefWindowProc(hwnd_, message, w_param, l_param); - - if (message == WM_NCDESTROY) { - // Notify the subclass that this is the last message before the window - // is destroyed. - OnFinalMessage(hwnd_); - hwnd_ = NULL; - } + result = DefWindowProc(hwnd_, message, w_param, l_param); return result; } diff --git a/base/window_impl.h b/base/window_impl.h index ff8dd15..2941c3d9 100644 --- a/base/window_impl.h +++ b/base/window_impl.h @@ -50,9 +50,6 @@ class WindowImpl : public MessageMapInterface { // Retrieves the default window icon to use for windows if none is specified. virtual HICON GetDefaultWindowIcon() const; - // Override this to be notified of the last message. - virtual void OnFinalMessage(HWND window) {} - // Returns the HWND associated with this Window. HWND hwnd() const { return hwnd_; } diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index b506cb8..fd247f9 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -4,12 +4,15 @@ #include "views/controls/native_control.h" -#include <algorithm> +#include <atlbase.h> +#include <atlapp.h> +#include <atlcrack.h> +#include <atlframe.h> +#include <atlmisc.h> #include "app/l10n_util_win.h" #include "base/logging.h" #include "base/win_util.h" -#include "base/window_impl.h" #include "views/background.h" #include "views/border.h" #include "views/controls/native/native_view_host.h" @@ -27,13 +30,16 @@ static const wchar_t* const kHandlerKey = // Maps to the NativeControl. static const wchar_t* const kNativeControlKey = L"__NATIVE_CONTROL__"; -class NativeControlContainer : public base::WindowImpl { +class NativeControlContainer : public CWindowImpl<NativeControlContainer, + CWindow, + CWinTraits<WS_CHILD | WS_CLIPSIBLINGS | + WS_CLIPCHILDREN>> { public: + explicit NativeControlContainer(NativeControl* parent) : parent_(parent), control_(NULL) { - set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - Init(parent->GetWidget()->GetNativeView(), gfx::Rect()); - ShowWindow(hwnd(), SW_SHOW); + Create(parent->GetWidget()->GetNativeView()); + ::ShowWindow(m_hWnd, SW_SHOW); } virtual ~NativeControlContainer() { @@ -41,7 +47,8 @@ class NativeControlContainer : public base::WindowImpl { // NOTE: If you add a new message, be sure and verify parent_ is valid before // calling into parent_. - BEGIN_MSG_MAP_EX(NativeControlContainer); + DECLARE_FRAME_WND_CLASS(L"ChromeViewsNativeControlContainer", NULL); + BEGIN_MSG_MAP(NativeControlContainer); MSG_WM_CREATE(OnCreate); MSG_WM_ERASEBKGND(OnEraseBkgnd); MSG_WM_PAINT(OnPaint); @@ -72,7 +79,7 @@ class NativeControlContainer : public base::WindowImpl { private: LRESULT OnCreate(LPCREATESTRUCT create_struct) { - control_ = parent_->CreateNativeControl(hwnd()); + control_ = parent_->CreateNativeControl(m_hWnd); // We subclass the control hwnd so we get the WM_KEYDOWN messages. WNDPROC original_handler = @@ -81,7 +88,7 @@ class NativeControlContainer : public base::WindowImpl { SetProp(control_, kHandlerKey, original_handler); SetProp(control_, kNativeControlKey , parent_); - ShowWindow(control_, SW_SHOW); + ::ShowWindow(control_, SW_SHOW); return 1; } @@ -91,12 +98,12 @@ class NativeControlContainer : public base::WindowImpl { void OnPaint(HDC ignore) { PAINTSTRUCT ps; - HDC dc = BeginPaint(hwnd(), &ps); - EndPaint(hwnd(), &ps); + HDC dc = ::BeginPaint(*this, &ps); + ::EndPaint(*this, &ps); } void OnSize(int type, const CSize& sz) { - MoveWindow(control_, 0, 0, sz.cx, sz.cy, TRUE); + ::MoveWindow(control_, 0, 0, sz.cx, sz.cy, TRUE); } LRESULT OnCommand(UINT code, int id, HWND source) { @@ -167,7 +174,7 @@ NativeControl::NativeControl() : hwnd_view_(NULL), NativeControl::~NativeControl() { if (container_) { container_->ResetParent(); - DestroyWindow(container_->hwnd()); + ::DestroyWindow(*container_); } } @@ -179,15 +186,15 @@ void NativeControl::ValidateNativeControl() { if (!container_ && IsVisible()) { container_ = new NativeControlContainer(this); - hwnd_view_->Attach(container_->hwnd()); + hwnd_view_->Attach(*container_); if (!enabled_) EnableWindow(GetNativeControlHWND(), enabled_); // This message ensures that the focus border is shown. - SendMessage(container_->GetControl(), - WM_CHANGEUISTATE, - MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), - 0); + ::SendMessage(container_->GetControl(), + WM_CHANGEUISTATE, + MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), + 0); } } @@ -267,7 +274,7 @@ void NativeControl::OnContextMenu(const CPoint& location) { void NativeControl::Focus() { if (container_) { DCHECK(container_->GetControl()); - SetFocus(container_->GetControl()); + ::SetFocus(container_->GetControl()); } } @@ -288,7 +295,7 @@ void NativeControl::SetVisible(bool f) { if (f != IsVisible()) { View::SetVisible(f); if (!f && container_) { - DestroyWindow(container_->hwnd()); + ::DestroyWindow(*container_); } else if (f && !container_) { ValidateNativeControl(); } @@ -312,13 +319,13 @@ void NativeControl::VisibilityChanged(View* starting_from, bool is_visible) { } void NativeControl::SetFixedWidth(int width, Alignment alignment) { - DCHECK_GT(width, 0); + DCHECK(width > 0); fixed_width_ = width; horizontal_alignment_ = alignment; } void NativeControl::SetFixedHeight(int height, Alignment alignment) { - DCHECK_GT(height, 0); + DCHECK(height > 0); fixed_height_ = height; vertical_alignment_ = alignment; } diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 255c63d..f54da9a 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -913,7 +913,11 @@ LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { if (ProcessNativeControlMessage(message, w_param, l_param, &result)) return result; - result = base::WindowImpl::OnWndProc(message, w_param, l_param); + // Otherwise we handle everything else. + if (!ProcessWindowMessage(window, message, w_param, l_param, result)) + result = DefWindowProc(window, message, w_param, l_param); + if (message == WM_NCDESTROY) + OnFinalMessage(window); if (message == WM_ACTIVATE) PostProcessActivateMessage(this, LOWORD(w_param)); return result; diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 072041f..3fbcc93 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -303,7 +303,6 @@ class WidgetWin : public base::WindowImpl, protected: // Overridden from WindowImpl: virtual HICON GetDefaultWindowIcon() const; - virtual void OnFinalMessage(HWND window); virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param); // Message Handlers @@ -375,10 +374,7 @@ class WidgetWin : public base::WindowImpl, virtual void OnMove(const CPoint& point) { SetMsgHandled(FALSE); } virtual void OnMoving(UINT param, const LPRECT new_bounds) { } virtual LRESULT OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param); - virtual LRESULT OnNCActivate(BOOL active) { - SetMsgHandled(FALSE); - return 0; - } + virtual LRESULT OnNCActivate(BOOL active) { SetMsgHandled(FALSE); return 0; } virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param) { SetMsgHandled(FALSE); return 0; @@ -452,6 +448,10 @@ class WidgetWin : public base::WindowImpl, SetMsgHandled(FALSE); } + // deletes this window as it is destroyed, override to provide different + // behavior. + virtual void OnFinalMessage(HWND window); + // Start tracking all mouse events so that this window gets sent mouse leave // messages too. |is_nonclient| is true when we should track WM_NCMOUSELEAVE // messages instead of WM_MOUSELEAVE ones. |