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

Unified Diff: views/controls/native/native_view_host.cc

Issue 5785001: A NativeViewHostViews class for embedding views inside NativeHostView instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed up the patchset to not include files that I pulled in by accident in #3 Created 10 years 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/native_view_host.h ('k') | views/controls/native/native_view_host_views.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/native/native_view_host.cc
diff --git a/views/controls/native/native_view_host.cc b/views/controls/native/native_view_host.cc
index 91f34c10564958978a3e68d9fd91cbc065e9ee43..d2edcba141b1ba5f4e7d2904bfa3e6bce049a90b 100644
--- a/views/controls/native/native_view_host.cc
+++ b/views/controls/native/native_view_host.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "gfx/canvas.h"
#include "views/controls/native/native_view_host_wrapper.h"
+#include "views/controls/native/native_view_host_views.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
@@ -29,6 +30,7 @@ const bool NativeViewHost::kRenderNativeControlFocus = true;
NativeViewHost::NativeViewHost()
: native_view_(NULL),
+ views_view_(NULL),
fast_resize_(false),
focus_view_(NULL) {
// The native widget is placed relative to the root. As such, we need to
@@ -43,6 +45,7 @@ NativeViewHost::~NativeViewHost() {
void NativeViewHost::Attach(gfx::NativeView native_view) {
DCHECK(native_view);
DCHECK(!native_view_);
+ DCHECK(!views_view_);
native_view_ = native_view;
// If set_focus_view() has not been invoked, this view is the one that should
// be seen as focused when the native view receives focus.
@@ -51,6 +54,21 @@ void NativeViewHost::Attach(gfx::NativeView native_view) {
native_wrapper_->NativeViewAttached();
}
+void NativeViewHost::AttachToView(View* view) {
+ if (view == views_view_)
+ return;
+ DCHECK(view);
+ DCHECK(!native_view_);
+ DCHECK(!views_view_);
+ native_wrapper_.reset(new NativeViewHostViews(this));
+ views_view_ = view;
+ // If set_focus_view() has not been invoked, this view is the one that should
+ // be seen as focused when the native view receives focus.
+ if (!focus_view_)
+ focus_view_ = this;
+ native_wrapper_->NativeViewAttached();
+}
+
void NativeViewHost::Detach() {
Detach(false);
}
@@ -74,7 +92,7 @@ gfx::Size NativeViewHost::GetPreferredSize() {
}
void NativeViewHost::Layout() {
- if (!native_view_ || !native_wrapper_.get())
+ if ((!native_view_ && !views_view_) || !native_wrapper_.get())
return;
gfx::Rect vis_bounds = GetVisibleBounds();
@@ -164,6 +182,8 @@ void NativeViewHost::Focus() {
bool NativeViewHost::ContainsNativeView(gfx::NativeView native_view) const {
if (native_view == native_view_)
return true;
+ if (!native_view_)
+ return false;
views::Widget* native_widget =
views::Widget::GetWidgetFromNativeView(native_view_);
@@ -179,9 +199,10 @@ bool NativeViewHost::ContainsNativeView(gfx::NativeView native_view) const {
// NativeViewHost, private:
void NativeViewHost::Detach(bool destroyed) {
- DCHECK(native_view_);
+ DCHECK(native_view_ || views_view_);
native_wrapper_->NativeViewDetaching(destroyed);
native_view_ = NULL;
+ views_view_ = NULL;
}
} // namespace views
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698