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

Side by Side Diff: views/controls/native/native_view_host.cc

Issue 8598024: Now that we are doing a hard-cut-over to Aura, remove a bunch of *Views based classes that are ob... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #include "views/controls/native/native_view_host_wrapper.h" 9 #include "views/controls/native/native_view_host_wrapper.h"
11 #include "views/widget/widget.h" 10 #include "views/widget/widget.h"
12 11
13 namespace views { 12 namespace views {
14 13
15 // static 14 // static
16 const char NativeViewHost::kViewClassName[] = "views/NativeViewHost"; 15 const char NativeViewHost::kViewClassName[] = "views/NativeViewHost";
17 16
18 #if defined(OS_LINUX) 17 #if defined(OS_LINUX)
19 // GTK renders the focus. 18 // GTK renders the focus.
20 // static 19 // static
21 const bool NativeViewHost::kRenderNativeControlFocus = false; 20 const bool NativeViewHost::kRenderNativeControlFocus = false;
22 #else 21 #else
23 // static 22 // static
24 const bool NativeViewHost::kRenderNativeControlFocus = true; 23 const bool NativeViewHost::kRenderNativeControlFocus = true;
25 #endif 24 #endif
26 25
27 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
28 // NativeViewHost, public: 27 // NativeViewHost, public:
29 28
30 NativeViewHost::NativeViewHost() 29 NativeViewHost::NativeViewHost()
31 : native_view_(NULL), 30 : native_view_(NULL),
32 views_view_(NULL),
33 fast_resize_(false), 31 fast_resize_(false),
34 fast_resize_at_last_layout_(false), 32 fast_resize_at_last_layout_(false),
35 focus_view_(NULL) { 33 focus_view_(NULL) {
36 } 34 }
37 35
38 NativeViewHost::~NativeViewHost() { 36 NativeViewHost::~NativeViewHost() {
39 } 37 }
40 38
41 void NativeViewHost::Attach(gfx::NativeView native_view) { 39 void NativeViewHost::Attach(gfx::NativeView native_view) {
42 DCHECK(native_view); 40 DCHECK(native_view);
43 DCHECK(!native_view_); 41 DCHECK(!native_view_);
44 DCHECK(!views_view_);
45 native_view_ = native_view; 42 native_view_ = native_view;
46 // If set_focus_view() has not been invoked, this view is the one that should 43 // If set_focus_view() has not been invoked, this view is the one that should
47 // be seen as focused when the native view receives focus. 44 // be seen as focused when the native view receives focus.
48 if (!focus_view_) 45 if (!focus_view_)
49 focus_view_ = this; 46 focus_view_ = this;
50 native_wrapper_->NativeViewAttached(); 47 native_wrapper_->NativeViewAttached();
51 } 48 }
52 49
53 void NativeViewHost::AttachToView(View* view) {
54 if (view == views_view_)
55 return;
56 DCHECK(view);
57 DCHECK(!native_view_);
58 DCHECK(!views_view_);
59 native_wrapper_.reset(new NativeViewHostViews(this));
60 views_view_ = view;
61 // If set_focus_view() has not been invoked, this view is the one that should
62 // be seen as focused when the native view receives focus.
63 if (!focus_view_)
64 focus_view_ = this;
65 native_wrapper_->NativeViewAttached();
66 }
67
68 void NativeViewHost::Detach() { 50 void NativeViewHost::Detach() {
69 Detach(false); 51 Detach(false);
70 } 52 }
71 53
72 void NativeViewHost::SetPreferredSize(const gfx::Size& size) { 54 void NativeViewHost::SetPreferredSize(const gfx::Size& size) {
73 preferred_size_ = size; 55 preferred_size_ = size;
74 PreferredSizeChanged(); 56 PreferredSizeChanged();
75 } 57 }
76 58
77 void NativeViewHost::NativeViewDestroyed() { 59 void NativeViewHost::NativeViewDestroyed() {
78 // Detach so we can clear our state and notify the native_wrapper_ to release 60 // Detach so we can clear our state and notify the native_wrapper_ to release
79 // ref on the native view. 61 // ref on the native view.
80 Detach(true); 62 Detach(true);
81 } 63 }
82 64
83 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
84 // NativeViewHost, View overrides: 66 // NativeViewHost, View overrides:
85 67
86 gfx::Size NativeViewHost::GetPreferredSize() { 68 gfx::Size NativeViewHost::GetPreferredSize() {
87 return preferred_size_; 69 return preferred_size_;
88 } 70 }
89 71
90 void NativeViewHost::Layout() { 72 void NativeViewHost::Layout() {
91 if ((!native_view_ && !views_view_) || !native_wrapper_.get()) 73 if (!native_view_ || !native_wrapper_.get())
92 return; 74 return;
93 75
94 gfx::Rect vis_bounds = GetVisibleBounds(); 76 gfx::Rect vis_bounds = GetVisibleBounds();
95 bool visible = !vis_bounds.IsEmpty(); 77 bool visible = !vis_bounds.IsEmpty();
96 78
97 if (visible && !fast_resize_) { 79 if (visible && !fast_resize_) {
98 if (vis_bounds.size() != size()) { 80 if (vis_bounds.size() != size()) {
99 // Only a portion of the Widget is really visible. 81 // Only a portion of the Widget is really visible.
100 int x = vis_bounds.x(); 82 int x = vis_bounds.x();
101 int y = vis_bounds.y(); 83 int y = vis_bounds.y();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return accessible_view; 172 return accessible_view;
191 } 173 }
192 174
193 return View::GetNativeViewAccessible(); 175 return View::GetNativeViewAccessible();
194 } 176 }
195 177
196 //////////////////////////////////////////////////////////////////////////////// 178 ////////////////////////////////////////////////////////////////////////////////
197 // NativeViewHost, private: 179 // NativeViewHost, private:
198 180
199 void NativeViewHost::Detach(bool destroyed) { 181 void NativeViewHost::Detach(bool destroyed) {
200 if (native_view_ || views_view_) { 182 if (native_view_) {
201 native_wrapper_->NativeViewDetaching(destroyed); 183 native_wrapper_->NativeViewDetaching(destroyed);
202 native_view_ = NULL; 184 native_view_ = NULL;
203 views_view_ = NULL;
204 } 185 }
205 } 186 }
206 187
207 } // namespace views 188 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698