| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 FocusManager::InstallFocusSubclass(host_->native_view(), focus_view); | 44 FocusManager::InstallFocusSubclass(host_->native_view(), focus_view); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void NativeViewHostWin::NativeViewDetaching() { | 47 void NativeViewHostWin::NativeViewDetaching() { |
| 48 DCHECK(host_->native_view()); | 48 DCHECK(host_->native_view()); |
| 49 FocusManager::UninstallFocusSubclass(host_->native_view()); | 49 FocusManager::UninstallFocusSubclass(host_->native_view()); |
| 50 installed_clip_ = false; | 50 installed_clip_ = false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void NativeViewHostWin::AddedToWidget() { | 53 void NativeViewHostWin::AddedToWidget() { |
| 54 if (!IsWindow(host_->native_view())) |
| 55 return; |
| 54 HWND parent_hwnd = GetParent(host_->native_view()); | 56 HWND parent_hwnd = GetParent(host_->native_view()); |
| 55 HWND widget_hwnd = host_->GetWidget()->GetNativeView(); | 57 HWND widget_hwnd = host_->GetWidget()->GetNativeView(); |
| 56 if (parent_hwnd != widget_hwnd) | 58 if (parent_hwnd != widget_hwnd) |
| 57 SetParent(host_->native_view(), widget_hwnd); | 59 SetParent(host_->native_view(), widget_hwnd); |
| 58 if (host_->IsVisibleInRootView()) | 60 if (host_->IsVisibleInRootView()) |
| 59 ShowWindow(host_->native_view(), SW_SHOW); | 61 ShowWindow(host_->native_view(), SW_SHOW); |
| 60 else | 62 else |
| 61 ShowWindow(host_->native_view(), SW_HIDE); | 63 ShowWindow(host_->native_view(), SW_HIDE); |
| 62 host_->Layout(); | 64 host_->Layout(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void NativeViewHostWin::RemovedFromWidget() { | 67 void NativeViewHostWin::RemovedFromWidget() { |
| 68 if (!IsWindow(host_->native_view())) |
| 69 return; |
| 66 ShowWindow(host_->native_view(), SW_HIDE); | 70 ShowWindow(host_->native_view(), SW_HIDE); |
| 67 SetParent(host_->native_view(), NULL); | 71 SetParent(host_->native_view(), NULL); |
| 68 } | 72 } |
| 69 | 73 |
| 70 void NativeViewHostWin::InstallClip(int x, int y, int w, int h) { | 74 void NativeViewHostWin::InstallClip(int x, int y, int w, int h) { |
| 71 HRGN clip_region = CreateRectRgn(x, y, x + w, y + h); | 75 HRGN clip_region = CreateRectRgn(x, y, x + w, y + h); |
| 72 // NOTE: SetWindowRgn owns the region (as well as the deleting the | 76 // NOTE: SetWindowRgn owns the region (as well as the deleting the |
| 73 // current region), as such we don't delete the old region. | 77 // current region), as such we don't delete the old region. |
| 74 SetWindowRgn(host_->native_view(), clip_region, FALSE); | 78 SetWindowRgn(host_->native_view(), clip_region, FALSE); |
| 75 installed_clip_ = true; | 79 installed_clip_ = true; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 //////////////////////////////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// |
| 127 // NativeViewHostWrapper, public: | 131 // NativeViewHostWrapper, public: |
| 128 | 132 |
| 129 // static | 133 // static |
| 130 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( | 134 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
| 131 NativeViewHost* host) { | 135 NativeViewHost* host) { |
| 132 return new NativeViewHostWin(host); | 136 return new NativeViewHostWin(host); |
| 133 } | 137 } |
| 134 | 138 |
| 135 } // namespace views | 139 } // namespace views |
| OLD | NEW |