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

Unified Diff: views/controls/native_control_win.cc

Issue 231022: Reverting 27113. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/native_control_gtk.cc ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/native_control_win.cc
===================================================================
--- views/controls/native_control_win.cc (revision 27114)
+++ views/controls/native_control_win.cc (working copy)
@@ -24,9 +24,10 @@
NativeControlWin::~NativeControlWin() {
HWND hwnd = native_view();
if (hwnd) {
- // Destroy the hwnd if it still exists. Otherwise we won't shut things down
- // correctly, leading to leaking and crashing if another message comes in
- // for the hwnd.
+ // Destroy the hwnd if it still exists. Otherwise we won't have shut things
+ // down correctly, leading to leaking and crashing if another message
+ // comes in for the hwnd.
+ Detach();
DestroyWindow(hwnd);
}
}
@@ -73,7 +74,9 @@
if (!is_visible) {
// We destroy the child control HWND when we become invisible because of the
// performance cost of maintaining many HWNDs.
- DestroyWindow(native_view());
+ HWND hwnd = native_view();
+ Detach();
+ DestroyWindow(hwnd);
} else if (!native_view()) {
if (GetWidget())
CreateNativeControl();
@@ -114,14 +117,14 @@
// Note that we never unset this property. We don't have to.
SetProp(native_control, kNativeControlWinKey, this);
- Attach(native_control);
- // native_view() is now valid.
-
- // Subclass so we get WM_KEYDOWN message.
+ // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages.
original_wndproc_ =
win_util::SetWindowProc(native_control,
&NativeControlWin::NativeControlWndProc);
+ Attach(native_control);
+ // native_view() is now valid.
+
// Update the newly created HWND with any resident enabled state.
EnableWindow(native_view(), IsEnabled());
@@ -183,10 +186,16 @@
if (message == WM_KEYDOWN &&
native_control->OnKeyDown(static_cast<int>(w_param))) {
return 0;
+ } else if (message == WM_SETFOCUS) {
+ // Let the focus manager know that the focus changed.
+ FocusManager* focus_manager = native_control->GetFocusManager();
+ if (focus_manager) {
+ focus_manager->SetFocusedView(native_control->focus_view());
+ } else {
+ NOTREACHED();
+ }
} else if (message == WM_DESTROY) {
- WNDPROC old_wndproc =
- win_util::SetWindowProc(window, native_control->original_wndproc_);
- DCHECK(old_wndproc == &NativeControlWin::NativeControlWndProc);
+ win_util::SetWindowProc(window, native_control->original_wndproc_);
}
return CallWindowProc(native_control->original_wndproc_, window, message,
« no previous file with comments | « views/controls/native_control_gtk.cc ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698