summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhansmuller@chromium.org <hansmuller@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 07:10:13 +0000
committerhansmuller@chromium.org <hansmuller@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 07:10:13 +0000
commitd771d67064ea6557814bd68ce13e4468c31223c7 (patch)
tree0c35a8fa0fa2f29be01bfe8d18d38fc261294e92
parent9fef6bd789d831fbc5634653eb9c5adfde4434ea (diff)
downloadchromium_src-d771d67064ea6557814bd68ce13e4468c31223c7.zip
chromium_src-d771d67064ea6557814bd68ce13e4468c31223c7.tar.gz
chromium_src-d771d67064ea6557814bd68ce13e4468c31223c7.tar.bz2
Preliminary interactive layout of window manager's demo_launcher.
The window manager now handles root node resize by resizing its (two) toplevel nodes to match the initial layout. This is just an intermediate step towards generalizing window manager layout a little. BUGi=393244 Review URL: https://codereview.chromium.org/383123006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283379 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--mojo/examples/browser/browser.cc3
-rw-r--r--mojo/examples/html_viewer/html_document_view.cc23
-rw-r--r--mojo/examples/html_viewer/html_document_view.h11
-rw-r--r--mojo/examples/media_viewer/media_viewer.cc51
-rw-r--r--mojo/examples/png_viewer/png_viewer.cc32
-rw-r--r--mojo/examples/window_manager/window_manager.cc106
-rw-r--r--mojo/views/native_widget_view_manager.cc32
-rw-r--r--mojo/views/native_widget_view_manager.h5
8 files changed, 218 insertions, 45 deletions
diff --git a/mojo/examples/browser/browser.cc b/mojo/examples/browser/browser.cc
index d9fcafa..3f325c3 100644
--- a/mojo/examples/browser/browser.cc
+++ b/mojo/examples/browser/browser.cc
@@ -155,6 +155,8 @@ class Browser : public ApplicationDelegate,
Browser() : view_manager_(NULL), root_(NULL), widget_(NULL) {}
virtual ~Browser() {
+ if (root_)
+ root_->RemoveObserver(this);
}
private:
@@ -242,6 +244,7 @@ class Browser : public ApplicationDelegate,
virtual void OnNodeDestroyed(view_manager::Node* node) OVERRIDE {
DCHECK_EQ(root_, node);
node->RemoveObserver(this);
+ root_ = NULL;
}
scoped_ptr<ViewsInit> views_init_;
diff --git a/mojo/examples/html_viewer/html_document_view.cc b/mojo/examples/html_viewer/html_document_view.cc
index 654161a..becde37 100644
--- a/mojo/examples/html_viewer/html_document_view.cc
+++ b/mojo/examples/html_viewer/html_document_view.cc
@@ -80,6 +80,7 @@ HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider,
: view_manager_(view_manager),
view_(view_manager::View::Create(view_manager_)),
web_view_(NULL),
+ root_(NULL),
repaint_pending_(false),
navigator_host_(service_provider),
weak_factory_(this) {
@@ -88,20 +89,23 @@ HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider,
HTMLDocumentView::~HTMLDocumentView() {
view_->RemoveObserver(this);
-
if (web_view_)
web_view_->close();
+ if (root_)
+ root_->RemoveObserver(this);
}
void HTMLDocumentView::AttachToNode(view_manager::Node* node) {
- node->SetActiveView(view_);
+ root_ = node;
+ root_->SetActiveView(view_);
view_->SetColor(SK_ColorCYAN); // Dummy background color.
web_view_ = blink::WebView::create(this);
ConfigureSettings(web_view_->settings());
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
+ web_view_->resize(root_->bounds().size());
- web_view_->resize(gfx::Size(node->bounds().size()));
+ root_->AddObserver(this);
}
void HTMLDocumentView::Load(URLResponsePtr response) {
@@ -184,6 +188,19 @@ void HTMLDocumentView::OnViewInputEvent(view_manager::View* view,
web_view_->handleInputEvent(*web_event);
}
+void HTMLDocumentView::OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ DCHECK_EQ(node, root_);
+ web_view_->resize(node->bounds().size());
+}
+
+void HTMLDocumentView::OnNodeDestroyed(view_manager::Node* node) {
+ DCHECK_EQ(node, root_);
+ node->RemoveObserver(this);
+ root_ = NULL;
+}
+
void HTMLDocumentView::Repaint() {
repaint_pending_ = false;
diff --git a/mojo/examples/html_viewer/html_document_view.h b/mojo/examples/html_viewer/html_document_view.h
index 8c324a5..6d843ab 100644
--- a/mojo/examples/html_viewer/html_document_view.h
+++ b/mojo/examples/html_viewer/html_document_view.h
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/application/lazy_interface_ptr.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
+#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/view_observer.h"
#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
#include "mojo/services/public/interfaces/network/url_loader.mojom.h"
@@ -28,7 +29,8 @@ namespace examples {
// A view for a single HTML document.
class HTMLDocumentView : public blink::WebViewClient,
public blink::WebFrameClient,
- public view_manager::ViewObserver {
+ public view_manager::ViewObserver,
+ public view_manager::NodeObserver {
public:
HTMLDocumentView(ServiceProvider* service_provider,
view_manager::ViewManager* view_manager);
@@ -65,11 +67,18 @@ class HTMLDocumentView : public blink::WebViewClient,
virtual void OnViewInputEvent(view_manager::View* view,
const EventPtr& event) OVERRIDE;
+ // NodeObserver methods:
+ virtual void OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE;
+ virtual void OnNodeDestroyed(view_manager::Node* node) OVERRIDE;
+
void Repaint();
view_manager::ViewManager* view_manager_;
view_manager::View* view_;
blink::WebView* web_view_;
+ view_manager::Node* root_;
bool repaint_pending_;
LazyInterfacePtr<navigation::NavigatorHost> navigator_host_;
diff --git a/mojo/examples/media_viewer/media_viewer.cc b/mojo/examples/media_viewer/media_viewer.cc
index 58cb3ed..4221012 100644
--- a/mojo/examples/media_viewer/media_viewer.cc
+++ b/mojo/examples/media_viewer/media_viewer.cc
@@ -14,6 +14,7 @@
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/bindings/interface_impl.h"
#include "mojo/services/public/cpp/view_manager/node.h"
+#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
@@ -202,17 +203,22 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
class MediaViewer : public ApplicationDelegate,
public view_manager::ViewManagerDelegate,
- public ControlPanel::Delegate {
+ public ControlPanel::Delegate,
+ public view_manager::NodeObserver {
public:
MediaViewer() : app_(NULL),
view_manager_(NULL),
+ root_node_(NULL),
control_node_(NULL),
content_node_(NULL),
control_panel_(this) {
handler_map_["image/png"] = "mojo:mojo_png_viewer";
}
- virtual ~MediaViewer() {}
+ virtual ~MediaViewer() {
+ if (root_node_)
+ root_node_->RemoveObserver(this);
+ }
void Navigate(
uint32_t node_id,
@@ -270,24 +276,32 @@ class MediaViewer : public ApplicationDelegate,
return true;
}
+ void LayoutNodes() {
+ view_manager::Node* root = content_node_->parent();
+ gfx::Rect control_bounds(root->bounds().width(), 28);
+ control_node_->SetBounds(control_bounds);
+ gfx::Rect content_bounds(0, control_bounds.height(), root->bounds().width(),
+ root->bounds().height() - control_bounds.height());
+ content_node_->SetBounds(content_bounds);
+ }
+
// Overridden from view_manager::ViewManagerDelegate:
virtual void OnRootAdded(view_manager::ViewManager* view_manager,
view_manager::Node* root) OVERRIDE {
+ root_node_ = root;
view_manager_ = view_manager;
control_node_ = view_manager::Node::Create(view_manager_);
- root->AddChild(control_node_);
- gfx::Rect control_bounds(root->bounds().width(), 28);
- control_node_->SetBounds(control_bounds);
- control_node_->SetActiveView(view_manager::View::Create(view_manager_));
+ root_node_->AddChild(control_node_);
+ content_node_ = view_manager::Node::Create(view_manager_);
+ root_node_->AddChild(content_node_);
+
+ control_node_->SetActiveView(view_manager::View::Create(view_manager_));
control_panel_.Initialize(control_node_);
- content_node_ = view_manager::Node::Create(view_manager_);
- root->AddChild(content_node_);
- gfx::Rect content_bounds(0, control_bounds.height(), root->bounds().width(),
- root->bounds().height() - control_bounds.height());
- content_node_->SetBounds(content_bounds);
+ LayoutNodes();
+ root_node_->AddObserver(this);
if (pending_navigate_request_) {
scoped_ptr<PendingNavigateRequest> request(
@@ -311,7 +325,7 @@ class MediaViewer : public ApplicationDelegate,
zoomable_media_->ZoomIn();
break;
case ControlPanel::CONTROL_ACTUAL_SIZE:
- zoomable_media_->ZoomToActualSize();
+ zoomable_media_->ZoomToActualSize();
break;
case ControlPanel::CONTROL_ZOOM_OUT:
zoomable_media_->ZoomOut();
@@ -321,6 +335,18 @@ class MediaViewer : public ApplicationDelegate,
}
}
+ // NodeObserver:
+ virtual void OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE {
+ LayoutNodes();
+ }
+ virtual void OnNodeDestroyed(view_manager::Node* node) OVERRIDE {
+ DCHECK_EQ(node, root_node_);
+ node->RemoveObserver(this);
+ root_node_ = NULL;
+ }
+
std::string GetHandlerForContentType(const std::string& content_type) {
HandlerMap::const_iterator it = handler_map_.find(content_type);
return it != handler_map_.end() ? it->second : std::string();
@@ -329,6 +355,7 @@ class MediaViewer : public ApplicationDelegate,
ApplicationImpl* app_;
scoped_ptr<ViewsInit> views_init_;
view_manager::ViewManager* view_manager_;
+ view_manager::Node* root_node_;
view_manager::Node* control_node_;
view_manager::Node* content_node_;
ControlPanel control_panel_;
diff --git a/mojo/examples/png_viewer/png_viewer.cc b/mojo/examples/png_viewer/png_viewer.cc
index a6f8741..c9488e7 100644
--- a/mojo/examples/png_viewer/png_viewer.cc
+++ b/mojo/examples/png_viewer/png_viewer.cc
@@ -10,6 +10,7 @@
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/public/cpp/view_manager/node.h"
+#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/types.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
@@ -111,10 +112,17 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
};
class PNGViewer : public ApplicationDelegate,
- public view_manager::ViewManagerDelegate {
+ public view_manager::ViewManagerDelegate,
+ public view_manager::NodeObserver {
public:
- PNGViewer() : content_view_(NULL), zoom_percentage_(kDefaultZoomPercentage) {}
- virtual ~PNGViewer() {}
+ PNGViewer()
+ : content_view_(NULL),
+ root_(NULL),
+ zoom_percentage_(kDefaultZoomPercentage) {}
+ virtual ~PNGViewer() {
+ if (root_)
+ root_->RemoveObserver(this);
+ }
void UpdateView(view_manager::Id node_id, const SkBitmap& bitmap) {
bitmap_ = bitmap;
@@ -161,8 +169,10 @@ class PNGViewer : public ApplicationDelegate,
// Overridden from view_manager::ViewManagerDelegate:
virtual void OnRootAdded(view_manager::ViewManager* view_manager,
view_manager::Node* root) OVERRIDE {
+ root_ = root;
+ root_->AddObserver(this);
content_view_ = view_manager::View::Create(view_manager);
- root->SetActiveView(content_view_);
+ root_->SetActiveView(content_view_);
content_view_->SetColor(SK_ColorGRAY);
if (!bitmap_.isNull())
DrawBitmap();
@@ -189,7 +199,21 @@ class PNGViewer : public ApplicationDelegate,
content_view_->SetContents(skia::GetTopDevice(*canvas)->accessBitmap(true));
}
+ // NodeObserver:
+ virtual void OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ DrawBitmap();
+ }
+ virtual void OnNodeDestroyed(view_manager::Node* node) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ node->RemoveObserver(this);
+ root_ = NULL;
+ }
+
view_manager::View* content_view_;
+ view_manager::Node* root_;
SkBitmap bitmap_;
uint16_t zoom_percentage_;
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc
index b23e908..704c10f 100644
--- a/mojo/examples/window_manager/window_manager.cc
+++ b/mojo/examples/window_manager/window_manager.cc
@@ -24,6 +24,7 @@
#include "mojo/views/views_init.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
+#include "ui/gfx/geometry/size_conversions.h"
#if defined CreateWindow
#undef CreateWindow
@@ -90,11 +91,14 @@ class NavigatorHost : public InterfaceImpl<navigation::NavigatorHost> {
DISALLOW_COPY_AND_ASSIGN(NavigatorHost);
};
-class KeyboardManager : public KeyboardClient {
+class KeyboardManager : public KeyboardClient,
+ public NodeObserver {
public:
KeyboardManager() : view_manager_(NULL), node_(NULL) {
}
virtual ~KeyboardManager() {
+ if (node_)
+ node_->parent()->RemoveObserver(this);
}
Node* node() { return node_; }
@@ -110,6 +114,7 @@ class KeyboardManager : public KeyboardClient {
node_->Embed("mojo:mojo_keyboard");
application->ConnectToService("mojo:mojo_keyboard", &keyboard_service_);
keyboard_service_.set_client(this);
+ parent->AddObserver(this);
}
void Show(Id view_id, const gfx::Rect& bounds) {
@@ -147,6 +152,22 @@ class KeyboardManager : public KeyboardClient {
flags, false)));
}
+ // Overridden from NodeObserver:
+ virtual void OnNodeBoundsChanged(Node* parent,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE {
+ gfx::Rect keyboard_bounds(node_->bounds());
+ keyboard_bounds.set_y(new_bounds.bottom() - keyboard_bounds.height());
+ keyboard_bounds.set_width(keyboard_bounds.width() +
+ new_bounds.width() - old_bounds.width());
+ node_->SetBounds(keyboard_bounds);
+ }
+ virtual void OnNodeDestroyed(Node* parent) OVERRIDE {
+ DCHECK_EQ(parent, node_->parent());
+ parent->RemoveObserver(this);
+ node_ = NULL;
+ }
+
KeyboardServicePtr keyboard_service_;
ViewManager* view_manager_;
@@ -158,30 +179,72 @@ class KeyboardManager : public KeyboardClient {
class RootLayoutManager : public NodeObserver {
public:
- explicit RootLayoutManager(ViewManager* view_manager,
- Node* root,
- Id content_node_id)
- : root_(root),
- view_manager_(view_manager),
- content_node_id_(content_node_id) {}
- virtual ~RootLayoutManager() {}
+ RootLayoutManager(ViewManager* view_manager,
+ Node* root,
+ Id content_node_id,
+ Id launcher_ui_node_id,
+ Id control_panel_node_id)
+ : root_(root),
+ view_manager_(view_manager),
+ content_node_id_(content_node_id),
+ launcher_ui_node_id_(launcher_ui_node_id),
+ control_panel_node_id_(control_panel_node_id) {}
+ virtual ~RootLayoutManager() {
+ if (root_)
+ root_->RemoveObserver(this);
+ }
private:
// Overridden from NodeObserver:
virtual void OnNodeBoundsChanged(Node* node,
- const gfx::Rect& /*old_bounds*/,
+ const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {
DCHECK_EQ(node, root_);
+
Node* content_node = view_manager_->GetNodeById(content_node_id_);
content_node->SetBounds(new_bounds);
// Force the view's bitmap to be recreated
content_node->active_view()->SetColor(SK_ColorBLUE);
- // TODO(hansmuller): Do Layout
+
+ int delta_width = new_bounds.width() - old_bounds.width();
+ int delta_height = new_bounds.height() - old_bounds.height();
+
+ Node* launcher_ui_node =
+ view_manager_->GetNodeById(launcher_ui_node_id_);
+ gfx::Rect launcher_ui_bounds(launcher_ui_node->bounds());
+ launcher_ui_bounds.set_width(launcher_ui_bounds.width() + delta_width);
+ launcher_ui_node->SetBounds(launcher_ui_bounds);
+
+ Node* control_panel_node =
+ view_manager_->GetNodeById(control_panel_node_id_);
+ gfx::Rect control_panel_bounds(control_panel_node->bounds());
+ control_panel_bounds.set_x(control_panel_bounds.x() + delta_width);
+ control_panel_node->SetBounds(control_panel_bounds);
+
+ const Node::Children& content_nodes = content_node->children();
+ Node::Children::const_iterator iter = content_nodes.begin();
+ for(; iter != content_nodes.end(); ++iter) {
+ Node* node = *iter;
+ if (node->id() == control_panel_node->id() ||
+ node->id() == launcher_ui_node->id())
+ continue;
+ gfx::Rect node_bounds(node->bounds());
+ node_bounds.set_width(node_bounds.width() + delta_width);
+ node_bounds.set_height(node_bounds.height() + delta_height);
+ node->SetBounds(node_bounds);
+ }
+ }
+ virtual void OnNodeDestroyed(Node* node) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ root_->RemoveObserver(this);
+ root_ = NULL;
}
Node* root_;
ViewManager* view_manager_;
- Id content_node_id_;
+ const Id content_node_id_;
+ const Id launcher_ui_node_id_;
+ const Id control_panel_node_id_;
DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
};
@@ -283,16 +346,19 @@ class WindowManager : public ApplicationDelegate,
node->SetBounds(gfx::Rect(root->bounds().size()));
content_node_id_ = node->id();
- root_layout_manager_.reset(
- new RootLayoutManager(view_manager_, root, content_node_id_));
- root->AddObserver(root_layout_manager_.get());
-
View* view = View::Create(view_manager_);
node->SetActiveView(view);
view->SetColor(SK_ColorBLUE);
- CreateLauncherUI();
- CreateControlPanel(node);
+ Id launcher_ui_id = CreateLauncherUI();
+ Id control_panel_id = CreateControlPanel(node);
+
+ root_layout_manager_.reset(
+ new RootLayoutManager(view_manager, root,
+ content_node_id_,
+ launcher_ui_id,
+ control_panel_id));
+ root->AddObserver(root_layout_manager_.get());
}
virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
DCHECK_EQ(view_manager_, view_manager);
@@ -349,7 +415,7 @@ class WindowManager : public ApplicationDelegate,
}
// TODO(beng): proper layout manager!!
- void CreateLauncherUI() {
+ Id CreateLauncherUI() {
navigation::NavigationDetailsPtr nav_details;
navigation::ResponseDetailsPtr response;
Node* node = view_manager_->GetNodeById(content_node_id_);
@@ -358,6 +424,7 @@ class WindowManager : public ApplicationDelegate,
bounds.set_height(kTextfieldHeight);
launcher_ui_ = CreateChild(content_node_id_, "mojo:mojo_browser", bounds,
nav_details.Pass(), response.Pass());
+ return launcher_ui_->id();
}
void CreateWindow(const std::string& handler_url,
@@ -409,7 +476,7 @@ class WindowManager : public ApplicationDelegate,
keyboard_manager_->node()->Contains(target->node());
}
- void CreateControlPanel(view_manager::Node* root) {
+ Id CreateControlPanel(view_manager::Node* root) {
Node* node = Node::Create(view_manager_);
View* view = view_manager::View::Create(view_manager_);
root->AddChild(node);
@@ -424,6 +491,7 @@ class WindowManager : public ApplicationDelegate,
node->SetBounds(bounds);
debug_panel_ = new DebugPanel(this, node);
+ return node->id();
}
scoped_ptr<ViewsInit> views_init_;
diff --git a/mojo/views/native_widget_view_manager.cc b/mojo/views/native_widget_view_manager.cc
index 36a6578..1d92e22 100644
--- a/mojo/views/native_widget_view_manager.cc
+++ b/mojo/views/native_widget_view_manager.cc
@@ -90,9 +90,11 @@ class MinimalInputEventFilter : public ui::internal::InputMethodDelegate,
NativeWidgetViewManager::NativeWidgetViewManager(
views::internal::NativeWidgetDelegate* delegate, view_manager::Node* node)
: NativeWidgetAura(delegate),
- node_(node) {
+ node_(node),
+ view_(node_->active_view()) {
node_->AddObserver(this);
- node_->active_view()->AddObserver(this);
+ if (view_)
+ view_->AddObserver(this);
window_tree_host_.reset(new WindowTreeHostMojo(node_, this));
window_tree_host_->InitHost();
@@ -113,9 +115,10 @@ NativeWidgetViewManager::NativeWidgetViewManager(
}
NativeWidgetViewManager::~NativeWidgetViewManager() {
- if (node_->active_view())
- node_->active_view()->RemoveObserver(this);
- node_->RemoveObserver(this);
+ if (view_)
+ view_->RemoveObserver(this);
+ if (node_)
+ node_->RemoveObserver(this);
}
void NativeWidgetViewManager::InitNativeWidget(
@@ -129,13 +132,23 @@ void NativeWidgetViewManager::InitNativeWidget(
void NativeWidgetViewManager::CompositorContentsChanged(
const SkBitmap& bitmap) {
- node_->active_view()->SetContents(bitmap);
+ if (view_)
+ view_->SetContents(bitmap);
}
void NativeWidgetViewManager::OnNodeDestroyed(view_manager::Node* node) {
+ DCHECK_EQ(node, node_);
+ node->RemoveObserver(this);
+ node_ = NULL;
window_tree_host_.reset();
}
+void NativeWidgetViewManager::OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ GetWidget()->SetBounds(gfx::Rect(node->bounds().size()));
+}
+
void NativeWidgetViewManager::OnNodeActiveViewChanged(
view_manager::Node* node,
view_manager::View* old_view,
@@ -144,6 +157,7 @@ void NativeWidgetViewManager::OnNodeActiveViewChanged(
old_view->RemoveObserver(this);
if (new_view)
new_view->AddObserver(this);
+ view_ = new_view;
}
void NativeWidgetViewManager::OnViewInputEvent(view_manager::View* view,
@@ -153,4 +167,10 @@ void NativeWidgetViewManager::OnViewInputEvent(view_manager::View* view,
window_tree_host_->SendEventToProcessor(ui_event.get());
}
+void NativeWidgetViewManager::OnViewDestroyed(view_manager::View* view) {
+ DCHECK_EQ(view, view_);
+ view->RemoveObserver(this);
+ view_ = NULL;
+}
+
} // namespace mojo
diff --git a/mojo/views/native_widget_view_manager.h b/mojo/views/native_widget_view_manager.h
index b8050f3..564e467 100644
--- a/mojo/views/native_widget_view_manager.h
+++ b/mojo/views/native_widget_view_manager.h
@@ -47,10 +47,14 @@ class NativeWidgetViewManager : public views::NativeWidgetAura,
virtual void OnNodeActiveViewChanged(view_manager::Node* node,
view_manager::View* old_view,
view_manager::View* new_view) OVERRIDE;
+ virtual void OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE;
// view_manager::ViewObserver
virtual void OnViewInputEvent(view_manager::View* view,
const EventPtr& event) OVERRIDE;
+ virtual void OnViewDestroyed(view_manager::View* view) OVERRIDE;
scoped_ptr<WindowTreeHostMojo> window_tree_host_;
@@ -59,6 +63,7 @@ class NativeWidgetViewManager : public views::NativeWidgetAura,
scoped_ptr<ui::internal::InputMethodDelegate> ime_filter_;
view_manager::Node* node_;
+ view_manager::View* view_;
scoped_ptr<wm::ScopedCaptureClient> capture_client_;