OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "views/controls/native/native_view_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "views/controls/native/native_view_host_views.h" | 9 #include "views/controls/native/native_view_host_views.h" |
10 #include "views/controls/native/native_view_host_wrapper.h" | 10 #include "views/controls/native/native_view_host_wrapper.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 const bool NativeViewHost::kRenderNativeControlFocus = true; | 24 const bool NativeViewHost::kRenderNativeControlFocus = true; |
25 #endif | 25 #endif |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
28 // NativeViewHost, public: | 28 // NativeViewHost, public: |
29 | 29 |
30 NativeViewHost::NativeViewHost() | 30 NativeViewHost::NativeViewHost() |
31 : native_view_(NULL), | 31 : native_view_(NULL), |
32 views_view_(NULL), | 32 views_view_(NULL), |
33 fast_resize_(false), | 33 fast_resize_(false), |
| 34 fast_resize_at_last_layout_(false), |
34 focus_view_(NULL) { | 35 focus_view_(NULL) { |
35 } | 36 } |
36 | 37 |
37 NativeViewHost::~NativeViewHost() { | 38 NativeViewHost::~NativeViewHost() { |
38 } | 39 } |
39 | 40 |
40 void NativeViewHost::Attach(gfx::NativeView native_view) { | 41 void NativeViewHost::Attach(gfx::NativeView native_view) { |
41 DCHECK(native_view); | 42 DCHECK(native_view); |
42 DCHECK(!native_view_); | 43 DCHECK(!native_view_); |
43 DCHECK(!views_view_); | 44 DCHECK(!views_view_); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // positioned in the coordinate system of the Widget, not the current | 114 // positioned in the coordinate system of the Widget, not the current |
114 // view. Also, they should be positioned respecting the border insets | 115 // view. Also, they should be positioned respecting the border insets |
115 // of the native view. | 116 // of the native view. |
116 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds()); | 117 gfx::Rect local_bounds = ConvertRectToWidget(GetContentsBounds()); |
117 native_wrapper_->ShowWidget(local_bounds.x(), local_bounds.y(), | 118 native_wrapper_->ShowWidget(local_bounds.x(), local_bounds.y(), |
118 local_bounds.width(), | 119 local_bounds.width(), |
119 local_bounds.height()); | 120 local_bounds.height()); |
120 } else { | 121 } else { |
121 native_wrapper_->HideWidget(); | 122 native_wrapper_->HideWidget(); |
122 } | 123 } |
| 124 fast_resize_at_last_layout_ = visible && fast_resize_; |
123 } | 125 } |
124 | 126 |
125 void NativeViewHost::OnPaint(gfx::Canvas* canvas) { | 127 void NativeViewHost::OnPaint(gfx::Canvas* canvas) { |
126 // Paint background if there is one. NativeViewHost needs to paint | 128 // Paint background if there is one. NativeViewHost needs to paint |
127 // a background when it is hosted in a TabbedPane. For Gtk implementation, | 129 // a background when it is hosted in a TabbedPane. For Gtk implementation, |
128 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because | 130 // NativeTabbedPaneGtk uses a NativeWidgetGtk as page container and because |
129 // NativeWidgetGtk hook "expose" with its root view's paint, we need to | 131 // NativeWidgetGtk hook "expose" with its root view's paint, we need to |
130 // fill the content. Otherwise, the tab page's background is not properly | 132 // fill the content. Otherwise, the tab page's background is not properly |
131 // cleared. For Windows case, it appears okay to not paint background because | 133 // cleared. For Windows case, it appears okay to not paint background because |
132 // we don't have a container window in-between. However if you want to use | 134 // we don't have a container window in-between. However if you want to use |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 198 |
197 void NativeViewHost::Detach(bool destroyed) { | 199 void NativeViewHost::Detach(bool destroyed) { |
198 if (native_view_ || views_view_) { | 200 if (native_view_ || views_view_) { |
199 native_wrapper_->NativeViewDetaching(destroyed); | 201 native_wrapper_->NativeViewDetaching(destroyed); |
200 native_view_ = NULL; | 202 native_view_ = NULL; |
201 views_view_ = NULL; | 203 views_view_ = NULL; |
202 } | 204 } |
203 } | 205 } |
204 | 206 |
205 } // namespace views | 207 } // namespace views |
OLD | NEW |