| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "views/controls/native/native_view_host_win.h" | 5 #include "views/controls/native/native_view_host_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "views/controls/native/native_view_host.h" | 9 #include "views/controls/native/native_view_host.h" |
| 10 #include "views/focus/focus_manager.h" | 10 #include "views/focus/focus_manager.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 DCHECK(host_->native_view()) | 30 DCHECK(host_->native_view()) |
| 31 << "Impossible detatched tab case; See crbug.com/6316"; | 31 << "Impossible detatched tab case; See crbug.com/6316"; |
| 32 | 32 |
| 33 // First hide the new window. We don't want anything to draw (like sub-hwnd | 33 // First hide the new window. We don't want anything to draw (like sub-hwnd |
| 34 // borders), when we change the parent below. | 34 // borders), when we change the parent below. |
| 35 ShowWindow(host_->native_view(), SW_HIDE); | 35 ShowWindow(host_->native_view(), SW_HIDE); |
| 36 | 36 |
| 37 // Need to set the HWND's parent before changing its size to avoid flashing. | 37 // Need to set the HWND's parent before changing its size to avoid flashing. |
| 38 SetParent(host_->native_view(), host_->GetWidget()->GetNativeView()); | 38 SetParent(host_->native_view(), host_->GetWidget()->GetNativeView()); |
| 39 host_->Layout(); | 39 host_->Layout(); |
| 40 | |
| 41 // Register with the focus manager so the associated view is focused when the | |
| 42 // native control gets the focus. | |
| 43 View* focus_view = host_->focus_view() ? host_->focus_view() : host_; | |
| 44 FocusManager::InstallFocusSubclass(host_->native_view(), focus_view); | |
| 45 } | 40 } |
| 46 | 41 |
| 47 void NativeViewHostWin::NativeViewDetaching() { | 42 void NativeViewHostWin::NativeViewDetaching() { |
| 48 DCHECK(host_->native_view()); | |
| 49 FocusManager::UninstallFocusSubclass(host_->native_view()); | |
| 50 installed_clip_ = false; | 43 installed_clip_ = false; |
| 51 } | 44 } |
| 52 | 45 |
| 53 void NativeViewHostWin::AddedToWidget() { | 46 void NativeViewHostWin::AddedToWidget() { |
| 54 if (!IsWindow(host_->native_view())) | 47 if (!IsWindow(host_->native_view())) |
| 55 return; | 48 return; |
| 56 HWND parent_hwnd = GetParent(host_->native_view()); | 49 HWND parent_hwnd = GetParent(host_->native_view()); |
| 57 HWND widget_hwnd = host_->GetWidget()->GetNativeView(); | 50 HWND widget_hwnd = host_->GetWidget()->GetNativeView(); |
| 58 if (parent_hwnd != widget_hwnd) | 51 if (parent_hwnd != widget_hwnd) |
| 59 SetParent(host_->native_view(), widget_hwnd); | 52 SetParent(host_->native_view(), widget_hwnd); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 131 // NativeViewHostWrapper, public: | 124 // NativeViewHostWrapper, public: |
| 132 | 125 |
| 133 // static | 126 // static |
| 134 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( | 127 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
| 135 NativeViewHost* host) { | 128 NativeViewHost* host) { |
| 136 return new NativeViewHostWin(host); | 129 return new NativeViewHostWin(host); |
| 137 } | 130 } |
| 138 | 131 |
| 139 } // namespace views | 132 } // namespace views |
| OLD | NEW |