summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2015-10-15 17:12:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-16 00:13:20 +0000
commit68afcf453d29c8f311b34a0aa210e042d4adc132 (patch)
tree5d7e25e02abe745aec485ecb4450f37d24b080c8
parentda33ab883a2046613836487d852d5fd36f1dc4c3 (diff)
downloadchromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.zip
chromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.tar.gz
chromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.tar.bz2
View => Window in components/mus/public/cpp
This CL updates the client lib to refer to mus::Windows and mus::WindowServer instead of View and View Manager. I hope I caught everything. I'll clean things up in subsequent CLs, and start renaming the interfaces and implementation. BUG=542848 Review URL: https://codereview.chromium.org/1402223003 Cr-Commit-Position: refs/heads/master@{#354411}
-rw-r--r--components/html_viewer/ax_provider_apptest.cc18
-rw-r--r--components/html_viewer/document_resource_waiter.cc20
-rw-r--r--components/html_viewer/document_resource_waiter.h28
-rw-r--r--components/html_viewer/html_document.cc72
-rw-r--r--components/html_viewer/html_document.h22
-rw-r--r--components/html_viewer/html_frame.cc112
-rw-r--r--components/html_viewer/html_frame.h49
-rw-r--r--components/html_viewer/html_frame_apptest.cc54
-rw-r--r--components/html_viewer/html_frame_tree_manager.cc39
-rw-r--r--components/html_viewer/html_frame_tree_manager.h10
-rw-r--r--components/html_viewer/html_widget.cc45
-rw-r--r--components/html_viewer/html_widget.h18
-rw-r--r--components/html_viewer/ime_controller.cc10
-rw-r--r--components/html_viewer/ime_controller.h8
-rw-r--r--components/html_viewer/layout_test_content_handler_impl.cc2
-rw-r--r--components/html_viewer/web_layer_tree_view_impl.cc21
-rw-r--r--components/html_viewer/web_layer_tree_view_impl.h10
-rw-r--r--components/mus/example/common/mus_views_init.cc14
-rw-r--r--components/mus/example/common/mus_views_init.h13
-rw-r--r--components/mus/example/wm/window_manager_application.cc24
-rw-r--r--components/mus/example/wm/window_manager_application.h12
-rw-r--r--components/mus/example/wm/window_manager_impl.cc26
-rw-r--r--components/mus/example/wm/window_manager_impl.h2
-rw-r--r--components/mus/mus_app.cc2
-rw-r--r--components/mus/mus_app.h6
-rw-r--r--components/mus/public/cpp/BUILD.gn42
-rw-r--r--components/mus/public/cpp/lib/output_surface.cc8
-rw-r--r--components/mus/public/cpp/lib/scoped_view_ptr.cc44
-rw-r--r--components/mus/public/cpp/lib/scoped_window_ptr.cc44
-rw-r--r--components/mus/public/cpp/lib/view_private.cc20
-rw-r--r--components/mus/public/cpp/lib/view_private.h66
-rw-r--r--components/mus/public/cpp/lib/view_tree_client_impl.cc449
-rw-r--r--components/mus/public/cpp/lib/view_tree_client_impl.h162
-rw-r--r--components/mus/public/cpp/lib/view_tree_host_factory.cc36
-rw-r--r--components/mus/public/cpp/lib/window.cc (renamed from components/mus/public/cpp/lib/view.cc)350
-rw-r--r--components/mus/public/cpp/lib/window_observer.cc (renamed from components/mus/public/cpp/lib/view_observer.cc)6
-rw-r--r--components/mus/public/cpp/lib/window_private.cc20
-rw-r--r--components/mus/public/cpp/lib/window_private.h68
-rw-r--r--components/mus/public/cpp/lib/window_surface.cc (renamed from components/mus/public/cpp/lib/view_surface.cc)16
-rw-r--r--components/mus/public/cpp/lib/window_tree_client_impl.cc457
-rw-r--r--components/mus/public/cpp/lib/window_tree_client_impl.h166
-rw-r--r--components/mus/public/cpp/lib/window_tree_delegate.cc (renamed from components/mus/public/cpp/lib/view_tree_delegate.cc)4
-rw-r--r--components/mus/public/cpp/lib/window_tree_host_factory.cc36
-rw-r--r--components/mus/public/cpp/output_surface.h14
-rw-r--r--components/mus/public/cpp/scoped_view_ptr.h38
-rw-r--r--components/mus/public/cpp/scoped_window_ptr.h38
-rw-r--r--components/mus/public/cpp/tests/BUILD.gn10
-rw-r--r--components/mus/public/cpp/tests/run_all_unittests.cc6
-rw-r--r--components/mus/public/cpp/tests/view_manager_test_suite.h27
-rw-r--r--components/mus/public/cpp/tests/view_unittest.cc874
-rw-r--r--components/mus/public/cpp/tests/window_server_test_base.cc (renamed from components/mus/public/cpp/tests/view_manager_test_base.cc)40
-rw-r--r--components/mus/public/cpp/tests/window_server_test_base.h (renamed from components/mus/public/cpp/tests/view_manager_test_base.h)46
-rw-r--r--components/mus/public/cpp/tests/window_server_test_suite.cc (renamed from components/mus/public/cpp/tests/view_manager_test_suite.cc)8
-rw-r--r--components/mus/public/cpp/tests/window_server_test_suite.h27
-rw-r--r--components/mus/public/cpp/tests/window_unittest.cc875
-rw-r--r--components/mus/public/cpp/view_observer.h102
-rw-r--r--components/mus/public/cpp/view_property.h139
-rw-r--r--components/mus/public/cpp/view_tracker.cc40
-rw-r--r--components/mus/public/cpp/view_tracker.h47
-rw-r--r--components/mus/public/cpp/window.h (renamed from components/mus/public/cpp/view.h)111
-rw-r--r--components/mus/public/cpp/window_observer.h104
-rw-r--r--components/mus/public/cpp/window_property.h140
-rw-r--r--components/mus/public/cpp/window_surface.h (renamed from components/mus/public/cpp/view_surface.h)26
-rw-r--r--components/mus/public/cpp/window_surface_client.h (renamed from components/mus/public/cpp/view_surface_client.h)8
-rw-r--r--components/mus/public/cpp/window_tracker.cc40
-rw-r--r--components/mus/public/cpp/window_tracker.h47
-rw-r--r--components/mus/public/cpp/window_tree_connection.h (renamed from components/mus/public/cpp/view_tree_connection.h)39
-rw-r--r--components/mus/public/cpp/window_tree_delegate.h (renamed from components/mus/public/cpp/view_tree_delegate.h)27
-rw-r--r--components/mus/public/cpp/window_tree_host_factory.h (renamed from components/mus/public/cpp/view_tree_host_factory.h)22
-rw-r--r--components/mus/public/interfaces/view_tree.mojom32
-rw-r--r--components/mus/public/interfaces/view_tree_host.mojom6
-rw-r--r--components/mus/vm/access_policy.h2
-rw-r--r--components/mus/vm/default_access_policy.cc5
-rw-r--r--components/mus/vm/default_access_policy.h2
-rw-r--r--components/mus/vm/test_change_tracker.cc38
-rw-r--r--components/mus/vm/test_change_tracker.h40
-rw-r--r--components/mus/vm/view_manager_client_apptest.cc705
-rw-r--r--components/mus/vm/view_tree_apptest.cc65
-rw-r--r--components/mus/vm/view_tree_host_impl.cc6
-rw-r--r--components/mus/vm/view_tree_impl.cc39
-rw-r--r--components/mus/vm/view_tree_unittest.cc65
-rw-r--r--components/mus/vm/window_manager_access_policy.cc2
-rw-r--r--components/mus/vm/window_manager_access_policy.h2
-rw-r--r--components/pdf_viewer/pdf_viewer.cc47
-rw-r--r--components/web_view/frame.cc25
-rw-r--r--components/web_view/frame.h22
-rw-r--r--components/web_view/frame_apptest.cc61
-rw-r--r--components/web_view/frame_tree.cc4
-rw-r--r--components/web_view/frame_tree.h4
-rw-r--r--components/web_view/frame_tree_delegate.cc2
-rw-r--r--components/web_view/frame_tree_delegate.h2
-rw-r--r--components/web_view/public/cpp/web_view.cc8
-rw-r--r--components/web_view/public/cpp/web_view.h4
-rw-r--r--components/web_view/test_frame_tree_delegate.cc2
-rw-r--r--components/web_view/test_frame_tree_delegate.h4
-rw-r--r--components/web_view/test_runner/test_runner_application_delegate.cc20
-rw-r--r--components/web_view/test_runner/test_runner_application_delegate.h14
-rw-r--r--components/web_view/web_view_apptest.cc25
-rw-r--r--components/web_view/web_view_impl.cc28
-rw-r--r--components/web_view/web_view_impl.h28
-rw-r--r--mandoline/ui/desktop_ui/browser_manager.cc4
-rw-r--r--mandoline/ui/desktop_ui/browser_window.cc18
-rw-r--r--mandoline/ui/desktop_ui/browser_window.h20
-rw-r--r--mandoline/ui/omnibox/omnibox_application.cc26
-rw-r--r--mandoline/ui/phone_ui/phone_browser_application_delegate.cc22
-rw-r--r--mandoline/ui/phone_ui/phone_browser_application_delegate.h26
-rw-r--r--ui/views/mus/aura_init.cc12
-rw-r--r--ui/views/mus/aura_init.h6
-rw-r--r--ui/views/mus/input_method_mus.cc10
-rw-r--r--ui/views/mus/input_method_mus.h9
-rw-r--r--ui/views/mus/native_widget_view_manager.cc53
-rw-r--r--ui/views/mus/native_widget_view_manager.h12
-rw-r--r--ui/views/mus/surface_binding.cc63
-rw-r--r--ui/views/mus/surface_binding.h10
-rw-r--r--ui/views/mus/surface_context_factory.cc6
-rw-r--r--ui/views/mus/surface_context_factory.h4
-rw-r--r--ui/views/mus/window_tree_host_mus.cc20
-rw-r--r--ui/views/mus/window_tree_host_mus.h16
118 files changed, 3616 insertions, 3556 deletions
diff --git a/components/html_viewer/ax_provider_apptest.cc b/components/html_viewer/ax_provider_apptest.cc
index d6af04c..ac703bc 100644
--- a/components/html_viewer/ax_provider_apptest.cc
+++ b/components/html_viewer/ax_provider_apptest.cc
@@ -8,9 +8,9 @@
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
-#include "components/mus/public/cpp/tests/view_manager_test_base.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/tests/window_server_test_base.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/application_test_base.h"
@@ -68,7 +68,7 @@ class TestFrame : public web_view::mojom::Frame {
} // namespace
-using AXProviderTest = mus::ViewManagerTestBase;
+using AXProviderTest = mus::WindowServerTestBase;
TEST_F(AXProviderTest, HelloWorld) {
// Start a test server for net/data/test.html access.
@@ -85,11 +85,11 @@ TEST_F(AXProviderTest, HelloWorld) {
scoped_ptr<ApplicationConnection> connection =
application_impl()->ConnectToApplication(request.Pass());
- // Embed the html_viewer in a View.
+ // Embed the html_viewer in a Window.
ViewTreeClientPtr tree_client;
connection->ConnectToService(&tree_client);
- mus::View* embed_view = window_manager()->CreateView();
- embed_view->Embed(tree_client.Pass());
+ mus::Window* embed_window = window_manager()->CreateWindow();
+ embed_window->Embed(tree_client.Pass());
TestFrame frame;
web_view::mojom::FramePtr frame_ptr;
@@ -98,13 +98,13 @@ TEST_F(AXProviderTest, HelloWorld) {
mojo::Array<web_view::mojom::FrameDataPtr> array(1u);
array[0] = web_view::mojom::FrameData::New().Pass();
- array[0]->frame_id = embed_view->id();
+ array[0]->frame_id = embed_window->id();
array[0]->parent_id = 0u;
web_view::mojom::FrameClientPtr frame_client;
connection->ConnectToService(&frame_client);
frame_client->OnConnect(
- frame_ptr.Pass(), 1u, embed_view->id(),
+ frame_ptr.Pass(), 1u, embed_window->id(),
web_view::mojom::VIEW_CONNECT_TYPE_USE_NEW, array.Pass(),
base::TimeTicks::Now().ToInternalValue(), base::Closure());
diff --git a/components/html_viewer/document_resource_waiter.cc b/components/html_viewer/document_resource_waiter.cc
index 996034c..bc6731d73 100644
--- a/components/html_viewer/document_resource_waiter.cc
+++ b/components/html_viewer/document_resource_waiter.cc
@@ -7,7 +7,7 @@
#include "components/html_viewer/global_state.h"
#include "components/html_viewer/html_document.h"
#include "components/html_viewer/html_frame_tree_manager.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
using web_view::mojom::ViewConnectType;
@@ -21,7 +21,7 @@ DocumentResourceWaiter::DocumentResourceWaiter(GlobalState* global_state,
response_(response.Pass()),
root_(nullptr),
change_id_(0u),
- view_id_(0u),
+ window_id_(0u),
view_connect_type_(web_view::mojom::VIEW_CONNECT_TYPE_USE_NEW),
frame_client_binding_(this),
is_ready_(false),
@@ -40,7 +40,7 @@ void DocumentResourceWaiter::Release(
web_view::mojom::FramePtr* frame,
mojo::Array<web_view::mojom::FrameDataPtr>* frame_data,
uint32_t* change_id,
- uint32_t* view_id,
+ uint32_t* window_id,
ViewConnectType* view_connect_type,
OnConnectCallback* on_connect_callback) {
DCHECK(is_ready_);
@@ -48,7 +48,7 @@ void DocumentResourceWaiter::Release(
*frame = frame_.Pass();
*frame_data = frame_data_.Pass();
*change_id = change_id_;
- *view_id = view_id_;
+ *window_id = window_id_;
*view_connect_type = view_connect_type_;
*on_connect_callback = on_connect_callback_;
}
@@ -57,7 +57,7 @@ mojo::URLResponsePtr DocumentResourceWaiter::ReleaseURLResponse() {
return response_.Pass();
}
-void DocumentResourceWaiter::SetRoot(mus::View* root) {
+void DocumentResourceWaiter::SetRoot(mus::Window* root) {
DCHECK(!root_);
root_ = root;
root_->AddObserver(this);
@@ -123,14 +123,14 @@ void DocumentResourceWaiter::UpdateIsReady() {
void DocumentResourceWaiter::OnConnect(
web_view::mojom::FramePtr frame,
uint32_t change_id,
- uint32_t view_id,
+ uint32_t window_id,
ViewConnectType view_connect_type,
mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
int64_t navigation_start_time_ticks,
const OnConnectCallback& callback) {
DCHECK(frame_data_.is_null());
change_id_ = change_id;
- view_id_ = view_id;
+ window_id_ = window_id;
view_connect_type_ = view_connect_type;
frame_ = frame.Pass();
frame_data_ = frame_data.Pass();
@@ -217,14 +217,14 @@ void DocumentResourceWaiter::StopHighlightingFindResults() {
NOTREACHED();
}
-void DocumentResourceWaiter::OnViewViewportMetricsChanged(
- mus::View* view,
+void DocumentResourceWaiter::OnWindowViewportMetricsChanged(
+ mus::Window* window,
const mojo::ViewportMetrics& old_metrics,
const mojo::ViewportMetrics& new_metrics) {
UpdateIsReady();
}
-void DocumentResourceWaiter::OnViewDestroyed(mus::View* view) {
+void DocumentResourceWaiter::OnWindowDestroyed(mus::Window* window) {
root_->RemoveObserver(this);
root_ = nullptr;
}
diff --git a/components/html_viewer/document_resource_waiter.h b/components/html_viewer/document_resource_waiter.h
index 948359a..be22006 100644
--- a/components/html_viewer/document_resource_waiter.h
+++ b/components/html_viewer/document_resource_waiter.h
@@ -8,15 +8,11 @@
#include "base/basictypes.h"
#include "base/time/time.h"
#include "components/html_viewer/html_frame_tree_manager_observer.h"
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window_observer.h"
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "mojo/services/network/public/interfaces/url_loader.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
-namespace mojo {
-class View;
-}
-
namespace html_viewer {
class HTMLDocument;
@@ -28,7 +24,7 @@ class GlobalState;
// assumed HTMLDocument will call back for the FrameClient and FrameData.
class DocumentResourceWaiter : public web_view::mojom::FrameClient,
public HTMLFrameTreeManagerObserver,
- public mus::ViewObserver {
+ public mus::WindowObserver {
public:
DocumentResourceWaiter(GlobalState* global_state,
mojo::URLResponsePtr response,
@@ -40,7 +36,7 @@ class DocumentResourceWaiter : public web_view::mojom::FrameClient,
frame_client_request,
web_view::mojom::FramePtr* frame,
mojo::Array<web_view::mojom::FrameDataPtr>* frame_data,
- uint32_t* view_id,
+ uint32_t* window_id,
uint32_t* change_id,
web_view::mojom::ViewConnectType* view_connect_type,
OnConnectCallback* on_connect_callback);
@@ -56,8 +52,8 @@ class DocumentResourceWaiter : public web_view::mojom::FrameClient,
return navigation_start_time_;
}
- void SetRoot(mus::View* root);
- mus::View* root() { return root_; }
+ void SetRoot(mus::Window* root);
+ mus::Window* root() { return root_; }
void Bind(mojo::InterfaceRequest<web_view::mojom::FrameClient> request);
@@ -68,7 +64,7 @@ class DocumentResourceWaiter : public web_view::mojom::FrameClient,
// web_view::mojom::FrameClient:
void OnConnect(web_view::mojom::FramePtr frame,
uint32_t change_id,
- uint32_t view_id,
+ uint32_t window_id,
web_view::mojom::ViewConnectType view_connect_type,
mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
int64_t navigation_start_time_ticks,
@@ -98,12 +94,12 @@ class DocumentResourceWaiter : public web_view::mojom::FrameClient,
bool reset) override;
void StopHighlightingFindResults() override;
- // ViewObserver:
- void OnViewViewportMetricsChanged(
- mus::View* view,
+ // WindowObserver:
+ void OnWindowViewportMetricsChanged(
+ mus::Window* window,
const mojo::ViewportMetrics& old_metrics,
const mojo::ViewportMetrics& new_metrics) override;
- void OnViewDestroyed(mus::View* view) override;
+ void OnWindowDestroyed(mus::Window* window) override;
// HTMLFrameTreeManagerObserver:
void OnHTMLFrameTreeManagerChangeIdAdvanced() override;
@@ -112,11 +108,11 @@ class DocumentResourceWaiter : public web_view::mojom::FrameClient,
GlobalState* global_state_;
HTMLDocument* document_;
mojo::URLResponsePtr response_;
- mus::View* root_;
+ mus::Window* root_;
web_view::mojom::FramePtr frame_;
mojo::Array<web_view::mojom::FrameDataPtr> frame_data_;
uint32_t change_id_;
- uint32_t view_id_;
+ uint32_t window_id_;
base::TimeTicks navigation_start_time_;
web_view::mojom::ViewConnectType view_connect_type_;
OnConnectCallback on_connect_callback_;
diff --git a/components/html_viewer/html_document.cc b/components/html_viewer/html_document.cc
index 7727a3b..adf7cbf 100644
--- a/components/html_viewer/html_document.cc
+++ b/components/html_viewer/html_document.cc
@@ -19,8 +19,8 @@
#include "components/html_viewer/html_frame_tree_manager.h"
#include "components/html_viewer/test_html_viewer_impl.h"
#include "components/html_viewer/web_url_loader_impl.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/vm/ids.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/connect.h"
@@ -32,7 +32,7 @@
#include "ui/gfx/geometry/size.h"
using mojo::AxProvider;
-using mus::View;
+using mus::Window;
namespace html_viewer {
namespace {
@@ -46,28 +46,28 @@ bool IsTestInterfaceEnabled() {
} // namespace
-// A ViewTreeDelegate implementation that delegates to a (swappable) delegate.
+// A WindowTreeDelegate implementation that delegates to a (swappable) delegate.
// This is used when one HTMLDocument takes over for another delegate
// (OnSwap()).
-class ViewTreeDelegateImpl : public mus::ViewTreeDelegate {
+class WindowTreeDelegateImpl : public mus::WindowTreeDelegate {
public:
- explicit ViewTreeDelegateImpl(mus::ViewTreeDelegate* delegate)
+ explicit WindowTreeDelegateImpl(mus::WindowTreeDelegate* delegate)
: delegate_(delegate) {}
- ~ViewTreeDelegateImpl() override {}
+ ~WindowTreeDelegateImpl() override {}
- void set_delegate(mus::ViewTreeDelegate* delegate) { delegate_ = delegate; }
+ void set_delegate(mus::WindowTreeDelegate* delegate) { delegate_ = delegate; }
private:
- // ViewTreeDelegate:
- void OnEmbed(mus::View* root) override { delegate_->OnEmbed(root); }
+ // WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override { delegate_->OnEmbed(root); }
void OnUnembed() override { delegate_->OnUnembed(); }
- void OnConnectionLost(mus::ViewTreeConnection* connection) override {
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override {
delegate_->OnConnectionLost(connection);
}
- mus::ViewTreeDelegate* delegate_;
+ mus::WindowTreeDelegate* delegate_;
- DISALLOW_COPY_AND_ASSIGN(ViewTreeDelegateImpl);
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeDelegateImpl);
};
HTMLDocument::BeforeLoadCache::BeforeLoadCache() {}
@@ -78,17 +78,17 @@ HTMLDocument::BeforeLoadCache::~BeforeLoadCache() {
}
HTMLDocument::TransferableState::TransferableState()
- : owns_view_tree_connection(false), root(nullptr) {}
+ : owns_window_tree_connection(false), root(nullptr) {}
HTMLDocument::TransferableState::~TransferableState() {}
void HTMLDocument::TransferableState::Move(TransferableState* other) {
- owns_view_tree_connection = other->owns_view_tree_connection;
+ owns_window_tree_connection = other->owns_window_tree_connection;
root = other->root;
- view_tree_delegate_impl = other->view_tree_delegate_impl.Pass();
+ window_tree_delegate_impl = other->window_tree_delegate_impl.Pass();
other->root = nullptr;
- other->owns_view_tree_connection = false;
+ other->owns_window_tree_connection = false;
}
HTMLDocument::HTMLDocument(mojo::ApplicationImpl* html_document_app,
@@ -118,7 +118,7 @@ HTMLDocument::HTMLDocument(mojo::ApplicationImpl* html_document_app,
void HTMLDocument::Destroy() {
if (resource_waiter_) {
- mus::View* root = resource_waiter_->root();
+ mus::Window* root = resource_waiter_->root();
if (root) {
resource_waiter_.reset();
delete root->connection();
@@ -131,7 +131,7 @@ void HTMLDocument::Destroy() {
frame_->Close();
} else if (transferable_state_.root) {
// This triggers deleting us.
- if (transferable_state_.owns_view_tree_connection)
+ if (transferable_state_.owns_window_tree_connection)
delete transferable_state_.root->connection();
else
delete this;
@@ -150,7 +150,7 @@ void HTMLDocument::Load() {
DCHECK(resource_waiter_ && resource_waiter_->is_ready());
// Note: |view| is null if we're taking over for an existing frame.
- mus::View* view = resource_waiter_->root();
+ mus::Window* view = resource_waiter_->root();
if (view) {
global_state_->InitIfNecessary(
view->viewport_metrics().size_in_pixels.To<gfx::Size>(),
@@ -198,12 +198,12 @@ HTMLDocument::BeforeLoadCache* HTMLDocument::GetBeforeLoadCache() {
return before_load_cache_.get();
}
-void HTMLDocument::OnEmbed(View* root) {
+void HTMLDocument::OnEmbed(Window* root) {
transferable_state_.root = root;
resource_waiter_->SetRoot(root);
}
-void HTMLDocument::OnConnectionLost(mus::ViewTreeConnection* connection) {
+void HTMLDocument::OnConnectionLost(mus::WindowTreeConnection* connection) {
delete this;
}
@@ -241,27 +241,27 @@ void HTMLDocument::OnFrameSwappedToRemote() {
void HTMLDocument::OnSwap(HTMLFrame* frame, HTMLFrameDelegate* old_delegate) {
DCHECK(frame->IsLocal());
- DCHECK(frame->view());
+ DCHECK(frame->window());
DCHECK(!frame_);
DCHECK(!transferable_state_.root);
if (!old_delegate) {
// We're taking over a child of a local root that isn't associated with a
// delegate. In this case the frame's view is not the root of the
- // ViewTreeConnection.
- transferable_state_.owns_view_tree_connection = false;
- transferable_state_.root = frame->view();
+ // WindowTreeConnection.
+ transferable_state_.owns_window_tree_connection = false;
+ transferable_state_.root = frame->window();
} else {
HTMLDocument* old_document = static_cast<HTMLDocument*>(old_delegate);
transferable_state_.Move(&old_document->transferable_state_);
- if (transferable_state_.view_tree_delegate_impl)
- transferable_state_.view_tree_delegate_impl->set_delegate(this);
+ if (transferable_state_.window_tree_delegate_impl)
+ transferable_state_.window_tree_delegate_impl->set_delegate(this);
old_document->frame_ = nullptr;
old_document->Destroy();
}
}
void HTMLDocument::OnFrameDestroyed() {
- if (!transferable_state_.owns_view_tree_connection)
+ if (!transferable_state_.owns_window_tree_connection)
delete this;
}
@@ -315,13 +315,13 @@ void HTMLDocument::Create(
void HTMLDocument::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ViewTreeClient> request) {
- DCHECK(!transferable_state_.view_tree_delegate_impl);
- transferable_state_.view_tree_delegate_impl.reset(
- new ViewTreeDelegateImpl(this));
- transferable_state_.owns_view_tree_connection = true;
- mus::ViewTreeConnection::Create(
- transferable_state_.view_tree_delegate_impl.get(), request.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ DCHECK(!transferable_state_.window_tree_delegate_impl);
+ transferable_state_.window_tree_delegate_impl.reset(
+ new WindowTreeDelegateImpl(this));
+ transferable_state_.owns_window_tree_connection = true;
+ mus::WindowTreeConnection::Create(
+ transferable_state_.window_tree_delegate_impl.get(), request.Pass(),
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
} // namespace html_viewer
diff --git a/components/html_viewer/html_document.h b/components/html_viewer/html_document.h
index 501d688..2b82384 100644
--- a/components/html_viewer/html_document.h
+++ b/components/html_viewer/html_document.h
@@ -15,7 +15,7 @@
#include "components/html_viewer/ax_provider_impl.h"
#include "components/html_viewer/html_frame_delegate.h"
#include "components/html_viewer/public/interfaces/test_html_viewer.mojom.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "mojo/application/public/cpp/app_lifetime_helper.h"
#include "mojo/application/public/cpp/interface_factory.h"
@@ -28,8 +28,8 @@ class SingleThreadTaskRunner;
}
namespace mus {
-class View;
-class ViewTreeConnection;
+class Window;
+class WindowTreeConnection;
}
namespace html_viewer {
@@ -40,7 +40,7 @@ class GlobalState;
class HTMLFactory;
class HTMLFrame;
class TestHTMLViewerImpl;
-class ViewTreeDelegateImpl;
+class WindowTreeDelegateImpl;
class WebLayerTreeViewImpl;
// A view for a single HTML document.
@@ -49,7 +49,7 @@ class WebLayerTreeViewImpl;
// . When the View the HTMLDocument is embedded in is destroyed.
// . Explicitly by way of Destroy().
class HTMLDocument
- : public mus::ViewTreeDelegate,
+ : public mus::WindowTreeDelegate,
public HTMLFrameDelegate,
public mojo::InterfaceFactory<mojo::AxProvider>,
public mojo::InterfaceFactory<web_view::mojom::FrameClient>,
@@ -95,9 +95,9 @@ class HTMLDocument
// Takes the state from |other|.
void Move(TransferableState* other);
- bool owns_view_tree_connection;
- mus::View* root;
- scoped_ptr<ViewTreeDelegateImpl> view_tree_delegate_impl;
+ bool owns_window_tree_connection;
+ mus::Window* root;
+ scoped_ptr<WindowTreeDelegateImpl> window_tree_delegate_impl;
};
~HTMLDocument() override;
@@ -106,9 +106,9 @@ class HTMLDocument
BeforeLoadCache* GetBeforeLoadCache();
- // ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// HTMLFrameDelegate:
mojo::ApplicationImpl* GetApp() override;
diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc
index 6ff9e91..c1b084d 100644
--- a/components/html_viewer/html_frame.cc
+++ b/components/html_viewer/html_frame.cc
@@ -34,9 +34,9 @@
#include "components/html_viewer/web_layer_tree_view_impl.h"
#include "components/html_viewer/web_storage_namespace_impl.h"
#include "components/html_viewer/web_url_loader_impl.h"
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/vm/ids.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/connect.h"
@@ -74,7 +74,6 @@ using mojo::AxProvider;
using mojo::Rect;
using mojo::ServiceProviderPtr;
using mojo::URLResponsePtr;
-using mus::View;
using web_view::mojom::HTMLMessageEvent;
using web_view::mojom::HTMLMessageEventPtr;
@@ -121,7 +120,7 @@ void RequireCallback(cc::SurfaceId surface_id,
HTMLFrame::HTMLFrame(CreateParams* params)
: frame_tree_manager_(params->manager),
parent_(params->parent),
- view_(nullptr),
+ window_(nullptr),
id_(params->id),
web_frame_(nullptr),
delegate_(params->delegate),
@@ -130,8 +129,8 @@ HTMLFrame::HTMLFrame(CreateParams* params)
if (parent_)
parent_->children_.push_back(this);
- if (params->view && params->view->id() == id_)
- SetView(params->view);
+ if (params->window && params->window->id() == id_)
+ SetWindow(params->window);
SetReplicatedFrameStateFromClientProperties(params->properties, &state_);
@@ -151,14 +150,14 @@ HTMLFrame::HTMLFrame(CreateParams* params)
// The resize and setDeviceScaleFactor() needs to be after setting the main
// frame.
- const gfx::Size size_in_pixels(params->view->bounds().width,
- params->view->bounds().height);
+ const gfx::Size size_in_pixels(params->window->bounds().width,
+ params->window->bounds().height);
const gfx::Size size_in_dips = gfx::ConvertSizeToDIP(
- params->view->viewport_metrics().device_pixel_ratio, size_in_pixels);
+ params->window->viewport_metrics().device_pixel_ratio, size_in_pixels);
web_view()->resize(size_in_dips);
web_frame_ = local_web_frame;
web_view()->setDeviceScaleFactor(global_state()->device_pixel_ratio());
- if (id_ != params->view->id()) {
+ if (id_ != params->window->id()) {
blink::WebRemoteFrame* remote_web_frame =
blink::WebRemoteFrame::create(state_.tree_scope, this);
local_web_frame->swap(remote_web_frame);
@@ -182,8 +181,8 @@ HTMLFrame::HTMLFrame(CreateParams* params)
startup_performance_data_collector_ =
StatsCollectionController::Install(web_frame_, GetApp());
}
- } else if (!params->is_local_create_child && params->view &&
- id_ == params->view->id()) {
+ } else if (!params->is_local_create_child && params->window &&
+ id_ == params->window->id()) {
// Frame represents the local frame, and it isn't the root of the tree.
HTMLFrame* previous_sibling = GetPreviousSibling(this);
blink::WebFrame* previous_web_frame =
@@ -301,9 +300,9 @@ HTMLFrame::~HTMLFrame() {
if (delegate_)
delegate_->OnFrameDestroyed();
- if (view_) {
- view_->RemoveObserver(this);
- mus::ScopedViewPtr::DeleteViewOrViewManager(view_);
+ if (window_) {
+ window_->RemoveObserver(this);
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(window_);
}
}
@@ -324,10 +323,10 @@ blink::WebFrame* HTMLFrame::createChildFrame(
blink::WebSandboxFlags sandbox_flags) {
DCHECK(IsLocal()); // Can't create children of remote frames.
DCHECK_EQ(parent, web_frame_);
- DCHECK(view_); // If we're local we have to have a view.
+ DCHECK(window_); // If we're local we have to have a view.
// Create the view that will house the frame now. We embed once we know the
// url (see decidePolicyForNavigation()).
- mus::View* child_view = view_->connection()->CreateView();
+ mus::Window* child_view = window_->connection()->CreateWindow();
ReplicatedFrameState child_state;
child_state.name = frame_name;
child_state.tree_scope = scope;
@@ -337,7 +336,7 @@ blink::WebFrame* HTMLFrame::createChildFrame(
ClientPropertiesFromReplicatedFrameState(child_state, &client_properties);
child_view->SetVisible(true);
- view_->AddChild(child_view);
+ window_->AddChild(child_view);
HTMLFrame::CreateParams params(frame_tree_manager_, this, child_view->id(),
child_view, client_properties, nullptr);
@@ -345,7 +344,7 @@ blink::WebFrame* HTMLFrame::createChildFrame(
HTMLFrame* child_frame = GetFirstAncestorWithDelegate()
->delegate_->GetHTMLFactory()
->CreateHTMLFrame(&params);
- child_frame->owned_view_.reset(new mus::ScopedViewPtr(child_view));
+ child_frame->owned_window_.reset(new mus::ScopedWindowPtr(child_view));
web_view::mojom::FrameClientPtr client_ptr;
child_frame->frame_client_binding_.reset(
@@ -581,19 +580,19 @@ web_view::mojom::Frame* HTMLFrame::GetServerFrame() {
return frame_tree_manager_->local_frame_->server_.get();
}
-void HTMLFrame::SetView(mus::View* view) {
- if (view_)
- view_->RemoveObserver(this);
- view_ = view;
- if (view_)
- view_->AddObserver(this);
+void HTMLFrame::SetWindow(mus::Window* window) {
+ if (window_)
+ window_->RemoveObserver(this);
+ window_ = window;
+ if (window_)
+ window_->AddObserver(this);
}
void HTMLFrame::CreateRootWebWidget() {
DCHECK(!html_widget_);
- if (view_) {
+ if (window_) {
HTMLWidgetRootLocal::CreateParams create_params(GetApp(), global_state(),
- view_);
+ window_);
html_widget_.reset(
delegate_->GetHTMLFactory()->CreateHTMLWidgetRootLocal(&create_params));
} else {
@@ -605,14 +604,14 @@ void HTMLFrame::CreateLocalRootWebWidget(blink::WebLocalFrame* local_frame) {
DCHECK(!html_widget_);
DCHECK(IsLocal());
html_widget_.reset(
- new HTMLWidgetLocalRoot(GetApp(), global_state(), view_, local_frame));
+ new HTMLWidgetLocalRoot(GetApp(), global_state(), window_, local_frame));
}
void HTMLFrame::UpdateFocus() {
blink::WebWidget* web_widget = GetWebWidget();
- if (!web_widget || !view_)
+ if (!web_widget || !window_)
return;
- const bool is_focused = view_ && view_->HasFocus();
+ const bool is_focused = window_ && window_->HasFocus();
web_widget->setFocus(is_focused);
if (web_widget->isWebView())
static_cast<blink::WebView*>(web_widget)->setIsActive(is_focused);
@@ -632,15 +631,15 @@ void HTMLFrame::SwapToRemote() {
// swap() ends up calling us back and we then close the frame, which deletes
// it.
web_frame_->swap(remote_frame);
- if (owned_view_) {
+ if (owned_window_) {
surface_layer_ =
cc::SurfaceLayer::Create(cc_blink::WebLayerImpl::LayerSettings(),
base::Bind(&SatisfyCallback),
base::Bind(&RequireCallback));
surface_layer_->SetSurfaceId(
- cc::SurfaceId(owned_view_->view()->id()),
+ cc::SurfaceId(owned_window_->window()->id()),
global_state()->device_pixel_ratio(),
- owned_view_->view()->bounds().To<gfx::Rect>().size());
+ owned_window_->window()->bounds().To<gfx::Rect>().size());
web_layer_.reset(new cc_blink::WebLayerImpl(surface_layer_));
}
@@ -655,7 +654,7 @@ void HTMLFrame::SwapToRemote() {
pending_navigation_ = false;
web_frame_ = remote_frame;
- SetView(nullptr);
+ SetWindow(nullptr);
server_.reset();
frame_client_binding_.reset();
if (delegate)
@@ -664,14 +663,14 @@ void HTMLFrame::SwapToRemote() {
void HTMLFrame::SwapToLocal(
HTMLFrameDelegate* delegate,
- mus::View* view,
+ mus::Window* window,
const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties) {
DVLOG(2) << "HTMLFrame::SwapToLocal this=" << this << " id=" << id_;
CHECK(!IsLocal());
// It doesn't make sense for the root to swap to local.
CHECK(parent_);
delegate_ = delegate;
- SetView(view);
+ SetWindow(window);
SetReplicatedFrameStateFromClientProperties(properties, &state_);
blink::WebLocalFrame* local_web_frame =
blink::WebLocalFrame::create(state_.tree_scope, this);
@@ -737,22 +736,23 @@ void HTMLFrame::FrameDetachedImpl(blink::WebFrame* web_frame) {
delete this;
}
-void HTMLFrame::OnViewBoundsChanged(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) {
- DCHECK_EQ(view, view_);
+void HTMLFrame::OnWindowBoundsChanged(mus::Window* window,
+ const Rect& old_bounds,
+ const Rect& new_bounds) {
+ DCHECK_EQ(window, window_);
if (html_widget_)
- html_widget_->OnViewBoundsChanged(view);
+ html_widget_->OnWindowBoundsChanged(window);
}
-void HTMLFrame::OnViewDestroyed(View* view) {
- DCHECK_EQ(view, view_);
- view_->RemoveObserver(this);
- view_ = nullptr;
+void HTMLFrame::OnWindowDestroyed(mus::Window* window) {
+ DCHECK_EQ(window, window_);
+ window_->RemoveObserver(this);
+ window_ = nullptr;
Close();
}
-void HTMLFrame::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
+void HTMLFrame::OnWindowInputEvent(mus::Window* window,
+ const mojo::EventPtr& event) {
if (event->pointer_data && event->pointer_data->location) {
// Blink expects coordintes to be in DIPs.
event->pointer_data->location->x /= global_state()->device_pixel_ratio();
@@ -787,15 +787,15 @@ void HTMLFrame::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
web_widget->handleInputEvent(*web_event);
}
-void HTMLFrame::OnViewFocusChanged(mus::View* gained_focus,
- mus::View* lost_focus) {
+void HTMLFrame::OnWindowFocusChanged(mus::Window* gained_focus,
+ mus::Window* lost_focus) {
UpdateFocus();
}
void HTMLFrame::OnConnect(web_view::mojom::FramePtr frame,
uint32_t change_id,
- uint32_t view_id,
- web_view::mojom::ViewConnectType view_connect_type,
+ uint32_t window_id,
+ web_view::mojom::ViewConnectType window_connect_type,
mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
int64_t navigation_start_time_ticks,
const OnConnectCallback& callback) {
@@ -993,7 +993,7 @@ void HTMLFrame::initializeChildFrame(const blink::WebRect& frame_rect,
const gfx::Rect rect_in_pixels(gfx::ConvertRectToPixel(
global_state()->device_pixel_ratio(), rect_in_dip));
const mojo::RectPtr mojo_rect_in_pixels(mojo::Rect::From(rect_in_pixels));
- view_->SetBounds(*mojo_rect_in_pixels);
+ window_->SetBounds(*mojo_rect_in_pixels);
}
void HTMLFrame::navigate(const blink::WebURLRequest& request,
@@ -1012,7 +1012,7 @@ void HTMLFrame::reload(bool ignore_cache, bool is_client_redirect) {
void HTMLFrame::frameRectsChanged(const blink::WebRect& frame_rect) {
// Only the owner of view can update its size.
- if (!owned_view_)
+ if (!owned_window_)
return;
const gfx::Rect rect_in_dip(frame_rect.x, frame_rect.y, frame_rect.width,
@@ -1020,15 +1020,15 @@ void HTMLFrame::frameRectsChanged(const blink::WebRect& frame_rect) {
const gfx::Rect rect_in_pixels(gfx::ConvertRectToPixel(
global_state()->device_pixel_ratio(), rect_in_dip));
const mojo::RectPtr mojo_rect_in_pixels(mojo::Rect::From(rect_in_pixels));
- owned_view_->view()->SetBounds(*mojo_rect_in_pixels);
+ owned_window_->window()->SetBounds(*mojo_rect_in_pixels);
if (!surface_layer_)
return;
surface_layer_->SetSurfaceId(
- cc::SurfaceId(owned_view_->view()->id()),
+ cc::SurfaceId(owned_window_->window()->id()),
global_state()->device_pixel_ratio(),
- owned_view_->view()->bounds().To<gfx::Rect>().size());
+ owned_window_->window()->bounds().To<gfx::Rect>().size());
}
} // namespace mojo
diff --git a/components/html_viewer/html_frame.h b/components/html_viewer/html_frame.h
index 4e4a128..e444f67 100644
--- a/components/html_viewer/html_frame.h
+++ b/components/html_viewer/html_frame.h
@@ -13,7 +13,7 @@
#include "cc/layers/surface_layer.h"
#include "components/html_viewer/html_frame_tree_manager.h"
#include "components/html_viewer/replicated_frame_state.h"
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window_observer.h"
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
@@ -38,8 +38,8 @@ class Rect;
}
namespace mus {
-class ScopedViewPtr;
-class View;
+class ScopedWindowPtr;
+class Window;
}
namespace html_viewer {
@@ -70,20 +70,20 @@ class WebLayerTreeViewImpl;
class HTMLFrame : public blink::WebFrameClient,
public blink::WebRemoteFrameClient,
public web_view::mojom::FrameClient,
- public mus::ViewObserver {
+ public mus::WindowObserver {
public:
struct CreateParams {
CreateParams(
HTMLFrameTreeManager* manager,
HTMLFrame* parent,
uint32_t id,
- mus::View* view,
+ mus::Window* window,
const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties,
HTMLFrameDelegate* delegate)
: manager(manager),
parent(parent),
id(id),
- view(view),
+ window(window),
properties(properties),
delegate(delegate),
is_local_create_child(false) {}
@@ -92,7 +92,7 @@ class HTMLFrame : public blink::WebFrameClient,
HTMLFrameTreeManager* manager;
HTMLFrame* parent;
uint32_t id;
- mus::View* view;
+ mus::Window* window;
const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties;
HTMLFrameDelegate* delegate;
@@ -134,7 +134,7 @@ class HTMLFrame : public blink::WebFrameClient,
// The mus::View this frame renders to. This is non-null for the local frame
// the frame tree was created with as well as non-null for any frames created
// locally.
- mus::View* view() { return view_; }
+ mus::Window* window() { return window_; }
HTMLFrameTreeManager* frame_tree_manager() { return frame_tree_manager_; }
@@ -228,7 +228,7 @@ class HTMLFrame : public blink::WebFrameClient,
// Gets the server Frame to use for this frame.
web_view::mojom::Frame* GetServerFrame();
- void SetView(mus::View* view);
+ void SetWindow(mus::Window* window);
// Creates the appropriate WebWidget implementation for the Frame.
void CreateRootWebWidget();
@@ -243,7 +243,7 @@ class HTMLFrame : public blink::WebFrameClient,
// Swaps this frame from a remote frame to a local frame.
void SwapToLocal(
HTMLFrameDelegate* delegate,
- mus::View* view,
+ mus::Window* window,
const mojo::Map<mojo::String, mojo::Array<uint8_t>>& properties);
// Invoked when changing the delegate. This informs the new delegate to take
@@ -263,19 +263,20 @@ class HTMLFrame : public blink::WebFrameClient,
// The various frameDetached() implementations call into this.
void FrameDetachedImpl(blink::WebFrame* web_frame);
- // mus::ViewObserver methods:
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override;
- void OnViewDestroyed(mus::View* view) override;
- void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override;
- void OnViewFocusChanged(mus::View* gained_focus,
- mus::View* lost_focus) override;
+ // mus::WindowObserver methods:
+ void OnWindowBoundsChanged(mus::Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override;
+ void OnWindowDestroyed(mus::Window* window) override;
+ void OnWindowInputEvent(mus::Window* window,
+ const mojo::EventPtr& event) override;
+ void OnWindowFocusChanged(mus::Window* gained_focus,
+ mus::Window* lost_focus) override;
// web_view::mojom::FrameClient:
void OnConnect(web_view::mojom::FramePtr server,
uint32_t change_id,
- uint32_t view_id,
+ uint32_t window_id,
web_view::mojom::ViewConnectType view_connect_type,
mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
int64_t navigation_start_time_ticks,
@@ -323,7 +324,7 @@ class HTMLFrame : public blink::WebFrameClient,
HTMLFrame* parent_;
// |view_| is non-null for local frames or remote frames that were once
// local.
- mus::View* view_;
+ mus::Window* window_;
// The id for this frame. If there is a view, this is the same id as the
// view has.
const uint32_t id_;
@@ -343,16 +344,16 @@ class HTMLFrame : public blink::WebFrameClient,
ReplicatedFrameState state_;
// If this frame is the result of creating a local frame
- // (createChildFrame()), then |owned_view_| is the View initially created
- // for the frame. While the frame is local |owned_view_| is the same as
+ // (createChildFrame()), then |owned_window_| is the View initially created
+ // for the frame. While the frame is local |owned_window_| is the same as
// |view_|. If this frame becomes remote |view_| is set to null and
- // |owned_view_| remains as the View initially created for the frame.
+ // |owned_window_| remains as the View initially created for the frame.
//
// This is done to ensure the View isn't prematurely deleted (it must exist
// as long as the frame is valid). If the View was deleted as soon as the
// frame was swapped to remote then the process rendering to the view would
// be severed.
- scoped_ptr<mus::ScopedViewPtr> owned_view_;
+ scoped_ptr<mus::ScopedWindowPtr> owned_window_;
// This object is only valid in the context of performance tests.
tracing::StartupPerformanceDataCollectorPtr
diff --git a/components/html_viewer/html_frame_apptest.cc b/components/html_viewer/html_frame_apptest.cc
index ffdab1d..d7302be 100644
--- a/components/html_viewer/html_frame_apptest.cc
+++ b/components/html_viewer/html_frame_apptest.cc
@@ -13,9 +13,9 @@
#include "base/time/time.h"
#include "base/values.h"
#include "components/html_viewer/public/interfaces/test_html_viewer.mojom.h"
-#include "components/mus/public/cpp/tests/view_manager_test_base.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/tests/window_server_test_base.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/web_view/frame.h"
#include "components/web_view/frame_connection.h"
#include "components/web_view/frame_tree.h"
@@ -25,7 +25,7 @@
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom.h"
-using mus::ViewManagerTestBase;
+using mus::WindowServerTestBase;
using web_view::Frame;
using web_view::FrameConnection;
using web_view::FrameTree;
@@ -43,7 +43,7 @@ const char kAddFrameWithEmptyPageScript[] =
void OnGotContentHandlerForRoot(bool* got_callback) {
*got_callback = true;
- ignore_result(ViewManagerTestBase::QuitRunLoop());
+ ignore_result(WindowServerTestBase::QuitRunLoop());
}
mojo::ApplicationConnection* ApplicationConnectionForFrame(Frame* frame) {
@@ -57,9 +57,9 @@ std::string GetFrameText(ApplicationConnection* connection) {
std::string result;
test_html_viewer->GetContentAsText([&result](const String& mojo_string) {
result = mojo_string;
- ASSERT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ ASSERT_TRUE(WindowServerTestBase::QuitRunLoop());
});
- if (!ViewManagerTestBase::DoRunLoopWithTimeout())
+ if (!WindowServerTestBase::DoRunLoopWithTimeout())
ADD_FAILURE() << "Timed out waiting for execute to complete";
// test_html_viewer.WaitForIncomingResponse();
return result;
@@ -72,9 +72,9 @@ scoped_ptr<base::Value> ExecuteScript(ApplicationConnection* connection,
scoped_ptr<base::Value> result;
test_html_viewer->ExecuteScript(script, [&result](const String& json_string) {
result = base::JSONReader::Read(json_string.To<std::string>());
- ASSERT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ ASSERT_TRUE(WindowServerTestBase::QuitRunLoop());
});
- if (!ViewManagerTestBase::DoRunLoopWithTimeout())
+ if (!WindowServerTestBase::DoRunLoopWithTimeout())
ADD_FAILURE() << "Timed out waiting for execute to complete";
return result.Pass();
}
@@ -100,7 +100,7 @@ class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate {
waiting_for_frame_child_count_->frame = frame;
waiting_for_frame_child_count_->count = count;
- return ViewManagerTestBase::DoRunLoopWithTimeout();
+ return WindowServerTestBase::DoRunLoopWithTimeout();
}
// Returns true if |frame| has navigated. If |frame| hasn't navigated runs
@@ -110,7 +110,7 @@ class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate {
return true;
frames_waiting_for_navigate_.insert(frame);
- return ViewManagerTestBase::DoRunLoopWithTimeout();
+ return WindowServerTestBase::DoRunLoopWithTimeout();
}
// TestFrameTreeDelegate:
@@ -121,12 +121,12 @@ class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate {
DidChildNavigate(waiting_for_frame_child_count_->frame,
waiting_for_frame_child_count_->count)) {
waiting_for_frame_child_count_.reset();
- ASSERT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ ASSERT_TRUE(WindowServerTestBase::QuitRunLoop());
}
if (frames_waiting_for_navigate_.count(frame)) {
frames_waiting_for_navigate_.erase(frame);
- ignore_result(ViewManagerTestBase::QuitRunLoop());
+ ignore_result(WindowServerTestBase::QuitRunLoop());
}
}
@@ -159,7 +159,7 @@ class TestFrameTreeDelegateImpl : public web_view::TestFrameTreeDelegate {
} // namespace
-class HTMLFrameTest : public ViewManagerTestBase {
+class HTMLFrameTest : public WindowServerTestBase {
public:
HTMLFrameTest() {}
~HTMLFrameTest() override {}
@@ -168,11 +168,11 @@ class HTMLFrameTest : public ViewManagerTestBase {
// Creates the frame tree showing an empty page at the root and adds (via
// script) a frame showing the same empty page.
Frame* LoadEmptyPageAndCreateFrame() {
- mus::View* embed_view = window_manager()->CreateView();
+ mus::Window* embed_window = window_manager()->CreateWindow();
frame_tree_delegate_.reset(
new TestFrameTreeDelegateImpl(application_impl()));
- FrameConnection* root_connection =
- InitFrameTree(embed_view, "http://127.0.0.1:%u/files/empty_page2.html");
+ FrameConnection* root_connection = InitFrameTree(
+ embed_window, "http://127.0.0.1:%u/files/empty_page2.html");
if (!root_connection) {
ADD_FAILURE() << "unable to establish root connection";
return nullptr;
@@ -212,7 +212,7 @@ class HTMLFrameTest : public ViewManagerTestBase {
return request.Pass();
}
- FrameConnection* InitFrameTree(mus::View* view,
+ FrameConnection* InitFrameTree(mus::Window* view,
const std::string& url_string) {
frame_tree_delegate_.reset(
new TestFrameTreeDelegateImpl(application_impl()));
@@ -221,7 +221,7 @@ class HTMLFrameTest : public ViewManagerTestBase {
frame_connection->Init(
application_impl(), BuildRequestForURL(url_string),
base::Bind(&OnGotContentHandlerForRoot, &got_callback));
- ignore_result(ViewManagerTestBase::DoRunLoopWithTimeout());
+ ignore_result(WindowServerTestBase::DoRunLoopWithTimeout());
if (!got_callback)
return nullptr;
FrameConnection* result = frame_connection.get();
@@ -237,7 +237,7 @@ class HTMLFrameTest : public ViewManagerTestBase {
// ViewManagerTest:
void SetUp() override {
- ViewManagerTestBase::SetUp();
+ WindowServerTestBase::SetUp();
// Start a test server.
http_server_.reset(new net::SpawnedTestServer(
@@ -248,7 +248,7 @@ class HTMLFrameTest : public ViewManagerTestBase {
void TearDown() override {
frame_tree_.reset();
http_server_.reset();
- ViewManagerTestBase::TearDown();
+ WindowServerTestBase::TearDown();
}
scoped_ptr<net::SpawnedTestServer> http_server_;
@@ -261,10 +261,10 @@ class HTMLFrameTest : public ViewManagerTestBase {
};
TEST_F(HTMLFrameTest, PageWithSingleFrame) {
- mus::View* embed_view = window_manager()->CreateView();
+ mus::Window* embed_window = window_manager()->CreateWindow();
FrameConnection* root_connection = InitFrameTree(
- embed_view, "http://127.0.0.1:%u/files/page_with_single_frame.html");
+ embed_window, "http://127.0.0.1:%u/files/page_with_single_frame.html");
ASSERT_TRUE(root_connection);
ASSERT_EQ("Page with single frame",
@@ -273,9 +273,9 @@ TEST_F(HTMLFrameTest, PageWithSingleFrame) {
ASSERT_NO_FATAL_FAILURE(
frame_tree_delegate_->WaitForChildFrameCount(frame_tree_->root(), 1u));
- ASSERT_EQ(1u, embed_view->children().size());
+ ASSERT_EQ(1u, embed_window->children().size());
Frame* child_frame =
- frame_tree_->root()->FindFrame(embed_view->children()[0]->id());
+ frame_tree_->root()->FindFrame(embed_window->children()[0]->id());
ASSERT_TRUE(child_frame);
ASSERT_EQ("child",
@@ -286,10 +286,10 @@ TEST_F(HTMLFrameTest, PageWithSingleFrame) {
// Creates two frames. The parent navigates the child frame by way of changing
// the location of the child frame.
TEST_F(HTMLFrameTest, ChangeLocationOfChildFrame) {
- mus::View* embed_view = window_manager()->CreateView();
+ mus::Window* embed_window = window_manager()->CreateWindow();
ASSERT_TRUE(InitFrameTree(
- embed_view, "http://127.0.0.1:%u/files/page_with_single_frame.html"));
+ embed_window, "http://127.0.0.1:%u/files/page_with_single_frame.html"));
// page_with_single_frame contains a child frame. The child frame should
// create a new View and Frame.
diff --git a/components/html_viewer/html_frame_tree_manager.cc b/components/html_viewer/html_frame_tree_manager.cc
index 2cefb66..e56a9a2 100644
--- a/components/html_viewer/html_frame_tree_manager.cc
+++ b/components/html_viewer/html_frame_tree_manager.cc
@@ -16,7 +16,7 @@
#include "components/html_viewer/html_frame.h"
#include "components/html_viewer/html_frame_delegate.h"
#include "components/html_viewer/html_frame_tree_manager_observer.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/web_view/web_view_switches.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebRemoteFrame.h"
@@ -69,7 +69,7 @@ HTMLFrameTreeManager::TreeMap* HTMLFrameTreeManager::instances_ = nullptr;
// static
HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
GlobalState* global_state,
- mus::View* view,
+ mus::Window* window,
scoped_ptr<DocumentResourceWaiter> resource_waiter,
HTMLFrameDelegate* delegate) {
if (!instances_)
@@ -79,11 +79,11 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
web_view::mojom::FramePtr server_frame;
mojo::Array<web_view::mojom::FrameDataPtr> frame_data;
uint32_t change_id;
- uint32_t view_id;
+ uint32_t window_id;
web_view::mojom::ViewConnectType view_connect_type;
web_view::mojom::FrameClient::OnConnectCallback on_connect_callback;
resource_waiter->Release(&frame_client_request, &server_frame, &frame_data,
- &change_id, &view_id, &view_connect_type,
+ &change_id, &window_id, &view_connect_type,
&on_connect_callback);
resource_waiter.reset();
@@ -98,7 +98,7 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
<< " frame_tree=" << frame_tree << " use_existing="
<< (view_connect_type ==
web_view::mojom::VIEW_CONNECT_TYPE_USE_EXISTING)
- << " frame_id=" << view_id;
+ << " frame_id=" << window_id;
if (view_connect_type == web_view::mojom::VIEW_CONNECT_TYPE_USE_EXISTING &&
!frame_tree) {
DVLOG(1) << "was told to use existing view but do not have frame tree";
@@ -107,11 +107,11 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
if (!frame_tree) {
frame_tree = new HTMLFrameTreeManager(global_state);
- frame_tree->Init(delegate, view, frame_data, change_id);
+ frame_tree->Init(delegate, window, frame_data, change_id);
(*instances_)[frame_data[0]->frame_id] = frame_tree;
} else if (view_connect_type ==
web_view::mojom::VIEW_CONNECT_TYPE_USE_EXISTING) {
- HTMLFrame* existing_frame = frame_tree->root_->FindFrame(view_id);
+ HTMLFrame* existing_frame = frame_tree->root_->FindFrame(window_id);
if (!existing_frame) {
DVLOG(1) << "was told to use existing view but could not find view";
return nullptr;
@@ -123,14 +123,14 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
existing_frame->SwapDelegate(delegate);
} else {
// We're going to share a frame tree. We should know about the frame.
- CHECK(view->id() != frame_data[0]->frame_id);
- HTMLFrame* existing_frame = frame_tree->root_->FindFrame(view->id());
+ CHECK(window->id() != frame_data[0]->frame_id);
+ HTMLFrame* existing_frame = frame_tree->root_->FindFrame(window->id());
if (existing_frame) {
CHECK(!existing_frame->IsLocal());
size_t frame_data_index = 0u;
- CHECK(FindFrameDataIndex(frame_data, view->id(), &frame_data_index));
+ CHECK(FindFrameDataIndex(frame_data, window->id(), &frame_data_index));
const web_view::mojom::FrameDataPtr& data = frame_data[frame_data_index];
- existing_frame->SwapToLocal(delegate, view, data->client_properties);
+ existing_frame->SwapToLocal(delegate, window, data->client_properties);
} else {
// If we can't find the frame and the change_id of the incoming
// tree is before the change id we've processed, then we removed the
@@ -139,7 +139,7 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
return nullptr;
// We removed the frame but it hasn't been acked yet.
- if (frame_tree->pending_remove_ids_.count(view->id()))
+ if (frame_tree->pending_remove_ids_.count(window->id()))
return nullptr;
// We don't know about the frame, but should. Something is wrong.
@@ -148,7 +148,7 @@ HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree(
}
}
- HTMLFrame* frame = frame_tree->root_->FindFrame(view_id);
+ HTMLFrame* frame = frame_tree->root_->FindFrame(window_id);
DCHECK(frame);
frame->Bind(server_frame.Pass(), frame_client_request.Pass());
return frame;
@@ -219,12 +219,13 @@ HTMLFrameTreeManager::~HTMLFrameTreeManager() {
void HTMLFrameTreeManager::Init(
HTMLFrameDelegate* delegate,
- mus::View* local_view,
+ mus::Window* local_window,
const mojo::Array<web_view::mojom::FrameDataPtr>& frame_data,
uint32_t change_id) {
change_id_ = change_id;
- root_ = BuildFrameTree(delegate, frame_data, local_view->id(), local_view);
- local_frame_ = root_->FindFrame(local_view->id());
+ root_ =
+ BuildFrameTree(delegate, frame_data, local_window->id(), local_window);
+ local_frame_ = root_->FindFrame(local_window->id());
CHECK(local_frame_);
local_frame_->UpdateFocus();
}
@@ -233,7 +234,7 @@ HTMLFrame* HTMLFrameTreeManager::BuildFrameTree(
HTMLFrameDelegate* delegate,
const mojo::Array<web_view::mojom::FrameDataPtr>& frame_data,
uint32_t local_frame_id,
- mus::View* local_view) {
+ mus::Window* local_window) {
std::vector<HTMLFrame*> parents;
HTMLFrame* root = nullptr;
HTMLFrame* last_frame = nullptr;
@@ -246,7 +247,7 @@ HTMLFrame* HTMLFrameTreeManager::BuildFrameTree(
}
HTMLFrame::CreateParams params(this,
!parents.empty() ? parents.back() : nullptr,
- frame_data[i]->frame_id, local_view,
+ frame_data[i]->frame_id, local_window,
frame_data[i]->client_properties, nullptr);
if (frame_data[i]->frame_id == local_frame_id)
params.delegate = delegate;
@@ -347,7 +348,7 @@ void HTMLFrameTreeManager::ProcessOnFrameRemoved(HTMLFrame* source,
return;
}
- // Requests to remove local frames are followed by the View being destroyed.
+ // Requests to remove local frames are followed by the Window being destroyed.
// We handle destruction there.
if (frame->IsLocal())
return;
diff --git a/components/html_viewer/html_frame_tree_manager.h b/components/html_viewer/html_frame_tree_manager.h
index 8ece76d..ef6451b 100644
--- a/components/html_viewer/html_frame_tree_manager.h
+++ b/components/html_viewer/html_frame_tree_manager.h
@@ -19,7 +19,7 @@ class WebView;
}
namespace mus {
-class View;
+class Window;
}
namespace html_viewer {
@@ -34,7 +34,7 @@ class HTMLFrameTreeManagerObserver;
// document. Some of the frames may be remote. HTMLFrameTreeManager updates its
// state in response to changes from the server Frame, as well as changes
// from the underlying frames. The frame tree has at least one local frame
-// that is backed by a mus::View.
+// that is backed by a mus::Window.
class HTMLFrameTreeManager {
public:
// Returns a new HTMLFrame or null if a HTMLFrame does not need to be created.
@@ -42,7 +42,7 @@ class HTMLFrameTreeManager {
// Close() when done.
static HTMLFrame* CreateFrameAndAttachToTree(
GlobalState* global_state,
- mus::View* view,
+ mus::Window* window,
scoped_ptr<DocumentResourceWaiter> resource_waiter,
HTMLFrameDelegate* delegate);
@@ -71,7 +71,7 @@ class HTMLFrameTreeManager {
~HTMLFrameTreeManager();
void Init(HTMLFrameDelegate* delegate,
- mus::View* local_view,
+ mus::Window* local_window,
const mojo::Array<web_view::mojom::FrameDataPtr>& frame_data,
uint32_t change_id);
@@ -80,7 +80,7 @@ class HTMLFrameTreeManager {
HTMLFrameDelegate* delegate,
const mojo::Array<web_view::mojom::FrameDataPtr>& frame_data,
uint32_t local_frame_id,
- mus::View* local_view);
+ mus::Window* local_window);
// Returns this HTMLFrameTreeManager from |instances_|.
void RemoveFromInstances();
diff --git a/components/html_viewer/html_widget.cc b/components/html_viewer/html_widget.cc
index 14c0474..0f34f76 100644
--- a/components/html_viewer/html_widget.cc
+++ b/components/html_viewer/html_widget.cc
@@ -10,7 +10,7 @@
#include "components/html_viewer/stats_collection_controller.h"
#include "components/html_viewer/web_layer_tree_view_impl.h"
#include "components/html_viewer/web_storage_namespace_impl.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h"
@@ -33,22 +33,23 @@ scoped_ptr<WebLayerTreeViewImpl> CreateWebLayerTreeView(
void InitializeWebLayerTreeView(WebLayerTreeViewImpl* web_layer_tree_view,
mojo::ApplicationImpl* app,
- mus::View* view,
+ mus::Window* window,
blink::WebWidget* widget) {
- DCHECK(view);
+ DCHECK(window);
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");
mojo::GpuPtr gpu_service;
app->ConnectToService(request.Pass(), &gpu_service);
- web_layer_tree_view->Initialize(gpu_service.Pass(), view, widget);
+ web_layer_tree_view->Initialize(gpu_service.Pass(), window, widget);
}
-void UpdateWebViewSizeFromViewSize(mus::View* view,
+void UpdateWebViewSizeFromViewSize(mus::Window* window,
blink::WebWidget* web_widget,
WebLayerTreeViewImpl* web_layer_tree_view) {
- const gfx::Size size_in_pixels(view->bounds().width, view->bounds().height);
+ const gfx::Size size_in_pixels(window->bounds().width,
+ window->bounds().height);
const gfx::Size size_in_dips = gfx::ConvertSizeToDIP(
- view->viewport_metrics().device_pixel_ratio, size_in_pixels);
+ window->viewport_metrics().device_pixel_ratio, size_in_pixels);
web_widget->resize(
blink::WebSize(size_in_dips.width(), size_in_dips.height()));
web_layer_tree_view->setViewportSize(size_in_pixels);
@@ -90,31 +91,31 @@ blink::WebWidget* HTMLWidgetRootRemote::GetWidget() {
return web_view_;
}
-void HTMLWidgetRootRemote::OnViewBoundsChanged(mus::View* view) {}
+void HTMLWidgetRootRemote::OnWindowBoundsChanged(mus::Window* window) {}
// HTMLWidgetRootLocal --------------------------------------------------------
HTMLWidgetRootLocal::CreateParams::CreateParams(mojo::ApplicationImpl* app,
GlobalState* global_state,
- mus::View* view)
- : app(app), global_state(global_state), view(view) {}
+ mus::Window* window)
+ : app(app), global_state(global_state), window(window) {}
HTMLWidgetRootLocal::CreateParams::~CreateParams() {}
HTMLWidgetRootLocal::HTMLWidgetRootLocal(CreateParams* create_params)
: app_(create_params->app),
global_state_(create_params->global_state),
- view_(create_params->view),
+ window_(create_params->window),
web_view_(nullptr) {
web_view_ = blink::WebView::create(this);
- ime_controller_.reset(new ImeController(view_, web_view_));
+ ime_controller_.reset(new ImeController(window_, web_view_));
// Creating the widget calls initializeLayerTreeView() to create the
// |web_layer_tree_view_impl_|. As we haven't yet assigned the |web_view_|
// we have to set it here.
if (web_layer_tree_view_impl_) {
- InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view_,
+ InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, window_,
web_view_);
- UpdateWebViewSizeFromViewSize(view_, web_view_,
+ UpdateWebViewSizeFromViewSize(window_, web_view_,
web_layer_tree_view_impl_.get());
}
ConfigureSettings(web_view_->settings());
@@ -169,8 +170,8 @@ blink::WebWidget* HTMLWidgetRootLocal::GetWidget() {
return web_view_;
}
-void HTMLWidgetRootLocal::OnViewBoundsChanged(mus::View* view) {
- UpdateWebViewSizeFromViewSize(view, web_view_,
+void HTMLWidgetRootLocal::OnWindowBoundsChanged(mus::Window* window) {
+ UpdateWebViewSizeFromViewSize(window, web_view_,
web_layer_tree_view_impl_.get());
}
@@ -178,19 +179,19 @@ void HTMLWidgetRootLocal::OnViewBoundsChanged(mus::View* view) {
HTMLWidgetLocalRoot::HTMLWidgetLocalRoot(mojo::ApplicationImpl* app,
GlobalState* global_state,
- mus::View* view,
+ mus::Window* window,
blink::WebLocalFrame* web_local_frame)
: app_(app), global_state_(global_state), web_frame_widget_(nullptr) {
web_frame_widget_ = blink::WebFrameWidget::create(this, web_local_frame);
- ime_controller_.reset(new ImeController(view, web_frame_widget_));
+ ime_controller_.reset(new ImeController(window, web_frame_widget_));
// Creating the widget calls initializeLayerTreeView() to create the
// |web_layer_tree_view_impl_|. As we haven't yet assigned the
// |web_frame_widget_|
// we have to set it here.
if (web_layer_tree_view_impl_) {
- InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, view,
+ InitializeWebLayerTreeView(web_layer_tree_view_impl_.get(), app_, window,
web_frame_widget_);
- UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
+ UpdateWebViewSizeFromViewSize(window, web_frame_widget_,
web_layer_tree_view_impl_.get());
}
}
@@ -201,8 +202,8 @@ blink::WebWidget* HTMLWidgetLocalRoot::GetWidget() {
return web_frame_widget_;
}
-void HTMLWidgetLocalRoot::OnViewBoundsChanged(mus::View* view) {
- UpdateWebViewSizeFromViewSize(view, web_frame_widget_,
+void HTMLWidgetLocalRoot::OnWindowBoundsChanged(mus::Window* window) {
+ UpdateWebViewSizeFromViewSize(window, web_frame_widget_,
web_layer_tree_view_impl_.get());
}
diff --git a/components/html_viewer/html_widget.h b/components/html_viewer/html_widget.h
index 21f7daa..88a2b11 100644
--- a/components/html_viewer/html_widget.h
+++ b/components/html_viewer/html_widget.h
@@ -17,7 +17,7 @@ class ApplicationImpl;
}
namespace mus {
-class View;
+class Window;
}
namespace html_viewer {
@@ -34,7 +34,7 @@ class HTMLWidget {
virtual blink::WebWidget* GetWidget() = 0;
- virtual void OnViewBoundsChanged(mus::View* view) = 0;
+ virtual void OnWindowBoundsChanged(mus::Window* window) = 0;
};
// Used for the root frame when the root frame is remote.
@@ -50,7 +50,7 @@ class HTMLWidgetRootRemote : public HTMLWidget, public blink::WebViewClient {
// HTMLWidget:
blink::WebWidget* GetWidget() override;
- void OnViewBoundsChanged(mus::View* view) override;
+ void OnWindowBoundsChanged(mus::Window* window) override;
blink::WebView* web_view_;
@@ -64,12 +64,12 @@ class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient {
struct CreateParams {
CreateParams(mojo::ApplicationImpl* app,
GlobalState* global_state,
- mus::View* view);
+ mus::Window* window);
~CreateParams();
mojo::ApplicationImpl* app;
GlobalState* global_state;
- mus::View* view;
+ mus::Window* window;
};
HTMLWidgetRootLocal(CreateParams* create_params);
@@ -92,11 +92,11 @@ class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient {
private:
// HTMLWidget:
blink::WebWidget* GetWidget() override;
- void OnViewBoundsChanged(mus::View* view) override;
+ void OnWindowBoundsChanged(mus::Window* window) override;
mojo::ApplicationImpl* app_;
GlobalState* global_state_;
- mus::View* view_;
+ mus::Window* window_;
blink::WebView* web_view_;
scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_;
scoped_ptr<ImeController> ime_controller_;
@@ -109,14 +109,14 @@ class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient {
public:
HTMLWidgetLocalRoot(mojo::ApplicationImpl* app,
GlobalState* global_state,
- mus::View* view,
+ mus::Window* window,
blink::WebLocalFrame* web_local_frame);
~HTMLWidgetLocalRoot() override;
private:
// HTMLWidget:
blink::WebWidget* GetWidget() override;
- void OnViewBoundsChanged(mus::View* view) override;
+ void OnWindowBoundsChanged(mus::Window* window) override;
// WebWidgetClient:
virtual void initializeLayerTreeView();
diff --git a/components/html_viewer/ime_controller.cc b/components/html_viewer/ime_controller.cc
index 9fe06b3..3b65a5a 100644
--- a/components/html_viewer/ime_controller.cc
+++ b/components/html_viewer/ime_controller.cc
@@ -6,14 +6,14 @@
#include "components/html_viewer/blink_input_events_type_converters.h"
#include "components/html_viewer/blink_text_input_type_converters.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebWidget.h"
namespace html_viewer {
-ImeController::ImeController(mus::View* view, blink::WebWidget* widget)
- : view_(view), widget_(widget) {}
+ImeController::ImeController(mus::Window* window, blink::WebWidget* widget)
+ : window_(window), widget_(widget) {}
ImeController::~ImeController() {}
@@ -65,9 +65,9 @@ void ImeController::UpdateTextInputState(bool show_ime) {
state->composition_start = new_info.compositionStart;
state->composition_end = new_info.compositionEnd;
if (show_ime)
- view_->SetImeVisibility(true, state.Pass());
+ window_->SetImeVisibility(true, state.Pass());
else
- view_->SetTextInputState(state.Pass());
+ window_->SetTextInputState(state.Pass());
}
}
diff --git a/components/html_viewer/ime_controller.h b/components/html_viewer/ime_controller.h
index 24923ab..740b5c5 100644
--- a/components/html_viewer/ime_controller.h
+++ b/components/html_viewer/ime_controller.h
@@ -13,7 +13,7 @@ class WebWidget;
}
namespace mus {
-class View;
+class Window;
}
namespace html_viewer {
@@ -22,7 +22,7 @@ namespace html_viewer {
// handling IME related stuff.
class ImeController {
public:
- ImeController(mus::View* view, blink::WebWidget* widget);
+ ImeController(mus::Window* window, blink::WebWidget* widget);
~ImeController();
// Methods called by WebWidget overrides.
@@ -33,13 +33,13 @@ class ImeController {
void ShowImeIfNeeded();
private:
- // Update text input state from WebWidget to mus::View. If the focused
+ // Update text input state from WebWidget to mus::Window. If the focused
// element is editable and |show_ime| is True, the software keyboard will be
// shown.
void UpdateTextInputState(bool show_ime);
// Not owned objects.
- mus::View* view_;
+ mus::Window* window_;
blink::WebWidget* widget_;
blink::WebTextInputInfo text_input_info_;
diff --git a/components/html_viewer/layout_test_content_handler_impl.cc b/components/html_viewer/layout_test_content_handler_impl.cc
index a76f294..169adae 100644
--- a/components/html_viewer/layout_test_content_handler_impl.cc
+++ b/components/html_viewer/layout_test_content_handler_impl.cc
@@ -80,7 +80,7 @@ HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame(
HTMLFrame::CreateParams* params) {
// The test harness isn't correctly set-up for iframes yet. So return a normal
// HTMLFrame for iframes.
- if (params->parent || !params->view || params->view->id() != params->id)
+ if (params->parent || !params->window || params->window->id() != params->id)
return new HTMLFrame(params);
using ProxyType =
diff --git a/components/html_viewer/web_layer_tree_view_impl.cc b/components/html_viewer/web_layer_tree_view_impl.cc
index 9b1f468..c54081e 100644
--- a/components/html_viewer/web_layer_tree_view_impl.cc
+++ b/components/html_viewer/web_layer_tree_view_impl.cc
@@ -12,7 +12,7 @@
#include "cc/trees/layer_tree_host.h"
#include "components/mus/public/cpp/context_provider.h"
#include "components/mus/public/cpp/output_surface.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
#include "third_party/WebKit/public/web/WebWidget.h"
#include "ui/gfx/buffer_types.h"
@@ -23,8 +23,8 @@ WebLayerTreeViewImpl::WebLayerTreeViewImpl(
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
cc::TaskGraphRunner* task_graph_runner)
- : widget_(NULL),
- view_(NULL),
+ : widget_(nullptr),
+ window_(nullptr),
main_thread_compositor_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_factory_(this) {
main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr();
@@ -58,9 +58,9 @@ WebLayerTreeViewImpl::WebLayerTreeViewImpl(
}
void WebLayerTreeViewImpl::Initialize(mojo::GpuPtr gpu_service,
- mus::View* view,
+ mus::Window* window,
blink::WebWidget* widget) {
- view_ = view;
+ window_ = window;
widget_ = widget;
if (gpu_service) {
mojo::CommandBufferPtr cb;
@@ -68,9 +68,9 @@ void WebLayerTreeViewImpl::Initialize(mojo::GpuPtr gpu_service,
scoped_refptr<cc::ContextProvider> context_provider(
new mus::ContextProvider(cb.PassInterface().PassHandle()));
output_surface_.reset(
- new mus::OutputSurface(context_provider, view_->RequestSurface()));
+ new mus::OutputSurface(context_provider, window_->RequestSurface()));
}
- layer_tree_host_->SetVisible(view_->visible());
+ layer_tree_host_->SetVisible(window_->visible());
}
WebLayerTreeViewImpl::~WebLayerTreeViewImpl() {
@@ -196,8 +196,9 @@ void WebLayerTreeViewImpl::registerViewportLayers(
// viewports.
overscrollElasticityLayer
? static_cast<const cc_blink::WebLayerImpl*>(
- overscrollElasticityLayer)->layer()
- : NULL,
+ overscrollElasticityLayer)
+ ->layer()
+ : nullptr,
static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(),
static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer)
->layer(),
@@ -206,7 +207,7 @@ void WebLayerTreeViewImpl::registerViewportLayers(
outerViewportScrollLayer
? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer)
->layer()
- : NULL);
+ : nullptr);
}
void WebLayerTreeViewImpl::clearViewportLayers() {
diff --git a/components/html_viewer/web_layer_tree_view_impl.h b/components/html_viewer/web_layer_tree_view_impl.h
index ed16fab..8ca4302 100644
--- a/components/html_viewer/web_layer_tree_view_impl.h
+++ b/components/html_viewer/web_layer_tree_view_impl.h
@@ -32,10 +32,6 @@ namespace gpu {
class GpuMemoryBufferManager;
}
-namespace mojo {
-class View;
-}
-
namespace html_viewer {
class WebLayerTreeViewImpl : public blink::WebLayerTreeView,
@@ -48,7 +44,7 @@ class WebLayerTreeViewImpl : public blink::WebLayerTreeView,
~WebLayerTreeViewImpl() override;
void Initialize(mojo::GpuPtr gpu_service,
- mus::View* view,
+ mus::Window* window,
blink::WebWidget* widget);
// cc::LayerTreeHostClient implementation.
@@ -112,9 +108,9 @@ class WebLayerTreeViewImpl : public blink::WebLayerTreeView,
virtual void setShowScrollBottleneckRects(bool) {}
private:
- // widget_ and view_ will outlive us.
+ // widget_ and window_ will outlive us.
blink::WebWidget* widget_;
- mus::View* view_;
+ mus::Window* window_;
scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
scoped_ptr<cc::OutputSurface> output_surface_;
scoped_refptr<base::SingleThreadTaskRunner>
diff --git a/components/mus/example/common/mus_views_init.cc b/components/mus/example/common/mus_views_init.cc
index cd2ba59..6c9863d 100644
--- a/components/mus/example/common/mus_views_init.cc
+++ b/components/mus/example/common/mus_views_init.cc
@@ -4,7 +4,7 @@
#include "components/mus/example/common/mus_views_init.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/interfaces/view_tree.mojom.h"
#include "components/mus/public/interfaces/window_manager.mojom.h"
#include "mojo/application/public/cpp/application_connection.h"
@@ -80,7 +80,7 @@ MUSViewsInit::MUSViewsInit(mojo::ApplicationImpl* app)
MUSViewsInit::~MUSViewsInit() {}
-mus::View* MUSViewsInit::CreateWindow() {
+mus::Window* MUSViewsInit::CreateWindow() {
mus::mojom::WindowManagerPtr wm;
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:example_wm";
@@ -89,10 +89,10 @@ mus::View* MUSViewsInit::CreateWindow() {
mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client_request =
GetProxy(&view_tree_client);
wm->OpenWindow(view_tree_client.Pass());
- mus::ViewTreeConnection* view_tree_connection =
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection* view_tree_connection =
+ mus::WindowTreeConnection::Create(
this, view_tree_client_request.Pass(),
- mus::ViewTreeConnection::CreateType::WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED);
DCHECK(view_tree_connection->GetRoot());
return view_tree_connection->GetRoot();
}
@@ -107,10 +107,10 @@ void MUSViewsInit::OnBeforeWidgetInit(
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) {}
-void MUSViewsInit::OnEmbed(mus::View* root) {
+void MUSViewsInit::OnEmbed(mus::Window* root) {
}
-void MUSViewsInit::OnConnectionLost(mus::ViewTreeConnection* connection) {}
+void MUSViewsInit::OnConnectionLost(mus::WindowTreeConnection* connection) {}
#if defined(OS_WIN)
HICON MUSViewsInit::GetSmallWindowIcon() const {
diff --git a/components/mus/example/common/mus_views_init.h b/components/mus/example/common/mus_views_init.h
index cc20fd8..a12bddc 100644
--- a/components/mus/example/common/mus_views_init.h
+++ b/components/mus/example/common/mus_views_init.h
@@ -6,7 +6,7 @@
#define COMPONENTS_MUS_EXAMPLE_COMMON_MUS_VIEWS_INIT_H_
#include "base/memory/scoped_ptr.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "ui/views/mus/aura_init.h"
#include "ui/views/views_delegate.h"
@@ -19,13 +19,14 @@ class AuraInit;
}
// Does the necessary setup to use mus, views and the example wm.
-class MUSViewsInit : public views::ViewsDelegate, public mus::ViewTreeDelegate {
+class MUSViewsInit : public views::ViewsDelegate,
+ public mus::WindowTreeDelegate {
public:
explicit MUSViewsInit(mojo::ApplicationImpl* app);
~MUSViewsInit() override;
private:
- mus::View* CreateWindow();
+ mus::Window* CreateWindow();
// views::ViewsDelegate:
views::NativeWidget* CreateNativeWidget(
@@ -34,9 +35,9 @@ class MUSViewsInit : public views::ViewsDelegate, public mus::ViewTreeDelegate {
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) override;
- // mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
#if defined(OS_WIN)
HICON GetSmallWindowIcon() const override;
#endif
diff --git a/components/mus/example/wm/window_manager_application.cc b/components/mus/example/wm/window_manager_application.cc
index 289c318..79c2e0f 100644
--- a/components/mus/example/wm/window_manager_application.cc
+++ b/components/mus/example/wm/window_manager_application.cc
@@ -7,9 +7,9 @@
#include "components/mus/example/wm/container.h"
#include "components/mus/example/wm/window_manager_impl.h"
#include "components/mus/public/cpp/util.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "mojo/application/public/cpp/application_connection.h"
WindowManagerApplication::WindowManagerApplication()
@@ -17,7 +17,7 @@ WindowManagerApplication::WindowManagerApplication()
WindowManagerApplication::~WindowManagerApplication() {}
void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) {
- mus::CreateSingleViewTreeHost(app, this, &host_);
+ mus::CreateSingleWindowTreeHost(app, this, &host_);
}
bool WindowManagerApplication::ConfigureIncomingConnection(
@@ -26,7 +26,7 @@ bool WindowManagerApplication::ConfigureIncomingConnection(
return true;
}
-void WindowManagerApplication::OnEmbed(mus::View* root) {
+void WindowManagerApplication::OnEmbed(mus::Window* root) {
root_ = root;
CreateContainers();
@@ -35,7 +35,7 @@ void WindowManagerApplication::OnEmbed(mus::View* root) {
}
void WindowManagerApplication::OnConnectionLost(
- mus::ViewTreeConnection* connection) {
+ mus::WindowTreeConnection* connection) {
// TODO(sky): shutdown.
NOTIMPLEMENTED();
}
@@ -54,12 +54,12 @@ void WindowManagerApplication::Create(
void WindowManagerApplication::CreateContainers() {
for (uint16 container = static_cast<uint16>(Container::ALL_USER_BACKGROUND);
container < static_cast<uint16>(Container::COUNT); ++container) {
- mus::View* view = root_->connection()->CreateView();
- DCHECK_EQ(mus::LoWord(view->id()), container)
- << "Containers must be created before other views!";
- view->SetBounds(root_->bounds());
- view->SetVisible(true);
- root_->AddChild(view);
+ mus::Window* window = root_->connection()->CreateWindow();
+ DCHECK_EQ(mus::LoWord(window->id()), container)
+ << "Containers must be created before other windows!";
+ window->SetBounds(root_->bounds());
+ window->SetVisible(true);
+ root_->AddChild(window);
}
}
diff --git a/components/mus/example/wm/window_manager_application.h b/components/mus/example/wm/window_manager_application.h
index 7e73772..79d45e6 100644
--- a/components/mus/example/wm/window_manager_application.h
+++ b/components/mus/example/wm/window_manager_application.h
@@ -8,7 +8,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/view_tree_host.mojom.h"
#include "components/mus/public/interfaces/window_manager.mojom.h"
#include "mojo/application/public/cpp/application_delegate.h"
@@ -16,13 +16,13 @@
class WindowManagerApplication
: public mojo::ApplicationDelegate,
- public mus::ViewTreeDelegate,
+ public mus::WindowTreeDelegate,
public mojo::InterfaceFactory<mus::mojom::WindowManager> {
public:
WindowManagerApplication();
~WindowManagerApplication() override;
- mus::View* root() { return root_; }
+ mus::Window* root() { return root_; }
int window_count() { return window_count_; }
void IncrementWindowCount() { ++window_count_; }
@@ -34,8 +34,8 @@ class WindowManagerApplication
mojo::ApplicationConnection* connection) override;
// ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// InterfaceFactory<mus::mojom::WindowManager>:
void Create(
@@ -46,7 +46,7 @@ class WindowManagerApplication
void CreateContainers();
// nullptr until the Mus connection is established via OnEmbed().
- mus::View* root_;
+ mus::Window* root_;
int window_count_;
mojo::ViewTreeHostPtr host_;
diff --git a/components/mus/example/wm/window_manager_impl.cc b/components/mus/example/wm/window_manager_impl.cc
index 65681c9..256fa14 100644
--- a/components/mus/example/wm/window_manager_impl.cc
+++ b/components/mus/example/wm/window_manager_impl.cc
@@ -7,13 +7,13 @@
#include "components/mus/example/wm/container.h"
#include "components/mus/example/wm/window_manager_application.h"
#include "components/mus/public/cpp/types.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
namespace {
-mus::Id GetViewIdForContainer(mus::ViewTreeConnection* connection,
- Container container) {
+mus::Id GetWindowIdForContainer(mus::WindowTreeConnection* connection,
+ Container container) {
return connection->GetConnectionId() << 16 | static_cast<uint16>(container);
}
@@ -29,29 +29,29 @@ WindowManagerImpl::WindowManagerImpl(
WindowManagerImpl::~WindowManagerImpl() {}
void WindowManagerImpl::OpenWindow(mojo::ViewTreeClientPtr client) {
- mus::View* root = state_->root();
+ mus::Window* root = state_->root();
DCHECK(root);
- mus::Id container_view_id = GetViewIdForContainer(root->connection(),
- Container::USER_WINDOWS);
- mus::View* container_view = root->GetChildById(container_view_id);
+ mus::Id container_window_id =
+ GetWindowIdForContainer(root->connection(), Container::USER_WINDOWS);
+ mus::Window* container_window = root->GetChildById(container_window_id);
const int width = (root->bounds().width - 240);
const int height = (root->bounds().height - 240);
- mus::View* child_view = root->connection()->CreateView();
+ mus::Window* child_window = root->connection()->CreateWindow();
mojo::Rect bounds;
bounds.x = 40 + (state_->window_count() % 4) * 40;
bounds.y = 40 + (state_->window_count() % 4) * 40;
bounds.width = width;
bounds.height = height;
- child_view->SetBounds(bounds);
- container_view->AddChild(child_view);
- child_view->Embed(client.Pass());
+ child_window->SetBounds(bounds);
+ container_window->AddChild(child_window);
+ child_window->Embed(client.Pass());
state_->IncrementWindowCount();
}
-void WindowManagerImpl::CenterWindow(uint32_t view_id, mojo::SizePtr size) {
+void WindowManagerImpl::CenterWindow(uint32_t window_id, mojo::SizePtr size) {
// TODO(beng):
}
diff --git a/components/mus/example/wm/window_manager_impl.h b/components/mus/example/wm/window_manager_impl.h
index 6a82495..d0a2348 100644
--- a/components/mus/example/wm/window_manager_impl.h
+++ b/components/mus/example/wm/window_manager_impl.h
@@ -20,7 +20,7 @@ class WindowManagerImpl : public mus::mojom::WindowManager {
private:
// mus::mojom::WindowManager:
void OpenWindow(mojo::ViewTreeClientPtr client) override;
- void CenterWindow(uint32_t view_id, mojo::SizePtr size) override;
+ void CenterWindow(uint32_t window_id, mojo::SizePtr size) override;
void GetDisplays(const GetDisplaysCallback& callback) override;
WindowManagerApplication* state_;
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc
index 963cc7b..3cb357a 100644
--- a/components/mus/mus_app.cc
+++ b/components/mus/mus_app.cc
@@ -122,7 +122,7 @@ void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection,
new GpuImpl(request.Pass(), gpu_state_);
}
-void MandolineUIServicesApp::CreateViewTreeHost(
+void MandolineUIServicesApp::CreateWindowTreeHost(
mojo::InterfaceRequest<mojo::ViewTreeHost> host,
mojo::ViewTreeHostClientPtr host_client,
mojo::ViewTreeClientPtr tree_client) {
diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h
index 9a7e8f5..c46ab0c 100644
--- a/components/mus/mus_app.h
+++ b/components/mus/mus_app.h
@@ -75,9 +75,9 @@ class MandolineUIServicesApp
mojo::InterfaceRequest<mojo::Gpu> request) override;
// mojo::ViewTreeHostFactory implementation.
- void CreateViewTreeHost(mojo::InterfaceRequest<mojo::ViewTreeHost> host,
- mojo::ViewTreeHostClientPtr host_client,
- mojo::ViewTreeClientPtr tree_client) override;
+ void CreateWindowTreeHost(mojo::InterfaceRequest<mojo::ViewTreeHost> host,
+ mojo::ViewTreeHostClientPtr host_client,
+ mojo::ViewTreeClientPtr tree_client) override;
mojo::WeakBindingSet<mojo::ViewTreeHostFactory> factory_bindings_;
mojo::ApplicationImpl* app_impl_;
diff --git a/components/mus/public/cpp/BUILD.gn b/components/mus/public/cpp/BUILD.gn
index 51304e3..27bdbce 100644
--- a/components/mus/public/cpp/BUILD.gn
+++ b/components/mus/public/cpp/BUILD.gn
@@ -10,28 +10,28 @@ mojo_sdk_source_set("cpp") {
"context_provider.h",
"lib/context_provider.cc",
"lib/output_surface.cc",
- "lib/scoped_view_ptr.cc",
- "lib/view.cc",
- "lib/view_observer.cc",
- "lib/view_private.cc",
- "lib/view_private.h",
- "lib/view_surface.cc",
- "lib/view_tree_client_impl.cc",
- "lib/view_tree_client_impl.h",
- "lib/view_tree_delegate.cc",
- "lib/view_tree_host_factory.cc",
+ "lib/scoped_window_ptr.cc",
+ "lib/window.cc",
+ "lib/window_observer.cc",
+ "lib/window_private.cc",
+ "lib/window_private.h",
+ "lib/window_surface.cc",
+ "lib/window_tree_client_impl.cc",
+ "lib/window_tree_client_impl.h",
+ "lib/window_tree_delegate.cc",
+ "lib/window_tree_host_factory.cc",
"output_surface.h",
- "scoped_view_ptr.h",
- "view.h",
- "view_observer.h",
- "view_property.h",
- "view_surface.h",
- "view_surface_client.h",
- "view_tracker.cc",
- "view_tracker.h",
- "view_tree_connection.h",
- "view_tree_delegate.h",
- "view_tree_host_factory.h",
+ "scoped_window_ptr.h",
+ "window.h",
+ "window_observer.h",
+ "window_property.h",
+ "window_surface.h",
+ "window_surface_client.h",
+ "window_tracker.cc",
+ "window_tracker.h",
+ "window_tree_connection.h",
+ "window_tree_delegate.h",
+ "window_tree_host_factory.h",
]
public_deps = [
diff --git a/components/mus/public/cpp/lib/output_surface.cc b/components/mus/public/cpp/lib/output_surface.cc
index 77b2422..5b195f7 100644
--- a/components/mus/public/cpp/lib/output_surface.cc
+++ b/components/mus/public/cpp/lib/output_surface.cc
@@ -8,14 +8,14 @@
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/output_surface_client.h"
-#include "components/mus/public/cpp/view_surface.h"
+#include "components/mus/public/cpp/window_surface.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
namespace mus {
OutputSurface::OutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider,
- scoped_ptr<mus::ViewSurface> surface)
+ scoped_ptr<mus::WindowSurface> surface)
: cc::OutputSurface(context_provider), surface_(surface.Pass()) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -37,7 +37,7 @@ void OutputSurface::DetachFromClient() {
void OutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
// TODO(fsamuel, rjkroege): We should probably throttle compositor frames.
client_->DidSwapBuffers();
- // OutputSurface owns ViewSurface, and so if OutputSurface is
+ // OutputSurface owns WindowSurface, and so if OutputSurface is
// destroyed then SubmitCompositorFrame's callback will never get called.
// Thus, base::Unretained is safe here.
surface_->SubmitCompositorFrame(
@@ -46,7 +46,7 @@ void OutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
}
void OutputSurface::OnResourcesReturned(
- mus::ViewSurface* surface,
+ mus::WindowSurface* surface,
mojo::Array<mojo::ReturnedResourcePtr> resources) {
cc::CompositorFrameAck cfa;
cfa.resources = resources.To<cc::ReturnedResourceArray>();
diff --git a/components/mus/public/cpp/lib/scoped_view_ptr.cc b/components/mus/public/cpp/lib/scoped_view_ptr.cc
deleted file mode 100644
index 4c41709..0000000
--- a/components/mus/public/cpp/lib/scoped_view_ptr.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-
-namespace mus {
-
-ScopedViewPtr::ScopedViewPtr(View* view) : view_(view) {
- view_->AddObserver(this);
-}
-
-ScopedViewPtr::~ScopedViewPtr() {
- if (view_)
- DeleteViewOrViewManager(view_);
- DetachFromView();
-}
-
-// static
-void ScopedViewPtr::DeleteViewOrViewManager(View* view) {
- if (view->connection()->GetRoot() == view)
- delete view->connection();
- else
- view->Destroy();
-}
-
-void ScopedViewPtr::DetachFromView() {
- if (!view_)
- return;
-
- view_->RemoveObserver(this);
- view_ = nullptr;
-}
-
-void ScopedViewPtr::OnViewDestroying(View* view) {
- DCHECK_EQ(view_, view);
- DetachFromView();
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/lib/scoped_window_ptr.cc b/components/mus/public/cpp/lib/scoped_window_ptr.cc
new file mode 100644
index 0000000..cf734cb
--- /dev/null
+++ b/components/mus/public/cpp/lib/scoped_window_ptr.cc
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+
+namespace mus {
+
+ScopedWindowPtr::ScopedWindowPtr(Window* window) : window_(window) {
+ window_->AddObserver(this);
+}
+
+ScopedWindowPtr::~ScopedWindowPtr() {
+ if (window_)
+ DeleteWindowOrWindowManager(window_);
+ DetachFromWindow();
+}
+
+// static
+void ScopedWindowPtr::DeleteWindowOrWindowManager(Window* window) {
+ if (window->connection()->GetRoot() == window)
+ delete window->connection();
+ else
+ window->Destroy();
+}
+
+void ScopedWindowPtr::DetachFromWindow() {
+ if (!window_)
+ return;
+
+ window_->RemoveObserver(this);
+ window_ = nullptr;
+}
+
+void ScopedWindowPtr::OnWindowDestroying(Window* window) {
+ DCHECK_EQ(window_, window);
+ DetachFromWindow();
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/lib/view_private.cc b/components/mus/public/cpp/lib/view_private.cc
deleted file mode 100644
index 8cee1cc..0000000
--- a/components/mus/public/cpp/lib/view_private.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/lib/view_private.h"
-
-namespace mus {
-
-ViewPrivate::ViewPrivate(View* view) : view_(view) {
- CHECK(view);
-}
-
-ViewPrivate::~ViewPrivate() {}
-
-// static
-View* ViewPrivate::LocalCreate() {
- return new View;
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/lib/view_private.h b/components/mus/public/cpp/lib/view_private.h
deleted file mode 100644
index 56b20aa..0000000
--- a/components/mus/public/cpp/lib/view_private.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
-
-#include "components/mus/public/cpp/view.h"
-
-namespace mus {
-
-// This class is a friend of a View and contains functions to mutate internal
-// state of View.
-class ViewPrivate {
- public:
- explicit ViewPrivate(View* view);
- ~ViewPrivate();
-
- // Creates and returns a new View. Caller owns the return value.
- static View* LocalCreate();
-
- base::ObserverList<ViewObserver>* observers() { return &view_->observers_; }
-
- void ClearParent() { view_->parent_ = NULL; }
-
- void set_visible(bool visible) { view_->visible_ = visible; }
-
- void set_drawn(bool drawn) { view_->drawn_ = drawn; }
-
- void set_id(Id id) { view_->id_ = id; }
-
- void set_connection(ViewTreeConnection* connection) {
- view_->connection_ = connection;
- }
-
- void set_properties(const std::map<std::string, std::vector<uint8_t>>& data) {
- view_->properties_ = data;
- }
-
- void LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics,
- const mojo::ViewportMetrics& new_metrics) {
- view_->LocalSetViewportMetrics(new_metrics, new_metrics);
- }
-
- void LocalDestroy() { view_->LocalDestroy(); }
- void LocalAddChild(View* child) { view_->LocalAddChild(child); }
- void LocalRemoveChild(View* child) { view_->LocalRemoveChild(child); }
- void LocalReorder(View* relative, mojo::OrderDirection direction) {
- view_->LocalReorder(relative, direction);
- }
- void LocalSetBounds(const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
- view_->LocalSetBounds(old_bounds, new_bounds);
- }
- void LocalSetDrawn(bool drawn) { view_->LocalSetDrawn(drawn); }
- void LocalSetVisible(bool visible) { view_->LocalSetVisible(visible); }
-
- private:
- View* view_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewPrivate);
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
diff --git a/components/mus/public/cpp/lib/view_tree_client_impl.cc b/components/mus/public/cpp/lib/view_tree_client_impl.cc
deleted file mode 100644
index bd2a8eb..0000000
--- a/components/mus/public/cpp/lib/view_tree_client_impl.cc
+++ /dev/null
@@ -1,449 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/lib/view_tree_client_impl.h"
-
-#include "components/mus/public/cpp/lib/view_private.h"
-#include "components/mus/public/cpp/util.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
-#include "mojo/application/public/cpp/application_impl.h"
-#include "mojo/application/public/cpp/connect.h"
-#include "mojo/application/public/cpp/service_provider_impl.h"
-#include "mojo/application/public/interfaces/service_provider.mojom.h"
-
-namespace mus {
-
-Id MakeTransportId(ConnectionSpecificId connection_id,
- ConnectionSpecificId local_id) {
- return (connection_id << 16) | local_id;
-}
-
-// Helper called to construct a local view object from transport data.
-View* AddViewToConnection(ViewTreeClientImpl* client,
- View* parent,
- const mojo::ViewDataPtr& view_data) {
- // We don't use the cto that takes a ViewTreeConnection here, since it will
- // call back to the service and attempt to create a new view.
- View* view = ViewPrivate::LocalCreate();
- ViewPrivate private_view(view);
- private_view.set_connection(client);
- private_view.set_id(view_data->view_id);
- private_view.set_visible(view_data->visible);
- private_view.set_drawn(view_data->drawn);
- private_view.LocalSetViewportMetrics(mojo::ViewportMetrics(),
- *view_data->viewport_metrics);
- private_view.set_properties(
- view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>());
- client->AddView(view);
- private_view.LocalSetBounds(mojo::Rect(), *view_data->bounds);
- if (parent)
- ViewPrivate(parent).LocalAddChild(view);
- return view;
-}
-
-View* BuildViewTree(ViewTreeClientImpl* client,
- const mojo::Array<mojo::ViewDataPtr>& views,
- View* initial_parent) {
- std::vector<View*> parents;
- View* root = NULL;
- View* last_view = NULL;
- if (initial_parent)
- parents.push_back(initial_parent);
- for (size_t i = 0; i < views.size(); ++i) {
- if (last_view && views[i]->parent_id == last_view->id()) {
- parents.push_back(last_view);
- } else if (!parents.empty()) {
- while (parents.back()->id() != views[i]->parent_id)
- parents.pop_back();
- }
- View* view = AddViewToConnection(
- client, !parents.empty() ? parents.back() : NULL, views[i]);
- if (!last_view)
- root = view;
- last_view = view;
- }
- return root;
-}
-
-ViewTreeConnection* ViewTreeConnection::Create(
- ViewTreeDelegate* delegate,
- mojo::InterfaceRequest<mojo::ViewTreeClient> request,
- CreateType create_type) {
- ViewTreeClientImpl* client = new ViewTreeClientImpl(delegate, request.Pass());
- if (create_type == CreateType::WAIT_FOR_EMBED)
- client->WaitForEmbed();
- return client;
-}
-
-ViewTreeClientImpl::ViewTreeClientImpl(
- ViewTreeDelegate* delegate,
- mojo::InterfaceRequest<mojo::ViewTreeClient> request)
- : connection_id_(0),
- next_id_(1),
- delegate_(delegate),
- root_(nullptr),
- capture_view_(nullptr),
- focused_view_(nullptr),
- activated_view_(nullptr),
- binding_(this, request.Pass()),
- is_embed_root_(false),
- in_destructor_(false) {}
-
-ViewTreeClientImpl::~ViewTreeClientImpl() {
- in_destructor_ = true;
-
- std::vector<View*> non_owned;
- while (!views_.empty()) {
- IdToViewMap::iterator it = views_.begin();
- if (OwnsView(it->second->id())) {
- it->second->Destroy();
- } else {
- non_owned.push_back(it->second);
- views_.erase(it);
- }
- }
-
- // Delete the non-owned views last. In the typical case these are roots. The
- // exception is the window manager and embed roots, which may know about
- // other random views that it doesn't own.
- // NOTE: we manually delete as we're a friend.
- for (size_t i = 0; i < non_owned.size(); ++i)
- delete non_owned[i];
-
- delegate_->OnConnectionLost(this);
-}
-
-void ViewTreeClientImpl::WaitForEmbed() {
- DCHECK(!root_);
- // OnEmbed() is the first function called.
- binding_.WaitForIncomingMethodCall();
- // TODO(sky): deal with pipe being closed before we get OnEmbed().
-}
-
-void ViewTreeClientImpl::DestroyView(Id view_id) {
- DCHECK(tree_);
- tree_->DeleteView(view_id, ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::AddChild(Id child_id, Id parent_id) {
- DCHECK(tree_);
- tree_->AddView(parent_id, child_id, ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::RemoveChild(Id child_id, Id parent_id) {
- DCHECK(tree_);
- tree_->RemoveViewFromParent(child_id, ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::Reorder(Id view_id,
- Id relative_view_id,
- mojo::OrderDirection direction) {
- DCHECK(tree_);
- tree_->ReorderView(view_id, relative_view_id, direction,
- ActionCompletedCallback());
-}
-
-bool ViewTreeClientImpl::OwnsView(Id id) const {
- return HiWord(id) == connection_id_;
-}
-
-void ViewTreeClientImpl::SetBounds(Id view_id, const mojo::Rect& bounds) {
- DCHECK(tree_);
- tree_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::SetFocus(Id view_id) {
- // In order for us to get here we had to have exposed a view, which implies we
- // got a connection.
- DCHECK(tree_);
- tree_->SetFocus(view_id);
-}
-
-void ViewTreeClientImpl::SetVisible(Id view_id, bool visible) {
- DCHECK(tree_);
- tree_->SetViewVisibility(view_id, visible, ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::SetProperty(Id view_id,
- const std::string& name,
- const std::vector<uint8_t>& data) {
- DCHECK(tree_);
- tree_->SetViewProperty(view_id, mojo::String(name),
- mojo::Array<uint8_t>::From(data),
- ActionCompletedCallback());
-}
-
-void ViewTreeClientImpl::SetViewTextInputState(Id view_id,
- mojo::TextInputStatePtr state) {
- DCHECK(tree_);
- tree_->SetViewTextInputState(view_id, state.Pass());
-}
-
-void ViewTreeClientImpl::SetImeVisibility(Id view_id,
- bool visible,
- mojo::TextInputStatePtr state) {
- DCHECK(tree_);
- tree_->SetImeVisibility(view_id, visible, state.Pass());
-}
-
-void ViewTreeClientImpl::Embed(Id view_id,
- mojo::ViewTreeClientPtr client,
- uint32_t policy_bitmask,
- const mojo::ViewTree::EmbedCallback& callback) {
- DCHECK(tree_);
- tree_->Embed(view_id, client.Pass(), policy_bitmask, callback);
-}
-
-void ViewTreeClientImpl::RequestSurface(
- Id view_id,
- mojo::InterfaceRequest<mojo::Surface> surface,
- mojo::SurfaceClientPtr client) {
- DCHECK(tree_);
- tree_->RequestSurface(view_id, surface.Pass(), client.Pass());
-}
-
-void ViewTreeClientImpl::AddView(View* view) {
- DCHECK(views_.find(view->id()) == views_.end());
- views_[view->id()] = view;
-}
-
-void ViewTreeClientImpl::RemoveView(Id view_id) {
- if (focused_view_ && focused_view_->id() == view_id)
- OnViewFocused(0);
-
- IdToViewMap::iterator it = views_.find(view_id);
- if (it != views_.end())
- views_.erase(it);
-}
-
-void ViewTreeClientImpl::OnRootDestroyed(View* root) {
- DCHECK_EQ(root, root_);
- root_ = nullptr;
-
- // When the root is gone we can't do anything useful.
- if (!in_destructor_)
- delete this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewTreeClientImpl, ViewTreeConnection implementation:
-
-Id ViewTreeClientImpl::CreateViewOnServer() {
- DCHECK(tree_);
- const Id view_id = MakeTransportId(connection_id_, next_id_++);
- tree_->CreateView(view_id, [this](mojo::ErrorCode code) {
- OnActionCompleted(code == mojo::ERROR_CODE_NONE);
- });
- return view_id;
-}
-
-View* ViewTreeClientImpl::GetRoot() {
- return root_;
-}
-
-View* ViewTreeClientImpl::GetViewById(Id id) {
- IdToViewMap::const_iterator it = views_.find(id);
- return it != views_.end() ? it->second : NULL;
-}
-
-View* ViewTreeClientImpl::GetFocusedView() {
- return focused_view_;
-}
-
-View* ViewTreeClientImpl::CreateView() {
- View* view = new View(this, CreateViewOnServer());
- AddView(view);
- return view;
-}
-
-bool ViewTreeClientImpl::IsEmbedRoot() {
- return is_embed_root_;
-}
-
-ConnectionSpecificId ViewTreeClientImpl::GetConnectionId() {
- return connection_id_;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewTreeClientImpl, ViewTreeClient implementation:
-
-void ViewTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id,
- mojo::ViewDataPtr root_data,
- mojo::ViewTreePtr tree,
- Id focused_view_id,
- uint32 access_policy) {
- if (tree) {
- DCHECK(!tree_);
- tree_ = tree.Pass();
- tree_.set_connection_error_handler([this]() { delete this; });
- }
- connection_id_ = connection_id;
- is_embed_root_ =
- (access_policy & mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0;
-
- DCHECK(!root_);
- root_ = AddViewToConnection(this, nullptr, root_data);
-
- focused_view_ = GetViewById(focused_view_id);
-
- delegate_->OnEmbed(root_);
-}
-
-void ViewTreeClientImpl::OnEmbeddedAppDisconnected(Id view_id) {
- View* view = GetViewById(view_id);
- if (view) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(),
- OnViewEmbeddedAppDisconnected(view));
- }
-}
-
-void ViewTreeClientImpl::OnUnembed() {
- delegate_->OnUnembed();
- // This will send out the various notifications.
- delete this;
-}
-
-void ViewTreeClientImpl::OnViewBoundsChanged(Id view_id,
- mojo::RectPtr old_bounds,
- mojo::RectPtr new_bounds) {
- View* view = GetViewById(view_id);
- ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds);
-}
-
-namespace {
-
-void SetViewportMetricsOnDecendants(View* root,
- const mojo::ViewportMetrics& old_metrics,
- const mojo::ViewportMetrics& new_metrics) {
- ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics);
- const View::Children& children = root->children();
- for (size_t i = 0; i < children.size(); ++i)
- SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics);
-}
-}
-
-void ViewTreeClientImpl::OnViewViewportMetricsChanged(
- mojo::ViewportMetricsPtr old_metrics,
- mojo::ViewportMetricsPtr new_metrics) {
- View* view = GetRoot();
- if (view)
- SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics);
-}
-
-void ViewTreeClientImpl::OnViewHierarchyChanged(
- Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- mojo::Array<mojo::ViewDataPtr> views) {
- View* initial_parent = views.size() ? GetViewById(views[0]->parent_id) : NULL;
-
- const bool was_view_known = GetViewById(view_id) != nullptr;
-
- BuildViewTree(this, views, initial_parent);
-
- // If the view was not known, then BuildViewTree() will have created it and
- // parented the view.
- if (!was_view_known)
- return;
-
- View* new_parent = GetViewById(new_parent_id);
- View* old_parent = GetViewById(old_parent_id);
- View* view = GetViewById(view_id);
- if (new_parent)
- ViewPrivate(new_parent).LocalAddChild(view);
- else
- ViewPrivate(old_parent).LocalRemoveChild(view);
-}
-
-void ViewTreeClientImpl::OnViewReordered(Id view_id,
- Id relative_view_id,
- mojo::OrderDirection direction) {
- View* view = GetViewById(view_id);
- View* relative_view = GetViewById(relative_view_id);
- if (view && relative_view)
- ViewPrivate(view).LocalReorder(relative_view, direction);
-}
-
-void ViewTreeClientImpl::OnViewDeleted(Id view_id) {
- View* view = GetViewById(view_id);
- if (view)
- ViewPrivate(view).LocalDestroy();
-}
-
-void ViewTreeClientImpl::OnViewVisibilityChanged(Id view_id, bool visible) {
- // TODO(sky): there is a race condition here. If this client and another
- // client change the visibility at the same time the wrong value may be set.
- // Deal with this some how.
- View* view = GetViewById(view_id);
- if (view)
- ViewPrivate(view).LocalSetVisible(visible);
-}
-
-void ViewTreeClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) {
- View* view = GetViewById(view_id);
- if (view)
- ViewPrivate(view).LocalSetDrawn(drawn);
-}
-
-void ViewTreeClientImpl::OnViewSharedPropertyChanged(
- Id view_id,
- const mojo::String& name,
- mojo::Array<uint8_t> new_data) {
- View* view = GetViewById(view_id);
- if (view) {
- std::vector<uint8_t> data;
- std::vector<uint8_t>* data_ptr = NULL;
- if (!new_data.is_null()) {
- data = new_data.To<std::vector<uint8_t>>();
- data_ptr = &data;
- }
-
- view->SetSharedProperty(name, data_ptr);
- }
-}
-
-void ViewTreeClientImpl::OnViewInputEvent(
- Id view_id,
- mojo::EventPtr event,
- const mojo::Callback<void()>& ack_callback) {
- View* view = GetViewById(view_id);
- if (view) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(),
- OnViewInputEvent(view, event));
- }
- ack_callback.Run();
-}
-
-void ViewTreeClientImpl::OnViewFocused(Id focused_view_id) {
- View* focused = GetViewById(focused_view_id);
- View* blurred = focused_view_;
- // Update |focused_view_| before calling any of the observers, so that the
- // observers get the correct result from calling |View::HasFocus()|,
- // |ViewTreeConnection::GetFocusedView()| etc.
- focused_view_ = focused;
- if (blurred) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(blurred).observers(),
- OnViewFocusChanged(focused, blurred));
- }
- if (focused) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(focused).observers(),
- OnViewFocusChanged(focused, blurred));
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewTreeClientImpl, private:
-
-void ViewTreeClientImpl::OnActionCompleted(bool success) {
- if (!change_acked_callback_.is_null())
- change_acked_callback_.Run();
-}
-
-mojo::Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() {
- return [this](bool success) { OnActionCompleted(success); };
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/lib/view_tree_client_impl.h b/components/mus/public/cpp/lib/view_tree_client_impl.h
deleted file mode 100644
index b532c73..0000000
--- a/components/mus/public/cpp/lib/view_tree_client_impl.h
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_
-
-#include "components/mus/public/cpp/types.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/interfaces/view_tree.mojom.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
-
-namespace mus {
-class ViewTreeConnection;
-class ViewTreeDelegate;
-
-// Manages the connection with the View Manager service.
-class ViewTreeClientImpl : public ViewTreeConnection,
- public mojo::ViewTreeClient {
- public:
- ViewTreeClientImpl(ViewTreeDelegate* delegate,
- mojo::InterfaceRequest<mojo::ViewTreeClient> request);
- ~ViewTreeClientImpl() override;
-
- // Wait for OnEmbed(), returning when done.
- void WaitForEmbed();
-
- bool connected() const { return tree_; }
- ConnectionSpecificId connection_id() const { return connection_id_; }
-
- // API exposed to the view implementations that pushes local changes to the
- // service.
- void DestroyView(Id view_id);
-
- // These methods take TransportIds. For views owned by the current connection,
- // the connection id high word can be zero. In all cases, the TransportId 0x1
- // refers to the root view.
- void AddChild(Id child_id, Id parent_id);
- void RemoveChild(Id child_id, Id parent_id);
-
- void Reorder(Id view_id, Id relative_view_id, mojo::OrderDirection direction);
-
- // Returns true if the specified view was created by this connection.
- bool OwnsView(Id id) const;
-
- void SetBounds(Id view_id, const mojo::Rect& bounds);
- void SetFocus(Id view_id);
- void SetVisible(Id view_id, bool visible);
- void SetProperty(Id view_id,
- const std::string& name,
- const std::vector<uint8_t>& data);
- void SetViewTextInputState(Id view_id, mojo::TextInputStatePtr state);
- void SetImeVisibility(Id view_id,
- bool visible,
- mojo::TextInputStatePtr state);
-
- void Embed(Id view_id,
- mojo::ViewTreeClientPtr client,
- uint32_t policy_bitmask,
- const mojo::ViewTree::EmbedCallback& callback);
-
- void RequestSurface(Id view_id,
- mojo::InterfaceRequest<mojo::Surface> surface,
- mojo::SurfaceClientPtr client);
-
- void set_change_acked_callback(const mojo::Callback<void(void)>& callback) {
- change_acked_callback_ = callback;
- }
- void ClearChangeAckedCallback() { change_acked_callback_.reset(); }
-
- // Start/stop tracking views. While tracked, they can be retrieved via
- // ViewTreeConnection::GetViewById.
- void AddView(View* view);
- void RemoveView(Id view_id);
-
- bool is_embed_root() const { return is_embed_root_; }
-
- // Called after the root view's observers have been notified of destruction
- // (as the last step of ~View). This ordering ensures that the View Manager
- // is torn down after the root.
- void OnRootDestroyed(View* root);
-
- private:
- typedef std::map<Id, View*> IdToViewMap;
-
- Id CreateViewOnServer();
-
- // Overridden from ViewTreeConnection:
- View* GetRoot() override;
- View* GetViewById(Id id) override;
- View* GetFocusedView() override;
- View* CreateView() override;
- bool IsEmbedRoot() override;
- ConnectionSpecificId GetConnectionId() override;
-
- // Overridden from ViewTreeClient:
- void OnEmbed(ConnectionSpecificId connection_id,
- mojo::ViewDataPtr root,
- mojo::ViewTreePtr tree,
- Id focused_view_id,
- uint32_t access_policy) override;
- void OnEmbeddedAppDisconnected(Id view_id) override;
- void OnUnembed() override;
- void OnViewBoundsChanged(Id view_id,
- mojo::RectPtr old_bounds,
- mojo::RectPtr new_bounds) override;
- void OnViewViewportMetricsChanged(
- mojo::ViewportMetricsPtr old_metrics,
- mojo::ViewportMetricsPtr new_metrics) override;
- void OnViewHierarchyChanged(Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- mojo::Array<mojo::ViewDataPtr> views) override;
- void OnViewReordered(Id view_id,
- Id relative_view_id,
- mojo::OrderDirection direction) override;
- void OnViewDeleted(Id view_id) override;
- void OnViewVisibilityChanged(Id view_id, bool visible) override;
- void OnViewDrawnStateChanged(Id view_id, bool drawn) override;
- void OnViewSharedPropertyChanged(Id view_id,
- const mojo::String& name,
- mojo::Array<uint8_t> new_data) override;
- void OnViewInputEvent(Id view_id,
- mojo::EventPtr event,
- const mojo::Callback<void()>& callback) override;
- void OnViewFocused(Id focused_view_id) override;
-
- void RootDestroyed(View* root);
-
- void OnActionCompleted(bool success);
-
- mojo::Callback<void(bool)> ActionCompletedCallback();
-
- ConnectionSpecificId connection_id_;
- ConnectionSpecificId next_id_;
-
- mojo::Callback<void(void)> change_acked_callback_;
-
- ViewTreeDelegate* delegate_;
-
- View* root_;
-
- IdToViewMap views_;
-
- View* capture_view_;
- View* focused_view_;
- View* activated_view_;
-
- mojo::Binding<ViewTreeClient> binding_;
- mojo::ViewTreePtr tree_;
-
- bool is_embed_root_;
-
- bool in_destructor_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl);
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_
diff --git a/components/mus/public/cpp/lib/view_tree_host_factory.cc b/components/mus/public/cpp/lib/view_tree_host_factory.cc
deleted file mode 100644
index 4f649fe..0000000
--- a/components/mus/public/cpp/lib/view_tree_host_factory.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/view_tree_host_factory.h"
-
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
-#include "mojo/application/public/cpp/application_impl.h"
-
-namespace mus {
-
-void CreateViewTreeHost(mojo::ViewTreeHostFactory* factory,
- mojo::ViewTreeHostClientPtr host_client,
- ViewTreeDelegate* delegate,
- mojo::ViewTreeHostPtr* host) {
- mojo::ViewTreeClientPtr tree_client;
- ViewTreeConnection::Create(
- delegate, GetProxy(&tree_client),
- ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
- factory->CreateViewTreeHost(GetProxy(host), host_client.Pass(),
- tree_client.Pass());
-}
-
-void CreateSingleViewTreeHost(mojo::ApplicationImpl* app,
- ViewTreeDelegate* delegate,
- mojo::ViewTreeHostPtr* host) {
- mojo::ViewTreeHostFactoryPtr factory;
- mojo::URLRequestPtr request(mojo::URLRequest::New());
- request->url = "mojo:mus";
- app->ConnectToService(request.Pass(), &factory);
- CreateViewTreeHost(factory.get(), mojo::ViewTreeHostClientPtr(), delegate,
- host);
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/lib/view.cc b/components/mus/public/cpp/lib/window.cc
index 88228eb..eb4f8ca 100644
--- a/components/mus/public/cpp/lib/view.cc
+++ b/components/mus/public/cpp/lib/window.cc
@@ -2,121 +2,124 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include <set>
#include <string>
#include "base/bind.h"
-#include "components/mus/public/cpp/lib/view_private.h"
-#include "components/mus/public/cpp/lib/view_tree_client_impl.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_surface.h"
-#include "components/mus/public/cpp/view_tracker.h"
+#include "components/mus/public/cpp/lib/window_private.h"
+#include "components/mus/public/cpp/lib/window_tree_client_impl.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_surface.h"
+#include "components/mus/public/cpp/window_tracker.h"
#include "mojo/application/public/cpp/service_provider_impl.h"
namespace mus {
namespace {
-void NotifyViewTreeChangeAtReceiver(
- View* receiver,
- const ViewObserver::TreeChangeParams& params,
+void NotifyWindowTreeChangeAtReceiver(
+ Window* receiver,
+ const WindowObserver::TreeChangeParams& params,
bool change_applied) {
- ViewObserver::TreeChangeParams local_params = params;
+ WindowObserver::TreeChangeParams local_params = params;
local_params.receiver = receiver;
if (change_applied) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(receiver).observers(),
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(receiver).observers(),
OnTreeChanged(local_params));
} else {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(receiver).observers(),
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(receiver).observers(),
OnTreeChanging(local_params));
}
}
-void NotifyViewTreeChangeUp(View* start_at,
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- for (View* current = start_at; current; current = current->parent())
- NotifyViewTreeChangeAtReceiver(current, params, change_applied);
+void NotifyWindowTreeChangeUp(Window* start_at,
+ const WindowObserver::TreeChangeParams& params,
+ bool change_applied) {
+ for (Window* current = start_at; current; current = current->parent())
+ NotifyWindowTreeChangeAtReceiver(current, params, change_applied);
}
-void NotifyViewTreeChangeDown(View* start_at,
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- NotifyViewTreeChangeAtReceiver(start_at, params, change_applied);
- View::Children::const_iterator it = start_at->children().begin();
+void NotifyWindowTreeChangeDown(Window* start_at,
+ const WindowObserver::TreeChangeParams& params,
+ bool change_applied) {
+ NotifyWindowTreeChangeAtReceiver(start_at, params, change_applied);
+ Window::Children::const_iterator it = start_at->children().begin();
for (; it != start_at->children().end(); ++it)
- NotifyViewTreeChangeDown(*it, params, change_applied);
+ NotifyWindowTreeChangeDown(*it, params, change_applied);
}
-void NotifyViewTreeChange(const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- NotifyViewTreeChangeDown(params.target, params, change_applied);
+void NotifyWindowTreeChange(const WindowObserver::TreeChangeParams& params,
+ bool change_applied) {
+ NotifyWindowTreeChangeDown(params.target, params, change_applied);
if (params.old_parent)
- NotifyViewTreeChangeUp(params.old_parent, params, change_applied);
+ NotifyWindowTreeChangeUp(params.old_parent, params, change_applied);
if (params.new_parent)
- NotifyViewTreeChangeUp(params.new_parent, params, change_applied);
+ NotifyWindowTreeChangeUp(params.new_parent, params, change_applied);
}
class ScopedTreeNotifier {
public:
- ScopedTreeNotifier(View* target, View* old_parent, View* new_parent) {
+ ScopedTreeNotifier(Window* target, Window* old_parent, Window* new_parent) {
params_.target = target;
params_.old_parent = old_parent;
params_.new_parent = new_parent;
- NotifyViewTreeChange(params_, false);
+ NotifyWindowTreeChange(params_, false);
}
- ~ScopedTreeNotifier() { NotifyViewTreeChange(params_, true); }
+ ~ScopedTreeNotifier() { NotifyWindowTreeChange(params_, true); }
private:
- ViewObserver::TreeChangeParams params_;
+ WindowObserver::TreeChangeParams params_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedTreeNotifier);
};
-void RemoveChildImpl(View* child, View::Children* children) {
- View::Children::iterator it =
+void RemoveChildImpl(Window* child, Window::Children* children) {
+ Window::Children::iterator it =
std::find(children->begin(), children->end(), child);
if (it != children->end()) {
children->erase(it);
- ViewPrivate(child).ClearParent();
+ WindowPrivate(child).ClearParent();
}
}
class ScopedOrderChangedNotifier {
public:
- ScopedOrderChangedNotifier(View* view,
- View* relative_view,
+ ScopedOrderChangedNotifier(Window* window,
+ Window* relative_window,
mojo::OrderDirection direction)
- : view_(view), relative_view_(relative_view), direction_(direction) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(),
- OnViewReordering(view_, relative_view_, direction_));
+ : window_(window),
+ relative_window_(relative_window),
+ direction_(direction) {
+ FOR_EACH_OBSERVER(
+ WindowObserver, *WindowPrivate(window_).observers(),
+ OnWindowReordering(window_, relative_window_, direction_));
}
~ScopedOrderChangedNotifier() {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(),
- OnViewReordered(view_, relative_view_, direction_));
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window_).observers(),
+ OnWindowReordered(window_, relative_window_, direction_));
}
private:
- View* view_;
- View* relative_view_;
+ Window* window_;
+ Window* relative_window_;
mojo::OrderDirection direction_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier);
};
// Returns true if the order actually changed.
-bool ReorderImpl(View::Children* children,
- View* view,
- View* relative,
+bool ReorderImpl(Window::Children* children,
+ Window* window,
+ Window* relative,
mojo::OrderDirection direction) {
DCHECK(relative);
- DCHECK_NE(view, relative);
- DCHECK_EQ(view->parent(), relative->parent());
+ DCHECK_NE(window, relative);
+ DCHECK_EQ(window->parent(), relative->parent());
const size_t child_i =
- std::find(children->begin(), children->end(), view) - children->begin();
+ std::find(children->begin(), children->end(), window) - children->begin();
const size_t target_i =
std::find(children->begin(), children->end(), relative) -
children->begin();
@@ -125,43 +128,45 @@ bool ReorderImpl(View::Children* children,
return false;
}
- ScopedOrderChangedNotifier notifier(view, relative, direction);
+ ScopedOrderChangedNotifier notifier(window, relative, direction);
const size_t dest_i = direction == mojo::ORDER_DIRECTION_ABOVE
? (child_i < target_i ? target_i : target_i + 1)
: (child_i < target_i ? target_i - 1 : target_i);
children->erase(children->begin() + child_i);
- children->insert(children->begin() + dest_i, view);
+ children->insert(children->begin() + dest_i, window);
return true;
}
class ScopedSetBoundsNotifier {
public:
- ScopedSetBoundsNotifier(View* view,
+ ScopedSetBoundsNotifier(Window* window,
const mojo::Rect& old_bounds,
const mojo::Rect& new_bounds)
- : view_(view), old_bounds_(old_bounds), new_bounds_(new_bounds) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(),
- OnViewBoundsChanging(view_, old_bounds_, new_bounds_));
+ : window_(window), old_bounds_(old_bounds), new_bounds_(new_bounds) {
+ FOR_EACH_OBSERVER(
+ WindowObserver, *WindowPrivate(window_).observers(),
+ OnWindowBoundsChanging(window_, old_bounds_, new_bounds_));
}
~ScopedSetBoundsNotifier() {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(),
- OnViewBoundsChanged(view_, old_bounds_, new_bounds_));
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window_).observers(),
+ OnWindowBoundsChanged(window_, old_bounds_, new_bounds_));
}
private:
- View* view_;
+ Window* window_;
const mojo::Rect old_bounds_;
const mojo::Rect new_bounds_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier);
};
-// Some operations are only permitted in the connection that created the view.
-bool OwnsView(ViewTreeConnection* connection, View* view) {
+// Some operations are only permitted in the connection that created the window.
+bool OwnsWindow(WindowTreeConnection* connection, Window* window) {
return !connection ||
- static_cast<ViewTreeClientImpl*>(connection)->OwnsView(view->id());
+ static_cast<WindowTreeClientImpl*>(connection)
+ ->OwnsWindow(window->id());
}
void EmptyEmbedCallback(bool result, ConnectionSpecificId connection_id) {}
@@ -169,18 +174,18 @@ void EmptyEmbedCallback(bool result, ConnectionSpecificId connection_id) {}
} // namespace
////////////////////////////////////////////////////////////////////////////////
-// View, public:
+// Window, public:
-void View::Destroy() {
- if (!OwnsView(connection_, this))
+void Window::Destroy() {
+ if (!OwnsWindow(connection_, this))
return;
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->DestroyView(id_);
+ static_cast<WindowTreeClientImpl*>(connection_)->DestroyWindow(id_);
while (!children_.empty()) {
- View* child = children_.front();
- if (!OwnsView(connection_, child)) {
- ViewPrivate(child).ClearParent();
+ Window* child = children_.front();
+ if (!OwnsWindow(connection_, child)) {
+ WindowPrivate(child).ClearParent();
children_.erase(children_.begin());
} else {
child->Destroy();
@@ -191,40 +196,40 @@ void View::Destroy() {
LocalDestroy();
}
-void View::SetBounds(const mojo::Rect& bounds) {
- if (!OwnsView(connection_, this))
+void Window::SetBounds(const mojo::Rect& bounds) {
+ if (!OwnsWindow(connection_, this))
return;
if (bounds_.Equals(bounds))
return;
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->SetBounds(id_, bounds);
+ static_cast<WindowTreeClientImpl*>(connection_)->SetBounds(id_, bounds);
LocalSetBounds(bounds_, bounds);
}
-void View::SetVisible(bool value) {
+void Window::SetVisible(bool value) {
if (visible_ == value)
return;
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->SetVisible(id_, value);
+ static_cast<WindowTreeClientImpl*>(connection_)->SetVisible(id_, value);
LocalSetVisible(value);
}
-scoped_ptr<ViewSurface> View::RequestSurface() {
+scoped_ptr<WindowSurface> Window::RequestSurface() {
mojo::SurfacePtr surface;
mojo::SurfaceClientPtr client;
mojo::InterfaceRequest<mojo::SurfaceClient> client_request =
GetProxy(&client);
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->RequestSurface(id_, GetProxy(&surface), client.Pass());
return make_scoped_ptr(
- new ViewSurface(surface.PassInterface(), client_request.Pass()));
+ new WindowSurface(surface.PassInterface(), client_request.Pass()));
}
-void View::SetSharedProperty(const std::string& name,
- const std::vector<uint8_t>* value) {
+void Window::SetSharedProperty(const std::string& name,
+ const std::vector<uint8_t>* value) {
std::vector<uint8_t> old_value;
std::vector<uint8_t>* old_value_ptr = nullptr;
auto it = properties_.find(name);
@@ -254,141 +259,142 @@ void View::SetSharedProperty(const std::string& name,
if (value->size())
memcpy(&transport_value.front(), &(value->front()), value->size());
}
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->SetProperty(id_, name, transport_value.Pass());
}
FOR_EACH_OBSERVER(
- ViewObserver, observers_,
- OnViewSharedPropertyChanged(this, name, old_value_ptr, value));
+ WindowObserver, observers_,
+ OnWindowSharedPropertyChanged(this, name, old_value_ptr, value));
}
-bool View::IsDrawn() const {
+bool Window::IsDrawn() const {
if (!visible_)
return false;
return parent_ ? parent_->IsDrawn() : drawn_;
}
-void View::AddObserver(ViewObserver* observer) {
+void Window::AddObserver(WindowObserver* observer) {
observers_.AddObserver(observer);
}
-void View::RemoveObserver(ViewObserver* observer) {
+void Window::RemoveObserver(WindowObserver* observer) {
observers_.RemoveObserver(observer);
}
-const View* View::GetRoot() const {
- const View* root = this;
- for (const View* parent = this; parent; parent = parent->parent())
+const Window* Window::GetRoot() const {
+ const Window* root = this;
+ for (const Window* parent = this; parent; parent = parent->parent())
root = parent;
return root;
}
-void View::AddChild(View* child) {
+void Window::AddChild(Window* child) {
// TODO(beng): not necessarily valid to all connections, but possibly to the
// embeddee in an embedder-embeddee relationship.
if (connection_)
CHECK_EQ(child->connection(), connection_);
LocalAddChild(child);
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->AddChild(child->id(), id_);
+ static_cast<WindowTreeClientImpl*>(connection_)->AddChild(child->id(), id_);
}
-void View::RemoveChild(View* child) {
+void Window::RemoveChild(Window* child) {
// TODO(beng): not necessarily valid to all connections, but possibly to the
// embeddee in an embedder-embeddee relationship.
if (connection_)
CHECK_EQ(child->connection(), connection_);
LocalRemoveChild(child);
if (connection_) {
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->RemoveChild(child->id(), id_);
}
}
-void View::MoveToFront() {
+void Window::MoveToFront() {
if (!parent_ || parent_->children_.back() == this)
return;
Reorder(parent_->children_.back(), mojo::ORDER_DIRECTION_ABOVE);
}
-void View::MoveToBack() {
+void Window::MoveToBack() {
if (!parent_ || parent_->children_.front() == this)
return;
Reorder(parent_->children_.front(), mojo::ORDER_DIRECTION_BELOW);
}
-void View::Reorder(View* relative, mojo::OrderDirection direction) {
+void Window::Reorder(Window* relative, mojo::OrderDirection direction) {
if (!LocalReorder(relative, direction))
return;
if (connection_) {
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->Reorder(id_, relative->id(), direction);
}
}
-bool View::Contains(View* child) const {
+bool Window::Contains(Window* child) const {
if (!child)
return false;
if (child == this)
return true;
if (connection_)
CHECK_EQ(child->connection(), connection_);
- for (View* p = child->parent(); p; p = p->parent()) {
+ for (Window* p = child->parent(); p; p = p->parent()) {
if (p == this)
return true;
}
return false;
}
-View* View::GetChildById(Id id) {
+Window* Window::GetChildById(Id id) {
if (id == id_)
return this;
- // TODO(beng): this could be improved depending on how we decide to own views.
+ // TODO(beng): this could be improved depending on how we decide to own
+ // windows.
Children::const_iterator it = children_.begin();
for (; it != children_.end(); ++it) {
- View* view = (*it)->GetChildById(id);
- if (view)
- return view;
+ Window* window = (*it)->GetChildById(id);
+ if (window)
+ return window;
}
return NULL;
}
-void View::SetTextInputState(mojo::TextInputStatePtr state) {
+void Window::SetTextInputState(mojo::TextInputStatePtr state) {
if (connection_) {
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->SetViewTextInputState(id_, state.Pass());
}
}
-void View::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) {
- // SetImeVisibility() shouldn't be used if the view is not editable.
+void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) {
+ // SetImeVisibility() shouldn't be used if the window is not editable.
DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE);
if (connection_) {
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->SetImeVisibility(id_, visible, state.Pass());
}
}
-void View::SetFocus() {
+void Window::SetFocus() {
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->SetFocus(id_);
+ static_cast<WindowTreeClientImpl*>(connection_)->SetFocus(id_);
}
-bool View::HasFocus() const {
- return connection_ && connection_->GetFocusedView() == this;
+bool Window::HasFocus() const {
+ return connection_ && connection_->GetFocusedWindow() == this;
}
-void View::Embed(mojo::ViewTreeClientPtr client) {
+void Window::Embed(mojo::ViewTreeClientPtr client) {
Embed(client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT,
base::Bind(&EmptyEmbedCallback));
}
-void View::Embed(mojo::ViewTreeClientPtr client,
- uint32_t policy_bitmask,
- const EmbedCallback& callback) {
+void Window::Embed(mojo::ViewTreeClientPtr client,
+ uint32_t policy_bitmask,
+ const EmbedCallback& callback) {
if (PrepareForEmbed()) {
- static_cast<ViewTreeClientImpl*>(connection_)
+ static_cast<WindowTreeClientImpl*>(connection_)
->Embed(id_, client.Pass(), policy_bitmask, callback);
} else {
callback.Run(false, 0);
@@ -396,7 +402,7 @@ void View::Embed(mojo::ViewTreeClientPtr client,
}
////////////////////////////////////////////////////////////////////////////////
-// View, protected:
+// Window, protected:
namespace {
@@ -410,7 +416,7 @@ mojo::ViewportMetricsPtr CreateEmptyViewportMetrics() {
} // namespace
-View::View()
+Window::Window()
: connection_(NULL),
id_(static_cast<Id>(-1)),
parent_(NULL),
@@ -418,23 +424,23 @@ View::View()
visible_(true),
drawn_(false) {}
-View::~View() {
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this));
+Window::~Window() {
+ FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroying(this));
if (parent_)
parent_->LocalRemoveChild(this);
// We may still have children. This can happen if the embedder destroys the
// root while we're still alive.
while (!children_.empty()) {
- View* child = children_.front();
+ Window* child = children_.front();
LocalRemoveChild(child);
DCHECK(children_.empty() || children_.front() != child);
}
// TODO(beng): It'd be better to do this via a destruction observer in the
- // ViewTreeClientImpl.
+ // WindowTreeClientImpl.
if (connection_)
- static_cast<ViewTreeClientImpl*>(connection_)->RemoveView(id_);
+ static_cast<WindowTreeClientImpl*>(connection_)->RemoveWindow(id_);
// Clear properties.
for (auto& pair : prop_map_) {
@@ -443,16 +449,16 @@ View::~View() {
}
prop_map_.clear();
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroyed(this));
+ FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this));
if (connection_ && connection_->GetRoot() == this)
- static_cast<ViewTreeClientImpl*>(connection_)->OnRootDestroyed(this);
+ static_cast<WindowTreeClientImpl*>(connection_)->OnRootDestroyed(this);
}
////////////////////////////////////////////////////////////////////////////////
// View, private:
-View::View(ViewTreeConnection* connection, Id id)
+Window::Window(WindowTreeConnection* connection, Id id)
: connection_(connection),
id_(id),
parent_(nullptr),
@@ -460,11 +466,11 @@ View::View(ViewTreeConnection* connection, Id id)
visible_(false),
drawn_(false) {}
-int64 View::SetLocalPropertyInternal(const void* key,
- const char* name,
- PropertyDeallocator deallocator,
- int64 value,
- int64 default_value) {
+int64 Window::SetLocalPropertyInternal(const void* key,
+ const char* name,
+ PropertyDeallocator deallocator,
+ int64 value,
+ int64 default_value) {
int64 old = GetLocalPropertyInternal(key, default_value);
if (value == default_value) {
prop_map_.erase(key);
@@ -475,24 +481,24 @@ int64 View::SetLocalPropertyInternal(const void* key,
prop_value.deallocator = deallocator;
prop_map_[key] = prop_value;
}
- FOR_EACH_OBSERVER(ViewObserver, observers_,
- OnViewLocalPropertyChanged(this, key, old));
+ FOR_EACH_OBSERVER(WindowObserver, observers_,
+ OnWindowLocalPropertyChanged(this, key, old));
return old;
}
-int64 View::GetLocalPropertyInternal(const void* key,
- int64 default_value) const {
+int64 Window::GetLocalPropertyInternal(const void* key,
+ int64 default_value) const {
std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
if (iter == prop_map_.end())
return default_value;
return iter->second.value;
}
-void View::LocalDestroy() {
+void Window::LocalDestroy() {
delete this;
}
-void View::LocalAddChild(View* child) {
+void Window::LocalAddChild(Window* child) {
ScopedTreeNotifier notifier(child, child->parent(), this);
if (child->parent())
RemoveChildImpl(child, &child->parent_->children_);
@@ -500,18 +506,18 @@ void View::LocalAddChild(View* child) {
child->parent_ = this;
}
-void View::LocalRemoveChild(View* child) {
+void Window::LocalRemoveChild(Window* child) {
DCHECK_EQ(this, child->parent());
ScopedTreeNotifier notifier(child, this, NULL);
RemoveChildImpl(child, &children_);
}
-bool View::LocalReorder(View* relative, mojo::OrderDirection direction) {
+bool Window::LocalReorder(Window* relative, mojo::OrderDirection direction) {
return ReorderImpl(&parent_->children_, this, relative, direction);
}
-void View::LocalSetBounds(const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
+void Window::LocalSetBounds(const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
DCHECK(old_bounds.x == bounds_.x);
DCHECK(old_bounds.y == bounds_.y);
DCHECK(old_bounds.width == bounds_.width);
@@ -520,16 +526,16 @@ void View::LocalSetBounds(const mojo::Rect& old_bounds,
bounds_ = new_bounds;
}
-void View::LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics,
- const mojo::ViewportMetrics& new_metrics) {
+void Window::LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics,
+ const mojo::ViewportMetrics& new_metrics) {
// TODO(eseidel): We could check old_metrics against viewport_metrics_.
viewport_metrics_ = new_metrics.Clone();
FOR_EACH_OBSERVER(
- ViewObserver, observers_,
- OnViewViewportMetricsChanged(this, old_metrics, new_metrics));
+ WindowObserver, observers_,
+ OnWindowViewportMetricsChanged(this, old_metrics, new_metrics));
}
-void View::LocalSetDrawn(bool value) {
+void Window::LocalSetDrawn(bool value) {
if (drawn_ == value)
return;
@@ -539,49 +545,51 @@ void View::LocalSetDrawn(bool value) {
drawn_ = value;
return;
}
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this));
+ FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDrawnChanging(this));
drawn_ = value;
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this));
+ FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDrawnChanged(this));
}
-void View::LocalSetVisible(bool visible) {
+void Window::LocalSetVisible(bool visible) {
if (visible_ == visible)
return;
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this));
+ FOR_EACH_OBSERVER(WindowObserver, observers_,
+ OnWindowVisibilityChanging(this));
visible_ = visible;
- NotifyViewVisibilityChanged(this);
+ NotifyWindowVisibilityChanged(this);
}
-void View::NotifyViewVisibilityChanged(View* target) {
- if (!NotifyViewVisibilityChangedDown(target)) {
+void Window::NotifyWindowVisibilityChanged(Window* target) {
+ if (!NotifyWindowVisibilityChangedDown(target)) {
return; // |this| has been deleted.
}
- NotifyViewVisibilityChangedUp(target);
+ NotifyWindowVisibilityChangedUp(target);
}
-bool View::NotifyViewVisibilityChangedAtReceiver(View* target) {
- // |this| may be deleted during a call to OnViewVisibilityChanged() on one
+bool Window::NotifyWindowVisibilityChangedAtReceiver(Window* target) {
+ // |this| may be deleted during a call to OnWindowVisibilityChanged() on one
// of the observers. We create an local observer for that. In that case we
// exit without further access to any members.
- ViewTracker tracker;
+ WindowTracker tracker;
tracker.Add(this);
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanged(target));
+ FOR_EACH_OBSERVER(WindowObserver, observers_,
+ OnWindowVisibilityChanged(target));
return tracker.Contains(this);
}
-bool View::NotifyViewVisibilityChangedDown(View* target) {
- if (!NotifyViewVisibilityChangedAtReceiver(target))
+bool Window::NotifyWindowVisibilityChangedDown(Window* target) {
+ if (!NotifyWindowVisibilityChangedAtReceiver(target))
return false; // |this| was deleted.
- std::set<const View*> child_already_processed;
+ std::set<const Window*> child_already_processed;
bool child_destroyed = false;
do {
child_destroyed = false;
- for (View::Children::const_iterator it = children_.begin();
+ for (Window::Children::const_iterator it = children_.begin();
it != children_.end(); ++it) {
if (!child_already_processed.insert(*it).second)
continue;
- if (!(*it)->NotifyViewVisibilityChangedDown(target)) {
+ if (!(*it)->NotifyWindowVisibilityChangedDown(target)) {
// |*it| was deleted, |it| is invalid and |children_| has changed. We
// exit the current for-loop and enter a new one.
child_destroyed = true;
@@ -592,18 +600,18 @@ bool View::NotifyViewVisibilityChangedDown(View* target) {
return true;
}
-void View::NotifyViewVisibilityChangedUp(View* target) {
+void Window::NotifyWindowVisibilityChangedUp(Window* target) {
// Start with the parent as we already notified |this|
- // in NotifyViewVisibilityChangedDown.
- for (View* view = parent(); view; view = view->parent()) {
- bool ret = view->NotifyViewVisibilityChangedAtReceiver(target);
+ // in NotifyWindowVisibilityChangedDown.
+ for (Window* window = parent(); window; window = window->parent()) {
+ bool ret = window->NotifyWindowVisibilityChangedAtReceiver(target);
DCHECK(ret);
}
}
-bool View::PrepareForEmbed() {
- if (!OwnsView(connection_, this) &&
- !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) {
+bool Window::PrepareForEmbed() {
+ if (!OwnsWindow(connection_, this) &&
+ !static_cast<WindowTreeClientImpl*>(connection_)->is_embed_root()) {
return false;
}
diff --git a/components/mus/public/cpp/lib/view_observer.cc b/components/mus/public/cpp/lib/window_observer.cc
index 40367ea..26e6507 100644
--- a/components/mus/public/cpp/lib/view_observer.cc
+++ b/components/mus/public/cpp/lib/window_observer.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window_observer.h"
namespace mus {
////////////////////////////////////////////////////////////////////////////////
-// ViewObserver, public:
+// WindowObserver, public:
-ViewObserver::TreeChangeParams::TreeChangeParams()
+WindowObserver::TreeChangeParams::TreeChangeParams()
: target(nullptr),
old_parent(nullptr),
new_parent(nullptr),
diff --git a/components/mus/public/cpp/lib/window_private.cc b/components/mus/public/cpp/lib/window_private.cc
new file mode 100644
index 0000000..5d8dca7
--- /dev/null
+++ b/components/mus/public/cpp/lib/window_private.cc
@@ -0,0 +1,20 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/lib/window_private.h"
+
+namespace mus {
+
+WindowPrivate::WindowPrivate(Window* window) : window_(window) {
+ CHECK(window);
+}
+
+WindowPrivate::~WindowPrivate() {}
+
+// static
+Window* WindowPrivate::LocalCreate() {
+ return new Window;
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/lib/window_private.h b/components/mus/public/cpp/lib/window_private.h
new file mode 100644
index 0000000..6dd6b80
--- /dev/null
+++ b/components/mus/public/cpp/lib/window_private.h
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_PRIVATE_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_PRIVATE_H_
+
+#include "components/mus/public/cpp/window.h"
+
+namespace mus {
+
+// This class is a friend of a View and contains functions to mutate internal
+// state of View.
+class WindowPrivate {
+ public:
+ explicit WindowPrivate(Window* view);
+ ~WindowPrivate();
+
+ // Creates and returns a new View. Caller owns the return value.
+ static Window* LocalCreate();
+
+ base::ObserverList<WindowObserver>* observers() {
+ return &window_->observers_;
+ }
+
+ void ClearParent() { window_->parent_ = NULL; }
+
+ void set_visible(bool visible) { window_->visible_ = visible; }
+
+ void set_drawn(bool drawn) { window_->drawn_ = drawn; }
+
+ void set_id(Id id) { window_->id_ = id; }
+
+ void set_connection(WindowTreeConnection* connection) {
+ window_->connection_ = connection;
+ }
+
+ void set_properties(const std::map<std::string, std::vector<uint8_t>>& data) {
+ window_->properties_ = data;
+ }
+
+ void LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics,
+ const mojo::ViewportMetrics& new_metrics) {
+ window_->LocalSetViewportMetrics(new_metrics, new_metrics);
+ }
+
+ void LocalDestroy() { window_->LocalDestroy(); }
+ void LocalAddChild(Window* child) { window_->LocalAddChild(child); }
+ void LocalRemoveChild(Window* child) { window_->LocalRemoveChild(child); }
+ void LocalReorder(Window* relative, mojo::OrderDirection direction) {
+ window_->LocalReorder(relative, direction);
+ }
+ void LocalSetBounds(const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
+ window_->LocalSetBounds(old_bounds, new_bounds);
+ }
+ void LocalSetDrawn(bool drawn) { window_->LocalSetDrawn(drawn); }
+ void LocalSetVisible(bool visible) { window_->LocalSetVisible(visible); }
+
+ private:
+ Window* window_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowPrivate);
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_PRIVATE_H_
diff --git a/components/mus/public/cpp/lib/view_surface.cc b/components/mus/public/cpp/lib/window_surface.cc
index 47409f7..78c4f55 100644
--- a/components/mus/public/cpp/lib/view_surface.cc
+++ b/components/mus/public/cpp/lib/window_surface.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/view_surface.h"
+#include "components/mus/public/cpp/window_surface.h"
-#include "components/mus/public/cpp/view_surface_client.h"
+#include "components/mus/public/cpp/window_surface_client.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
namespace mus {
-ViewSurface::~ViewSurface() {}
+WindowSurface::~WindowSurface() {}
-void ViewSurface::BindToThread() {
+void WindowSurface::BindToThread() {
DCHECK(!bound_to_thread_);
bound_to_thread_ = true;
surface_.Bind(surface_info_.Pass());
@@ -19,15 +19,15 @@ void ViewSurface::BindToThread() {
new mojo::Binding<mojo::SurfaceClient>(this, client_request_.Pass()));
}
-void ViewSurface::SubmitCompositorFrame(mojo::CompositorFramePtr frame,
- const mojo::Closure& callback) {
+void WindowSurface::SubmitCompositorFrame(mojo::CompositorFramePtr frame,
+ const mojo::Closure& callback) {
DCHECK(bound_to_thread_);
if (!surface_)
return;
surface_->SubmitCompositorFrame(frame.Pass(), callback);
}
-ViewSurface::ViewSurface(
+WindowSurface::WindowSurface(
mojo::InterfacePtrInfo<mojo::Surface> surface_info,
mojo::InterfaceRequest<mojo::SurfaceClient> client_request)
: client_(nullptr),
@@ -35,7 +35,7 @@ ViewSurface::ViewSurface(
client_request_(client_request.Pass()),
bound_to_thread_(false) {}
-void ViewSurface::ReturnResources(
+void WindowSurface::ReturnResources(
mojo::Array<mojo::ReturnedResourcePtr> resources) {
if (!client_)
return;
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
new file mode 100644
index 0000000..0fc663e
--- /dev/null
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -0,0 +1,457 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/lib/window_tree_client_impl.h"
+
+#include "components/mus/public/cpp/lib/window_private.h"
+#include "components/mus/public/cpp/util.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "mojo/application/public/cpp/connect.h"
+#include "mojo/application/public/cpp/service_provider_impl.h"
+#include "mojo/application/public/interfaces/service_provider.mojom.h"
+
+namespace mus {
+
+Id MakeTransportId(ConnectionSpecificId connection_id,
+ ConnectionSpecificId local_id) {
+ return (connection_id << 16) | local_id;
+}
+
+// Helper called to construct a local window object from transport data.
+Window* AddWindowToConnection(WindowTreeClientImpl* client,
+ Window* parent,
+ const mojo::ViewDataPtr& window_data) {
+ // We don't use the cto that takes a WindowTreeConnection here, since it will
+ // call back to the service and attempt to create a new view.
+ Window* window = WindowPrivate::LocalCreate();
+ WindowPrivate private_window(window);
+ private_window.set_connection(client);
+ private_window.set_id(window_data->view_id);
+ private_window.set_visible(window_data->visible);
+ private_window.set_drawn(window_data->drawn);
+ private_window.LocalSetViewportMetrics(mojo::ViewportMetrics(),
+ *window_data->viewport_metrics);
+ private_window.set_properties(
+ window_data->properties
+ .To<std::map<std::string, std::vector<uint8_t>>>());
+ client->AddWindow(window);
+ private_window.LocalSetBounds(mojo::Rect(), *window_data->bounds);
+ if (parent)
+ WindowPrivate(parent).LocalAddChild(window);
+ return window;
+}
+
+Window* BuildWindowTree(WindowTreeClientImpl* client,
+ const mojo::Array<mojo::ViewDataPtr>& windows,
+ Window* initial_parent) {
+ std::vector<Window*> parents;
+ Window* root = NULL;
+ Window* last_window = NULL;
+ if (initial_parent)
+ parents.push_back(initial_parent);
+ for (size_t i = 0; i < windows.size(); ++i) {
+ if (last_window && windows[i]->parent_id == last_window->id()) {
+ parents.push_back(last_window);
+ } else if (!parents.empty()) {
+ while (parents.back()->id() != windows[i]->parent_id)
+ parents.pop_back();
+ }
+ Window* window = AddWindowToConnection(
+ client, !parents.empty() ? parents.back() : NULL, windows[i]);
+ if (!last_window)
+ root = window;
+ last_window = window;
+ }
+ return root;
+}
+
+WindowTreeConnection* WindowTreeConnection::Create(
+ WindowTreeDelegate* delegate,
+ mojo::InterfaceRequest<mojo::ViewTreeClient> request,
+ CreateType create_type) {
+ WindowTreeClientImpl* client =
+ new WindowTreeClientImpl(delegate, request.Pass());
+ if (create_type == CreateType::WAIT_FOR_EMBED)
+ client->WaitForEmbed();
+ return client;
+}
+
+WindowTreeClientImpl::WindowTreeClientImpl(
+ WindowTreeDelegate* delegate,
+ mojo::InterfaceRequest<mojo::ViewTreeClient> request)
+ : connection_id_(0),
+ next_id_(1),
+ delegate_(delegate),
+ root_(nullptr),
+ capture_window_(nullptr),
+ focused_window_(nullptr),
+ activated_window_(nullptr),
+ binding_(this, request.Pass()),
+ is_embed_root_(false),
+ in_destructor_(false) {}
+
+WindowTreeClientImpl::~WindowTreeClientImpl() {
+ in_destructor_ = true;
+
+ std::vector<Window*> non_owned;
+ while (!windows_.empty()) {
+ IdToWindowMap::iterator it = windows_.begin();
+ if (OwnsWindow(it->second->id())) {
+ it->second->Destroy();
+ } else {
+ non_owned.push_back(it->second);
+ windows_.erase(it);
+ }
+ }
+
+ // Delete the non-owned views last. In the typical case these are roots. The
+ // exception is the window manager and embed roots, which may know about
+ // other random windows that it doesn't own.
+ // NOTE: we manually delete as we're a friend.
+ for (size_t i = 0; i < non_owned.size(); ++i)
+ delete non_owned[i];
+
+ delegate_->OnConnectionLost(this);
+}
+
+void WindowTreeClientImpl::WaitForEmbed() {
+ DCHECK(!root_);
+ // OnEmbed() is the first function called.
+ binding_.WaitForIncomingMethodCall();
+ // TODO(sky): deal with pipe being closed before we get OnEmbed().
+}
+
+void WindowTreeClientImpl::DestroyWindow(Id window_id) {
+ DCHECK(tree_);
+ tree_->DeleteView(window_id, ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::AddChild(Id child_id, Id parent_id) {
+ DCHECK(tree_);
+ tree_->AddView(parent_id, child_id, ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::RemoveChild(Id child_id, Id parent_id) {
+ DCHECK(tree_);
+ tree_->RemoveViewFromParent(child_id, ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::Reorder(Id window_id,
+ Id relative_window_id,
+ mojo::OrderDirection direction) {
+ DCHECK(tree_);
+ tree_->ReorderView(window_id, relative_window_id, direction,
+ ActionCompletedCallback());
+}
+
+bool WindowTreeClientImpl::OwnsWindow(Id id) const {
+ return HiWord(id) == connection_id_;
+}
+
+void WindowTreeClientImpl::SetBounds(Id window_id, const mojo::Rect& bounds) {
+ DCHECK(tree_);
+ tree_->SetViewBounds(window_id, bounds.Clone(), ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::SetFocus(Id window_id) {
+ // In order for us to get here we had to have exposed a window, which implies
+ // we
+ // got a connection.
+ DCHECK(tree_);
+ tree_->SetFocus(window_id);
+}
+
+void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) {
+ DCHECK(tree_);
+ tree_->SetViewVisibility(window_id, visible, ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::SetProperty(Id window_id,
+ const std::string& name,
+ const std::vector<uint8_t>& data) {
+ DCHECK(tree_);
+ tree_->SetViewProperty(window_id, mojo::String(name),
+ mojo::Array<uint8_t>::From(data),
+ ActionCompletedCallback());
+}
+
+void WindowTreeClientImpl::SetViewTextInputState(
+ Id window_id,
+ mojo::TextInputStatePtr state) {
+ DCHECK(tree_);
+ tree_->SetViewTextInputState(window_id, state.Pass());
+}
+
+void WindowTreeClientImpl::SetImeVisibility(Id window_id,
+ bool visible,
+ mojo::TextInputStatePtr state) {
+ DCHECK(tree_);
+ tree_->SetImeVisibility(window_id, visible, state.Pass());
+}
+
+void WindowTreeClientImpl::Embed(
+ Id window_id,
+ mojo::ViewTreeClientPtr client,
+ uint32_t policy_bitmask,
+ const mojo::ViewTree::EmbedCallback& callback) {
+ DCHECK(tree_);
+ tree_->Embed(window_id, client.Pass(), policy_bitmask, callback);
+}
+
+void WindowTreeClientImpl::RequestSurface(
+ Id window_id,
+ mojo::InterfaceRequest<mojo::Surface> surface,
+ mojo::SurfaceClientPtr client) {
+ DCHECK(tree_);
+ tree_->RequestSurface(window_id, surface.Pass(), client.Pass());
+}
+
+void WindowTreeClientImpl::AddWindow(Window* window) {
+ DCHECK(windows_.find(window->id()) == windows_.end());
+ windows_[window->id()] = window;
+}
+
+void WindowTreeClientImpl::RemoveWindow(Id window_id) {
+ if (focused_window_ && focused_window_->id() == window_id)
+ OnWindowFocused(0);
+
+ IdToWindowMap::iterator it = windows_.find(window_id);
+ if (it != windows_.end())
+ windows_.erase(it);
+}
+
+void WindowTreeClientImpl::OnRootDestroyed(Window* root) {
+ DCHECK_EQ(root, root_);
+ root_ = nullptr;
+
+ // When the root is gone we can't do anything useful.
+ if (!in_destructor_)
+ delete this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeClientImpl, WindowTreeConnection implementation:
+
+Id WindowTreeClientImpl::CreateWindowOnServer() {
+ DCHECK(tree_);
+ const Id window_id = MakeTransportId(connection_id_, next_id_++);
+ tree_->CreateView(window_id, [this](mojo::ErrorCode code) {
+ OnActionCompleted(code == mojo::ERROR_CODE_NONE);
+ });
+ return window_id;
+}
+
+Window* WindowTreeClientImpl::GetRoot() {
+ return root_;
+}
+
+Window* WindowTreeClientImpl::GetWindowById(Id id) {
+ IdToWindowMap::const_iterator it = windows_.find(id);
+ return it != windows_.end() ? it->second : NULL;
+}
+
+Window* WindowTreeClientImpl::GetFocusedWindow() {
+ return focused_window_;
+}
+
+Window* WindowTreeClientImpl::CreateWindow() {
+ Window* window = new Window(this, CreateWindowOnServer());
+ AddWindow(window);
+ return window;
+}
+
+bool WindowTreeClientImpl::IsEmbedRoot() {
+ return is_embed_root_;
+}
+
+ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() {
+ return connection_id_;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeClientImpl, ViewTreeClient implementation:
+
+void WindowTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id,
+ mojo::ViewDataPtr root_data,
+ mojo::ViewTreePtr tree,
+ Id focused_window_id,
+ uint32 access_policy) {
+ if (tree) {
+ DCHECK(!tree_);
+ tree_ = tree.Pass();
+ tree_.set_connection_error_handler([this]() { delete this; });
+ }
+ connection_id_ = connection_id;
+ is_embed_root_ =
+ (access_policy & mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0;
+
+ DCHECK(!root_);
+ root_ = AddWindowToConnection(this, nullptr, root_data);
+
+ focused_window_ = GetWindowById(focused_window_id);
+
+ delegate_->OnEmbed(root_);
+}
+
+void WindowTreeClientImpl::OnEmbeddedAppDisconnected(Id window_id) {
+ Window* window = GetWindowById(window_id);
+ if (window) {
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(),
+ OnWindowEmbeddedAppDisconnected(window));
+ }
+}
+
+void WindowTreeClientImpl::OnUnembed() {
+ delegate_->OnUnembed();
+ // This will send out the various notifications.
+ delete this;
+}
+
+void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id,
+ mojo::RectPtr old_bounds,
+ mojo::RectPtr new_bounds) {
+ Window* window = GetWindowById(window_id);
+ WindowPrivate(window).LocalSetBounds(*old_bounds, *new_bounds);
+}
+
+namespace {
+
+void SetViewportMetricsOnDecendants(Window* root,
+ const mojo::ViewportMetrics& old_metrics,
+ const mojo::ViewportMetrics& new_metrics) {
+ WindowPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics);
+ const Window::Children& children = root->children();
+ for (size_t i = 0; i < children.size(); ++i)
+ SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics);
+}
+}
+
+void WindowTreeClientImpl::OnWindowViewportMetricsChanged(
+ mojo::ViewportMetricsPtr old_metrics,
+ mojo::ViewportMetricsPtr new_metrics) {
+ Window* window = GetRoot();
+ if (window)
+ SetViewportMetricsOnDecendants(window, *old_metrics, *new_metrics);
+}
+
+void WindowTreeClientImpl::OnWindowHierarchyChanged(
+ Id window_id,
+ Id new_parent_id,
+ Id old_parent_id,
+ mojo::Array<mojo::ViewDataPtr> windows) {
+ Window* initial_parent =
+ windows.size() ? GetWindowById(windows[0]->parent_id) : NULL;
+
+ const bool was_window_known = GetWindowById(window_id) != nullptr;
+
+ BuildWindowTree(this, windows, initial_parent);
+
+ // If the window was not known, then BuildWindowTree() will have created it
+ // and
+ // parented the window.
+ if (!was_window_known)
+ return;
+
+ Window* new_parent = GetWindowById(new_parent_id);
+ Window* old_parent = GetWindowById(old_parent_id);
+ Window* window = GetWindowById(window_id);
+ if (new_parent)
+ WindowPrivate(new_parent).LocalAddChild(window);
+ else
+ WindowPrivate(old_parent).LocalRemoveChild(window);
+}
+
+void WindowTreeClientImpl::OnWindowReordered(Id window_id,
+ Id relative_window_id,
+ mojo::OrderDirection direction) {
+ Window* window = GetWindowById(window_id);
+ Window* relative_window = GetWindowById(relative_window_id);
+ if (window && relative_window)
+ WindowPrivate(window).LocalReorder(relative_window, direction);
+}
+
+void WindowTreeClientImpl::OnWindowDeleted(Id window_id) {
+ Window* window = GetWindowById(window_id);
+ if (window)
+ WindowPrivate(window).LocalDestroy();
+}
+
+void WindowTreeClientImpl::OnWindowVisibilityChanged(Id window_id,
+ bool visible) {
+ // TODO(sky): there is a race condition here. If this client and another
+ // client change the visibility at the same time the wrong value may be set.
+ // Deal with this some how.
+ Window* window = GetWindowById(window_id);
+ if (window)
+ WindowPrivate(window).LocalSetVisible(visible);
+}
+
+void WindowTreeClientImpl::OnWindowDrawnStateChanged(Id window_id, bool drawn) {
+ Window* window = GetWindowById(window_id);
+ if (window)
+ WindowPrivate(window).LocalSetDrawn(drawn);
+}
+
+void WindowTreeClientImpl::OnWindowSharedPropertyChanged(
+ Id window_id,
+ const mojo::String& name,
+ mojo::Array<uint8_t> new_data) {
+ Window* window = GetWindowById(window_id);
+ if (window) {
+ std::vector<uint8_t> data;
+ std::vector<uint8_t>* data_ptr = NULL;
+ if (!new_data.is_null()) {
+ data = new_data.To<std::vector<uint8_t>>();
+ data_ptr = &data;
+ }
+
+ window->SetSharedProperty(name, data_ptr);
+ }
+}
+
+void WindowTreeClientImpl::OnWindowInputEvent(
+ Id window_id,
+ mojo::EventPtr event,
+ const mojo::Callback<void()>& ack_callback) {
+ Window* window = GetWindowById(window_id);
+ if (window) {
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(),
+ OnWindowInputEvent(window, event));
+ }
+ ack_callback.Run();
+}
+
+void WindowTreeClientImpl::OnWindowFocused(Id focused_window_id) {
+ Window* focused = GetWindowById(focused_window_id);
+ Window* blurred = focused_window_;
+ // Update |focused_window_| before calling any of the observers, so that the
+ // observers get the correct result from calling |Window::HasFocus()|,
+ // |WindowTreeConnection::GetFocusedWindow()| etc.
+ focused_window_ = focused;
+ if (blurred) {
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(blurred).observers(),
+ OnWindowFocusChanged(focused, blurred));
+ }
+ if (focused) {
+ FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(focused).observers(),
+ OnWindowFocusChanged(focused, blurred));
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeClientImpl, private:
+
+void WindowTreeClientImpl::OnActionCompleted(bool success) {
+ if (!change_acked_callback_.is_null())
+ change_acked_callback_.Run();
+}
+
+mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() {
+ return [this](bool success) { OnActionCompleted(success); };
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.h b/components/mus/public/cpp/lib/window_tree_client_impl.h
new file mode 100644
index 0000000..7f3a7ba
--- /dev/null
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.h
@@ -0,0 +1,166 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
+
+#include "components/mus/public/cpp/types.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/interfaces/view_tree.mojom.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
+
+namespace mus {
+class WindowTreeConnection;
+class WindowTreeDelegate;
+
+// Manages the connection with the Window Server service.
+class WindowTreeClientImpl : public WindowTreeConnection,
+ public mojo::ViewTreeClient {
+ public:
+ WindowTreeClientImpl(WindowTreeDelegate* delegate,
+ mojo::InterfaceRequest<mojo::ViewTreeClient> request);
+ ~WindowTreeClientImpl() override;
+
+ // Wait for OnEmbed(), returning when done.
+ void WaitForEmbed();
+
+ bool connected() const { return tree_; }
+ ConnectionSpecificId connection_id() const { return connection_id_; }
+
+ // API exposed to the window implementations that pushes local changes to the
+ // service.
+ void DestroyWindow(Id window_id);
+
+ // These methods take TransportIds. For windows owned by the current
+ // connection,
+ // the connection id high word can be zero. In all cases, the TransportId 0x1
+ // refers to the root window.
+ void AddChild(Id child_id, Id parent_id);
+ void RemoveChild(Id child_id, Id parent_id);
+
+ void Reorder(Id window_id,
+ Id relative_window_id,
+ mojo::OrderDirection direction);
+
+ // Returns true if the specified window was created by this connection.
+ bool OwnsWindow(Id id) const;
+
+ void SetBounds(Id window_id, const mojo::Rect& bounds);
+ void SetFocus(Id window_id);
+ void SetVisible(Id window_id, bool visible);
+ void SetProperty(Id window_id,
+ const std::string& name,
+ const std::vector<uint8_t>& data);
+ void SetViewTextInputState(Id window_id, mojo::TextInputStatePtr state);
+ void SetImeVisibility(Id window_id,
+ bool visible,
+ mojo::TextInputStatePtr state);
+
+ void Embed(Id window_id,
+ mojo::ViewTreeClientPtr client,
+ uint32_t policy_bitmask,
+ const mojo::ViewTree::EmbedCallback& callback);
+
+ void RequestSurface(Id window_id,
+ mojo::InterfaceRequest<mojo::Surface> surface,
+ mojo::SurfaceClientPtr client);
+
+ void set_change_acked_callback(const mojo::Callback<void(void)>& callback) {
+ change_acked_callback_ = callback;
+ }
+ void ClearChangeAckedCallback() { change_acked_callback_.reset(); }
+
+ // Start/stop tracking views. While tracked, they can be retrieved via
+ // WindowTreeConnection::GetWindowById.
+ void AddWindow(Window* window);
+ void RemoveWindow(Id window_id);
+
+ bool is_embed_root() const { return is_embed_root_; }
+
+ // Called after the root window's observers have been notified of destruction
+ // (as the last step of ~Window). This ordering ensures that the Window Server
+ // is torn down after the root.
+ void OnRootDestroyed(Window* root);
+
+ private:
+ typedef std::map<Id, Window*> IdToWindowMap;
+
+ Id CreateWindowOnServer();
+
+ // Overridden from WindowTreeConnection:
+ Window* GetRoot() override;
+ Window* GetWindowById(Id id) override;
+ Window* GetFocusedWindow() override;
+ Window* CreateWindow() override;
+ bool IsEmbedRoot() override;
+ ConnectionSpecificId GetConnectionId() override;
+
+ // Overridden from ViewTreeClient:
+ void OnEmbed(ConnectionSpecificId connection_id,
+ mojo::ViewDataPtr root,
+ mojo::ViewTreePtr tree,
+ Id focused_window_id,
+ uint32_t access_policy) override;
+ void OnEmbeddedAppDisconnected(Id window_id) override;
+ void OnUnembed() override;
+ void OnWindowBoundsChanged(Id window_id,
+ mojo::RectPtr old_bounds,
+ mojo::RectPtr new_bounds) override;
+ void OnWindowViewportMetricsChanged(
+ mojo::ViewportMetricsPtr old_metrics,
+ mojo::ViewportMetricsPtr new_metrics) override;
+ void OnWindowHierarchyChanged(
+ Id window_id,
+ Id new_parent_id,
+ Id old_parent_id,
+ mojo::Array<mojo::ViewDataPtr> windows) override;
+ void OnWindowReordered(Id window_id,
+ Id relative_window_id,
+ mojo::OrderDirection direction) override;
+ void OnWindowDeleted(Id window_id) override;
+ void OnWindowVisibilityChanged(Id window_id, bool visible) override;
+ void OnWindowDrawnStateChanged(Id window_id, bool drawn) override;
+ void OnWindowSharedPropertyChanged(Id window_id,
+ const mojo::String& name,
+ mojo::Array<uint8_t> new_data) override;
+ void OnWindowInputEvent(Id window_id,
+ mojo::EventPtr event,
+ const mojo::Callback<void()>& callback) override;
+ void OnWindowFocused(Id focused_window_id) override;
+
+ void RootDestroyed(Window* root);
+
+ void OnActionCompleted(bool success);
+
+ mojo::Callback<void(bool)> ActionCompletedCallback();
+
+ ConnectionSpecificId connection_id_;
+ ConnectionSpecificId next_id_;
+
+ mojo::Callback<void(void)> change_acked_callback_;
+
+ WindowTreeDelegate* delegate_;
+
+ Window* root_;
+
+ IdToWindowMap windows_;
+
+ Window* capture_window_;
+ Window* focused_window_;
+ Window* activated_window_;
+
+ mojo::Binding<ViewTreeClient> binding_;
+ mojo::ViewTreePtr tree_;
+
+ bool is_embed_root_;
+
+ bool in_destructor_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl);
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
diff --git a/components/mus/public/cpp/lib/view_tree_delegate.cc b/components/mus/public/cpp/lib/window_tree_delegate.cc
index c134414..c9377ba 100644
--- a/components/mus/public/cpp/lib/view_tree_delegate.cc
+++ b/components/mus/public/cpp/lib/window_tree_delegate.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
namespace mus {
-void ViewTreeDelegate::OnUnembed() {}
+void WindowTreeDelegate::OnUnembed() {}
} // namespace mus
diff --git a/components/mus/public/cpp/lib/window_tree_host_factory.cc b/components/mus/public/cpp/lib/window_tree_host_factory.cc
new file mode 100644
index 0000000..0636559
--- /dev/null
+++ b/components/mus/public/cpp/lib/window_tree_host_factory.cc
@@ -0,0 +1,36 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/window_tree_host_factory.h"
+
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
+#include "mojo/application/public/cpp/application_impl.h"
+
+namespace mus {
+
+void CreateWindowTreeHost(mojo::ViewTreeHostFactory* factory,
+ mojo::ViewTreeHostClientPtr host_client,
+ WindowTreeDelegate* delegate,
+ mojo::ViewTreeHostPtr* host) {
+ mojo::ViewTreeClientPtr tree_client;
+ WindowTreeConnection::Create(
+ delegate, GetProxy(&tree_client),
+ WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ factory->CreateWindowTreeHost(GetProxy(host), host_client.Pass(),
+ tree_client.Pass());
+}
+
+void CreateSingleWindowTreeHost(mojo::ApplicationImpl* app,
+ WindowTreeDelegate* delegate,
+ mojo::ViewTreeHostPtr* host) {
+ mojo::ViewTreeHostFactoryPtr factory;
+ mojo::URLRequestPtr request(mojo::URLRequest::New());
+ request->url = "mojo:mus";
+ app->ConnectToService(request.Pass(), &factory);
+ CreateWindowTreeHost(factory.get(), mojo::ViewTreeHostClientPtr(), delegate,
+ host);
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/output_surface.h b/components/mus/public/cpp/output_surface.h
index e187fb3..f99665d 100644
--- a/components/mus/public/cpp/output_surface.h
+++ b/components/mus/public/cpp/output_surface.h
@@ -8,16 +8,16 @@
#include "base/macros.h"
#include "cc/output/output_surface.h"
#include "cc/surfaces/surface_id.h"
-#include "components/mus/public/cpp/view_surface.h"
-#include "components/mus/public/cpp/view_surface_client.h"
+#include "components/mus/public/cpp/window_surface.h"
+#include "components/mus/public/cpp/window_surface_client.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
namespace mus {
-class OutputSurface : public cc::OutputSurface, public ViewSurfaceClient {
+class OutputSurface : public cc::OutputSurface, public WindowSurfaceClient {
public:
OutputSurface(const scoped_refptr<cc::ContextProvider>& context_provider,
- scoped_ptr<ViewSurface> surface);
+ scoped_ptr<WindowSurface> surface);
~OutputSurface() override;
// cc::OutputSurface implementation.
@@ -26,14 +26,14 @@ class OutputSurface : public cc::OutputSurface, public ViewSurfaceClient {
void DetachFromClient() override;
private:
- // ViewSurfaceClient implementation:
+ // WindowSurfaceClient implementation:
void OnResourcesReturned(
- ViewSurface* surface,
+ WindowSurface* surface,
mojo::Array<mojo::ReturnedResourcePtr> resources) override;
void SwapBuffersComplete();
- scoped_ptr<ViewSurface> surface_;
+ scoped_ptr<WindowSurface> surface_;
DISALLOW_COPY_AND_ASSIGN(OutputSurface);
};
diff --git a/components/mus/public/cpp/scoped_view_ptr.h b/components/mus/public/cpp/scoped_view_ptr.h
deleted file mode 100644
index 92c12f2..0000000
--- a/components/mus/public/cpp/scoped_view_ptr.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_SCOPED_VIEW_PTR_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_SCOPED_VIEW_PTR_H_
-
-#include "components/mus/public/cpp/view_observer.h"
-
-namespace mus {
-
-// Wraps a View, taking overship of the View. Also deals with View being
-// destroyed while ScopedViewPtr still exists.
-class ScopedViewPtr : public ViewObserver {
- public:
- explicit ScopedViewPtr(View* view);
- ~ScopedViewPtr() override;
-
- // Destroys |view|. If |view| is the root of the ViewManager than the
- // ViewManager is destroyed (which in turn destroys |view|).
- static void DeleteViewOrViewManager(View* view);
-
- View* view() { return view_; }
- const View* view() const { return view_; }
-
- private:
- void DetachFromView();
-
- void OnViewDestroying(View* view) override;
-
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedViewPtr);
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_SCOPED_VIEW_PTR_H_
diff --git a/components/mus/public/cpp/scoped_window_ptr.h b/components/mus/public/cpp/scoped_window_ptr.h
new file mode 100644
index 0000000..9fb7ada
--- /dev/null
+++ b/components/mus/public/cpp/scoped_window_ptr.h
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_SCOPED_WINDOW_PTR_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_SCOPED_WINDOW_PTR_H_
+
+#include "components/mus/public/cpp/window_observer.h"
+
+namespace mus {
+
+// Wraps a View, taking overship of the View. Also deals with View being
+// destroyed while ScopedWindowPtr still exists.
+class ScopedWindowPtr : public WindowObserver {
+ public:
+ explicit ScopedWindowPtr(Window* view);
+ ~ScopedWindowPtr() override;
+
+ // Destroys |window|. If |window| is the root of the WindowManager than the
+ // WindowManager is destroyed (which in turn destroys |window|).
+ static void DeleteWindowOrWindowManager(Window* window);
+
+ Window* window() { return window_; }
+ const Window* window() const { return window_; }
+
+ private:
+ void DetachFromWindow();
+
+ void OnWindowDestroying(Window* window) override;
+
+ Window* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedWindowPtr);
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_SCOPED_WINDOW_PTR_H_
diff --git a/components/mus/public/cpp/tests/BUILD.gn b/components/mus/public/cpp/tests/BUILD.gn
index c582994..b9ba5d0 100644
--- a/components/mus/public/cpp/tests/BUILD.gn
+++ b/components/mus/public/cpp/tests/BUILD.gn
@@ -9,8 +9,8 @@ source_set("test_support") {
testonly = true
sources = [
- "view_manager_test_base.cc",
- "view_manager_test_base.h",
+ "window_server_test_base.cc",
+ "window_server_test_base.h",
]
deps = [
@@ -26,9 +26,9 @@ source_set("test_support") {
test("mojo_view_manager_lib_unittests") {
sources = [
"run_all_unittests.cc",
- "view_manager_test_suite.cc",
- "view_manager_test_suite.h",
- "view_unittest.cc",
+ "window_server_test_suite.cc",
+ "window_server_test_suite.h",
+ "window_unittest.cc",
]
deps = [
diff --git a/components/mus/public/cpp/tests/run_all_unittests.cc b/components/mus/public/cpp/tests/run_all_unittests.cc
index ee82a07..1af6dbd 100644
--- a/components/mus/public/cpp/tests/run_all_unittests.cc
+++ b/components/mus/public/cpp/tests/run_all_unittests.cc
@@ -4,12 +4,12 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
-#include "components/mus/public/cpp/tests/view_manager_test_suite.h"
+#include "components/mus/public/cpp/tests/window_server_test_suite.h"
int main(int argc, char** argv) {
- mus::ViewManagerTestSuite test_suite(argc, argv);
+ mus::WindowServerTestSuite test_suite(argc, argv);
return base::LaunchUnitTests(argc, argv,
- base::Bind(&mus::ViewManagerTestSuite::Run,
+ base::Bind(&mus::WindowServerTestSuite::Run,
base::Unretained(&test_suite)));
}
diff --git a/components/mus/public/cpp/tests/view_manager_test_suite.h b/components/mus/public/cpp/tests/view_manager_test_suite.h
deleted file mode 100644
index b68bb2f..0000000
--- a/components/mus/public/cpp/tests/view_manager_test_suite.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
-
-#include "base/test/test_suite.h"
-#include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
-
-namespace mus {
-
-class ViewManagerTestSuite : public base::TestSuite {
- public:
- ViewManagerTestSuite(int argc, char** argv);
- ~ViewManagerTestSuite() override;
-
- protected:
- void Initialize() override;
-
- private:
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestSuite);
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
diff --git a/components/mus/public/cpp/tests/view_unittest.cc b/components/mus/public/cpp/tests/view_unittest.cc
deleted file mode 100644
index c991ca3..0000000
--- a/components/mus/public/cpp/tests/view_unittest.cc
+++ /dev/null
@@ -1,874 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/view.h"
-
-#include "base/logging.h"
-#include "base/strings/stringprintf.h"
-#include "components/mus/public/cpp/lib/view_private.h"
-#include "components/mus/public/cpp/util.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_property.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace mus {
-
-// View ------------------------------------------------------------------------
-
-typedef testing::Test ViewTest;
-
-// Subclass with public ctor/dtor.
-class TestView : public View {
- public:
- TestView() { ViewPrivate(this).set_id(1); }
- ~TestView() {}
-
- private:
- MOJO_DISALLOW_COPY_AND_ASSIGN(TestView);
-};
-
-TEST_F(ViewTest, AddChild) {
- TestView v1;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
-}
-
-TEST_F(ViewTest, RemoveChild) {
- TestView v1;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
- v1.RemoveChild(&v11);
- EXPECT_EQ(0U, v1.children().size());
-}
-
-TEST_F(ViewTest, Reparent) {
- TestView v1;
- TestView v2;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
- v2.AddChild(&v11);
- EXPECT_EQ(1U, v2.children().size());
- EXPECT_EQ(0U, v1.children().size());
-}
-
-TEST_F(ViewTest, Contains) {
- TestView v1;
-
- // Direct descendant.
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_TRUE(v1.Contains(&v11));
-
- // Indirect descendant.
- TestView v111;
- v11.AddChild(&v111);
- EXPECT_TRUE(v1.Contains(&v111));
-}
-
-TEST_F(ViewTest, GetChildById) {
- TestView v1;
- ViewPrivate(&v1).set_id(1);
- TestView v11;
- ViewPrivate(&v11).set_id(11);
- v1.AddChild(&v11);
- TestView v111;
- ViewPrivate(&v111).set_id(111);
- v11.AddChild(&v111);
-
- // Find direct & indirect descendents.
- EXPECT_EQ(&v11, v1.GetChildById(v11.id()));
- EXPECT_EQ(&v111, v1.GetChildById(v111.id()));
-}
-
-TEST_F(ViewTest, DrawnAndVisible) {
- TestView v1;
- EXPECT_TRUE(v1.visible());
- EXPECT_FALSE(v1.IsDrawn());
-
- ViewPrivate(&v1).set_drawn(true);
-
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_TRUE(v11.visible());
- EXPECT_TRUE(v11.IsDrawn());
-
- v1.RemoveChild(&v11);
- EXPECT_TRUE(v11.visible());
- EXPECT_FALSE(v11.IsDrawn());
-}
-
-namespace {
-DEFINE_VIEW_PROPERTY_KEY(int, kIntKey, -2);
-DEFINE_VIEW_PROPERTY_KEY(const char*, kStringKey, "squeamish");
-}
-
-TEST_F(ViewTest, Property) {
- TestView v;
-
- // Non-existent properties should return the default values.
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
-
- // A set property value should be returned again (even if it's the default
- // value).
- v.SetLocalProperty(kIntKey, INT_MAX);
- EXPECT_EQ(INT_MAX, v.GetLocalProperty(kIntKey));
- v.SetLocalProperty(kIntKey, -2);
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- v.SetLocalProperty(kIntKey, INT_MIN);
- EXPECT_EQ(INT_MIN, v.GetLocalProperty(kIntKey));
-
- v.SetLocalProperty(kStringKey, static_cast<const char*>(NULL));
- EXPECT_EQ(NULL, v.GetLocalProperty(kStringKey));
- v.SetLocalProperty(kStringKey, "squeamish");
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
- v.SetLocalProperty(kStringKey, "ossifrage");
- EXPECT_EQ(std::string("ossifrage"), v.GetLocalProperty(kStringKey));
-
- // ClearProperty should restore the default value.
- v.ClearLocalProperty(kIntKey);
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- v.ClearLocalProperty(kStringKey);
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
-}
-
-namespace {
-
-class TestProperty {
- public:
- TestProperty() {}
- virtual ~TestProperty() { last_deleted_ = this; }
- static TestProperty* last_deleted() { return last_deleted_; }
-
- private:
- static TestProperty* last_deleted_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(TestProperty);
-};
-
-TestProperty* TestProperty::last_deleted_ = NULL;
-
-DEFINE_OWNED_VIEW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL);
-
-} // namespace
-
-TEST_F(ViewTest, OwnedProperty) {
- TestProperty* p3 = NULL;
- {
- TestView v;
- EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey));
- TestProperty* p1 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p1);
- EXPECT_EQ(p1, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(NULL, TestProperty::last_deleted());
-
- TestProperty* p2 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p2);
- EXPECT_EQ(p2, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p1, TestProperty::last_deleted());
-
- v.ClearLocalProperty(kOwnedKey);
- EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p2, TestProperty::last_deleted());
-
- p3 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p3);
- EXPECT_EQ(p3, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p2, TestProperty::last_deleted());
- }
-
- EXPECT_EQ(p3, TestProperty::last_deleted());
-}
-
-// ViewObserver --------------------------------------------------------
-
-typedef testing::Test ViewObserverTest;
-
-bool TreeChangeParamsMatch(const ViewObserver::TreeChangeParams& lhs,
- const ViewObserver::TreeChangeParams& rhs) {
- return lhs.target == rhs.target && lhs.old_parent == rhs.old_parent &&
- lhs.new_parent == rhs.new_parent && lhs.receiver == rhs.receiver;
-}
-
-class TreeChangeObserver : public ViewObserver {
- public:
- explicit TreeChangeObserver(View* observee) : observee_(observee) {
- observee_->AddObserver(this);
- }
- ~TreeChangeObserver() override { observee_->RemoveObserver(this); }
-
- void Reset() { received_params_.clear(); }
-
- const std::vector<TreeChangeParams>& received_params() {
- return received_params_;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnTreeChanging(const TreeChangeParams& params) override {
- received_params_.push_back(params);
- }
- void OnTreeChanged(const TreeChangeParams& params) override {
- received_params_.push_back(params);
- }
-
- View* observee_;
- std::vector<TreeChangeParams> received_params_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver);
-};
-
-// Adds/Removes v11 to v1.
-TEST_F(ViewObserverTest, TreeChange_SimpleAddRemove) {
- TestView v1;
- TreeChangeObserver o1(&v1);
- EXPECT_TRUE(o1.received_params().empty());
-
- TestView v11;
- TreeChangeObserver o11(&v11);
- EXPECT_TRUE(o11.received_params().empty());
-
- // Add.
-
- v1.AddChild(&v11);
-
- EXPECT_EQ(2U, o1.received_params().size());
- ViewObserver::TreeChangeParams p1;
- p1.target = &v11;
- p1.receiver = &v1;
- p1.old_parent = NULL;
- p1.new_parent = &v1;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- ViewObserver::TreeChangeParams p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-
- o1.Reset();
- o11.Reset();
- EXPECT_TRUE(o1.received_params().empty());
- EXPECT_TRUE(o11.received_params().empty());
-
- // Remove.
-
- v1.RemoveChild(&v11);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v11;
- p1.receiver = &v1;
- p1.old_parent = &v1;
- p1.new_parent = NULL;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-}
-
-// Creates these two trees:
-// v1
-// +- v11
-// v111
-// +- v1111
-// +- v1112
-// Then adds/removes v111 from v11.
-TEST_F(ViewObserverTest, TreeChange_NestedAddRemove) {
- TestView v1, v11, v111, v1111, v1112;
-
- // Root tree.
- v1.AddChild(&v11);
-
- // Tree to be attached.
- v111.AddChild(&v1111);
- v111.AddChild(&v1112);
-
- TreeChangeObserver o1(&v1), o11(&v11), o111(&v111), o1111(&v1111),
- o1112(&v1112);
- ViewObserver::TreeChangeParams p1, p11, p111, p1111, p1112;
-
- // Add.
-
- v11.AddChild(&v111);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = NULL;
- p1.new_parent = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-
- EXPECT_EQ(2U, o111.received_params().size());
- p111 = p11;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-
- EXPECT_EQ(2U, o1111.received_params().size());
- p1111 = p111;
- p1111.receiver = &v1111;
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
-
- EXPECT_EQ(2U, o1112.received_params().size());
- p1112 = p111;
- p1112.receiver = &v1112;
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
-
- // Remove.
- o1.Reset();
- o11.Reset();
- o111.Reset();
- o1111.Reset();
- o1112.Reset();
- EXPECT_TRUE(o1.received_params().empty());
- EXPECT_TRUE(o11.received_params().empty());
- EXPECT_TRUE(o111.received_params().empty());
- EXPECT_TRUE(o1111.received_params().empty());
- EXPECT_TRUE(o1112.received_params().empty());
-
- v11.RemoveChild(&v111);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = &v11;
- p1.new_parent = NULL;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
-
- EXPECT_EQ(2U, o111.received_params().size());
- p111 = p11;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-
- EXPECT_EQ(2U, o1111.received_params().size());
- p1111 = p111;
- p1111.receiver = &v1111;
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
-
- EXPECT_EQ(2U, o1112.received_params().size());
- p1112 = p111;
- p1112.receiver = &v1112;
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
-}
-
-TEST_F(ViewObserverTest, TreeChange_Reparent) {
- TestView v1, v11, v12, v111;
- v1.AddChild(&v11);
- v1.AddChild(&v12);
- v11.AddChild(&v111);
-
- TreeChangeObserver o1(&v1), o11(&v11), o12(&v12), o111(&v111);
-
- // Reparent.
- v12.AddChild(&v111);
-
- // v1 (root) should see both changing and changed notifications.
- EXPECT_EQ(4U, o1.received_params().size());
- ViewObserver::TreeChangeParams p1;
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = &v11;
- p1.new_parent = &v12;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- // v11 should see changing notifications.
- EXPECT_EQ(2U, o11.received_params().size());
- ViewObserver::TreeChangeParams p11;
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
-
- // v12 should see changed notifications.
- EXPECT_EQ(2U, o12.received_params().size());
- ViewObserver::TreeChangeParams p12;
- p12 = p1;
- p12.receiver = &v12;
- EXPECT_TRUE(TreeChangeParamsMatch(p12, o12.received_params().back()));
-
- // v111 should see both changing and changed notifications.
- EXPECT_EQ(2U, o111.received_params().size());
- ViewObserver::TreeChangeParams p111;
- p111 = p1;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-}
-
-namespace {
-
-class OrderChangeObserver : public ViewObserver {
- public:
- struct Change {
- View* view;
- View* relative_view;
- mojo::OrderDirection direction;
- };
- typedef std::vector<Change> Changes;
-
- explicit OrderChangeObserver(View* observee) : observee_(observee) {
- observee_->AddObserver(this);
- }
- ~OrderChangeObserver() override { observee_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes_.swap(changes);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewReordering(View* view,
- View* relative_view,
- mojo::OrderDirection direction) override {
- OnViewReordered(view, relative_view, direction);
- }
-
- void OnViewReordered(View* view,
- View* relative_view,
- mojo::OrderDirection direction) override {
- Change change;
- change.view = view;
- change.relative_view = relative_view;
- change.direction = direction;
- changes_.push_back(change);
- }
-
- View* observee_;
- Changes changes_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, Order) {
- TestView v1, v11, v12, v13;
- v1.AddChild(&v11);
- v1.AddChild(&v12);
- v1.AddChild(&v13);
-
- // Order: v11, v12, v13
- EXPECT_EQ(3U, v1.children().size());
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 to front.
- // Resulting order: v12, v13, v11
- v11.MoveToFront();
- EXPECT_EQ(&v12, v1.children().front());
- EXPECT_EQ(&v11, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v13, changes[0].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v13, changes[1].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 to back.
- // Resulting order: v11, v12, v13
- v11.MoveToBack();
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 above v12.
- // Resulting order: v12. v11, v13
- v11.Reorder(&v12, mojo::ORDER_DIRECTION_ABOVE);
- EXPECT_EQ(&v12, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 below v12.
- // Resulting order: v11, v12, v13
- v11.Reorder(&v12, mojo::ORDER_DIRECTION_BELOW);
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[1].direction);
- }
-}
-
-namespace {
-
-typedef std::vector<std::string> Changes;
-
-std::string ViewIdToString(Id id) {
- return (id == 0) ? "null"
- : base::StringPrintf("%d,%d", HiWord(id), LoWord(id));
-}
-
-std::string RectToString(const mojo::Rect& rect) {
- return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width,
- rect.height);
-}
-
-class BoundsChangeObserver : public ViewObserver {
- public:
- explicit BoundsChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~BoundsChangeObserver() override { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewBoundsChanging(View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override {
- changes_.push_back(base::StringPrintf(
- "view=%s old_bounds=%s new_bounds=%s phase=changing",
- ViewIdToString(view->id()).c_str(), RectToString(old_bounds).c_str(),
- RectToString(new_bounds).c_str()));
- }
- void OnViewBoundsChanged(View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override {
- changes_.push_back(base::StringPrintf(
- "view=%s old_bounds=%s new_bounds=%s phase=changed",
- ViewIdToString(view->id()).c_str(), RectToString(old_bounds).c_str(),
- RectToString(new_bounds).c_str()));
- }
-
- View* view_;
- Changes changes_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetBounds) {
- TestView v1;
- {
- BoundsChangeObserver observer(&v1);
- mojo::Rect rect;
- rect.width = rect.height = 100;
- v1.SetBounds(rect);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(
- "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changing",
- changes[0]);
- EXPECT_EQ(
- "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changed",
- changes[1]);
- }
-}
-
-namespace {
-
-class VisibilityChangeObserver : public ViewObserver {
- public:
- explicit VisibilityChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~VisibilityChangeObserver() override { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewVisibilityChanging(View* view) override {
- changes_.push_back(
- base::StringPrintf("view=%s phase=changing visibility=%s",
- ViewIdToString(view->id()).c_str(),
- view->visible() ? "true" : "false"));
- }
- void OnViewVisibilityChanged(View* view) override {
- changes_.push_back(base::StringPrintf("view=%s phase=changed visibility=%s",
- ViewIdToString(view->id()).c_str(),
- view->visible() ? "true" : "false"));
- }
-
- View* view_;
- Changes changes_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetVisible) {
- TestView v1;
- EXPECT_TRUE(v1.visible());
- {
- // Change visibility from true to false and make sure we get notifications.
- VisibilityChangeObserver observer(&v1);
- v1.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ("view=0,1 phase=changing visibility=true", changes[0]);
- EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[1]);
- }
- {
- // Set visible to existing value and verify no notifications.
- VisibilityChangeObserver observer(&v1);
- v1.SetVisible(false);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- }
-}
-
-TEST_F(ViewObserverTest, SetVisibleParent) {
- TestView parent;
- ViewPrivate(&parent).set_id(1);
- TestView child;
- ViewPrivate(&child).set_id(2);
- parent.AddChild(&child);
- EXPECT_TRUE(parent.visible());
- EXPECT_TRUE(child.visible());
- {
- // Change visibility from true to false and make sure we get notifications
- // on the parent.
- VisibilityChangeObserver observer(&parent);
- child.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ("view=0,2 phase=changed visibility=false", changes[0]);
- }
-}
-
-TEST_F(ViewObserverTest, SetVisibleChild) {
- TestView parent;
- ViewPrivate(&parent).set_id(1);
- TestView child;
- ViewPrivate(&child).set_id(2);
- parent.AddChild(&child);
- EXPECT_TRUE(parent.visible());
- EXPECT_TRUE(child.visible());
- {
- // Change visibility from true to false and make sure we get notifications
- // on the child.
- VisibilityChangeObserver observer(&child);
- parent.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[0]);
- }
-}
-
-namespace {
-
-class SharedPropertyChangeObserver : public ViewObserver {
- public:
- explicit SharedPropertyChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~SharedPropertyChangeObserver() override { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewSharedPropertyChanged(
- View* view,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) override {
- changes_.push_back(base::StringPrintf(
- "view=%s shared property changed key=%s old_value=%s new_value=%s",
- ViewIdToString(view->id()).c_str(), name.c_str(),
- VectorToString(old_data).c_str(), VectorToString(new_data).c_str()));
- }
-
- std::string VectorToString(const std::vector<uint8_t>* data) {
- if (!data)
- return "NULL";
- std::string s;
- for (char c : *data)
- s += c;
- return s;
- }
-
- View* view_;
- Changes changes_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(SharedPropertyChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetLocalProperty) {
- TestView v1;
- std::vector<uint8_t> one(1, '1');
-
- {
- // Change visibility from true to false and make sure we get notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", &one);
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ(
- "view=0,1 shared property changed key=one old_value=NULL new_value=1",
- changes[0]);
- EXPECT_EQ(1U, v1.shared_properties().size());
- }
- {
- // Set visible to existing value and verify no notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", &one);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- EXPECT_EQ(1U, v1.shared_properties().size());
- }
- {
- // Set the value to NULL to delete it.
- // Change visibility from true to false and make sure we get notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", NULL);
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ(
- "view=0,1 shared property changed key=one old_value=1 new_value=NULL",
- changes[0]);
- EXPECT_EQ(0U, v1.shared_properties().size());
- }
- {
- // Setting a null property to null shouldn't update us.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", NULL);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- EXPECT_EQ(0U, v1.shared_properties().size());
- }
-}
-
-namespace {
-
-typedef std::pair<const void*, intptr_t> PropertyChangeInfo;
-
-class LocalPropertyChangeObserver : public ViewObserver {
- public:
- explicit LocalPropertyChangeObserver(View* view)
- : view_(view), property_key_(nullptr), old_property_value_(-1) {
- view_->AddObserver(this);
- }
- ~LocalPropertyChangeObserver() override { view_->RemoveObserver(this); }
-
- PropertyChangeInfo PropertyChangeInfoAndClear() {
- PropertyChangeInfo result(property_key_, old_property_value_);
- property_key_ = NULL;
- old_property_value_ = -3;
- return result;
- }
-
- private:
- void OnViewLocalPropertyChanged(View* window,
- const void* key,
- intptr_t old) override {
- property_key_ = key;
- old_property_value_ = old;
- }
-
- View* view_;
- const void* property_key_;
- intptr_t old_property_value_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(LocalPropertyChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, LocalPropertyChanged) {
- TestView v1;
- LocalPropertyChangeObserver o(&v1);
-
- static const ViewProperty<int> prop = {-2};
-
- v1.SetLocalProperty(&prop, 1);
- EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
- v1.SetLocalProperty(&prop, -2);
- EXPECT_EQ(PropertyChangeInfo(&prop, 1), o.PropertyChangeInfoAndClear());
- v1.SetLocalProperty(&prop, 3);
- EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
- v1.ClearLocalProperty(&prop);
- EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear());
-
- // Sanity check to see if |PropertyChangeInfoAndClear| really clears.
- EXPECT_EQ(PropertyChangeInfo(reinterpret_cast<const void*>(NULL), -3),
- o.PropertyChangeInfoAndClear());
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/tests/view_manager_test_base.cc b/components/mus/public/cpp/tests/window_server_test_base.cc
index e4bf2ba..649fc24 100644
--- a/components/mus/public/cpp/tests/view_manager_test_base.cc
+++ b/components/mus/public/cpp/tests/window_server_test_base.cc
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/tests/view_manager_test_base.h"
+#include "components/mus/public/cpp/tests/window_server_test_base.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/test_timeouts.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "mojo/application/public/cpp/application_impl.h"
namespace mus {
@@ -26,15 +26,15 @@ void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) {
} // namespace
-ViewManagerTestBase::ViewManagerTestBase()
+WindowServerTestBase::WindowServerTestBase()
: most_recent_connection_(nullptr),
window_manager_(nullptr),
- view_tree_connection_destroyed_(false) {}
+ window_tree_connection_destroyed_(false) {}
-ViewManagerTestBase::~ViewManagerTestBase() {}
+WindowServerTestBase::~WindowServerTestBase() {}
// static
-bool ViewManagerTestBase::DoRunLoopWithTimeout() {
+bool WindowServerTestBase::DoRunLoopWithTimeout() {
if (current_run_loop != nullptr)
return false;
@@ -51,7 +51,7 @@ bool ViewManagerTestBase::DoRunLoopWithTimeout() {
}
// static
-bool ViewManagerTestBase::QuitRunLoop() {
+bool WindowServerTestBase::QuitRunLoop() {
if (!current_run_loop)
return false;
@@ -60,44 +60,44 @@ bool ViewManagerTestBase::QuitRunLoop() {
return true;
}
-void ViewManagerTestBase::SetUp() {
+void WindowServerTestBase::SetUp() {
ApplicationTestBase::SetUp();
- CreateSingleViewTreeHost(application_impl(), this, &host_);
+ CreateSingleWindowTreeHost(application_impl(), this, &host_);
ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed().
std::swap(window_manager_, most_recent_connection_);
}
-void ViewManagerTestBase::TearDown() {
+void WindowServerTestBase::TearDown() {
ApplicationTestBase::TearDown();
}
-mojo::ApplicationDelegate* ViewManagerTestBase::GetApplicationDelegate() {
+mojo::ApplicationDelegate* WindowServerTestBase::GetApplicationDelegate() {
return this;
}
-bool ViewManagerTestBase::ConfigureIncomingConnection(
+bool WindowServerTestBase::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
connection->AddService<mojo::ViewTreeClient>(this);
return true;
}
-void ViewManagerTestBase::OnEmbed(View* root) {
+void WindowServerTestBase::OnEmbed(Window* root) {
most_recent_connection_ = root->connection();
EXPECT_TRUE(QuitRunLoop());
}
-void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) {
- view_tree_connection_destroyed_ = true;
+void WindowServerTestBase::OnConnectionLost(WindowTreeConnection* connection) {
+ window_tree_connection_destroyed_ = true;
}
-void ViewManagerTestBase::Create(
+void WindowServerTestBase::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ViewTreeClient> request) {
- ViewTreeConnection::Create(
+ WindowTreeConnection::Create(
this, request.Pass(),
- ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
} // namespace mus
diff --git a/components/mus/public/cpp/tests/view_manager_test_base.h b/components/mus/public/cpp/tests/window_server_test_base.h
index a1529f3..b46c871 100644
--- a/components/mus/public/cpp/tests/view_manager_test_base.h
+++ b/components/mus/public/cpp/tests/window_server_test_base.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_
#include "base/memory/scoped_ptr.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/view_tree.mojom.h"
#include "components/mus/public/interfaces/view_tree_host.mojom.h"
#include "mojo/application/public/cpp/application_delegate.h"
@@ -15,22 +15,22 @@
namespace mus {
-// ViewManagerTestBase is a base class for use with app tests that use
-// ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed()
-// has been invoked. window_manager() can be used to access the ViewManager
+// WindowServerTestBase is a base class for use with app tests that use
+// WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed()
+// has been invoked. window_manager() can be used to access the WindowServer
// established as part of SetUp().
-class ViewManagerTestBase
+class WindowServerTestBase
: public mojo::test::ApplicationTestBase,
public mojo::ApplicationDelegate,
- public ViewTreeDelegate,
+ public WindowTreeDelegate,
public mojo::InterfaceFactory<mojo::ViewTreeClient> {
public:
- ViewManagerTestBase();
- ~ViewManagerTestBase() override;
+ WindowServerTestBase();
+ ~WindowServerTestBase() override;
- // True if ViewTreeDelegate::OnConnectionLost() was called.
- bool view_tree_connection_destroyed() const {
- return view_tree_connection_destroyed_;
+ // True if WindowTreeDelegate::OnConnectionLost() was called.
+ bool window_tree_connection_destroyed() const {
+ return window_tree_connection_destroyed_;
}
// Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs.
@@ -42,10 +42,10 @@ class ViewManagerTestBase
// success, false if a RunLoop isn't running.
static bool QuitRunLoop() WARN_UNUSED_RESULT;
- ViewTreeConnection* window_manager() { return window_manager_; }
+ WindowTreeConnection* window_manager() { return window_manager_; }
protected:
- ViewTreeConnection* most_recent_connection() {
+ WindowTreeConnection* most_recent_connection() {
return most_recent_connection_;
}
@@ -60,9 +60,9 @@ class ViewManagerTestBase
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // ViewTreeDelegate:
- void OnEmbed(View* root) override;
- void OnConnectionLost(ViewTreeConnection* connection) override;
+ // WindowTreeDelegate:
+ void OnEmbed(Window* root) override;
+ void OnConnectionLost(WindowTreeConnection* connection) override;
// InterfaceFactory<ViewTreeClient>:
void Create(mojo::ApplicationConnection* connection,
@@ -70,20 +70,20 @@ class ViewManagerTestBase
// Used to receive the most recent view tree connection loaded by an embed
// action.
- ViewTreeConnection* most_recent_connection_;
+ WindowTreeConnection* most_recent_connection_;
private:
mojo::ViewTreeHostPtr host_;
// The View Manager connection held by the window manager (app running at the
// root view).
- ViewTreeConnection* window_manager_;
+ WindowTreeConnection* window_manager_;
- bool view_tree_connection_destroyed_;
+ bool window_tree_connection_destroyed_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase);
};
} // namespace mus
-#endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_
+#endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_
diff --git a/components/mus/public/cpp/tests/view_manager_test_suite.cc b/components/mus/public/cpp/tests/window_server_test_suite.cc
index a1e0c98..ea1a04c 100644
--- a/components/mus/public/cpp/tests/view_manager_test_suite.cc
+++ b/components/mus/public/cpp/tests/window_server_test_suite.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/public/cpp/tests/view_manager_test_suite.h"
+#include "components/mus/public/cpp/tests/window_server_test_suite.h"
#include "base/i18n/icu_util.h"
@@ -12,12 +12,12 @@
namespace mus {
-ViewManagerTestSuite::ViewManagerTestSuite(int argc, char** argv)
+WindowServerTestSuite::WindowServerTestSuite(int argc, char** argv)
: TestSuite(argc, argv) {}
-ViewManagerTestSuite::~ViewManagerTestSuite() {}
+WindowServerTestSuite::~WindowServerTestSuite() {}
-void ViewManagerTestSuite::Initialize() {
+void WindowServerTestSuite::Initialize() {
#if defined(USE_X11)
// Each test ends up creating a new thread for the native viewport service.
// In other words we'll use X on different threads, so tell it that.
diff --git a/components/mus/public/cpp/tests/window_server_test_suite.h b/components/mus/public/cpp/tests/window_server_test_suite.h
new file mode 100644
index 0000000..cbc2eb7
--- /dev/null
+++ b/components/mus/public/cpp/tests/window_server_test_suite.h
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_SUITE_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_SUITE_H_
+
+#include "base/test/test_suite.h"
+#include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
+
+namespace mus {
+
+class WindowServerTestSuite : public base::TestSuite {
+ public:
+ WindowServerTestSuite(int argc, char** argv);
+ ~WindowServerTestSuite() override;
+
+ protected:
+ void Initialize() override;
+
+ private:
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowServerTestSuite);
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_SUITE_H_
diff --git a/components/mus/public/cpp/tests/window_unittest.cc b/components/mus/public/cpp/tests/window_unittest.cc
new file mode 100644
index 0000000..870a026
--- /dev/null
+++ b/components/mus/public/cpp/tests/window_unittest.cc
@@ -0,0 +1,875 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/window.h"
+
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+#include "components/mus/public/cpp/lib/window_private.h"
+#include "components/mus/public/cpp/util.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_property.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mus {
+
+// Window ---------------------------------------------------------------------
+
+typedef testing::Test WindowTest;
+
+// Subclass with public ctor/dtor.
+class TestWindow : public Window {
+ public:
+ TestWindow() { WindowPrivate(this).set_id(1); }
+ ~TestWindow() {}
+
+ private:
+ MOJO_DISALLOW_COPY_AND_ASSIGN(TestWindow);
+};
+
+TEST_F(WindowTest, AddChild) {
+ TestWindow w1;
+ TestWindow w11;
+ w1.AddChild(&w11);
+ EXPECT_EQ(1U, w1.children().size());
+}
+
+TEST_F(WindowTest, RemoveChild) {
+ TestWindow w1;
+ TestWindow w11;
+ w1.AddChild(&w11);
+ EXPECT_EQ(1U, w1.children().size());
+ w1.RemoveChild(&w11);
+ EXPECT_EQ(0U, w1.children().size());
+}
+
+TEST_F(WindowTest, Reparent) {
+ TestWindow w1;
+ TestWindow w2;
+ TestWindow w11;
+ w1.AddChild(&w11);
+ EXPECT_EQ(1U, w1.children().size());
+ w2.AddChild(&w11);
+ EXPECT_EQ(1U, w2.children().size());
+ EXPECT_EQ(0U, w1.children().size());
+}
+
+TEST_F(WindowTest, Contains) {
+ TestWindow w1;
+
+ // Direct descendant.
+ TestWindow w11;
+ w1.AddChild(&w11);
+ EXPECT_TRUE(w1.Contains(&w11));
+
+ // Indirect descendant.
+ TestWindow w111;
+ w11.AddChild(&w111);
+ EXPECT_TRUE(w1.Contains(&w111));
+}
+
+TEST_F(WindowTest, GetChildById) {
+ TestWindow w1;
+ WindowPrivate(&w1).set_id(1);
+ TestWindow w11;
+ WindowPrivate(&w11).set_id(11);
+ w1.AddChild(&w11);
+ TestWindow w111;
+ WindowPrivate(&w111).set_id(111);
+ w11.AddChild(&w111);
+
+ // Find direct & indirect descendents.
+ EXPECT_EQ(&w11, w1.GetChildById(w11.id()));
+ EXPECT_EQ(&w111, w1.GetChildById(w111.id()));
+}
+
+TEST_F(WindowTest, DrawnAndVisible) {
+ TestWindow w1;
+ EXPECT_TRUE(w1.visible());
+ EXPECT_FALSE(w1.IsDrawn());
+
+ WindowPrivate(&w1).set_drawn(true);
+
+ TestWindow w11;
+ w1.AddChild(&w11);
+ EXPECT_TRUE(w11.visible());
+ EXPECT_TRUE(w11.IsDrawn());
+
+ w1.RemoveChild(&w11);
+ EXPECT_TRUE(w11.visible());
+ EXPECT_FALSE(w11.IsDrawn());
+}
+
+namespace {
+DEFINE_WINDOW_PROPERTY_KEY(int, kIntKey, -2);
+DEFINE_WINDOW_PROPERTY_KEY(const char*, kStringKey, "squeamish");
+}
+
+TEST_F(WindowTest, Property) {
+ TestWindow w;
+
+ // Non-existent properties should return the default walues.
+ EXPECT_EQ(-2, w.GetLocalProperty(kIntKey));
+ EXPECT_EQ(std::string("squeamish"), w.GetLocalProperty(kStringKey));
+
+ // A set property walue should be returned again (even if it's the default
+ // walue).
+ w.SetLocalProperty(kIntKey, INT_MAX);
+ EXPECT_EQ(INT_MAX, w.GetLocalProperty(kIntKey));
+ w.SetLocalProperty(kIntKey, -2);
+ EXPECT_EQ(-2, w.GetLocalProperty(kIntKey));
+ w.SetLocalProperty(kIntKey, INT_MIN);
+ EXPECT_EQ(INT_MIN, w.GetLocalProperty(kIntKey));
+
+ w.SetLocalProperty(kStringKey, static_cast<const char*>(NULL));
+ EXPECT_EQ(NULL, w.GetLocalProperty(kStringKey));
+ w.SetLocalProperty(kStringKey, "squeamish");
+ EXPECT_EQ(std::string("squeamish"), w.GetLocalProperty(kStringKey));
+ w.SetLocalProperty(kStringKey, "ossifrage");
+ EXPECT_EQ(std::string("ossifrage"), w.GetLocalProperty(kStringKey));
+
+ // ClearProperty should restore the default walue.
+ w.ClearLocalProperty(kIntKey);
+ EXPECT_EQ(-2, w.GetLocalProperty(kIntKey));
+ w.ClearLocalProperty(kStringKey);
+ EXPECT_EQ(std::string("squeamish"), w.GetLocalProperty(kStringKey));
+}
+
+namespace {
+
+class TestProperty {
+ public:
+ TestProperty() {}
+ virtual ~TestProperty() { last_deleted_ = this; }
+ static TestProperty* last_deleted() { return last_deleted_; }
+
+ private:
+ static TestProperty* last_deleted_;
+ MOJO_DISALLOW_COPY_AND_ASSIGN(TestProperty);
+};
+
+TestProperty* TestProperty::last_deleted_ = NULL;
+
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL);
+
+} // namespace
+
+TEST_F(WindowTest, OwnedProperty) {
+ TestProperty* p3 = NULL;
+ {
+ TestWindow w;
+ EXPECT_EQ(NULL, w.GetLocalProperty(kOwnedKey));
+ TestProperty* p1 = new TestProperty();
+ w.SetLocalProperty(kOwnedKey, p1);
+ EXPECT_EQ(p1, w.GetLocalProperty(kOwnedKey));
+ EXPECT_EQ(NULL, TestProperty::last_deleted());
+
+ TestProperty* p2 = new TestProperty();
+ w.SetLocalProperty(kOwnedKey, p2);
+ EXPECT_EQ(p2, w.GetLocalProperty(kOwnedKey));
+ EXPECT_EQ(p1, TestProperty::last_deleted());
+
+ w.ClearLocalProperty(kOwnedKey);
+ EXPECT_EQ(NULL, w.GetLocalProperty(kOwnedKey));
+ EXPECT_EQ(p2, TestProperty::last_deleted());
+
+ p3 = new TestProperty();
+ w.SetLocalProperty(kOwnedKey, p3);
+ EXPECT_EQ(p3, w.GetLocalProperty(kOwnedKey));
+ EXPECT_EQ(p2, TestProperty::last_deleted());
+ }
+
+ EXPECT_EQ(p3, TestProperty::last_deleted());
+}
+
+// WindowObserver --------------------------------------------------------
+
+typedef testing::Test WindowObserverTest;
+
+bool TreeChangeParamsMatch(const WindowObserver::TreeChangeParams& lhs,
+ const WindowObserver::TreeChangeParams& rhs) {
+ return lhs.target == rhs.target && lhs.old_parent == rhs.old_parent &&
+ lhs.new_parent == rhs.new_parent && lhs.receiver == rhs.receiver;
+}
+
+class TreeChangeObserver : public WindowObserver {
+ public:
+ explicit TreeChangeObserver(Window* observee) : observee_(observee) {
+ observee_->AddObserver(this);
+ }
+ ~TreeChangeObserver() override { observee_->RemoveObserver(this); }
+
+ void Reset() { received_params_.clear(); }
+
+ const std::vector<TreeChangeParams>& received_params() {
+ return received_params_;
+ }
+
+ private:
+ // Overridden from WindowObserver:
+ void OnTreeChanging(const TreeChangeParams& params) override {
+ received_params_.push_back(params);
+ }
+ void OnTreeChanged(const TreeChangeParams& params) override {
+ received_params_.push_back(params);
+ }
+
+ Window* observee_;
+ std::vector<TreeChangeParams> received_params_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver);
+};
+
+// Adds/Removes w11 to w1.
+TEST_F(WindowObserverTest, TreeChange_SimpleAddRemove) {
+ TestWindow w1;
+ TreeChangeObserver o1(&w1);
+ EXPECT_TRUE(o1.received_params().empty());
+
+ TestWindow w11;
+ TreeChangeObserver o11(&w11);
+ EXPECT_TRUE(o11.received_params().empty());
+
+ // Add.
+
+ w1.AddChild(&w11);
+
+ EXPECT_EQ(2U, o1.received_params().size());
+ WindowObserver::TreeChangeParams p1;
+ p1.target = &w11;
+ p1.receiver = &w1;
+ p1.old_parent = NULL;
+ p1.new_parent = &w1;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
+
+ EXPECT_EQ(2U, o11.received_params().size());
+ WindowObserver::TreeChangeParams p11 = p1;
+ p11.receiver = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
+
+ o1.Reset();
+ o11.Reset();
+ EXPECT_TRUE(o1.received_params().empty());
+ EXPECT_TRUE(o11.received_params().empty());
+
+ // Remove.
+
+ w1.RemoveChild(&w11);
+
+ EXPECT_EQ(2U, o1.received_params().size());
+ p1.target = &w11;
+ p1.receiver = &w1;
+ p1.old_parent = &w1;
+ p1.new_parent = NULL;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
+
+ EXPECT_EQ(2U, o11.received_params().size());
+ p11 = p1;
+ p11.receiver = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
+}
+
+// Creates these two trees:
+// w1
+// +- w11
+// w111
+// +- w1111
+// +- w1112
+// Then adds/removes w111 from w11.
+TEST_F(WindowObserverTest, TreeChange_NestedAddRemove) {
+ TestWindow w1, w11, w111, w1111, w1112;
+
+ // Root tree.
+ w1.AddChild(&w11);
+
+ // Tree to be attached.
+ w111.AddChild(&w1111);
+ w111.AddChild(&w1112);
+
+ TreeChangeObserver o1(&w1), o11(&w11), o111(&w111), o1111(&w1111),
+ o1112(&w1112);
+ WindowObserver::TreeChangeParams p1, p11, p111, p1111, p1112;
+
+ // Add.
+
+ w11.AddChild(&w111);
+
+ EXPECT_EQ(2U, o1.received_params().size());
+ p1.target = &w111;
+ p1.receiver = &w1;
+ p1.old_parent = NULL;
+ p1.new_parent = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
+
+ EXPECT_EQ(2U, o11.received_params().size());
+ p11 = p1;
+ p11.receiver = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
+
+ EXPECT_EQ(2U, o111.received_params().size());
+ p111 = p11;
+ p111.receiver = &w111;
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
+
+ EXPECT_EQ(2U, o1111.received_params().size());
+ p1111 = p111;
+ p1111.receiver = &w1111;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
+
+ EXPECT_EQ(2U, o1112.received_params().size());
+ p1112 = p111;
+ p1112.receiver = &w1112;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
+
+ // Remove.
+ o1.Reset();
+ o11.Reset();
+ o111.Reset();
+ o1111.Reset();
+ o1112.Reset();
+ EXPECT_TRUE(o1.received_params().empty());
+ EXPECT_TRUE(o11.received_params().empty());
+ EXPECT_TRUE(o111.received_params().empty());
+ EXPECT_TRUE(o1111.received_params().empty());
+ EXPECT_TRUE(o1112.received_params().empty());
+
+ w11.RemoveChild(&w111);
+
+ EXPECT_EQ(2U, o1.received_params().size());
+ p1.target = &w111;
+ p1.receiver = &w1;
+ p1.old_parent = &w11;
+ p1.new_parent = NULL;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
+
+ EXPECT_EQ(2U, o11.received_params().size());
+ p11 = p1;
+ p11.receiver = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
+
+ EXPECT_EQ(2U, o111.received_params().size());
+ p111 = p11;
+ p111.receiver = &w111;
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
+
+ EXPECT_EQ(2U, o1111.received_params().size());
+ p1111 = p111;
+ p1111.receiver = &w1111;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
+
+ EXPECT_EQ(2U, o1112.received_params().size());
+ p1112 = p111;
+ p1112.receiver = &w1112;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
+}
+
+TEST_F(WindowObserverTest, TreeChange_Reparent) {
+ TestWindow w1, w11, w12, w111;
+ w1.AddChild(&w11);
+ w1.AddChild(&w12);
+ w11.AddChild(&w111);
+
+ TreeChangeObserver o1(&w1), o11(&w11), o12(&w12), o111(&w111);
+
+ // Reparent.
+ w12.AddChild(&w111);
+
+ // w1 (root) should see both changing and changed notifications.
+ EXPECT_EQ(4U, o1.received_params().size());
+ WindowObserver::TreeChangeParams p1;
+ p1.target = &w111;
+ p1.receiver = &w1;
+ p1.old_parent = &w11;
+ p1.new_parent = &w12;
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
+
+ // w11 should see changing notifications.
+ EXPECT_EQ(2U, o11.received_params().size());
+ WindowObserver::TreeChangeParams p11;
+ p11 = p1;
+ p11.receiver = &w11;
+ EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
+
+ // w12 should see changed notifications.
+ EXPECT_EQ(2U, o12.received_params().size());
+ WindowObserver::TreeChangeParams p12;
+ p12 = p1;
+ p12.receiver = &w12;
+ EXPECT_TRUE(TreeChangeParamsMatch(p12, o12.received_params().back()));
+
+ // w111 should see both changing and changed notifications.
+ EXPECT_EQ(2U, o111.received_params().size());
+ WindowObserver::TreeChangeParams p111;
+ p111 = p1;
+ p111.receiver = &w111;
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
+ EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
+}
+
+namespace {
+
+class OrderChangeObserver : public WindowObserver {
+ public:
+ struct Change {
+ Window* window;
+ Window* relative_window;
+ mojo::OrderDirection direction;
+ };
+ typedef std::vector<Change> Changes;
+
+ explicit OrderChangeObserver(Window* observee) : observee_(observee) {
+ observee_->AddObserver(this);
+ }
+ ~OrderChangeObserver() override { observee_->RemoveObserver(this); }
+
+ Changes GetAndClearChanges() {
+ Changes changes;
+ changes_.swap(changes);
+ return changes;
+ }
+
+ private:
+ // Overridden from WindowObserver:
+ void OnWindowReordering(Window* window,
+ Window* relative_window,
+ mojo::OrderDirection direction) override {
+ OnWindowReordered(window, relative_window, direction);
+ }
+
+ void OnWindowReordered(Window* window,
+ Window* relative_window,
+ mojo::OrderDirection direction) override {
+ Change change;
+ change.window = window;
+ change.relative_window = relative_window;
+ change.direction = direction;
+ changes_.push_back(change);
+ }
+
+ Window* observee_;
+ Changes changes_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
+};
+
+} // namespace
+
+TEST_F(WindowObserverTest, Order) {
+ TestWindow w1, w11, w12, w13;
+ w1.AddChild(&w11);
+ w1.AddChild(&w12);
+ w1.AddChild(&w13);
+
+ // Order: w11, w12, w13
+ EXPECT_EQ(3U, w1.children().size());
+ EXPECT_EQ(&w11, w1.children().front());
+ EXPECT_EQ(&w13, w1.children().back());
+
+ {
+ OrderChangeObserver observer(&w11);
+
+ // Move w11 to front.
+ // Resulting order: w12, w13, w11
+ w11.MoveToFront();
+ EXPECT_EQ(&w12, w1.children().front());
+ EXPECT_EQ(&w11, w1.children().back());
+
+ OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ(&w11, changes[0].window);
+ EXPECT_EQ(&w13, changes[0].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[0].direction);
+
+ EXPECT_EQ(&w11, changes[1].window);
+ EXPECT_EQ(&w13, changes[1].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[1].direction);
+ }
+
+ {
+ OrderChangeObserver observer(&w11);
+
+ // Move w11 to back.
+ // Resulting order: w11, w12, w13
+ w11.MoveToBack();
+ EXPECT_EQ(&w11, w1.children().front());
+ EXPECT_EQ(&w13, w1.children().back());
+
+ OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ(&w11, changes[0].window);
+ EXPECT_EQ(&w12, changes[0].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[0].direction);
+
+ EXPECT_EQ(&w11, changes[1].window);
+ EXPECT_EQ(&w12, changes[1].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[1].direction);
+ }
+
+ {
+ OrderChangeObserver observer(&w11);
+
+ // Move w11 above w12.
+ // Resulting order: w12. w11, w13
+ w11.Reorder(&w12, mojo::ORDER_DIRECTION_ABOVE);
+ EXPECT_EQ(&w12, w1.children().front());
+ EXPECT_EQ(&w13, w1.children().back());
+
+ OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ(&w11, changes[0].window);
+ EXPECT_EQ(&w12, changes[0].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[0].direction);
+
+ EXPECT_EQ(&w11, changes[1].window);
+ EXPECT_EQ(&w12, changes[1].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_ABOVE, changes[1].direction);
+ }
+
+ {
+ OrderChangeObserver observer(&w11);
+
+ // Move w11 below w12.
+ // Resulting order: w11, w12, w13
+ w11.Reorder(&w12, mojo::ORDER_DIRECTION_BELOW);
+ EXPECT_EQ(&w11, w1.children().front());
+ EXPECT_EQ(&w13, w1.children().back());
+
+ OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ(&w11, changes[0].window);
+ EXPECT_EQ(&w12, changes[0].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[0].direction);
+
+ EXPECT_EQ(&w11, changes[1].window);
+ EXPECT_EQ(&w12, changes[1].relative_window);
+ EXPECT_EQ(mojo::ORDER_DIRECTION_BELOW, changes[1].direction);
+ }
+}
+
+namespace {
+
+typedef std::vector<std::string> Changes;
+
+std::string WindowIdToString(Id id) {
+ return (id == 0) ? "null"
+ : base::StringPrintf("%d,%d", HiWord(id), LoWord(id));
+}
+
+std::string RectToString(const mojo::Rect& rect) {
+ return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width,
+ rect.height);
+}
+
+class BoundsChangeObserver : public WindowObserver {
+ public:
+ explicit BoundsChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
+ }
+ ~BoundsChangeObserver() override { window_->RemoveObserver(this); }
+
+ Changes GetAndClearChanges() {
+ Changes changes;
+ changes.swap(changes_);
+ return changes;
+ }
+
+ private:
+ // Overridden from WindowObserver:
+ void OnWindowBoundsChanging(Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override {
+ changes_.push_back(base::StringPrintf(
+ "window=%s old_bounds=%s new_bounds=%s phase=changing",
+ WindowIdToString(window->id()).c_str(),
+ RectToString(old_bounds).c_str(), RectToString(new_bounds).c_str()));
+ }
+ void OnWindowBoundsChanged(Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override {
+ changes_.push_back(base::StringPrintf(
+ "window=%s old_bounds=%s new_bounds=%s phase=changed",
+ WindowIdToString(window->id()).c_str(),
+ RectToString(old_bounds).c_str(), RectToString(new_bounds).c_str()));
+ }
+
+ Window* window_;
+ Changes changes_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
+};
+
+} // namespace
+
+TEST_F(WindowObserverTest, SetBounds) {
+ TestWindow w1;
+ {
+ BoundsChangeObserver observer(&w1);
+ mojo::Rect rect;
+ rect.width = rect.height = 100;
+ w1.SetBounds(rect);
+
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ(
+ "window=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changing",
+ changes[0]);
+ EXPECT_EQ(
+ "window=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changed",
+ changes[1]);
+ }
+}
+
+namespace {
+
+class VisibilityChangeObserver : public WindowObserver {
+ public:
+ explicit VisibilityChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
+ }
+ ~VisibilityChangeObserver() override { window_->RemoveObserver(this); }
+
+ Changes GetAndClearChanges() {
+ Changes changes;
+ changes.swap(changes_);
+ return changes;
+ }
+
+ private:
+ // Overridden from WindowObserver:
+ void OnWindowVisibilityChanging(Window* window) override {
+ changes_.push_back(
+ base::StringPrintf("window=%s phase=changing wisibility=%s",
+ WindowIdToString(window->id()).c_str(),
+ window->visible() ? "true" : "false"));
+ }
+ void OnWindowVisibilityChanged(Window* window) override {
+ changes_.push_back(
+ base::StringPrintf("window=%s phase=changed wisibility=%s",
+ WindowIdToString(window->id()).c_str(),
+ window->visible() ? "true" : "false"));
+ }
+
+ Window* window_;
+ Changes changes_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
+};
+
+} // namespace
+
+TEST_F(WindowObserverTest, SetVisible) {
+ TestWindow w1;
+ EXPECT_TRUE(w1.visible());
+ {
+ // Change wisibility from true to false and make sure we get notifications.
+ VisibilityChangeObserver observer(&w1);
+ w1.SetVisible(false);
+
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(2U, changes.size());
+ EXPECT_EQ("window=0,1 phase=changing wisibility=true", changes[0]);
+ EXPECT_EQ("window=0,1 phase=changed wisibility=false", changes[1]);
+ }
+ {
+ // Set visible to existing walue and werify no notifications.
+ VisibilityChangeObserver observer(&w1);
+ w1.SetVisible(false);
+ EXPECT_TRUE(observer.GetAndClearChanges().empty());
+ }
+}
+
+TEST_F(WindowObserverTest, SetVisibleParent) {
+ TestWindow parent;
+ WindowPrivate(&parent).set_id(1);
+ TestWindow child;
+ WindowPrivate(&child).set_id(2);
+ parent.AddChild(&child);
+ EXPECT_TRUE(parent.visible());
+ EXPECT_TRUE(child.visible());
+ {
+ // Change wisibility from true to false and make sure we get notifications
+ // on the parent.
+ VisibilityChangeObserver observer(&parent);
+ child.SetVisible(false);
+
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(1U, changes.size());
+ EXPECT_EQ("window=0,2 phase=changed wisibility=false", changes[0]);
+ }
+}
+
+TEST_F(WindowObserverTest, SetVisibleChild) {
+ TestWindow parent;
+ WindowPrivate(&parent).set_id(1);
+ TestWindow child;
+ WindowPrivate(&child).set_id(2);
+ parent.AddChild(&child);
+ EXPECT_TRUE(parent.visible());
+ EXPECT_TRUE(child.visible());
+ {
+ // Change wisibility from true to false and make sure we get notifications
+ // on the child.
+ VisibilityChangeObserver observer(&child);
+ parent.SetVisible(false);
+
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(1U, changes.size());
+ EXPECT_EQ("window=0,1 phase=changed wisibility=false", changes[0]);
+ }
+}
+
+namespace {
+
+class SharedPropertyChangeObserver : public WindowObserver {
+ public:
+ explicit SharedPropertyChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
+ }
+ ~SharedPropertyChangeObserver() override { window_->RemoveObserver(this); }
+
+ Changes GetAndClearChanges() {
+ Changes changes;
+ changes.swap(changes_);
+ return changes;
+ }
+
+ private:
+ // Overridden from WindowObserver:
+ void OnWindowSharedPropertyChanged(
+ Window* window,
+ const std::string& name,
+ const std::vector<uint8_t>* old_data,
+ const std::vector<uint8_t>* new_data) override {
+ changes_.push_back(base::StringPrintf(
+ "window=%s shared property changed key=%s old_value=%s new_value=%s",
+ WindowIdToString(window->id()).c_str(), name.c_str(),
+ VectorToString(old_data).c_str(), VectorToString(new_data).c_str()));
+ }
+
+ std::string VectorToString(const std::vector<uint8_t>* data) {
+ if (!data)
+ return "NULL";
+ std::string s;
+ for (char c : *data)
+ s += c;
+ return s;
+ }
+
+ Window* window_;
+ Changes changes_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(SharedPropertyChangeObserver);
+};
+
+} // namespace
+
+TEST_F(WindowObserverTest, SetLocalProperty) {
+ TestWindow w1;
+ std::vector<uint8_t> one(1, '1');
+
+ {
+ // Change wisibility from true to false and make sure we get notifications.
+ SharedPropertyChangeObserver observer(&w1);
+ w1.SetSharedProperty("one", &one);
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(1U, changes.size());
+ EXPECT_EQ(
+ "window=0,1 shared property changed key=one old_value=NULL new_value=1",
+ changes[0]);
+ EXPECT_EQ(1U, w1.shared_properties().size());
+ }
+ {
+ // Set visible to existing walue and werify no notifications.
+ SharedPropertyChangeObserver observer(&w1);
+ w1.SetSharedProperty("one", &one);
+ EXPECT_TRUE(observer.GetAndClearChanges().empty());
+ EXPECT_EQ(1U, w1.shared_properties().size());
+ }
+ {
+ // Set the walue to NULL to delete it.
+ // Change wisibility from true to false and make sure we get notifications.
+ SharedPropertyChangeObserver observer(&w1);
+ w1.SetSharedProperty("one", NULL);
+ Changes changes = observer.GetAndClearChanges();
+ ASSERT_EQ(1U, changes.size());
+ EXPECT_EQ(
+ "window=0,1 shared property changed key=one old_value=1 new_value=NULL",
+ changes[0]);
+ EXPECT_EQ(0U, w1.shared_properties().size());
+ }
+ {
+ // Setting a null property to null shouldn't update us.
+ SharedPropertyChangeObserver observer(&w1);
+ w1.SetSharedProperty("one", NULL);
+ EXPECT_TRUE(observer.GetAndClearChanges().empty());
+ EXPECT_EQ(0U, w1.shared_properties().size());
+ }
+}
+
+namespace {
+
+typedef std::pair<const void*, intptr_t> PropertyChangeInfo;
+
+class LocalPropertyChangeObserver : public WindowObserver {
+ public:
+ explicit LocalPropertyChangeObserver(Window* window)
+ : window_(window), property_key_(nullptr), old_property_value_(-1) {
+ window_->AddObserver(this);
+ }
+ ~LocalPropertyChangeObserver() override { window_->RemoveObserver(this); }
+
+ PropertyChangeInfo PropertyChangeInfoAndClear() {
+ PropertyChangeInfo result(property_key_, old_property_value_);
+ property_key_ = NULL;
+ old_property_value_ = -3;
+ return result;
+ }
+
+ private:
+ void OnWindowLocalPropertyChanged(Window* window,
+ const void* key,
+ intptr_t old) override {
+ property_key_ = key;
+ old_property_value_ = old;
+ }
+
+ Window* window_;
+ const void* property_key_;
+ intptr_t old_property_value_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(LocalPropertyChangeObserver);
+};
+
+} // namespace
+
+TEST_F(WindowObserverTest, LocalPropertyChanged) {
+ TestWindow w1;
+ LocalPropertyChangeObserver o(&w1);
+
+ static const WindowProperty<int> prop = {-2};
+
+ w1.SetLocalProperty(&prop, 1);
+ EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
+ w1.SetLocalProperty(&prop, -2);
+ EXPECT_EQ(PropertyChangeInfo(&prop, 1), o.PropertyChangeInfoAndClear());
+ w1.SetLocalProperty(&prop, 3);
+ EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
+ w1.ClearLocalProperty(&prop);
+ EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear());
+
+ // Sanity check to see if |PropertyChangeInfoAndClear| really clears.
+ EXPECT_EQ(PropertyChangeInfo(reinterpret_cast<const void*>(NULL), -3),
+ o.PropertyChangeInfoAndClear());
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/view_observer.h b/components/mus/public/cpp/view_observer.h
deleted file mode 100644
index 2bd541b..0000000
--- a/components/mus/public/cpp/view_observer.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_
-
-#include <vector>
-
-#include "components/mus/public/cpp/view.h"
-#include "ui/mojo/events/input_events.mojom.h"
-
-namespace mus {
-
-class View;
-
-// A note on -ing and -ed suffixes:
-//
-// -ing methods are called before changes are applied to the local view model.
-// -ed methods are called after changes are applied to the local view model.
-//
-// If the change originated from another connection to the view manager, it's
-// possible that the change has already been applied to the service-side model
-// prior to being called, so for example in the case of OnViewDestroying(), it's
-// possible the view has already been destroyed on the service side.
-
-class ViewObserver {
- public:
- struct TreeChangeParams {
- TreeChangeParams();
- View* target;
- View* old_parent;
- View* new_parent;
- View* receiver;
- };
-
- virtual void OnTreeChanging(const TreeChangeParams& params) {}
- virtual void OnTreeChanged(const TreeChangeParams& params) {}
-
- virtual void OnViewReordering(View* view,
- View* relative_view,
- mojo::OrderDirection direction) {}
- virtual void OnViewReordered(View* view,
- View* relative_view,
- mojo::OrderDirection direction) {}
-
- virtual void OnViewDestroying(View* view) {}
- virtual void OnViewDestroyed(View* view) {}
-
- virtual void OnViewBoundsChanging(View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {}
- virtual void OnViewBoundsChanged(View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {}
-
- virtual void OnViewViewportMetricsChanged(
- View* view,
- const mojo::ViewportMetrics& old_metrics,
- const mojo::ViewportMetrics& new_metrics) {}
-
- virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {}
-
- virtual void OnViewInputEvent(View* view, const mojo::EventPtr& event) {}
-
- virtual void OnViewVisibilityChanging(View* view) {}
- virtual void OnViewVisibilityChanged(View* view) {}
-
- // Invoked when this View's shared properties have changed. This can either
- // be caused by SetSharedProperty() being called locally, or by us receiving
- // a mojo message that this property has changed. If this property has been
- // added, |old_data| is null. If this property was removed, |new_data| is
- // null.
- virtual void OnViewSharedPropertyChanged(
- View* view,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) {}
-
- // Invoked when SetProperty() or ClearProperty() is called on the window.
- // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either
- // way, it can simply be compared for equality with the property
- // constant. |old| is the old property value, which must be cast to the
- // appropriate type before use.
- virtual void OnViewLocalPropertyChanged(View* view,
- const void* key,
- intptr_t old) {}
-
- virtual void OnViewEmbeddedAppDisconnected(View* view) {}
-
- // Sent when the drawn state changes. This is only sent for the root nodes
- // when embedded.
- virtual void OnViewDrawnChanging(View* view) {}
- virtual void OnViewDrawnChanged(View* view) {}
-
- protected:
- virtual ~ViewObserver() {}
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_
diff --git a/components/mus/public/cpp/view_property.h b/components/mus/public/cpp/view_property.h
deleted file mode 100644
index ccebb7c..0000000
--- a/components/mus/public/cpp/view_property.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_PROPERTY_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_PROPERTY_H_
-
-#include <stdint.h>
-
-// This header should be included by code that defines ViewProperties. It
-// should not be included by code that only gets and sets ViewProperties.
-//
-// To define a new ViewProperty:
-//
-// #include "components/mus/public/cpp/view_property.h"
-//
-// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType);
-// namespace foo {
-// // Use this to define an exported property that is primitive,
-// // or a pointer you don't want automatically deleted.
-// DEFINE_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
-//
-// // Use this to define an exported property whose value is a heap
-// // allocated object, and has to be owned and freed by the view.
-// DEFINE_OWNED_VIEW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr);
-//
-// // Use this to define a non exported property that is primitive,
-// // or a pointer you don't want to automatically deleted, and is used
-// // only in a specific file. This will define the property in an unnamed
-// // namespace which cannot be accessed from another file.
-// DEFINE_LOCAL_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
-//
-// } // foo namespace
-//
-// To define a new type used for ViewProperty.
-//
-// // outside all namespaces:
-// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType)
-//
-// If a property type is not exported, use DECLARE_VIEW_PROPERTY_TYPE(MyType)
-// which is a shorthand for DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, MyType).
-
-namespace mus {
-namespace {
-
-// No single new-style cast works for every conversion to/from int64_t, so we
-// need this helper class. A third specialization is needed for bool because
-// MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit
-// cast (!).
-template <typename T>
-class ViewPropertyCaster {
- public:
- static int64_t ToInt64(T x) { return static_cast<int64_t>(x); }
- static T FromInt64(int64_t x) { return static_cast<T>(x); }
-};
-template <typename T>
-class ViewPropertyCaster<T*> {
- public:
- static int64_t ToInt64(T* x) { return reinterpret_cast<int64_t>(x); }
- static T* FromInt64(int64_t x) { return reinterpret_cast<T*>(x); }
-};
-template <>
-class ViewPropertyCaster<bool> {
- public:
- static int64_t ToInt64(bool x) { return static_cast<int64_t>(x); }
- static bool FromInt64(int64_t x) { return x != 0; }
-};
-
-} // namespace
-
-template <typename T>
-struct ViewProperty {
- T default_value;
- const char* name;
- View::PropertyDeallocator deallocator;
-};
-
-template <typename T>
-void View::SetLocalProperty(const ViewProperty<T>* property, T value) {
- int64_t old = SetLocalPropertyInternal(
- property, property->name,
- value == property->default_value ? nullptr : property->deallocator,
- ViewPropertyCaster<T>::ToInt64(value),
- ViewPropertyCaster<T>::ToInt64(property->default_value));
- if (property->deallocator &&
- old != ViewPropertyCaster<T>::ToInt64(property->default_value)) {
- (*property->deallocator)(old);
- }
-}
-
-template <typename T>
-T View::GetLocalProperty(const ViewProperty<T>* property) const {
- return ViewPropertyCaster<T>::FromInt64(GetLocalPropertyInternal(
- property, ViewPropertyCaster<T>::ToInt64(property->default_value)));
-}
-
-template <typename T>
-void View::ClearLocalProperty(const ViewProperty<T>* property) {
- SetLocalProperty(property, property->default_value);
-}
-
-} // namespace mus
-
-// Macros to instantiate the property getter/setter template functions.
-#define DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(EXPORT, T) \
- template EXPORT void mus::View::SetLocalProperty( \
- const mus::ViewProperty<T>*, T); \
- template EXPORT T mus::View::GetLocalProperty(const mus::ViewProperty<T>*) \
- const; \
- template EXPORT void mus::View::ClearLocalProperty( \
- const mus::ViewProperty<T>*);
-#define DECLARE_VIEW_PROPERTY_TYPE(T) DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, T)
-
-#define DEFINE_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \
- namespace { \
- const mus::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
- } \
- const mus::ViewProperty<TYPE>* const NAME = &NAME##_Value;
-
-#define DEFINE_LOCAL_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \
- namespace { \
- const mus::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
- const mus::ViewProperty<TYPE>* const NAME = &NAME##_Value; \
- }
-
-#define DEFINE_OWNED_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- namespace { \
- void Deallocator##NAME(int64_t p) { \
- enum { type_must_be_complete = sizeof(TYPE) }; \
- delete mus::ViewPropertyCaster<TYPE*>::FromInt64(p); \
- } \
- const mus::ViewProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \
- &Deallocator##NAME}; \
- } \
- const mus::ViewProperty<TYPE*>* const NAME = &NAME##_Value;
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_PROPERTY_H_
diff --git a/components/mus/public/cpp/view_tracker.cc b/components/mus/public/cpp/view_tracker.cc
deleted file mode 100644
index 3d97857..0000000
--- a/components/mus/public/cpp/view_tracker.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/mus/public/cpp/view_tracker.h"
-
-namespace mus {
-
-ViewTracker::ViewTracker() {}
-
-ViewTracker::~ViewTracker() {
- for (Views::iterator i = views_.begin(); i != views_.end(); ++i)
- (*i)->RemoveObserver(this);
-}
-
-void ViewTracker::Add(View* view) {
- if (views_.count(view))
- return;
-
- view->AddObserver(this);
- views_.insert(view);
-}
-
-void ViewTracker::Remove(View* view) {
- if (views_.count(view)) {
- views_.erase(view);
- view->RemoveObserver(this);
- }
-}
-
-bool ViewTracker::Contains(View* view) {
- return views_.count(view) > 0;
-}
-
-void ViewTracker::OnViewDestroying(View* view) {
- DCHECK_GT(views_.count(view), 0u);
- Remove(view);
-}
-
-} // namespace mus
diff --git a/components/mus/public/cpp/view_tracker.h b/components/mus/public/cpp/view_tracker.h
deleted file mode 100644
index f551d5a..0000000
--- a/components/mus/public/cpp/view_tracker.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_
-
-#include <stdint.h>
-#include <set>
-
-#include "components/mus/public/cpp/view_observer.h"
-#include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
-
-namespace mus {
-
-class ViewTracker : public ViewObserver {
- public:
- using Views = std::set<View*>;
-
- ViewTracker();
- ~ViewTracker() override;
-
- // Returns the set of views being observed.
- const std::set<View*>& views() const { return views_; }
-
- // Adds |view| to the set of Views being tracked.
- void Add(View* view);
-
- // Removes |view| from the set of views being tracked.
- void Remove(View* view);
-
- // Returns true if |view| was previously added and has not been removed or
- // deleted.
- bool Contains(View* view);
-
- // ViewObserver overrides:
- void OnViewDestroying(View* view) override;
-
- private:
- Views views_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTracker);
-};
-
-} // namespace mus
-
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_
diff --git a/components/mus/public/cpp/view.h b/components/mus/public/cpp/window.h
index f65f79a..fb232d0 100644
--- a/components/mus/public/cpp/view.h
+++ b/components/mus/public/cpp/window.h
@@ -22,34 +22,35 @@
namespace mus {
class ServiceProviderImpl;
-class View;
-class ViewObserver;
-class ViewSurface;
-class ViewTreeConnection;
+class WindowObserver;
+class WindowSurface;
+class WindowTreeConnection;
-// Defined in view_property.h (which we do not include)
+// Defined in window_property.h (which we do not include)
template <typename T>
-struct ViewProperty;
+struct WindowProperty;
-// Views are owned by the ViewTreeConnection. See ViewTreeDelegate for details
+// Windows are owned by the WindowTreeConnection. See WindowTreeDelegate for
+// details
// on ownership.
//
-// TODO(beng): Right now, you'll have to implement a ViewObserver to track
+// TODO(beng): Right now, you'll have to implement a WindowObserver to track
// destruction and NULL any pointers you have.
// Investigate some kind of smart pointer or weak pointer for these.
-class View {
+class Window {
public:
- using Children = std::vector<View*>;
+ using Children = std::vector<Window*>;
using SharedProperties = std::map<std::string, std::vector<uint8_t>>;
using EmbedCallback = base::Callback<void(bool, ConnectionSpecificId)>;
- // Destroys this view and all its children. Destruction is allowed for views
- // that were created by this connection. For views from other connections
+ // Destroys this window and all its children. Destruction is allowed for
+ // windows
+ // that were created by this connection. For windows from other connections
// (such as the root) Destroy() does nothing. If the destruction is allowed
- // observers are notified and the View is immediately deleted.
+ // observers are notified and the Window is immediately deleted.
void Destroy();
- ViewTreeConnection* connection() { return connection_; }
+ WindowTreeConnection* connection() { return connection_; }
// Configuration.
Id id() const { return id_; }
@@ -58,16 +59,16 @@ class View {
const mojo::Rect& bounds() const { return bounds_; }
void SetBounds(const mojo::Rect& bounds);
- // Visibility (also see IsDrawn()). When created views are hidden.
+ // Visibility (also see IsDrawn()). When created windows are hidden.
bool visible() const { return visible_; }
void SetVisible(bool value);
const mojo::ViewportMetrics& viewport_metrics() { return *viewport_metrics_; }
- scoped_ptr<ViewSurface> RequestSurface();
+ scoped_ptr<WindowSurface> RequestSurface();
// Returns the set of string to bag of byte properties. These properties are
- // shared with the view manager.
+ // shared with the window manager.
const SharedProperties& shared_properties() const { return properties_; }
// Sets a property. If |data| is null, this property is deleted.
void SetSharedProperty(const std::string& name,
@@ -75,11 +76,11 @@ class View {
// Sets the |value| of the given window |property|. Setting to the default
// value (e.g., NULL) removes the property. The caller is responsible for the
- // lifetime of any object set as a property on the View.
+ // lifetime of any object set as a property on the Window.
//
- // These properties are not visible to the view manager.
+ // These properties are not visible to the window manager.
template <typename T>
- void SetLocalProperty(const ViewProperty<T>* property, T value);
+ void SetLocalProperty(const WindowProperty<T>* property, T value);
// Returns the value of the given window |property|. Returns the
// property-specific default value if the property was not previously set.
@@ -87,7 +88,7 @@ class View {
// These properties are only visible in the current process and are not
// shared with other mojo services.
template <typename T>
- T GetLocalProperty(const ViewProperty<T>* property) const;
+ T GetLocalProperty(const WindowProperty<T>* property) const;
// Sets the |property| to its default value. Useful for avoiding a cast when
// setting to NULL.
@@ -95,38 +96,38 @@ class View {
// These properties are only visible in the current process and are not
// shared with other mojo services.
template <typename T>
- void ClearLocalProperty(const ViewProperty<T>* property);
+ void ClearLocalProperty(const WindowProperty<T>* property);
- // Type of a function to delete a property that this view owns.
+ // Type of a function to delete a property that this window owns.
typedef void (*PropertyDeallocator)(int64_t value);
- // A View is drawn if the View and all its ancestors are visible and the
- // View is attached to the root.
+ // A Window is drawn if the Window and all its ancestors are visible and the
+ // Window is attached to the root.
bool IsDrawn() const;
// Observation.
- void AddObserver(ViewObserver* observer);
- void RemoveObserver(ViewObserver* observer);
+ void AddObserver(WindowObserver* observer);
+ void RemoveObserver(WindowObserver* observer);
// Tree.
- View* parent() { return parent_; }
- const View* parent() const { return parent_; }
+ Window* parent() { return parent_; }
+ const Window* parent() const { return parent_; }
const Children& children() const { return children_; }
- View* GetRoot() {
- return const_cast<View*>(const_cast<const View*>(this)->GetRoot());
+ Window* GetRoot() {
+ return const_cast<Window*>(const_cast<const Window*>(this)->GetRoot());
}
- const View* GetRoot() const;
+ const Window* GetRoot() const;
- void AddChild(View* child);
- void RemoveChild(View* child);
+ void AddChild(Window* child);
+ void RemoveChild(Window* child);
- void Reorder(View* relative, mojo::OrderDirection direction);
+ void Reorder(Window* relative, mojo::OrderDirection direction);
void MoveToFront();
void MoveToBack();
- bool Contains(View* child) const;
+ bool Contains(Window* child) const;
- View* GetChildById(Id id);
+ Window* GetChildById(Id id);
void SetTextInputState(mojo::TextInputStatePtr state);
void SetImeVisibility(bool visible, mojo::TextInputStatePtr state);
@@ -139,21 +140,21 @@ class View {
void Embed(mojo::ViewTreeClientPtr client);
// NOTE: callback is run synchronously if Embed() is not allowed on this
- // View.
+ // Window.
void Embed(mojo::ViewTreeClientPtr client,
uint32_t policy_bitmask,
const EmbedCallback& callback);
protected:
// This class is subclassed only by test classes that provide a public ctor.
- View();
- ~View();
+ Window();
+ ~Window();
private:
- friend class ViewPrivate;
- friend class ViewTreeClientImpl;
+ friend class WindowPrivate;
+ friend class WindowTreeClientImpl;
- View(ViewTreeConnection* connection, Id id);
+ Window(WindowTreeConnection* connection, Id id);
// Called by the public {Set,Get,Clear}Property functions.
int64_t SetLocalPropertyInternal(const void* key,
@@ -165,10 +166,10 @@ class View {
int64_t default_value) const;
void LocalDestroy();
- void LocalAddChild(View* child);
- void LocalRemoveChild(View* child);
+ void LocalAddChild(Window* child);
+ void LocalRemoveChild(Window* child);
// Returns true if the order actually changed.
- bool LocalReorder(View* relative, mojo::OrderDirection direction);
+ bool LocalReorder(Window* relative, mojo::OrderDirection direction);
void LocalSetBounds(const mojo::Rect& old_bounds,
const mojo::Rect& new_bounds);
void LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics,
@@ -176,28 +177,28 @@ class View {
void LocalSetDrawn(bool drawn);
void LocalSetVisible(bool visible);
- // Methods implementing visibility change notifications. See ViewObserver
+ // Methods implementing visibility change notifications. See WindowObserver
// for more details.
- void NotifyViewVisibilityChanged(View* target);
+ void NotifyWindowVisibilityChanged(Window* target);
// Notifies this view's observers. Returns false if |this| was deleted during
// the call (by an observer), otherwise true.
- bool NotifyViewVisibilityChangedAtReceiver(View* target);
+ bool NotifyWindowVisibilityChangedAtReceiver(Window* target);
// Notifies this view and its child hierarchy. Returns false if |this| was
// deleted during the call (by an observer), otherwise true.
- bool NotifyViewVisibilityChangedDown(View* target);
+ bool NotifyWindowVisibilityChangedDown(Window* target);
// Notifies this view and its parent hierarchy.
- void NotifyViewVisibilityChangedUp(View* target);
+ void NotifyWindowVisibilityChangedUp(Window* target);
// Returns true if embed is allowed for this node. If embedding is allowed all
// the children are removed.
bool PrepareForEmbed();
- ViewTreeConnection* connection_;
+ WindowTreeConnection* connection_;
Id id_;
- View* parent_;
+ Window* parent_;
Children children_;
- base::ObserverList<ViewObserver> observers_;
+ base::ObserverList<WindowObserver> observers_;
mojo::Rect bounds_;
mojo::ViewportMetricsPtr viewport_metrics_;
@@ -221,7 +222,7 @@ class View {
std::map<const void*, Value> prop_map_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(View);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(Window);
};
} // namespace mus
diff --git a/components/mus/public/cpp/window_observer.h b/components/mus/public/cpp/window_observer.h
new file mode 100644
index 0000000..5e88a55
--- /dev/null
+++ b/components/mus/public/cpp/window_observer.h
@@ -0,0 +1,104 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_OBSERVER_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_OBSERVER_H_
+
+#include <vector>
+
+#include "components/mus/public/cpp/window.h"
+#include "ui/mojo/events/input_events.mojom.h"
+
+namespace mus {
+
+class Window;
+
+// A note on -ing and -ed suffixes:
+//
+// -ing methods are called before changes are applied to the local window model.
+// -ed methods are called after changes are applied to the local window model.
+//
+// If the change originated from another connection to the window manager, it's
+// possible that the change has already been applied to the service-side model
+// prior to being called, so for example in the case of OnWindowDestroying(),
+// it's
+// possible the window has already been destroyed on the service side.
+
+class WindowObserver {
+ public:
+ struct TreeChangeParams {
+ TreeChangeParams();
+ Window* target;
+ Window* old_parent;
+ Window* new_parent;
+ Window* receiver;
+ };
+
+ virtual void OnTreeChanging(const TreeChangeParams& params) {}
+ virtual void OnTreeChanged(const TreeChangeParams& params) {}
+
+ virtual void OnWindowReordering(Window* window,
+ Window* relative_window,
+ mojo::OrderDirection direction) {}
+ virtual void OnWindowReordered(Window* window,
+ Window* relative_window,
+ mojo::OrderDirection direction) {}
+
+ virtual void OnWindowDestroying(Window* window) {}
+ virtual void OnWindowDestroyed(Window* window) {}
+
+ virtual void OnWindowBoundsChanging(Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {}
+ virtual void OnWindowBoundsChanged(Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {}
+
+ virtual void OnWindowViewportMetricsChanged(
+ Window* window,
+ const mojo::ViewportMetrics& old_metrics,
+ const mojo::ViewportMetrics& new_metrics) {}
+
+ virtual void OnWindowFocusChanged(Window* gained_focus, Window* lost_focus) {}
+
+ virtual void OnWindowInputEvent(Window* window, const mojo::EventPtr& event) {
+ }
+
+ virtual void OnWindowVisibilityChanging(Window* window) {}
+ virtual void OnWindowVisibilityChanged(Window* window) {}
+
+ // Invoked when this Window's shared properties have changed. This can either
+ // be caused by SetSharedProperty() being called locally, or by us receiving
+ // a mojo message that this property has changed. If this property has been
+ // added, |old_data| is null. If this property was removed, |new_data| is
+ // null.
+ virtual void OnWindowSharedPropertyChanged(
+ Window* window,
+ const std::string& name,
+ const std::vector<uint8_t>* old_data,
+ const std::vector<uint8_t>* new_data) {}
+
+ // Invoked when SetProperty() or ClearProperty() is called on the window.
+ // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either
+ // way, it can simply be compared for equality with the property
+ // constant. |old| is the old property value, which must be cast to the
+ // appropriate type before use.
+ virtual void OnWindowLocalPropertyChanged(Window* window,
+ const void* key,
+ intptr_t old) {}
+
+ virtual void OnWindowEmbeddedAppDisconnected(Window* window) {}
+
+ // Sent when the drawn state changes. This is only sent for the root nodes
+ // when embedded.
+ virtual void OnWindowDrawnChanging(Window* window) {}
+ virtual void OnWindowDrawnChanged(Window* window) {}
+
+ protected:
+ virtual ~WindowObserver() {}
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_OBSERVER_H_
diff --git a/components/mus/public/cpp/window_property.h b/components/mus/public/cpp/window_property.h
new file mode 100644
index 0000000..3d4df9e
--- /dev/null
+++ b/components/mus/public/cpp/window_property.h
@@ -0,0 +1,140 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
+
+#include <stdint.h>
+
+// This header should be included by code that defines WindowProperties. It
+// should not be included by code that only gets and sets WindowProperties.
+//
+// To define a new WindowProperty:
+//
+// #include "components/mus/public/cpp/window_property.h"
+//
+// DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(FOO_EXPORT, MyType);
+// namespace foo {
+// // Use this to define an exported property that is primitive,
+// // or a pointer you don't want automatically deleted.
+// DEFINE_WINDOW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
+//
+// // Use this to define an exported property whose value is a heap
+// // allocated object, and has to be owned and freed by the view.
+// DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr);
+//
+// // Use this to define a non exported property that is primitive,
+// // or a pointer you don't want to automatically deleted, and is used
+// // only in a specific file. This will define the property in an unnamed
+// // namespace which cannot be accessed from another file.
+// DEFINE_LOCAL_WINDOW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
+//
+// } // foo namespace
+//
+// To define a new type used for WindowProperty.
+//
+// // outside all namespaces:
+// DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(FOO_EXPORT, MyType)
+//
+// If a property type is not exported, use DECLARE_WINDOW_PROPERTY_TYPE(MyType)
+// which is a shorthand for DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, MyType).
+
+namespace mus {
+namespace {
+
+// No single new-style cast works for every conversion to/from int64_t, so we
+// need this helper class. A third specialization is needed for bool because
+// MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit
+// cast (!).
+template <typename T>
+class WindowPropertyCaster {
+ public:
+ static int64_t ToInt64(T x) { return static_cast<int64_t>(x); }
+ static T FromInt64(int64_t x) { return static_cast<T>(x); }
+};
+template <typename T>
+class WindowPropertyCaster<T*> {
+ public:
+ static int64_t ToInt64(T* x) { return reinterpret_cast<int64_t>(x); }
+ static T* FromInt64(int64_t x) { return reinterpret_cast<T*>(x); }
+};
+template <>
+class WindowPropertyCaster<bool> {
+ public:
+ static int64_t ToInt64(bool x) { return static_cast<int64_t>(x); }
+ static bool FromInt64(int64_t x) { return x != 0; }
+};
+
+} // namespace
+
+template <typename T>
+struct WindowProperty {
+ T default_value;
+ const char* name;
+ Window::PropertyDeallocator deallocator;
+};
+
+template <typename T>
+void Window::SetLocalProperty(const WindowProperty<T>* property, T value) {
+ int64_t old = SetLocalPropertyInternal(
+ property, property->name,
+ value == property->default_value ? nullptr : property->deallocator,
+ WindowPropertyCaster<T>::ToInt64(value),
+ WindowPropertyCaster<T>::ToInt64(property->default_value));
+ if (property->deallocator &&
+ old != WindowPropertyCaster<T>::ToInt64(property->default_value)) {
+ (*property->deallocator)(old);
+ }
+}
+
+template <typename T>
+T Window::GetLocalProperty(const WindowProperty<T>* property) const {
+ return WindowPropertyCaster<T>::FromInt64(GetLocalPropertyInternal(
+ property, WindowPropertyCaster<T>::ToInt64(property->default_value)));
+}
+
+template <typename T>
+void Window::ClearLocalProperty(const WindowProperty<T>* property) {
+ SetLocalProperty(property, property->default_value);
+}
+
+} // namespace mus
+
+// Macros to instantiate the property getter/setter template functions.
+#define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \
+ template EXPORT void mus::Window::SetLocalProperty( \
+ const mus::WindowProperty<T>*, T); \
+ template EXPORT T mus::Window::GetLocalProperty( \
+ const mus::WindowProperty<T>*) const; \
+ template EXPORT void mus::Window::ClearLocalProperty( \
+ const mus::WindowProperty<T>*);
+#define DECLARE_WINDOW_PROPERTY_TYPE(T) \
+ DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T)
+
+#define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
+ COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \
+ namespace { \
+ const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
+ } \
+ const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value;
+
+#define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
+ COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \
+ namespace { \
+ const mus::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
+ const mus::WindowProperty<TYPE>* const NAME = &NAME##_Value; \
+ }
+
+#define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
+ namespace { \
+ void Deallocator##NAME(int64_t p) { \
+ enum { type_must_be_complete = sizeof(TYPE) }; \
+ delete mus::WindowPropertyCaster<TYPE*>::FromInt64(p); \
+ } \
+ const mus::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \
+ &Deallocator##NAME}; \
+ } \
+ const mus::WindowProperty<TYPE*>* const NAME = &NAME##_Value;
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_PROPERTY_H_
diff --git a/components/mus/public/cpp/view_surface.h b/components/mus/public/cpp/window_surface.h
index 5718f16..284e48c 100644
--- a/components/mus/public/cpp/view_surface.h
+++ b/components/mus/public/cpp/window_surface.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_H_
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
@@ -13,14 +13,14 @@
namespace mus {
-class ViewSurfaceClient;
-class View;
+class WindowSurfaceClient;
+class Window;
-// A ViewSurface is wrapper to simplify submitting CompositorFrames to Views,
+// A WindowSurface is wrapper to simplify submitting CompositorFrames to Views,
// and receiving ReturnedResources.
-class ViewSurface : public mojo::SurfaceClient {
+class WindowSurface : public mojo::SurfaceClient {
public:
- ~ViewSurface() override;
+ ~WindowSurface() override;
// Called to indicate that the current thread has assumed control of this
// object.
@@ -29,19 +29,19 @@ class ViewSurface : public mojo::SurfaceClient {
void SubmitCompositorFrame(mojo::CompositorFramePtr frame,
const mojo::Closure& callback);
- void set_client(ViewSurfaceClient* client) { client_ = client; }
+ void set_client(WindowSurfaceClient* client) { client_ = client; }
private:
- friend class View;
+ friend class Window;
- ViewSurface(mojo::InterfacePtrInfo<mojo::Surface> surface_info,
- mojo::InterfaceRequest<mojo::SurfaceClient> client_request);
+ WindowSurface(mojo::InterfacePtrInfo<mojo::Surface> surface_info,
+ mojo::InterfaceRequest<mojo::SurfaceClient> client_request);
// SurfaceClient implementation:
void ReturnResources(
mojo::Array<mojo::ReturnedResourcePtr> resources) override;
- ViewSurfaceClient* client_;
+ WindowSurfaceClient* client_;
mojo::InterfacePtrInfo<mojo::Surface> surface_info_;
mojo::InterfaceRequest<mojo::SurfaceClient> client_request_;
mojo::SurfacePtr surface_;
@@ -51,4 +51,4 @@ class ViewSurface : public mojo::SurfaceClient {
} // namespace mus
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_H_
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
diff --git a/components/mus/public/cpp/view_surface_client.h b/components/mus/public/cpp/window_surface_client.h
index 0ac2c54..0906c8a 100644
--- a/components/mus/public/cpp/view_surface_client.h
+++ b/components/mus/public/cpp/window_surface_client.h
@@ -7,16 +7,16 @@
namespace mus {
-class ViewSurface;
+class WindowSurface;
-class ViewSurfaceClient {
+class WindowSurfaceClient {
public:
virtual void OnResourcesReturned(
- ViewSurface* surface,
+ WindowSurface* surface,
mojo::Array<mojo::ReturnedResourcePtr> resources) = 0;
protected:
- ~ViewSurfaceClient() {}
+ ~WindowSurfaceClient() {}
};
} // namespace mus
diff --git a/components/mus/public/cpp/window_tracker.cc b/components/mus/public/cpp/window_tracker.cc
new file mode 100644
index 0000000..1fa1a4c
--- /dev/null
+++ b/components/mus/public/cpp/window_tracker.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/mus/public/cpp/window_tracker.h"
+
+namespace mus {
+
+WindowTracker::WindowTracker() {}
+
+WindowTracker::~WindowTracker() {
+ for (Windows::iterator i = windows_.begin(); i != windows_.end(); ++i)
+ (*i)->RemoveObserver(this);
+}
+
+void WindowTracker::Add(Window* window) {
+ if (windows_.count(window))
+ return;
+
+ window->AddObserver(this);
+ windows_.insert(window);
+}
+
+void WindowTracker::Remove(Window* window) {
+ if (windows_.count(window)) {
+ windows_.erase(window);
+ window->RemoveObserver(this);
+ }
+}
+
+bool WindowTracker::Contains(Window* window) {
+ return windows_.count(window) > 0;
+}
+
+void WindowTracker::OnWindowDestroying(Window* window) {
+ DCHECK_GT(windows_.count(window), 0u);
+ Remove(window);
+}
+
+} // namespace mus
diff --git a/components/mus/public/cpp/window_tracker.h b/components/mus/public/cpp/window_tracker.h
new file mode 100644
index 0000000..f2f4963
--- /dev/null
+++ b/components/mus/public/cpp/window_tracker.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TRACKER_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TRACKER_H_
+
+#include <stdint.h>
+#include <set>
+
+#include "components/mus/public/cpp/window_observer.h"
+#include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
+
+namespace mus {
+
+class WindowTracker : public WindowObserver {
+ public:
+ using Windows = std::set<Window*>;
+
+ WindowTracker();
+ ~WindowTracker() override;
+
+ // Returns the set of windows being observed.
+ const std::set<Window*>& windows() const { return windows_; }
+
+ // Adds |window| to the set of Windows being tracked.
+ void Add(Window* window);
+
+ // Removes |window| from the set of windows being tracked.
+ void Remove(Window* window);
+
+ // Returns true if |window| was previously added and has not been removed or
+ // deleted.
+ bool Contains(Window* window);
+
+ // WindowObserver overrides:
+ void OnWindowDestroying(Window* window) override;
+
+ private:
+ Windows windows_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTracker);
+};
+
+} // namespace mus
+
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TRACKER_H_
diff --git a/components/mus/public/cpp/view_tree_connection.h b/components/mus/public/cpp/window_tree_connection.h
index ee1095a..d677b2a 100644
--- a/components/mus/public/cpp/view_tree_connection.h
+++ b/components/mus/public/cpp/window_tree_connection.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CONNECTION_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CONNECTION_H_
#include <string>
@@ -11,45 +11,52 @@
#include "components/mus/public/interfaces/view_tree.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
+#if defined(OS_WIN)
+// Windows headers define a macro for CreateWindow.
+#if defined(CreateWindow)
+#undef CreateWindow
+#endif
+#endif
+
namespace mus {
-class View;
-class ViewTreeDelegate;
+class Window;
+class WindowTreeDelegate;
// Encapsulates a connection to a view tree. A unique connection is made
// every time an app is embedded.
-class ViewTreeConnection {
+class WindowTreeConnection {
public:
enum class CreateType {
// Indicates Create() should wait for OnEmbed(). If true, the
- // ViewTreeConnection returned from Create() will have its root, otherwise
- // the ViewTreeConnection will get the root at a later time.
+ // WindowTreeConnection returned from Create() will have its root, otherwise
+ // the WindowTreeConnection will get the root at a later time.
WAIT_FOR_EMBED,
DONT_WAIT_FOR_EMBED
};
- virtual ~ViewTreeConnection() {}
+ virtual ~WindowTreeConnection() {}
- // The returned ViewTreeConnection instance owns itself, and is deleted when
+ // The returned WindowTreeConnection instance owns itself, and is deleted when
// the last root is destroyed or the connection to the service is broken.
- static ViewTreeConnection* Create(
- ViewTreeDelegate* delegate,
+ static WindowTreeConnection* Create(
+ WindowTreeDelegate* delegate,
mojo::InterfaceRequest<mojo::ViewTreeClient> request,
CreateType create_type);
// Returns the root of this connection.
- virtual View* GetRoot() = 0;
+ virtual Window* GetRoot() = 0;
// Returns a View known to this connection.
- virtual View* GetViewById(Id id) = 0;
+ virtual Window* GetWindowById(Id id) = 0;
// Returns the focused view; null if focus is not yet known or another app is
// focused.
- virtual View* GetFocusedView() = 0;
+ virtual Window* GetFocusedWindow() = 0;
// Creates and returns a new View (which is owned by the ViewManager). Views
// are initially hidden, use SetVisible(true) to show.
- virtual View* CreateView() = 0;
+ virtual Window* CreateWindow() = 0;
// Returns true if ACCESS_POLICY_EMBED_ROOT was specified.
virtual bool IsEmbedRoot() = 0;
@@ -60,4 +67,4 @@ class ViewTreeConnection {
} // namespace mus
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CONNECTION_H_
diff --git a/components/mus/public/cpp/view_tree_delegate.h b/components/mus/public/cpp/window_tree_delegate.h
index 2e2115e..2d6874b 100644
--- a/components/mus/public/cpp/view_tree_delegate.h
+++ b/components/mus/public/cpp/window_tree_delegate.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_DELEGATE_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_DELEGATE_H_
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_DELEGATE_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_DELEGATE_H_
#include <string>
@@ -13,23 +13,24 @@
namespace mus {
-class View;
-class ViewTreeConnection;
+class Window;
+class WindowTreeConnection;
// Interface implemented by an application using the view manager.
//
-// Each call to OnEmbed() results in a new ViewTreeConnection and new root View.
-// ViewTreeConnection is deleted by any of the following:
+// Each call to OnEmbed() results in a new WindowTreeConnection and new root
+// View.
+// WindowTreeConnection is deleted by any of the following:
// . If the root of the connection is destroyed. This happens if the owner
// of the root Embed()s another app in root, or the owner explicitly deletes
// root.
// . The connection to the view manager is lost.
// . Explicitly by way of calling delete.
//
-// When the ViewTreeConnection is deleted all views are deleted (and observers
+// When the WindowTreeConnection is deleted all views are deleted (and observers
// notified). This is followed by notifying the delegate by way of
// OnConnectionLost().
-class ViewTreeDelegate {
+class WindowTreeDelegate {
public:
// Called when the application implementing this interface is embedded at
// |root|.
@@ -43,21 +44,21 @@ class ViewTreeDelegate {
// the pipes connecting |services| and |exposed_services| to the embedder and
// any services obtained from them are not broken and will continue to be
// valid.
- virtual void OnEmbed(View* root) = 0;
+ virtual void OnEmbed(Window* root) = 0;
// Sent when another app is embedded in the same View as this connection.
// Subsequently the root View and this object are destroyed (observers are
// notified appropriately).
virtual void OnUnembed();
- // Called from the destructor of ViewTreeConnection after all the Views have
+ // Called from the destructor of WindowTreeConnection after all the Views have
// been destroyed. |connection| is no longer valid after this call.
- virtual void OnConnectionLost(ViewTreeConnection* connection) = 0;
+ virtual void OnConnectionLost(WindowTreeConnection* connection) = 0;
protected:
- virtual ~ViewTreeDelegate() {}
+ virtual ~WindowTreeDelegate() {}
};
} // namespace mus
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_DELEGATE_H_
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_DELEGATE_H_
diff --git a/components/mus/public/cpp/view_tree_host_factory.h b/components/mus/public/cpp/window_tree_host_factory.h
index 0e44441..c4e0790 100644
--- a/components/mus/public/cpp/view_tree_host_factory.h
+++ b/components/mus/public/cpp/window_tree_host_factory.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_HOST_FACTORY_H_
-#define COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_HOST_FACTORY_H_
+#ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_HOST_FACTORY_H_
+#define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_HOST_FACTORY_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
@@ -17,21 +17,21 @@ class ApplicationImpl;
namespace mus {
-class ViewTreeDelegate;
+class WindowTreeDelegate;
// Uses |factory| to create a new |host|, providing the supplied |host_client|
// which may be null. |delegate| must not be null.
-void CreateViewTreeHost(mojo::ViewTreeHostFactory* factory,
- mojo::ViewTreeHostClientPtr host_client,
- ViewTreeDelegate* delegate,
- mojo::ViewTreeHostPtr* host);
+void CreateWindowTreeHost(mojo::ViewTreeHostFactory* factory,
+ mojo::ViewTreeHostClientPtr host_client,
+ WindowTreeDelegate* delegate,
+ mojo::ViewTreeHostPtr* host);
// Creates a single host with no client by connecting to the view manager
// application. Useful only for tests and trivial UIs.
-void CreateSingleViewTreeHost(mojo::ApplicationImpl* app,
- ViewTreeDelegate* delegate,
- mojo::ViewTreeHostPtr* host);
+void CreateSingleWindowTreeHost(mojo::ApplicationImpl* app,
+ WindowTreeDelegate* delegate,
+ mojo::ViewTreeHostPtr* host);
} // namespace mus
-#endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_HOST_FACTORY_H_
+#endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_HOST_FACTORY_H_
diff --git a/components/mus/public/interfaces/view_tree.mojom b/components/mus/public/interfaces/view_tree.mojom
index 47ed4c7..b9889c0 100644
--- a/components/mus/public/interfaces/view_tree.mojom
+++ b/components/mus/public/interfaces/view_tree.mojom
@@ -98,17 +98,17 @@ interface ViewTree {
// . |child| is an ancestor of |parent|.
// . |child| is already a child of |parent|.
//
- // This may result in a connection getting OnViewDeleted(). See
+ // This may result in a connection getting OnWindowDeleted(). See
// RemoveViewFromParent for details.
AddView(uint32 parent, uint32 child) => (bool success);
// Removes a view from its current parent. This fails if the view is not
// valid or the view already has no parent.
//
- // Removing a view from a parent may result in OnViewDeleted() being sent to
+ // Removing a view from a parent may result in OnWindowDeleted() being sent to
// other connections. For example, connection A has views 1 and 2, with 2 a
// child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
- // OnViewDeleted(). This is done as view 2 is effectively no longer visible to
+ // OnWindowDeleted(). This is done as view 2 is effectively no longer visible to
// connection B.
RemoveViewFromParent(uint32 view_id) => (bool success);
@@ -144,7 +144,7 @@ interface ViewTree {
// A view may only have one embedding in it at a time. Subsequent calls to
// Embed() for the same view result in the currently embedded
// ViewTreeClient being removed. The embedded app is told this by way of
- // OnUnembed(), which is followed by OnViewDeleted() (as the connection no
+ // OnUnembed(), which is followed by OnWindowDeleted() (as the connection no
// longer has access to the view).
//
// The embedder can detect when the embedded app disconnects by way of
@@ -173,7 +173,7 @@ interface ViewTree {
// Changes to views are not sent to the connection that originated the
// change. For example, if connection 1 changes the bounds of a view by calling
-// SetBounds(), connection 1 does not receive OnViewBoundsChanged().
+// SetBounds(), connection 1 does not receive OnWindowBoundsChanged().
interface ViewTreeClient {
// Invoked when the client application has been embedded at |root|.
// See Embed() on ViewTree for more details. |tree| will be a handle back to
@@ -196,13 +196,13 @@ interface ViewTreeClient {
OnUnembed();
// Invoked when a view's bounds have changed.
- OnViewBoundsChanged(uint32 view,
+ OnWindowBoundsChanged(uint32 view,
mojo.Rect old_bounds,
mojo.Rect new_bounds);
// Invoked when the viewport metrics for the view have changed.
// Clients are expected to propagate this to the view tree.
- OnViewViewportMetricsChanged(mojo.ViewportMetrics old_metrics,
+ OnWindowViewportMetricsChanged(mojo.ViewportMetrics old_metrics,
mojo.ViewportMetrics new_metrics);
// Invoked when a change is done to the hierarchy. A value of 0 is used to
@@ -211,21 +211,21 @@ interface ViewTreeClient {
// |views| contains any views that are that the client has not been told
// about. This is not sent for hierarchy changes of views not known to this
// client or not attached to the tree.
- OnViewHierarchyChanged(uint32 view,
+ OnWindowHierarchyChanged(uint32 view,
uint32 new_parent,
uint32 old_parent,
array<ViewData> views);
// Invoked when the order of views within a parent changes.
- OnViewReordered(uint32 view_id,
+ OnWindowReordered(uint32 view_id,
uint32 relative_view_id,
OrderDirection direction);
// Invoked when a view is deleted.
- OnViewDeleted(uint32 view);
+ OnWindowDeleted(uint32 view);
// Invoked when the visibility of the specified view changes.
- OnViewVisibilityChanged(uint32 view, bool visible);
+ OnWindowVisibilityChanged(uint32 view, bool visible);
// Invoked when a change to the visibility of |view| or one if it's ancestors
// is done such that the drawn state changes. This is only invoked for the
@@ -236,15 +236,15 @@ interface ViewTreeClient {
// the drawn state of B1 has changed (to false), but is not told anything
// about B2 as it's drawn state can be calculated from that of B1.
//
- // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked.
- OnViewDrawnStateChanged(uint32 view, bool drawn);
+ // NOTE: This is not invoked if OnWindowVisibilityChanged() is invoked.
+ OnWindowDrawnStateChanged(uint32 view, bool drawn);
// Invoked when a view property is changed. If this change is a removal,
// |new_data| is null.
- OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data);
+ OnWindowSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data);
// Invoked when an event is targeted at the specified view.
- OnViewInputEvent(uint32 view, mojo.Event event) => ();
+ OnWindowInputEvent(uint32 view, mojo.Event event) => ();
- OnViewFocused(uint32 focused_view_id);
+ OnWindowFocused(uint32 focused_view_id);
};
diff --git a/components/mus/public/interfaces/view_tree_host.mojom b/components/mus/public/interfaces/view_tree_host.mojom
index 74ef56b..2d436bd 100644
--- a/components/mus/public/interfaces/view_tree_host.mojom
+++ b/components/mus/public/interfaces/view_tree_host.mojom
@@ -35,7 +35,7 @@ interface ViewTreeHostClient {
};
interface ViewTreeHostFactory {
- CreateViewTreeHost(ViewTreeHost& view_tree_host,
- ViewTreeHostClient? host_client,
- ViewTreeClient tree_client);
+ CreateWindowTreeHost(ViewTreeHost& view_tree_host,
+ ViewTreeHostClient? host_client,
+ ViewTreeClient tree_client);
};
diff --git a/components/mus/vm/access_policy.h b/components/mus/vm/access_policy.h
index d28e678..f2862b4 100644
--- a/components/mus/vm/access_policy.h
+++ b/components/mus/vm/access_policy.h
@@ -35,7 +35,7 @@ class AccessPolicy {
virtual bool CanEmbed(const ServerView* view,
uint32_t policy_bitmask) const = 0;
virtual bool CanChangeViewVisibility(const ServerView* view) const = 0;
- virtual bool CanSetViewSurfaceId(const ServerView* view) const = 0;
+ virtual bool CanSetWindowSurfaceId(const ServerView* view) const = 0;
virtual bool CanSetViewBounds(const ServerView* view) const = 0;
virtual bool CanSetViewProperties(const ServerView* view) const = 0;
virtual bool CanSetViewTextInputState(const ServerView* view) const = 0;
diff --git a/components/mus/vm/default_access_policy.cc b/components/mus/vm/default_access_policy.cc
index 852f310..f2a049a 100644
--- a/components/mus/vm/default_access_policy.cc
+++ b/components/mus/vm/default_access_policy.cc
@@ -73,9 +73,10 @@ bool DefaultAccessPolicy::CanChangeViewVisibility(
delegate_->IsRootForAccessPolicy(view->id());
}
-bool DefaultAccessPolicy::CanSetViewSurfaceId(const ServerView* view) const {
+bool DefaultAccessPolicy::CanSetWindowSurfaceId(const ServerView* view) const {
// Once a view embeds another app, the embedder app is no longer able to
- // call SetViewSurfaceId() - this ability is transferred to the embedded app.
+ // call SetWindowSurfaceId() - this ability is transferred to the embedded
+ // app.
if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
return false;
return WasCreatedByThisConnection(view) ||
diff --git a/components/mus/vm/default_access_policy.h b/components/mus/vm/default_access_policy.h
index 194c903..6bda02e 100644
--- a/components/mus/vm/default_access_policy.h
+++ b/components/mus/vm/default_access_policy.h
@@ -31,7 +31,7 @@ class DefaultAccessPolicy : public AccessPolicy {
bool CanDescendIntoViewForViewTree(const ServerView* view) const override;
bool CanEmbed(const ServerView* view, uint32_t policy_bitmask) const override;
bool CanChangeViewVisibility(const ServerView* view) const override;
- bool CanSetViewSurfaceId(const ServerView* view) const override;
+ bool CanSetWindowSurfaceId(const ServerView* view) const override;
bool CanSetViewBounds(const ServerView* view) const override;
bool CanSetViewProperties(const ServerView* view) const override;
bool CanSetViewTextInputState(const ServerView* view) const override;
diff --git a/components/mus/vm/test_change_tracker.cc b/components/mus/vm/test_change_tracker.cc
index 3a3dd97..9ff3b11 100644
--- a/components/mus/vm/test_change_tracker.cc
+++ b/components/mus/vm/test_change_tracker.cc
@@ -187,9 +187,9 @@ void TestChangeTracker::OnEmbeddedAppDisconnected(Id view_id) {
AddChange(change);
}
-void TestChangeTracker::OnViewBoundsChanged(Id view_id,
- mojo::RectPtr old_bounds,
- mojo::RectPtr new_bounds) {
+void TestChangeTracker::OnWindowBoundsChanged(Id view_id,
+ mojo::RectPtr old_bounds,
+ mojo::RectPtr new_bounds) {
Change change;
change.type = CHANGE_TYPE_NODE_BOUNDS_CHANGED;
change.view_id = view_id;
@@ -210,7 +210,7 @@ void TestChangeTracker::OnUnembed() {
AddChange(change);
}
-void TestChangeTracker::OnViewViewportMetricsChanged(
+void TestChangeTracker::OnWindowViewportMetricsChanged(
mojo::ViewportMetricsPtr old_metrics,
mojo::ViewportMetricsPtr new_metrics) {
Change change;
@@ -219,10 +219,10 @@ void TestChangeTracker::OnViewViewportMetricsChanged(
AddChange(change);
}
-void TestChangeTracker::OnViewHierarchyChanged(Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- Array<ViewDataPtr> views) {
+void TestChangeTracker::OnWindowHierarchyChanged(Id view_id,
+ Id new_parent_id,
+ Id old_parent_id,
+ Array<ViewDataPtr> views) {
Change change;
change.type = CHANGE_TYPE_NODE_HIERARCHY_CHANGED;
change.view_id = view_id;
@@ -232,9 +232,9 @@ void TestChangeTracker::OnViewHierarchyChanged(Id view_id,
AddChange(change);
}
-void TestChangeTracker::OnViewReordered(Id view_id,
- Id relative_view_id,
- mojo::OrderDirection direction) {
+void TestChangeTracker::OnWindowReordered(Id view_id,
+ Id relative_view_id,
+ mojo::OrderDirection direction) {
Change change;
change.type = CHANGE_TYPE_NODE_REORDERED;
change.view_id = view_id;
@@ -243,14 +243,14 @@ void TestChangeTracker::OnViewReordered(Id view_id,
AddChange(change);
}
-void TestChangeTracker::OnViewDeleted(Id view_id) {
+void TestChangeTracker::OnWindowDeleted(Id view_id) {
Change change;
change.type = CHANGE_TYPE_NODE_DELETED;
change.view_id = view_id;
AddChange(change);
}
-void TestChangeTracker::OnViewVisibilityChanged(Id view_id, bool visible) {
+void TestChangeTracker::OnWindowVisibilityChanged(Id view_id, bool visible) {
Change change;
change.type = CHANGE_TYPE_NODE_VISIBILITY_CHANGED;
change.view_id = view_id;
@@ -258,7 +258,7 @@ void TestChangeTracker::OnViewVisibilityChanged(Id view_id, bool visible) {
AddChange(change);
}
-void TestChangeTracker::OnViewDrawnStateChanged(Id view_id, bool drawn) {
+void TestChangeTracker::OnWindowDrawnStateChanged(Id view_id, bool drawn) {
Change change;
change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED;
change.view_id = view_id;
@@ -266,7 +266,7 @@ void TestChangeTracker::OnViewDrawnStateChanged(Id view_id, bool drawn) {
AddChange(change);
}
-void TestChangeTracker::OnViewInputEvent(Id view_id, mojo::EventPtr event) {
+void TestChangeTracker::OnWindowInputEvent(Id view_id, mojo::EventPtr event) {
Change change;
change.type = CHANGE_TYPE_INPUT_EVENT;
change.view_id = view_id;
@@ -274,9 +274,9 @@ void TestChangeTracker::OnViewInputEvent(Id view_id, mojo::EventPtr event) {
AddChange(change);
}
-void TestChangeTracker::OnViewSharedPropertyChanged(Id view_id,
- String name,
- Array<uint8_t> data) {
+void TestChangeTracker::OnWindowSharedPropertyChanged(Id view_id,
+ String name,
+ Array<uint8_t> data) {
Change change;
change.type = CHANGE_TYPE_PROPERTY_CHANGED;
change.view_id = view_id;
@@ -288,7 +288,7 @@ void TestChangeTracker::OnViewSharedPropertyChanged(Id view_id,
AddChange(change);
}
-void TestChangeTracker::OnViewFocused(Id view_id) {
+void TestChangeTracker::OnWindowFocused(Id view_id) {
Change change;
change.type = CHANGE_TYPE_FOCUSED;
change.view_id = view_id;
diff --git a/components/mus/vm/test_change_tracker.h b/components/mus/vm/test_change_tracker.h
index 1896de2..aa1514b 100644
--- a/components/mus/vm/test_change_tracker.h
+++ b/components/mus/vm/test_change_tracker.h
@@ -120,26 +120,26 @@ class TestChangeTracker {
void OnEmbed(ConnectionSpecificId connection_id, mojo::ViewDataPtr root);
void OnEmbeddedAppDisconnected(Id view_id);
void OnUnembed();
- void OnViewBoundsChanged(Id view_id,
- mojo::RectPtr old_bounds,
- mojo::RectPtr new_bounds);
- void OnViewViewportMetricsChanged(mojo::ViewportMetricsPtr old_bounds,
- mojo::ViewportMetricsPtr new_bounds);
- void OnViewHierarchyChanged(Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- mojo::Array<mojo::ViewDataPtr> views);
- void OnViewReordered(Id view_id,
- Id relative_view_id,
- mojo::OrderDirection direction);
- void OnViewDeleted(Id view_id);
- void OnViewVisibilityChanged(Id view_id, bool visible);
- void OnViewDrawnStateChanged(Id view_id, bool drawn);
- void OnViewInputEvent(Id view_id, mojo::EventPtr event);
- void OnViewSharedPropertyChanged(Id view_id,
- mojo::String name,
- mojo::Array<uint8_t> data);
- void OnViewFocused(Id view_id);
+ void OnWindowBoundsChanged(Id view_id,
+ mojo::RectPtr old_bounds,
+ mojo::RectPtr new_bounds);
+ void OnWindowViewportMetricsChanged(mojo::ViewportMetricsPtr old_bounds,
+ mojo::ViewportMetricsPtr new_bounds);
+ void OnWindowHierarchyChanged(Id view_id,
+ Id new_parent_id,
+ Id old_parent_id,
+ mojo::Array<mojo::ViewDataPtr> views);
+ void OnWindowReordered(Id view_id,
+ Id relative_view_id,
+ mojo::OrderDirection direction);
+ void OnWindowDeleted(Id view_id);
+ void OnWindowVisibilityChanged(Id view_id, bool visible);
+ void OnWindowDrawnStateChanged(Id view_id, bool drawn);
+ void OnWindowInputEvent(Id view_id, mojo::EventPtr event);
+ void OnWindowSharedPropertyChanged(Id view_id,
+ mojo::String name,
+ mojo::Array<uint8_t> data);
+ void OnWindowFocused(Id view_id);
void DelegateEmbed(const mojo::String& url);
private:
diff --git a/components/mus/vm/view_manager_client_apptest.cc b/components/mus/vm/view_manager_client_apptest.cc
index 1b38820..9d6e1af 100644
--- a/components/mus/vm/view_manager_client_apptest.cc
+++ b/components/mus/vm/view_manager_client_apptest.cc
@@ -5,11 +5,11 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/run_loop.h"
-#include "components/mus/public/cpp/tests/view_manager_test_base.h"
+#include "components/mus/public/cpp/tests/window_server_test_base.h"
#include "components/mus/public/cpp/util.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/application_test_base.h"
@@ -19,133 +19,142 @@ namespace mus {
namespace {
-class BoundsChangeObserver : public ViewObserver {
+class BoundsChangeObserver : public WindowObserver {
public:
- explicit BoundsChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
+ explicit BoundsChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
}
- ~BoundsChangeObserver() override { view_->RemoveObserver(this); }
+ ~BoundsChangeObserver() override { window_->RemoveObserver(this); }
private:
- // Overridden from ViewObserver:
- void OnViewBoundsChanged(View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override {
- DCHECK_EQ(view, view_);
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ // Overridden from WindowObserver:
+ void OnWindowBoundsChanged(Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override {
+ DCHECK_EQ(window, window_);
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- View* view_;
+ Window* window_;
MOJO_DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
};
-// Wait until the bounds of the supplied view change; returns false on timeout.
-bool WaitForBoundsToChange(View* view) {
- BoundsChangeObserver observer(view);
- return ViewManagerTestBase::DoRunLoopWithTimeout();
+// Wait until the bounds of the supplied window change; returns false on
+// timeout.
+bool WaitForBoundsToChange(Window* window) {
+ BoundsChangeObserver observer(window);
+ return WindowServerTestBase::DoRunLoopWithTimeout();
}
-// Spins a run loop until the tree beginning at |root| has |tree_size| views
+// Spins a run loop until the tree beginning at |root| has |tree_size| windows
// (including |root|).
-class TreeSizeMatchesObserver : public ViewObserver {
+class TreeSizeMatchesObserver : public WindowObserver {
public:
- TreeSizeMatchesObserver(View* tree, size_t tree_size)
+ TreeSizeMatchesObserver(Window* tree, size_t tree_size)
: tree_(tree), tree_size_(tree_size) {
tree_->AddObserver(this);
}
~TreeSizeMatchesObserver() override { tree_->RemoveObserver(this); }
- bool IsTreeCorrectSize() { return CountViews(tree_) == tree_size_; }
+ bool IsTreeCorrectSize() { return CountWindows(tree_) == tree_size_; }
private:
- // Overridden from ViewObserver:
+ // Overridden from WindowObserver:
void OnTreeChanged(const TreeChangeParams& params) override {
if (IsTreeCorrectSize())
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- size_t CountViews(const View* view) const {
+ size_t CountWindows(const Window* window) const {
size_t count = 1;
- View::Children::const_iterator it = view->children().begin();
- for (; it != view->children().end(); ++it)
- count += CountViews(*it);
+ Window::Children::const_iterator it = window->children().begin();
+ for (; it != window->children().end(); ++it)
+ count += CountWindows(*it);
return count;
}
- View* tree_;
+ Window* tree_;
size_t tree_size_;
MOJO_DISALLOW_COPY_AND_ASSIGN(TreeSizeMatchesObserver);
};
-// Wait until |view| has |tree_size| descendants; returns false on timeout. The
-// count includes |view|. For example, if you want to wait for |view| to have
+// Wait until |window| has |tree_size| descendants; returns false on timeout.
+// The
+// count includes |window|. For example, if you want to wait for |window| to
+// have
// a single child, use a |tree_size| of 2.
-bool WaitForTreeSizeToMatch(View* view, size_t tree_size) {
- TreeSizeMatchesObserver observer(view, tree_size);
+bool WaitForTreeSizeToMatch(Window* window, size_t tree_size) {
+ TreeSizeMatchesObserver observer(window, tree_size);
return observer.IsTreeCorrectSize() ||
- ViewManagerTestBase::DoRunLoopWithTimeout();
+ WindowServerTestBase::DoRunLoopWithTimeout();
}
-class OrderChangeObserver : public ViewObserver {
+class OrderChangeObserver : public WindowObserver {
public:
- OrderChangeObserver(View* view) : view_(view) { view_->AddObserver(this); }
- ~OrderChangeObserver() override { view_->RemoveObserver(this); }
+ OrderChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
+ }
+ ~OrderChangeObserver() override { window_->RemoveObserver(this); }
private:
- // Overridden from ViewObserver:
- void OnViewReordered(View* view,
- View* relative_view,
- mojo::OrderDirection direction) override {
- DCHECK_EQ(view, view_);
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ // Overridden from WindowObserver:
+ void OnWindowReordered(Window* window,
+ Window* relative_window,
+ mojo::OrderDirection direction) override {
+ DCHECK_EQ(window, window_);
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- View* view_;
+ Window* window_;
MOJO_DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
};
-// Wait until |view|'s tree size matches |tree_size|; returns false on timeout.
-bool WaitForOrderChange(ViewTreeConnection* connection, View* view) {
- OrderChangeObserver observer(view);
- return ViewManagerTestBase::DoRunLoopWithTimeout();
+// Wait until |window|'s tree size matches |tree_size|; returns false on
+// timeout.
+bool WaitForOrderChange(WindowTreeConnection* connection, Window* window) {
+ OrderChangeObserver observer(window);
+ return WindowServerTestBase::DoRunLoopWithTimeout();
}
-// Tracks a view's destruction. Query is_valid() for current state.
-class ViewTracker : public ViewObserver {
+// Tracks a window's destruction. Query is_valid() for current state.
+class WindowTracker : public WindowObserver {
public:
- explicit ViewTracker(View* view) : view_(view) { view_->AddObserver(this); }
- ~ViewTracker() override {
- if (view_)
- view_->RemoveObserver(this);
+ explicit WindowTracker(Window* window) : window_(window) {
+ window_->AddObserver(this);
+ }
+ ~WindowTracker() override {
+ if (window_)
+ window_->RemoveObserver(this);
}
- bool is_valid() const { return !!view_; }
+ bool is_valid() const { return !!window_; }
private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- DCHECK_EQ(view, view_);
- view_ = nullptr;
+ // Overridden from WindowObserver:
+ void OnWindowDestroyed(Window* window) override {
+ DCHECK_EQ(window, window_);
+ window_ = nullptr;
}
- View* view_;
+ Window* window_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTracker);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowTracker);
};
} // namespace
-// ViewManager -----------------------------------------------------------------
+// WindowServer
+// -----------------------------------------------------------------
struct EmbedResult {
- EmbedResult(ViewTreeConnection* connection, ConnectionSpecificId id)
+ EmbedResult(WindowTreeConnection* connection, ConnectionSpecificId id)
: connection(connection), connection_id(id) {}
EmbedResult() : connection(nullptr), connection_id(0) {}
- ViewTreeConnection* connection;
+ WindowTreeConnection* connection;
// The id supplied to the callback from OnEmbed(). Depending upon the
// access policy this may or may not match the connection id of
@@ -153,29 +162,30 @@ struct EmbedResult {
ConnectionSpecificId connection_id;
};
-// These tests model synchronization of two peer connections to the view manager
-// service, that are given access to some root view.
+// These tests model synchronization of two peer connections to the window
+// manager
+// service, that are given access to some root window.
-class ViewManagerTest : public ViewManagerTestBase {
+class WindowServerTest : public WindowServerTestBase {
public:
- ViewManagerTest() {}
+ WindowServerTest() {}
- // Embeds another version of the test app @ view. This runs a run loop until
- // a response is received, or a timeout. On success the new ViewManager is
+ // Embeds another version of the test app @ window. This runs a run loop until
+ // a response is received, or a timeout. On success the new WindowServer is
// returned.
- EmbedResult Embed(View* view) {
- return Embed(view, mojo::ViewTree::ACCESS_POLICY_DEFAULT);
+ EmbedResult Embed(Window* window) {
+ return Embed(window, mojo::ViewTree::ACCESS_POLICY_DEFAULT);
}
- EmbedResult Embed(View* view, uint32_t access_policy_bitmask) {
+ EmbedResult Embed(Window* window, uint32_t access_policy_bitmask) {
DCHECK(!embed_details_);
embed_details_.reset(new EmbedDetails);
- view->Embed(ConnectToApplicationAndGetViewManagerClient(),
- access_policy_bitmask,
- base::Bind(&ViewManagerTest::EmbedCallbackImpl,
- base::Unretained(this)));
+ window->Embed(ConnectToApplicationAndGetWindowServerClient(),
+ access_policy_bitmask,
+ base::Bind(&WindowServerTest::EmbedCallbackImpl,
+ base::Unretained(this)));
embed_details_->waiting = true;
- if (!ViewManagerTestBase::DoRunLoopWithTimeout())
+ if (!WindowServerTestBase::DoRunLoopWithTimeout())
return EmbedResult();
const EmbedResult result(embed_details_->connection,
embed_details_->connection_id);
@@ -185,7 +195,7 @@ class ViewManagerTest : public ViewManagerTestBase {
// Establishes a connection to this application and asks for a
// ViewTreeClient.
- mojo::ViewTreeClientPtr ConnectToApplicationAndGetViewManagerClient() {
+ mojo::ViewTreeClientPtr ConnectToApplicationAndGetWindowServerClient() {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From(application_impl()->url());
scoped_ptr<mojo::ApplicationConnection> connection =
@@ -195,20 +205,20 @@ class ViewManagerTest : public ViewManagerTestBase {
return client.Pass();
}
- // ViewManagerTestBase:
- void OnEmbed(View* root) override {
+ // WindowServerTestBase:
+ void OnEmbed(Window* root) override {
if (!embed_details_) {
- ViewManagerTestBase::OnEmbed(root);
+ WindowServerTestBase::OnEmbed(root);
return;
}
embed_details_->connection = root->connection();
if (embed_details_->callback_run)
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
private:
- // Used to track the state of a call to view->Embed().
+ // Used to track the state of a call to window->Embed().
struct EmbedDetails {
EmbedDetails()
: callback_run(false),
@@ -229,9 +239,9 @@ class ViewManagerTest : public ViewManagerTestBase {
// Connection id supplied to the Embed() callback.
ConnectionSpecificId connection_id;
- // The ViewTreeConnection that resulted from the Embed(). null if |result|
+ // The WindowTreeConnection that resulted from the Embed(). null if |result|
// is false.
- ViewTreeConnection* connection;
+ WindowTreeConnection* connection;
};
void EmbedCallbackImpl(bool result, ConnectionSpecificId connection_id) {
@@ -239,217 +249,218 @@ class ViewManagerTest : public ViewManagerTestBase {
embed_details_->result = result;
embed_details_->connection_id = connection_id;
if (embed_details_->waiting && (!result || embed_details_->connection))
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
scoped_ptr<EmbedDetails> embed_details_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowServerTest);
};
-TEST_F(ViewManagerTest, RootView) {
+TEST_F(WindowServerTest, RootWindow) {
ASSERT_NE(nullptr, window_manager());
EXPECT_NE(nullptr, window_manager()->GetRoot());
}
-TEST_F(ViewManagerTest, Embed) {
- View* view = window_manager()->CreateView();
- ASSERT_NE(nullptr, view);
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* embedded = Embed(view).connection;
+TEST_F(WindowServerTest, Embed) {
+ Window* window = window_manager()->CreateWindow();
+ ASSERT_NE(nullptr, window);
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* embedded = Embed(window).connection;
ASSERT_NE(nullptr, embedded);
- View* view_in_embedded = embedded->GetRoot();
- ASSERT_NE(nullptr, view_in_embedded);
- EXPECT_EQ(view->id(), view_in_embedded->id());
- EXPECT_EQ(nullptr, view_in_embedded->parent());
- EXPECT_TRUE(view_in_embedded->children().empty());
+ Window* window_in_embedded = embedded->GetRoot();
+ ASSERT_NE(nullptr, window_in_embedded);
+ EXPECT_EQ(window->id(), window_in_embedded->id());
+ EXPECT_EQ(nullptr, window_in_embedded->parent());
+ EXPECT_TRUE(window_in_embedded->children().empty());
}
-// Window manager has two views, N1 and N11. Embeds A at N1. A should not see
+// Window manager has two windows, N1 and N11. Embeds A at N1. A should not see
// N11.
-TEST_F(ViewManagerTest, EmbeddedDoesntSeeChild) {
- View* view = window_manager()->CreateView();
- ASSERT_NE(nullptr, view);
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- View* nested = window_manager()->CreateView();
+TEST_F(WindowServerTest, EmbeddedDoesntSeeChild) {
+ Window* window = window_manager()->CreateWindow();
+ ASSERT_NE(nullptr, window);
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ Window* nested = window_manager()->CreateWindow();
ASSERT_NE(nullptr, nested);
nested->SetVisible(true);
- view->AddChild(nested);
+ window->AddChild(nested);
- ViewTreeConnection* embedded = Embed(view).connection;
+ WindowTreeConnection* embedded = Embed(window).connection;
ASSERT_NE(nullptr, embedded);
- View* view_in_embedded = embedded->GetRoot();
- EXPECT_EQ(view->id(), view_in_embedded->id());
- EXPECT_EQ(nullptr, view_in_embedded->parent());
- EXPECT_TRUE(view_in_embedded->children().empty());
+ Window* window_in_embedded = embedded->GetRoot();
+ EXPECT_EQ(window->id(), window_in_embedded->id());
+ EXPECT_EQ(nullptr, window_in_embedded->parent());
+ EXPECT_TRUE(window_in_embedded->children().empty());
}
// TODO(beng): write a replacement test for the one that once existed here:
// This test validates the following scenario:
-// - a view originating from one connection
-// - a view originating from a second connection
-// + the connection originating the view is destroyed
-// -> the view should still exist (since the second connection is live) but
-// should be disconnected from any views.
+// - a window originating from one connection
+// - a window originating from a second connection
+// + the connection originating the window is destroyed
+// -> the window should still exist (since the second connection is live) but
+// should be disconnected from any windows.
// http://crbug.com/396300
//
// TODO(beng): The new test should validate the scenario as described above
// except that the second connection still has a valid tree.
-// Verifies that bounds changes applied to a view hierarchy in one connection
+// Verifies that bounds changes applied to a window hierarchy in one connection
// are reflected to another.
-TEST_F(ViewManagerTest, SetBounds) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* embedded = Embed(view).connection;
+TEST_F(WindowServerTest, SetBounds) {
+ Window* window = window_manager()->CreateWindow();
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* embedded = Embed(window).connection;
ASSERT_NE(nullptr, embedded);
- View* view_in_embedded = embedded->GetViewById(view->id());
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
+ Window* window_in_embedded = embedded->GetWindowById(window->id());
+ EXPECT_EQ(window->bounds(), window_in_embedded->bounds());
mojo::Rect rect;
rect.width = rect.height = 100;
- view->SetBounds(rect);
- ASSERT_TRUE(WaitForBoundsToChange(view_in_embedded));
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
+ window->SetBounds(rect);
+ ASSERT_TRUE(WaitForBoundsToChange(window_in_embedded));
+ EXPECT_EQ(window->bounds(), window_in_embedded->bounds());
}
-// Verifies that bounds changes applied to a view owned by a different
+// Verifies that bounds changes applied to a window owned by a different
// connection are refused.
-TEST_F(ViewManagerTest, SetBoundsSecurity) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* embedded = Embed(view).connection;
+TEST_F(WindowServerTest, SetBoundsSecurity) {
+ Window* window = window_manager()->CreateWindow();
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* embedded = Embed(window).connection;
ASSERT_NE(nullptr, embedded);
- View* view_in_embedded = embedded->GetViewById(view->id());
+ Window* window_in_embedded = embedded->GetWindowById(window->id());
mojo::Rect rect;
rect.width = 800;
rect.height = 600;
- view->SetBounds(rect);
- ASSERT_TRUE(WaitForBoundsToChange(view_in_embedded));
+ window->SetBounds(rect);
+ ASSERT_TRUE(WaitForBoundsToChange(window_in_embedded));
rect.width = 1024;
rect.height = 768;
- view_in_embedded->SetBounds(rect);
+ window_in_embedded->SetBounds(rect);
// Bounds change should have been rejected.
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
+ EXPECT_EQ(window->bounds(), window_in_embedded->bounds());
}
-// Verifies that a view can only be destroyed by the connection that created it.
-TEST_F(ViewManagerTest, DestroySecurity) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* embedded = Embed(view).connection;
+// Verifies that a window can only be destroyed by the connection that created
+// it.
+TEST_F(WindowServerTest, DestroySecurity) {
+ Window* window = window_manager()->CreateWindow();
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* embedded = Embed(window).connection;
ASSERT_NE(nullptr, embedded);
- View* view_in_embedded = embedded->GetViewById(view->id());
+ Window* window_in_embedded = embedded->GetWindowById(window->id());
- ViewTracker tracker2(view_in_embedded);
- view_in_embedded->Destroy();
- // View should not have been destroyed.
+ WindowTracker tracker2(window_in_embedded);
+ window_in_embedded->Destroy();
+ // Window should not have been destroyed.
EXPECT_TRUE(tracker2.is_valid());
- ViewTracker tracker1(view);
- view->Destroy();
+ WindowTracker tracker1(window);
+ window->Destroy();
EXPECT_FALSE(tracker1.is_valid());
}
-TEST_F(ViewManagerTest, MultiRoots) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
- View* view2 = window_manager()->CreateView();
- view2->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view2);
- ViewTreeConnection* embedded1 = Embed(view1).connection;
+TEST_F(WindowServerTest, MultiRoots) {
+ Window* window1 = window_manager()->CreateWindow();
+ window1->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window1);
+ Window* window2 = window_manager()->CreateWindow();
+ window2->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window2);
+ WindowTreeConnection* embedded1 = Embed(window1).connection;
ASSERT_NE(nullptr, embedded1);
- ViewTreeConnection* embedded2 = Embed(view2).connection;
+ WindowTreeConnection* embedded2 = Embed(window2).connection;
ASSERT_NE(nullptr, embedded2);
EXPECT_NE(embedded1, embedded2);
}
// TODO(alhaad): Currently, the RunLoop gets stuck waiting for order change.
// Debug and re-enable this.
-TEST_F(ViewManagerTest, DISABLED_Reorder) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
+TEST_F(WindowServerTest, DISABLED_Reorder) {
+ Window* window1 = window_manager()->CreateWindow();
+ window1->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window1);
- ViewTreeConnection* embedded = Embed(view1).connection;
+ WindowTreeConnection* embedded = Embed(window1).connection;
ASSERT_NE(nullptr, embedded);
- View* view11 = embedded->CreateView();
- view11->SetVisible(true);
- embedded->GetRoot()->AddChild(view11);
- View* view12 = embedded->CreateView();
- view12->SetVisible(true);
- embedded->GetRoot()->AddChild(view12);
+ Window* window11 = embedded->CreateWindow();
+ window11->SetVisible(true);
+ embedded->GetRoot()->AddChild(window11);
+ Window* window12 = embedded->CreateWindow();
+ window12->SetVisible(true);
+ embedded->GetRoot()->AddChild(window12);
- View* root_in_embedded = embedded->GetRoot();
+ Window* root_in_embedded = embedded->GetRoot();
{
ASSERT_TRUE(WaitForTreeSizeToMatch(root_in_embedded, 3u));
- view11->MoveToFront();
+ window11->MoveToFront();
ASSERT_TRUE(WaitForOrderChange(embedded, root_in_embedded));
EXPECT_EQ(root_in_embedded->children().front(),
- embedded->GetViewById(view12->id()));
+ embedded->GetWindowById(window12->id()));
EXPECT_EQ(root_in_embedded->children().back(),
- embedded->GetViewById(view11->id()));
+ embedded->GetWindowById(window11->id()));
}
{
- view11->MoveToBack();
+ window11->MoveToBack();
ASSERT_TRUE(
- WaitForOrderChange(embedded, embedded->GetViewById(view11->id())));
+ WaitForOrderChange(embedded, embedded->GetWindowById(window11->id())));
EXPECT_EQ(root_in_embedded->children().front(),
- embedded->GetViewById(view11->id()));
+ embedded->GetWindowById(window11->id()));
EXPECT_EQ(root_in_embedded->children().back(),
- embedded->GetViewById(view12->id()));
+ embedded->GetWindowById(window12->id()));
}
}
namespace {
-class VisibilityChangeObserver : public ViewObserver {
+class VisibilityChangeObserver : public WindowObserver {
public:
- explicit VisibilityChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
+ explicit VisibilityChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
}
- ~VisibilityChangeObserver() override { view_->RemoveObserver(this); }
+ ~VisibilityChangeObserver() override { window_->RemoveObserver(this); }
private:
- // Overridden from ViewObserver:
- void OnViewVisibilityChanged(View* view) override {
- EXPECT_EQ(view, view_);
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ // Overridden from WindowObserver:
+ void OnWindowVisibilityChanged(Window* window) override {
+ EXPECT_EQ(window, window_);
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- View* view_;
+ Window* window_;
MOJO_DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
};
} // namespace
-TEST_F(ViewManagerTest, Visible) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
+TEST_F(WindowServerTest, Visible) {
+ Window* window1 = window_manager()->CreateWindow();
+ window1->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window1);
// Embed another app and verify initial state.
- ViewTreeConnection* embedded = Embed(view1).connection;
+ WindowTreeConnection* embedded = Embed(window1).connection;
ASSERT_NE(nullptr, embedded);
ASSERT_NE(nullptr, embedded->GetRoot());
- View* embedded_root = embedded->GetRoot();
+ Window* embedded_root = embedded->GetRoot();
EXPECT_TRUE(embedded_root->visible());
EXPECT_TRUE(embedded_root->IsDrawn());
@@ -457,12 +468,12 @@ TEST_F(ViewManagerTest, Visible) {
// correctly to the embedded app.
{
VisibilityChangeObserver observer(embedded_root);
- view1->SetVisible(false);
- ASSERT_TRUE(ViewManagerTestBase::DoRunLoopWithTimeout());
+ window1->SetVisible(false);
+ ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout());
}
- EXPECT_FALSE(view1->visible());
- EXPECT_FALSE(view1->IsDrawn());
+ EXPECT_FALSE(window1->visible());
+ EXPECT_FALSE(window1->IsDrawn());
EXPECT_FALSE(embedded_root->visible());
EXPECT_FALSE(embedded_root->IsDrawn());
@@ -470,12 +481,12 @@ TEST_F(ViewManagerTest, Visible) {
// Make the node visible again.
{
VisibilityChangeObserver observer(embedded_root);
- view1->SetVisible(true);
- ASSERT_TRUE(ViewManagerTestBase::DoRunLoopWithTimeout());
+ window1->SetVisible(true);
+ ASSERT_TRUE(WindowServerTestBase::DoRunLoopWithTimeout());
}
- EXPECT_TRUE(view1->visible());
- EXPECT_TRUE(view1->IsDrawn());
+ EXPECT_TRUE(window1->visible());
+ EXPECT_TRUE(window1->IsDrawn());
EXPECT_TRUE(embedded_root->visible());
EXPECT_TRUE(embedded_root->IsDrawn());
@@ -483,37 +494,37 @@ TEST_F(ViewManagerTest, Visible) {
namespace {
-class DrawnChangeObserver : public ViewObserver {
+class DrawnChangeObserver : public WindowObserver {
public:
- explicit DrawnChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
+ explicit DrawnChangeObserver(Window* window) : window_(window) {
+ window_->AddObserver(this);
}
- ~DrawnChangeObserver() override { view_->RemoveObserver(this); }
+ ~DrawnChangeObserver() override { window_->RemoveObserver(this); }
private:
- // Overridden from ViewObserver:
- void OnViewDrawnChanged(View* view) override {
- EXPECT_EQ(view, view_);
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ // Overridden from WindowObserver:
+ void OnWindowDrawnChanged(Window* window) override {
+ EXPECT_EQ(window, window_);
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- View* view_;
+ Window* window_;
MOJO_DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver);
};
} // namespace
-TEST_F(ViewManagerTest, Drawn) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
+TEST_F(WindowServerTest, Drawn) {
+ Window* window1 = window_manager()->CreateWindow();
+ window1->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window1);
// Embed another app and verify initial state.
- ViewTreeConnection* embedded = Embed(view1).connection;
+ WindowTreeConnection* embedded = Embed(window1).connection;
ASSERT_NE(nullptr, embedded);
ASSERT_NE(nullptr, embedded->GetRoot());
- View* embedded_root = embedded->GetRoot();
+ Window* embedded_root = embedded->GetRoot();
EXPECT_TRUE(embedded_root->visible());
EXPECT_TRUE(embedded_root->IsDrawn());
@@ -525,64 +536,66 @@ TEST_F(ViewManagerTest, Drawn) {
ASSERT_TRUE(DoRunLoopWithTimeout());
}
- EXPECT_TRUE(view1->visible());
- EXPECT_FALSE(view1->IsDrawn());
+ EXPECT_TRUE(window1->visible());
+ EXPECT_FALSE(window1->IsDrawn());
EXPECT_TRUE(embedded_root->visible());
EXPECT_FALSE(embedded_root->IsDrawn());
}
-// TODO(beng): tests for view event dispatcher.
-// - verify that we see events for all views.
+// TODO(beng): tests for window event dispatcher.
+// - verify that we see events for all windows.
namespace {
-class FocusChangeObserver : public ViewObserver {
+class FocusChangeObserver : public WindowObserver {
public:
- explicit FocusChangeObserver(View* view)
- : view_(view), last_gained_focus_(nullptr), last_lost_focus_(nullptr) {
- view_->AddObserver(this);
+ explicit FocusChangeObserver(Window* window)
+ : window_(window),
+ last_gained_focus_(nullptr),
+ last_lost_focus_(nullptr) {
+ window_->AddObserver(this);
}
- ~FocusChangeObserver() override { view_->RemoveObserver(this); }
+ ~FocusChangeObserver() override { window_->RemoveObserver(this); }
- View* last_gained_focus() { return last_gained_focus_; }
+ Window* last_gained_focus() { return last_gained_focus_; }
- View* last_lost_focus() { return last_lost_focus_; }
+ Window* last_lost_focus() { return last_lost_focus_; }
private:
- // Overridden from ViewObserver.
- void OnViewFocusChanged(View* gained_focus, View* lost_focus) override {
+ // Overridden from WindowObserver.
+ void OnWindowFocusChanged(Window* gained_focus, Window* lost_focus) override {
EXPECT_TRUE(!gained_focus || gained_focus->HasFocus());
EXPECT_FALSE(lost_focus && lost_focus->HasFocus());
last_gained_focus_ = gained_focus;
last_lost_focus_ = lost_focus;
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- View* view_;
- View* last_gained_focus_;
- View* last_lost_focus_;
+ Window* window_;
+ Window* last_gained_focus_;
+ Window* last_lost_focus_;
MOJO_DISALLOW_COPY_AND_ASSIGN(FocusChangeObserver);
};
} // namespace
-TEST_F(ViewManagerTest, Focus) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
+TEST_F(WindowServerTest, Focus) {
+ Window* window1 = window_manager()->CreateWindow();
+ window1->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window1);
- ViewTreeConnection* embedded = Embed(view1).connection;
+ WindowTreeConnection* embedded = Embed(window1).connection;
ASSERT_NE(nullptr, embedded);
- View* view11 = embedded->CreateView();
- view11->SetVisible(true);
- embedded->GetRoot()->AddChild(view11);
+ Window* window11 = embedded->CreateWindow();
+ window11->SetVisible(true);
+ embedded->GetRoot()->AddChild(window11);
- // TODO(alhaad): Figure out why switching focus between views from different
+ // TODO(alhaad): Figure out why switching focus between windows from different
// connections is causing the tests to crash and add tests for that.
{
- View* embedded_root = embedded->GetRoot();
+ Window* embedded_root = embedded->GetRoot();
FocusChangeObserver observer(embedded_root);
embedded_root->SetFocus();
ASSERT_TRUE(DoRunLoopWithTimeout());
@@ -590,56 +603,57 @@ TEST_F(ViewManagerTest, Focus) {
EXPECT_EQ(embedded_root->id(), observer.last_gained_focus()->id());
}
{
- FocusChangeObserver observer(view11);
- view11->SetFocus();
+ FocusChangeObserver observer(window11);
+ window11->SetFocus();
ASSERT_TRUE(DoRunLoopWithTimeout());
ASSERT_NE(nullptr, observer.last_gained_focus());
ASSERT_NE(nullptr, observer.last_lost_focus());
- EXPECT_EQ(view11->id(), observer.last_gained_focus()->id());
+ EXPECT_EQ(window11->id(), observer.last_gained_focus()->id());
EXPECT_EQ(embedded->GetRoot()->id(), observer.last_lost_focus()->id());
}
{
- // Add an observer on the View that loses focus, and make sure the observer
+ // Add an observer on the Window that loses focus, and make sure the
+ // observer
// sees the right values.
- FocusChangeObserver observer(view11);
+ FocusChangeObserver observer(window11);
embedded->GetRoot()->SetFocus();
ASSERT_TRUE(DoRunLoopWithTimeout());
ASSERT_NE(nullptr, observer.last_gained_focus());
ASSERT_NE(nullptr, observer.last_lost_focus());
- EXPECT_EQ(view11->id(), observer.last_lost_focus()->id());
+ EXPECT_EQ(window11->id(), observer.last_lost_focus()->id());
EXPECT_EQ(embedded->GetRoot()->id(), observer.last_gained_focus()->id());
}
}
namespace {
-class DestroyedChangedObserver : public ViewObserver {
+class DestroyedChangedObserver : public WindowObserver {
public:
- DestroyedChangedObserver(ViewManagerTestBase* test,
- View* view,
+ DestroyedChangedObserver(WindowServerTestBase* test,
+ Window* window,
bool* got_destroy)
- : test_(test), view_(view), got_destroy_(got_destroy) {
- view_->AddObserver(this);
+ : test_(test), window_(window), got_destroy_(got_destroy) {
+ window_->AddObserver(this);
}
~DestroyedChangedObserver() override {
- if (view_)
- view_->RemoveObserver(this);
+ if (window_)
+ window_->RemoveObserver(this);
}
private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- EXPECT_EQ(view, view_);
- view_->RemoveObserver(this);
+ // Overridden from WindowObserver:
+ void OnWindowDestroyed(Window* window) override {
+ EXPECT_EQ(window, window_);
+ window_->RemoveObserver(this);
*got_destroy_ = true;
- view_ = nullptr;
+ window_ = nullptr;
- // We should always get OnViewDestroyed() before OnConnectionLost().
- EXPECT_FALSE(test_->view_tree_connection_destroyed());
+ // We should always get OnWindowDestroyed() before OnConnectionLost().
+ EXPECT_FALSE(test_->window_tree_connection_destroyed());
}
- ViewManagerTestBase* test_;
- View* view_;
+ WindowServerTestBase* test_;
+ Window* window_;
bool* got_destroy_;
MOJO_DISALLOW_COPY_AND_ASSIGN(DestroyedChangedObserver);
@@ -647,73 +661,73 @@ class DestroyedChangedObserver : public ViewObserver {
} // namespace
-// Verifies deleting a ViewManager sends the right notifications.
-TEST_F(ViewManagerTest, DeleteViewManager) {
- View* view = window_manager()->CreateView();
- ASSERT_NE(nullptr, view);
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* connection = Embed(view).connection;
+// Verifies deleting a WindowServer sends the right notifications.
+TEST_F(WindowServerTest, DeleteWindowServer) {
+ Window* window = window_manager()->CreateWindow();
+ ASSERT_NE(nullptr, window);
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* connection = Embed(window).connection;
ASSERT_TRUE(connection);
bool got_destroy = false;
DestroyedChangedObserver observer(this, connection->GetRoot(), &got_destroy);
delete connection;
- EXPECT_TRUE(view_tree_connection_destroyed());
+ EXPECT_TRUE(window_tree_connection_destroyed());
EXPECT_TRUE(got_destroy);
}
-// Verifies two Embed()s in the same view trigger deletion of the first
-// ViewManager.
-TEST_F(ViewManagerTest, DisconnectTriggersDelete) {
- View* view = window_manager()->CreateView();
- ASSERT_NE(nullptr, view);
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewTreeConnection* connection = Embed(view).connection;
+// Verifies two Embed()s in the same window trigger deletion of the first
+// WindowServer.
+TEST_F(WindowServerTest, DisconnectTriggersDelete) {
+ Window* window = window_manager()->CreateWindow();
+ ASSERT_NE(nullptr, window);
+ window->SetVisible(true);
+ window_manager()->GetRoot()->AddChild(window);
+ WindowTreeConnection* connection = Embed(window).connection;
EXPECT_NE(connection, window_manager());
- View* embedded_view = connection->CreateView();
+ Window* embedded_window = connection->CreateWindow();
// Embed again, this should trigger disconnect and deletion of connection.
bool got_destroy;
- DestroyedChangedObserver observer(this, embedded_view, &got_destroy);
- EXPECT_FALSE(view_tree_connection_destroyed());
- Embed(view);
- EXPECT_TRUE(view_tree_connection_destroyed());
+ DestroyedChangedObserver observer(this, embedded_window, &got_destroy);
+ EXPECT_FALSE(window_tree_connection_destroyed());
+ Embed(window);
+ EXPECT_TRUE(window_tree_connection_destroyed());
}
-class ViewRemovedFromParentObserver : public ViewObserver {
+class WindowRemovedFromParentObserver : public WindowObserver {
public:
- explicit ViewRemovedFromParentObserver(View* view)
- : view_(view), was_removed_(false) {
- view_->AddObserver(this);
+ explicit WindowRemovedFromParentObserver(Window* window)
+ : window_(window), was_removed_(false) {
+ window_->AddObserver(this);
}
- ~ViewRemovedFromParentObserver() override { view_->RemoveObserver(this); }
+ ~WindowRemovedFromParentObserver() override { window_->RemoveObserver(this); }
bool was_removed() const { return was_removed_; }
private:
- // Overridden from ViewObserver:
+ // Overridden from WindowObserver:
void OnTreeChanged(const TreeChangeParams& params) override {
- if (params.target == view_ && !params.new_parent)
+ if (params.target == window_ && !params.new_parent)
was_removed_ = true;
}
- View* view_;
+ Window* window_;
bool was_removed_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewRemovedFromParentObserver);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(WindowRemovedFromParentObserver);
};
-TEST_F(ViewManagerTest, EmbedRemovesChildren) {
- View* view1 = window_manager()->CreateView();
- View* view2 = window_manager()->CreateView();
- window_manager()->GetRoot()->AddChild(view1);
- view1->AddChild(view2);
+TEST_F(WindowServerTest, EmbedRemovesChildren) {
+ Window* window1 = window_manager()->CreateWindow();
+ Window* window2 = window_manager()->CreateWindow();
+ window_manager()->GetRoot()->AddChild(window1);
+ window1->AddChild(window2);
- ViewRemovedFromParentObserver observer(view2);
- view1->Embed(ConnectToApplicationAndGetViewManagerClient());
+ WindowRemovedFromParentObserver observer(window2);
+ window1->Embed(ConnectToApplicationAndGetWindowServerClient());
EXPECT_TRUE(observer.was_removed());
- EXPECT_EQ(nullptr, view2->parent());
- EXPECT_TRUE(view1->children().empty());
+ EXPECT_EQ(nullptr, window2->parent());
+ EXPECT_TRUE(window1->children().empty());
// Run the message loop so the Embed() call above completes. Without this
// we may end up reconnecting to the test and rerunning the test, which is
@@ -723,10 +737,10 @@ TEST_F(ViewManagerTest, EmbedRemovesChildren) {
namespace {
-class DestroyObserver : public ViewObserver {
+class DestroyObserver : public WindowObserver {
public:
- DestroyObserver(ViewManagerTestBase* test,
- ViewTreeConnection* connection,
+ DestroyObserver(WindowServerTestBase* test,
+ WindowTreeConnection* connection,
bool* got_destroy)
: test_(test), got_destroy_(got_destroy) {
connection->GetRoot()->AddObserver(this);
@@ -734,18 +748,19 @@ class DestroyObserver : public ViewObserver {
~DestroyObserver() override {}
private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
+ // Overridden from WindowObserver:
+ void OnWindowDestroyed(Window* window) override {
*got_destroy_ = true;
- view->RemoveObserver(this);
+ window->RemoveObserver(this);
- // We should always get OnViewDestroyed() before OnViewManagerDestroyed().
- EXPECT_FALSE(test_->view_tree_connection_destroyed());
+ // We should always get OnWindowDestroyed() before
+ // OnWindowManagerDestroyed().
+ EXPECT_FALSE(test_->window_tree_connection_destroyed());
- EXPECT_TRUE(ViewManagerTestBase::QuitRunLoop());
+ EXPECT_TRUE(WindowServerTestBase::QuitRunLoop());
}
- ViewManagerTestBase* test_;
+ WindowServerTestBase* test_;
bool* got_destroy_;
MOJO_DISALLOW_COPY_AND_ASSIGN(DestroyObserver);
@@ -753,59 +768,59 @@ class DestroyObserver : public ViewObserver {
} // namespace
-// Verifies deleting a View that is the root of another connection notifies
-// observers in the right order (OnViewDestroyed() before
-// OnViewManagerDestroyed()).
-TEST_F(ViewManagerTest, ViewManagerDestroyedAfterRootObserver) {
- View* embed_view = window_manager()->CreateView();
- window_manager()->GetRoot()->AddChild(embed_view);
+// Verifies deleting a Window that is the root of another connection notifies
+// observers in the right order (OnWindowDestroyed() before
+// OnWindowManagerDestroyed()).
+TEST_F(WindowServerTest, WindowServerDestroyedAfterRootObserver) {
+ Window* embed_window = window_manager()->CreateWindow();
+ window_manager()->GetRoot()->AddChild(embed_window);
- ViewTreeConnection* embedded_connection = Embed(embed_view).connection;
+ WindowTreeConnection* embedded_connection = Embed(embed_window).connection;
bool got_destroy = false;
DestroyObserver observer(this, embedded_connection, &got_destroy);
- // Delete the view |embedded_connection| is embedded in. This is async,
+ // Delete the window |embedded_connection| is embedded in. This is async,
// but will eventually trigger deleting |embedded_connection|.
- embed_view->Destroy();
+ embed_window->Destroy();
EXPECT_TRUE(DoRunLoopWithTimeout());
EXPECT_TRUE(got_destroy);
}
-// Verifies an embed root sees views created beneath it from another
+// Verifies an embed root sees windows created beneath it from another
// connection.
-TEST_F(ViewManagerTest, EmbedRootSeesHierarchyChanged) {
- View* embed_view = window_manager()->CreateView();
- window_manager()->GetRoot()->AddChild(embed_view);
+TEST_F(WindowServerTest, EmbedRootSeesHierarchyChanged) {
+ Window* embed_window = window_manager()->CreateWindow();
+ window_manager()->GetRoot()->AddChild(embed_window);
- ViewTreeConnection* vm2 =
- Embed(embed_view, mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT).connection;
- View* vm2_v1 = vm2->CreateView();
+ WindowTreeConnection* vm2 =
+ Embed(embed_window, mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT).connection;
+ Window* vm2_v1 = vm2->CreateWindow();
vm2->GetRoot()->AddChild(vm2_v1);
- ViewTreeConnection* vm3 = Embed(vm2_v1).connection;
- View* vm3_v1 = vm3->CreateView();
+ WindowTreeConnection* vm3 = Embed(vm2_v1).connection;
+ Window* vm3_v1 = vm3->CreateWindow();
vm3->GetRoot()->AddChild(vm3_v1);
// As |vm2| is an embed root it should get notified about |vm3_v1|.
ASSERT_TRUE(WaitForTreeSizeToMatch(vm2_v1, 2));
}
-TEST_F(ViewManagerTest, EmbedFromEmbedRoot) {
- View* embed_view = window_manager()->CreateView();
- window_manager()->GetRoot()->AddChild(embed_view);
+TEST_F(WindowServerTest, EmbedFromEmbedRoot) {
+ Window* embed_window = window_manager()->CreateWindow();
+ window_manager()->GetRoot()->AddChild(embed_window);
- // Give the connection embedded at |embed_view| embed root powers.
+ // Give the connection embedded at |embed_window| embed root powers.
const EmbedResult result1 =
- Embed(embed_view, mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT);
- ViewTreeConnection* vm2 = result1.connection;
+ Embed(embed_window, mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT);
+ WindowTreeConnection* vm2 = result1.connection;
EXPECT_EQ(result1.connection_id, vm2->GetConnectionId());
- View* vm2_v1 = vm2->CreateView();
+ Window* vm2_v1 = vm2->CreateWindow();
vm2->GetRoot()->AddChild(vm2_v1);
const EmbedResult result2 = Embed(vm2_v1);
- ViewTreeConnection* vm3 = result2.connection;
+ WindowTreeConnection* vm3 = result2.connection;
EXPECT_EQ(result2.connection_id, vm3->GetConnectionId());
- View* vm3_v1 = vm3->CreateView();
+ Window* vm3_v1 = vm3->CreateWindow();
vm3->GetRoot()->AddChild(vm3_v1);
// Embed from v3, the callback should not get the connection id as vm3 is not
@@ -820,7 +835,7 @@ TEST_F(ViewManagerTest, EmbedFromEmbedRoot) {
// Embed() from vm2 in vm3_v1. This is allowed as vm2 is an embed root, and
// further the callback should see the connection id.
ASSERT_EQ(1u, vm2_v1->children().size());
- View* vm3_v1_in_vm2 = vm2_v1->children()[0];
+ Window* vm3_v1_in_vm2 = vm2_v1->children()[0];
const EmbedResult result4 = Embed(vm3_v1_in_vm2);
ASSERT_TRUE(result4.connection);
EXPECT_EQ(result4.connection_id, result4.connection->GetConnectionId());
diff --git a/components/mus/vm/view_tree_apptest.cc b/components/mus/vm/view_tree_apptest.cc
index 14c812a..3f34d10 100644
--- a/components/mus/vm/view_tree_apptest.cc
+++ b/components/mus/vm/view_tree_apptest.cc
@@ -316,55 +316,55 @@ class TestViewTreeClientImpl : public mojo::ViewTreeClient,
tracker()->OnEmbeddedAppDisconnected(view_id);
}
void OnUnembed() override { tracker()->OnUnembed(); }
- void OnViewBoundsChanged(Id view_id,
- RectPtr old_bounds,
- RectPtr new_bounds) override {
+ void OnWindowBoundsChanged(Id view_id,
+ RectPtr old_bounds,
+ RectPtr new_bounds) override {
// The bounds of the root may change during startup on Android at random
// times. As this doesn't matter, and shouldn't impact test exepctations,
// it is ignored.
if (view_id == root_view_id_)
return;
- tracker()->OnViewBoundsChanged(view_id, old_bounds.Pass(),
- new_bounds.Pass());
+ tracker()->OnWindowBoundsChanged(view_id, old_bounds.Pass(),
+ new_bounds.Pass());
}
- void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics,
- ViewportMetricsPtr new_metrics) override {
+ void OnWindowViewportMetricsChanged(ViewportMetricsPtr old_metrics,
+ ViewportMetricsPtr new_metrics) override {
// Don't track the metrics as they are available at an indeterministic time
// on Android.
}
- void OnViewHierarchyChanged(Id view,
- Id new_parent,
- Id old_parent,
- Array<ViewDataPtr> views) override {
- tracker()->OnViewHierarchyChanged(view, new_parent, old_parent,
- views.Pass());
+ void OnWindowHierarchyChanged(Id view,
+ Id new_parent,
+ Id old_parent,
+ Array<ViewDataPtr> views) override {
+ tracker()->OnWindowHierarchyChanged(view, new_parent, old_parent,
+ views.Pass());
}
- void OnViewReordered(Id view_id,
- Id relative_view_id,
- OrderDirection direction) override {
- tracker()->OnViewReordered(view_id, relative_view_id, direction);
+ void OnWindowReordered(Id view_id,
+ Id relative_view_id,
+ OrderDirection direction) override {
+ tracker()->OnWindowReordered(view_id, relative_view_id, direction);
}
- void OnViewDeleted(Id view) override { tracker()->OnViewDeleted(view); }
- void OnViewVisibilityChanged(uint32_t view, bool visible) override {
- tracker()->OnViewVisibilityChanged(view, visible);
+ void OnWindowDeleted(Id view) override { tracker()->OnWindowDeleted(view); }
+ void OnWindowVisibilityChanged(uint32_t view, bool visible) override {
+ tracker()->OnWindowVisibilityChanged(view, visible);
}
- void OnViewDrawnStateChanged(uint32_t view, bool drawn) override {
- tracker()->OnViewDrawnStateChanged(view, drawn);
+ void OnWindowDrawnStateChanged(uint32_t view, bool drawn) override {
+ tracker()->OnWindowDrawnStateChanged(view, drawn);
}
- void OnViewInputEvent(Id view_id,
- EventPtr event,
- const Callback<void()>& callback) override {
+ void OnWindowInputEvent(Id view_id,
+ EventPtr event,
+ const Callback<void()>& callback) override {
// Don't log input events as none of the tests care about them and they
// may come in at random points.
callback.Run();
}
- void OnViewSharedPropertyChanged(uint32_t view,
- const String& name,
- Array<uint8_t> new_data) override {
- tracker_.OnViewSharedPropertyChanged(view, name, new_data.Pass());
+ void OnWindowSharedPropertyChanged(uint32_t view,
+ const String& name,
+ Array<uint8_t> new_data) override {
+ tracker_.OnWindowSharedPropertyChanged(view, name, new_data.Pass());
}
// TODO(sky): add testing coverage.
- void OnViewFocused(uint32_t focused_view_id) override {}
+ void OnWindowFocused(uint32_t focused_view_id) override {}
TestChangeTracker tracker_;
@@ -534,8 +534,9 @@ class ViewTreeAppTest : public mojo::test::ApplicationTestBase,
vm_client1_.reset(new TestViewTreeClientImpl(application_impl()));
vm_client1_->Bind(GetProxy(&tree_client_ptr));
- factory->CreateViewTreeHost(GetProxy(&host_), mojo::ViewTreeHostClientPtr(),
- tree_client_ptr.Pass());
+ factory->CreateWindowTreeHost(GetProxy(&host_),
+ mojo::ViewTreeHostClientPtr(),
+ tree_client_ptr.Pass());
// Next we should get an embed call on the "window manager" client.
vm_client1_->WaitForIncomingMethodCall();
diff --git a/components/mus/vm/view_tree_host_impl.cc b/components/mus/vm/view_tree_host_impl.cc
index 6dc9c3e..5fdbdc5 100644
--- a/components/mus/vm/view_tree_host_impl.cc
+++ b/components/mus/vm/view_tree_host_impl.cc
@@ -111,9 +111,9 @@ void ViewTreeHostImpl::DispatchInputEventToView(ServerView* target,
connection_manager_->GetConnectionWithRoot(target->id());
if (!connection)
connection = connection_manager_->GetConnection(target->id().connection_id);
- connection->client()->OnViewInputEvent(ViewIdToTransportId(target->id()),
- event.Pass(),
- base::Bind(&base::DoNothing));
+ connection->client()->OnWindowInputEvent(ViewIdToTransportId(target->id()),
+ event.Pass(),
+ base::Bind(&base::DoNothing));
}
void ViewTreeHostImpl::SetSize(mojo::SizePtr size) {
diff --git a/components/mus/vm/view_tree_impl.cc b/components/mus/vm/view_tree_impl.cc
index 794f56b..40e2c07 100644
--- a/components/mus/vm/view_tree_impl.cc
+++ b/components/mus/vm/view_tree_impl.cc
@@ -181,16 +181,17 @@ void ViewTreeImpl::ProcessViewBoundsChanged(const ServerView* view,
bool originated_change) {
if (originated_change || !IsViewKnown(view))
return;
- client()->OnViewBoundsChanged(ViewIdToTransportId(view->id()),
- Rect::From(old_bounds), Rect::From(new_bounds));
+ client()->OnWindowBoundsChanged(ViewIdToTransportId(view->id()),
+ Rect::From(old_bounds),
+ Rect::From(new_bounds));
}
void ViewTreeImpl::ProcessViewportMetricsChanged(
const mojo::ViewportMetrics& old_metrics,
const mojo::ViewportMetrics& new_metrics,
bool originated_change) {
- client()->OnViewViewportMetricsChanged(old_metrics.Clone(),
- new_metrics.Clone());
+ client()->OnWindowViewportMetricsChanged(old_metrics.Clone(),
+ new_metrics.Clone());
}
void ViewTreeImpl::ProcessWillChangeViewHierarchy(const ServerView* view,
@@ -220,8 +221,8 @@ void ViewTreeImpl::ProcessViewPropertyChanged(
if (new_data)
data = Array<uint8_t>::From(*new_data);
- client()->OnViewSharedPropertyChanged(ViewIdToTransportId(view->id()),
- String(name), data.Pass());
+ client()->OnWindowSharedPropertyChanged(ViewIdToTransportId(view->id()),
+ String(name), data.Pass());
}
void ViewTreeImpl::ProcessViewHierarchyChanged(const ServerView* view,
@@ -249,7 +250,7 @@ void ViewTreeImpl::ProcessViewHierarchyChanged(const ServerView* view,
GetUnknownViewsFrom(view, &to_send);
const ViewId new_parent_id(new_parent ? new_parent->id() : ViewId());
const ViewId old_parent_id(old_parent ? old_parent->id() : ViewId());
- client()->OnViewHierarchyChanged(
+ client()->OnWindowHierarchyChanged(
ViewIdToTransportId(view->id()), ViewIdToTransportId(new_parent_id),
ViewIdToTransportId(old_parent_id), ViewsToViewDatas(to_send));
connection_manager_->OnConnectionMessagedClient(id_);
@@ -262,9 +263,9 @@ void ViewTreeImpl::ProcessViewReorder(const ServerView* view,
if (originated_change || !IsViewKnown(view) || !IsViewKnown(relative_view))
return;
- client()->OnViewReordered(ViewIdToTransportId(view->id()),
- ViewIdToTransportId(relative_view->id()),
- direction);
+ client()->OnWindowReordered(ViewIdToTransportId(view->id()),
+ ViewIdToTransportId(relative_view->id()),
+ direction);
}
void ViewTreeImpl::ProcessViewDeleted(const ViewId& view,
@@ -281,7 +282,7 @@ void ViewTreeImpl::ProcessViewDeleted(const ViewId& view,
return;
if (in_known) {
- client()->OnViewDeleted(ViewIdToTransportId(view));
+ client()->OnWindowDeleted(ViewIdToTransportId(view));
connection_manager_->OnConnectionMessagedClient(id_);
}
}
@@ -292,8 +293,8 @@ void ViewTreeImpl::ProcessWillChangeViewVisibility(const ServerView* view,
return;
if (IsViewKnown(view)) {
- client()->OnViewVisibilityChanged(ViewIdToTransportId(view->id()),
- !view->visible());
+ client()->OnWindowVisibilityChanged(ViewIdToTransportId(view->id()),
+ !view->visible());
return;
}
@@ -314,8 +315,8 @@ void ViewTreeImpl::ProcessFocusChanged(const ServerView* old_focused_view,
const ServerView* view =
new_focused_view ? access_policy_->GetViewForFocusChange(new_focused_view)
: nullptr;
- client()->OnViewFocused(view ? ViewIdToTransportId(view->id())
- : ViewIdToTransportId(ViewId()));
+ client()->OnWindowFocused(view ? ViewIdToTransportId(view->id())
+ : ViewIdToTransportId(ViewId()));
}
bool ViewTreeImpl::IsViewKnown(const ServerView* view) const {
@@ -391,7 +392,7 @@ void ViewTreeImpl::RemoveRoot() {
return;
client()->OnUnembed();
- client()->OnViewDeleted(ViewIdToTransportId(root_id));
+ client()->OnWindowDeleted(ViewIdToTransportId(root_id));
connection_manager_->OnConnectionMessagedClient(id_);
// This connection no longer knows about the view. Unparent any views that
@@ -458,8 +459,8 @@ void ViewTreeImpl::NotifyDrawnStateChanged(const ServerView* view,
const ServerView* root = GetView(*root_);
DCHECK(root);
if (view->Contains(root) && (new_drawn_value != root->IsDrawn())) {
- client()->OnViewDrawnStateChanged(ViewIdToTransportId(root->id()),
- new_drawn_value);
+ client()->OnWindowDrawnStateChanged(ViewIdToTransportId(root->id()),
+ new_drawn_value);
}
}
@@ -609,7 +610,7 @@ void ViewTreeImpl::RequestSurface(Id view_id,
mojo::InterfaceRequest<mojo::Surface> surface,
mojo::SurfaceClientPtr client) {
ServerView* view = GetView(ViewIdFromTransportId(view_id));
- const bool success = view && access_policy_->CanSetViewSurfaceId(view);
+ const bool success = view && access_policy_->CanSetWindowSurfaceId(view);
if (!success)
return;
view->Bind(surface.Pass(), client.Pass());
diff --git a/components/mus/vm/view_tree_unittest.cc b/components/mus/vm/view_tree_unittest.cc
index a775d03..352625c 100644
--- a/components/mus/vm/view_tree_unittest.cc
+++ b/components/mus/vm/view_tree_unittest.cc
@@ -61,47 +61,50 @@ class TestViewTreeClient : public mojo::ViewTreeClient {
tracker_.OnEmbeddedAppDisconnected(view);
}
void OnUnembed() override { tracker_.OnUnembed(); }
- void OnViewBoundsChanged(uint32_t view,
- mojo::RectPtr old_bounds,
- mojo::RectPtr new_bounds) override {
- tracker_.OnViewBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass());
+ void OnWindowBoundsChanged(uint32_t view,
+ mojo::RectPtr old_bounds,
+ mojo::RectPtr new_bounds) override {
+ tracker_.OnWindowBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass());
}
- void OnViewViewportMetricsChanged(
+ void OnWindowViewportMetricsChanged(
mojo::ViewportMetricsPtr old_metrics,
mojo::ViewportMetricsPtr new_metrics) override {
- tracker_.OnViewViewportMetricsChanged(old_metrics.Pass(),
- new_metrics.Pass());
+ tracker_.OnWindowViewportMetricsChanged(old_metrics.Pass(),
+ new_metrics.Pass());
}
- void OnViewHierarchyChanged(uint32_t view,
- uint32_t new_parent,
- uint32_t old_parent,
- Array<ViewDataPtr> views) override {
- tracker_.OnViewHierarchyChanged(view, new_parent, old_parent, views.Pass());
+ void OnWindowHierarchyChanged(uint32_t view,
+ uint32_t new_parent,
+ uint32_t old_parent,
+ Array<ViewDataPtr> views) override {
+ tracker_.OnWindowHierarchyChanged(view, new_parent, old_parent,
+ views.Pass());
}
- void OnViewReordered(uint32_t view_id,
- uint32_t relative_view_id,
- mojo::OrderDirection direction) override {
- tracker_.OnViewReordered(view_id, relative_view_id, direction);
+ void OnWindowReordered(uint32_t view_id,
+ uint32_t relative_view_id,
+ mojo::OrderDirection direction) override {
+ tracker_.OnWindowReordered(view_id, relative_view_id, direction);
}
- void OnViewDeleted(uint32_t view) override { tracker_.OnViewDeleted(view); }
- void OnViewVisibilityChanged(uint32_t view, bool visible) override {
- tracker_.OnViewVisibilityChanged(view, visible);
+ void OnWindowDeleted(uint32_t view) override {
+ tracker_.OnWindowDeleted(view);
}
- void OnViewDrawnStateChanged(uint32_t view, bool drawn) override {
- tracker_.OnViewDrawnStateChanged(view, drawn);
+ void OnWindowVisibilityChanged(uint32_t view, bool visible) override {
+ tracker_.OnWindowVisibilityChanged(view, visible);
}
- void OnViewSharedPropertyChanged(uint32_t view,
- const String& name,
- Array<uint8_t> new_data) override {
- tracker_.OnViewSharedPropertyChanged(view, name, new_data.Pass());
+ void OnWindowDrawnStateChanged(uint32_t view, bool drawn) override {
+ tracker_.OnWindowDrawnStateChanged(view, drawn);
}
- void OnViewInputEvent(uint32_t view,
- mojo::EventPtr event,
- const mojo::Callback<void()>& callback) override {
- tracker_.OnViewInputEvent(view, event.Pass());
+ void OnWindowSharedPropertyChanged(uint32_t view,
+ const String& name,
+ Array<uint8_t> new_data) override {
+ tracker_.OnWindowSharedPropertyChanged(view, name, new_data.Pass());
}
- void OnViewFocused(uint32_t focused_view_id) override {
- tracker_.OnViewFocused(focused_view_id);
+ void OnWindowInputEvent(uint32_t view,
+ mojo::EventPtr event,
+ const mojo::Callback<void()>& callback) override {
+ tracker_.OnWindowInputEvent(view, event.Pass());
+ }
+ void OnWindowFocused(uint32_t focused_view_id) override {
+ tracker_.OnWindowFocused(focused_view_id);
}
TestChangeTracker tracker_;
diff --git a/components/mus/vm/window_manager_access_policy.cc b/components/mus/vm/window_manager_access_policy.cc
index a7da497..6cfb620 100644
--- a/components/mus/vm/window_manager_access_policy.cc
+++ b/components/mus/vm/window_manager_access_policy.cc
@@ -61,7 +61,7 @@ bool WindowManagerAccessPolicy::CanChangeViewVisibility(
(view->GetRoot() == view);
}
-bool WindowManagerAccessPolicy::CanSetViewSurfaceId(
+bool WindowManagerAccessPolicy::CanSetWindowSurfaceId(
const ServerView* view) const {
if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
return false;
diff --git a/components/mus/vm/window_manager_access_policy.h b/components/mus/vm/window_manager_access_policy.h
index 78f9513..b08946b 100644
--- a/components/mus/vm/window_manager_access_policy.h
+++ b/components/mus/vm/window_manager_access_policy.h
@@ -30,7 +30,7 @@ class WindowManagerAccessPolicy : public AccessPolicy {
bool CanDescendIntoViewForViewTree(const ServerView* view) const override;
bool CanEmbed(const ServerView* view, uint32_t policy_bitmask) const override;
bool CanChangeViewVisibility(const ServerView* view) const override;
- bool CanSetViewSurfaceId(const ServerView* view) const override;
+ bool CanSetWindowSurfaceId(const ServerView* view) const override;
bool CanSetViewBounds(const ServerView* view) const override;
bool CanSetViewProperties(const ServerView* view) const override;
bool CanSetViewTextInputState(const ServerView* view) const override;
diff --git a/components/pdf_viewer/pdf_viewer.cc b/components/pdf_viewer/pdf_viewer.cc
index 01336a3..b1c11c7 100644
--- a/components/pdf_viewer/pdf_viewer.cc
+++ b/components/pdf_viewer/pdf_viewer.cc
@@ -7,11 +7,11 @@
#include "base/containers/hash_tables.h"
#include "base/memory/scoped_ptr.h"
#include "components/mus/public/cpp/types.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_surface.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_surface.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/compositor_frame.mojom.h"
#include "components/mus/public/interfaces/gpu.mojom.h"
#include "components/mus/public/interfaces/surface_id.mojom.h"
@@ -58,7 +58,7 @@ void OnGotContentHandlerID(uint32_t content_handler_id) {}
// BitmapUploader is useful if you want to draw a bitmap or color in a View.
class BitmapUploader : public mojo::SurfaceClient {
public:
- explicit BitmapUploader(mus::View* view)
+ explicit BitmapUploader(mus::Window* view)
: view_(view),
color_(g_transparent_color),
width_(0),
@@ -289,9 +289,9 @@ class BitmapUploader : public mojo::SurfaceClient {
}
}
- mus::View* view_;
+ mus::Window* view_;
mojo::GpuPtr gpu_service_;
- scoped_ptr<mus::ViewSurface> surface_;
+ scoped_ptr<mus::WindowSurface> surface_;
MojoGLES2Context gles2_context_;
mojo::Size size_;
@@ -311,7 +311,7 @@ class BitmapUploader : public mojo::SurfaceClient {
class EmbedderData {
public:
- EmbedderData(mojo::Shell* shell, mus::View* root) : bitmap_uploader_(root) {
+ EmbedderData(mojo::Shell* shell, mus::Window* root) : bitmap_uploader_(root) {
bitmap_uploader_.Init(shell);
bitmap_uploader_.SetColor(g_background_color);
}
@@ -325,8 +325,8 @@ class EmbedderData {
};
class PDFView : public mojo::ApplicationDelegate,
- public mus::ViewTreeDelegate,
- public mus::ViewObserver,
+ public mus::WindowTreeDelegate,
+ public mus::WindowObserver,
public mojo::InterfaceFactory<mojo::ViewTreeClient> {
public:
PDFView(mojo::InterfaceRequest<mojo::Application> request,
@@ -354,8 +354,8 @@ class PDFView : public mojo::ApplicationDelegate,
return true;
}
- // Overridden from ViewTreeDelegate:
- void OnEmbed(mus::View* root) override {
+ // Overridden from WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override {
DCHECK(embedder_for_roots_.find(root) == embedder_for_roots_.end());
root->AddObserver(this);
EmbedderData* embedder_data = new EmbedderData(app_.shell(), root);
@@ -363,17 +363,18 @@ class PDFView : public mojo::ApplicationDelegate,
DrawBitmap(embedder_data);
}
- void OnConnectionLost(mus::ViewTreeConnection* connection) override {}
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override {}
- // Overridden from ViewObserver:
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override {
+ // Overridden from WindowObserver:
+ void OnWindowBoundsChanged(mus::Window* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override {
DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end());
DrawBitmap(embedder_for_roots_[view]);
}
- void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override {
+ void OnWindowInputEvent(mus::Window* view,
+ const mojo::EventPtr& event) override {
DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end());
if (event->key_data &&
(event->action != mojo::EVENT_TYPE_KEY_PRESSED ||
@@ -400,7 +401,7 @@ class PDFView : public mojo::ApplicationDelegate,
}
}
- void OnViewDestroyed(mus::View* view) override {
+ void OnWindowDestroyed(mus::Window* view) override {
DCHECK(embedder_for_roots_.find(view) != embedder_for_roots_.end());
const auto& it = embedder_for_roots_.find(view);
DCHECK(it != embedder_for_roots_.end());
@@ -414,9 +415,9 @@ class PDFView : public mojo::ApplicationDelegate,
void Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ViewTreeClient> request) override {
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection::Create(
this, request.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
void DrawBitmap(EmbedderData* embedder_data) {
@@ -465,7 +466,7 @@ class PDFView : public mojo::ApplicationDelegate,
int current_page_;
int page_count_;
FPDF_DOCUMENT doc_;
- std::map<mus::View*, EmbedderData*> embedder_for_roots_;
+ std::map<mus::Window*, EmbedderData*> embedder_for_roots_;
DISALLOW_COPY_AND_ASSIGN(PDFView);
};
diff --git a/components/web_view/frame.cc b/components/web_view/frame.cc
index 96fd328..9cc9163 100644
--- a/components/web_view/frame.cc
+++ b/components/web_view/frame.cc
@@ -10,8 +10,8 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/stl_util.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_property.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_property.h"
#include "components/web_view/frame_tree.h"
#include "components/web_view/frame_tree_delegate.h"
#include "components/web_view/frame_user_data.h"
@@ -20,14 +20,14 @@
#include "mojo/common/url_type_converters.h"
#include "url/gurl.h"
-using mus::View;
+using mus::Window;
-DECLARE_VIEW_PROPERTY_TYPE(web_view::Frame*);
+DECLARE_WINDOW_PROPERTY_TYPE(web_view::Frame*);
namespace web_view {
// Used to find the Frame associated with a View.
-DEFINE_LOCAL_VIEW_PROPERTY_KEY(Frame*, kFrame, nullptr);
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(Frame*, kFrame, nullptr);
namespace {
@@ -52,7 +52,7 @@ struct Frame::FrameUserDataAndBinding {
};
Frame::Frame(FrameTree* tree,
- View* view,
+ Window* view,
uint32_t frame_id,
uint32_t app_id,
ViewOwnership view_ownership,
@@ -120,7 +120,7 @@ void Frame::Init(Frame* parent,
}
// static
-Frame* Frame::FindFirstFrameAncestor(View* view) {
+Frame* Frame::FindFirstFrameAncestor(Window* view) {
while (view && !view->GetLocalProperty(kFrame))
view = view->parent();
return view ? view->GetLocalProperty(kFrame) : nullptr;
@@ -301,7 +301,7 @@ void Frame::OnWillNavigateAck(mojom::FrameClient* frame_client,
StartNavigate(pending_navigate_.Pass());
}
-void Frame::SetView(mus::View* view) {
+void Frame::SetView(mus::Window* view) {
DCHECK(!view_);
DCHECK_EQ(id_, view->id());
view_ = view;
@@ -442,7 +442,7 @@ void Frame::OnTreeChanged(const TreeChangeParams& params) {
}
}
-void Frame::OnViewDestroying(mus::View* view) {
+void Frame::OnWindowDestroying(mus::Window* view) {
if (parent_)
parent_->Remove(this);
@@ -459,15 +459,16 @@ void Frame::OnViewDestroying(mus::View* view) {
delete this;
}
-void Frame::OnViewEmbeddedAppDisconnected(mus::View* view) {
- // See FrameTreeDelegate::OnViewEmbeddedAppDisconnected() for details of when
+void Frame::OnWindowEmbeddedAppDisconnected(mus::Window* view) {
+ // See FrameTreeDelegate::OnWindowEmbeddedAppDisconnected() for details of
+ // when
// this happens.
//
// Currently we have no way to distinguish between the cases that lead to this
// being called, so we assume we can continue on. Continuing on is important
// for html as it's entirely possible for a page to create a frame, navigate
// to a bogus url and expect the frame to still exist.
- tree_->delegate_->OnViewEmbeddedInFrameDisconnected(this);
+ tree_->delegate_->OnWindowEmbeddedInFrameDisconnected(this);
}
void Frame::PostMessageEventToFrame(uint32_t target_frame_id,
diff --git a/components/web_view/frame.h b/components/web_view/frame.h
index 361c66a..38e1078 100644
--- a/components/web_view/frame.h
+++ b/components/web_view/frame.h
@@ -12,7 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "components/mus/public/cpp/types.h"
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window_observer.h"
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
@@ -52,13 +52,13 @@ enum class ViewOwnership {
// the argument |reuse_existing_view| supplied to OnConnect(). Typically the id
// is that of content handler id, but this is left up to the FrameTreeDelegate
// to decide.
-class Frame : public mus::ViewObserver, public mojom::Frame {
+class Frame : public mus::WindowObserver, public mojom::Frame {
public:
using ClientPropertyMap = std::map<std::string, std::vector<uint8_t>>;
using FindCallback = mojo::Callback<void(bool)>;
Frame(FrameTree* tree,
- mus::View* view,
+ mus::Window* view,
uint32_t frame_id,
uint32_t app_id,
ViewOwnership view_ownership,
@@ -76,15 +76,15 @@ class Frame : public mus::ViewObserver, public mojom::Frame {
// Frame that is associated with |view|. For example, if |view|
// has a Frame associated with it, then that is returned. Otherwise
// this checks view->parent() and so on.
- static Frame* FindFirstFrameAncestor(mus::View* view);
+ static Frame* FindFirstFrameAncestor(mus::Window* view);
FrameTree* tree() { return tree_; }
Frame* parent() { return parent_; }
const Frame* parent() const { return parent_; }
- mus::View* view() { return view_; }
- const mus::View* view() const { return view_; }
+ mus::Window* view() { return view_; }
+ const mus::Window* view() const { return view_; }
uint32_t id() const { return id_; }
@@ -187,7 +187,7 @@ class Frame : public mus::ViewObserver, public mojom::Frame {
uint32 app_id,
base::TimeTicks navigation_start_time);
- void SetView(mus::View* view);
+ void SetView(mus::Window* view);
// Adds this to |frames| and recurses through the children calling the
// same function.
@@ -220,10 +220,10 @@ class Frame : public mus::ViewObserver, public mojom::Frame {
void NotifyFrameLoadingStateChanged(const Frame* frame, bool loading);
void NotifyDispatchFrameLoadEvent(const Frame* frame);
- // mus::ViewObserver:
+ // mus::WindowObserver:
void OnTreeChanged(const TreeChangeParams& params) override;
- void OnViewDestroying(mus::View* view) override;
- void OnViewEmbeddedAppDisconnected(mus::View* view) override;
+ void OnWindowDestroying(mus::Window* view) override;
+ void OnWindowEmbeddedAppDisconnected(mus::Window* view) override;
// mojom::Frame:
void PostMessageEventToFrame(uint32_t target_frame_id,
@@ -251,7 +251,7 @@ class Frame : public mus::ViewObserver, public mojom::Frame {
FrameTree* const tree_;
// WARNING: this may be null. See class description for details.
- mus::View* view_;
+ mus::Window* view_;
// The connection id returned from ViewManager::Embed(). Frames created by
// way of OnCreatedFrame() inherit the id from the parent.
mus::ConnectionSpecificId embedded_connection_id_;
diff --git a/components/web_view/frame_apptest.cc b/components/web_view/frame_apptest.cc
index 629b081..a8f0bb8 100644
--- a/components/web_view/frame_apptest.cc
+++ b/components/web_view/frame_apptest.cc
@@ -11,10 +11,10 @@
#include "base/run_loop.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "components/web_view/frame.h"
#include "components/web_view/frame_connection.h"
#include "components/web_view/frame_tree.h"
@@ -27,8 +27,8 @@
#include "mojo/application/public/cpp/application_test_base.h"
#include "mojo/application/public/cpp/service_provider_impl.h"
-using mus::View;
-using mus::ViewTreeConnection;
+using mus::Window;
+using mus::WindowTreeConnection;
namespace web_view {
@@ -132,7 +132,7 @@ class TestFrameClient : public mojom::FrameClient {
// mojom::FrameClient:
void OnConnect(mojom::FramePtr frame,
uint32_t change_id,
- uint32_t view_id,
+ uint32_t window_id,
mojom::ViewConnectType view_connect_type,
mojo::Array<mojom::FrameDataPtr> frames,
int64_t navigation_start_time_ticks,
@@ -216,7 +216,7 @@ class FrameTest;
// a single FrameClient. In other words this maintains the data structures
// needed to represent a client side frame. To obtain one use
// FrameTest::WaitForViewAndFrame().
-class ViewAndFrame : public mus::ViewTreeDelegate {
+class ViewAndFrame : public mus::WindowTreeDelegate {
public:
~ViewAndFrame() override {
if (view_)
@@ -224,7 +224,7 @@ class ViewAndFrame : public mus::ViewTreeDelegate {
}
// The View associated with the frame.
- mus::View* view() { return view_; }
+ mus::Window* view() { return view_; }
TestFrameClient* test_frame_client() { return &test_frame_tree_client_; }
mojom::Frame* server_frame() {
return test_frame_tree_client_.server_frame();
@@ -236,7 +236,7 @@ class ViewAndFrame : public mus::ViewTreeDelegate {
ViewAndFrame()
: view_(nullptr), frame_client_binding_(&test_frame_tree_client_) {}
- void set_view(View* view) { view_ = view; }
+ void set_view(Window* view) { view_ = view; }
// Runs a message loop until the view and frame data have been received.
void WaitForViewAndFrame() { run_loop_.Run(); }
@@ -265,16 +265,16 @@ class ViewAndFrame : public mus::ViewTreeDelegate {
run_loop_.Quit();
}
- // Overridden from ViewTreeDelegate:
- void OnEmbed(View* root) override {
+ // Overridden from WindowTreeDelegate:
+ void OnEmbed(Window* root) override {
view_ = root;
QuitRunLoopIfNecessary();
}
- void OnConnectionLost(ViewTreeConnection* connection) override {
+ void OnConnectionLost(WindowTreeConnection* connection) override {
view_ = nullptr;
}
- mus::View* view_;
+ mus::Window* view_;
base::RunLoop run_loop_;
TestFrameClient test_frame_tree_client_;
mojo::Binding<mojom::FrameClient> frame_client_binding_;
@@ -284,18 +284,18 @@ class ViewAndFrame : public mus::ViewTreeDelegate {
class FrameTest : public mojo::test::ApplicationTestBase,
public mojo::ApplicationDelegate,
- public mus::ViewTreeDelegate,
+ public mus::WindowTreeDelegate,
public mojo::InterfaceFactory<mojo::ViewTreeClient>,
public mojo::InterfaceFactory<mojom::FrameClient> {
public:
FrameTest() : most_recent_connection_(nullptr), window_manager_(nullptr) {}
- ViewTreeConnection* most_recent_connection() {
+ WindowTreeConnection* most_recent_connection() {
return most_recent_connection_;
}
protected:
- ViewTreeConnection* window_manager() { return window_manager_; }
+ WindowTreeConnection* window_manager() { return window_manager_; }
TestFrameTreeDelegate* frame_tree_delegate() {
return frame_tree_delegate_.get();
}
@@ -320,7 +320,8 @@ class FrameTest : public mojo::test::ApplicationTestBase,
// Creates a new shared frame as a child of |parent|.
scoped_ptr<ViewAndFrame> CreateChildViewAndFrame(ViewAndFrame* parent) {
- mus::View* child_frame_view = parent->view()->connection()->CreateView();
+ mus::Window* child_frame_view =
+ parent->view()->connection()->CreateWindow();
parent->view()->AddChild(child_frame_view);
scoped_ptr<ViewAndFrame> view_and_frame(new ViewAndFrame);
@@ -357,18 +358,18 @@ class FrameTest : public mojo::test::ApplicationTestBase,
return true;
}
- // Overridden from ViewTreeDelegate:
- void OnEmbed(View* root) override {
+ // Overridden from WindowTreeDelegate:
+ void OnEmbed(Window* root) override {
most_recent_connection_ = root->connection();
QuitRunLoop();
}
- void OnConnectionLost(ViewTreeConnection* connection) override {}
+ void OnConnectionLost(WindowTreeConnection* connection) override {}
// Overridden from testing::Test:
void SetUp() override {
ApplicationTestBase::SetUp();
- mus::CreateSingleViewTreeHost(application_impl(), this, &host_);
+ mus::CreateSingleWindowTreeHost(application_impl(), this, &host_);
ASSERT_TRUE(DoRunLoopWithTimeout());
std::swap(window_manager_, most_recent_connection_);
@@ -381,7 +382,7 @@ class FrameTest : public mojo::test::ApplicationTestBase,
mojom::FrameClient* frame_client = frame_connection->frame_client();
mojo::ViewTreeClientPtr view_tree_client =
frame_connection->GetViewTreeClient();
- mus::View* frame_root_view = window_manager()->CreateView();
+ mus::Window* frame_root_view = window_manager()->CreateWindow();
window_manager()->GetRoot()->AddChild(frame_root_view);
frame_tree_.reset(new FrameTree(
0u, frame_root_view, view_tree_client.Pass(),
@@ -403,13 +404,13 @@ class FrameTest : public mojo::test::ApplicationTestBase,
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::ViewTreeClient> request) override {
if (view_and_frame_) {
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection::Create(
view_and_frame_.get(), request.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
} else {
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection::Create(
this, request.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
}
@@ -427,10 +428,10 @@ class FrameTest : public mojo::test::ApplicationTestBase,
mojo::ViewTreeHostPtr host_;
// Used to receive the most recent view manager loaded by an embed action.
- ViewTreeConnection* most_recent_connection_;
+ WindowTreeConnection* most_recent_connection_;
// The View Manager connection held by the window manager (app running at the
// root view).
- ViewTreeConnection* window_manager_;
+ WindowTreeConnection* window_manager_;
scoped_ptr<ViewAndFrame> view_and_frame_;
@@ -478,7 +479,7 @@ TEST_F(FrameTest, OnViewEmbeddedInFrameDisconnected) {
scoped_ptr<ViewAndFrame> navigated_child_view_and_frame =
NavigateFrame(child_view_and_frame.get()).Pass();
- // Delete the ViewTreeConnection for the child, which should trigger
+ // Delete the WindowTreeConnection for the child, which should trigger
// notification.
delete navigated_child_view_and_frame->view()->connection();
ASSERT_EQ(1u, frame_tree()->root()->children().size());
diff --git a/components/web_view/frame_tree.cc b/components/web_view/frame_tree.cc
index f3b5a7c..7132739 100644
--- a/components/web_view/frame_tree.cc
+++ b/components/web_view/frame_tree.cc
@@ -10,7 +10,7 @@
namespace web_view {
FrameTree::FrameTree(uint32_t root_app_id,
- mus::View* view,
+ mus::Window* view,
mojo::ViewTreeClientPtr view_tree_client,
FrameTreeDelegate* delegate,
mojom::FrameClient* root_client,
@@ -49,7 +49,7 @@ Frame* FrameTree::CreateChildFrame(
mojom::FrameClient* raw_client = client.get();
scoped_ptr<FrameUserData> user_data =
delegate_->CreateUserDataForNewFrame(client.Pass());
- mus::View* frame_view = root_->view()->GetChildById(frame_id);
+ mus::Window* frame_view = root_->view()->GetChildById(frame_id);
// |frame_view| may be null if the View hasn't been created yet. If this is
// the case the View will be connected to the Frame in Frame::OnTreeChanged.
Frame* frame =
diff --git a/components/web_view/frame_tree.h b/components/web_view/frame_tree.h
index 10d5df9..f252ceb 100644
--- a/components/web_view/frame_tree.h
+++ b/components/web_view/frame_tree.h
@@ -37,7 +37,7 @@ class FrameTree {
// |root_app_id| is a unique identifier of the app providing |root_client|.
// See Frame for details on app id's.
FrameTree(uint32_t root_app_id,
- mus::View* view,
+ mus::Window* view,
mojo::ViewTreeClientPtr view_tree_client,
FrameTreeDelegate* delegate,
mojom::FrameClient* root_client,
@@ -74,7 +74,7 @@ class FrameTree {
const mojo::String& name,
const mojo::Array<uint8_t>& value);
- mus::View* view_;
+ mus::Window* view_;
FrameTreeDelegate* delegate_;
diff --git a/components/web_view/frame_tree_delegate.cc b/components/web_view/frame_tree_delegate.cc
index c04ec70..dbc3773 100644
--- a/components/web_view/frame_tree_delegate.cc
+++ b/components/web_view/frame_tree_delegate.cc
@@ -8,7 +8,7 @@ namespace web_view {
void FrameTreeDelegate::DidCreateFrame(Frame* frame) {}
void FrameTreeDelegate::DidDestroyFrame(Frame* frame) {}
-void FrameTreeDelegate::OnViewEmbeddedInFrameDisconnected(Frame* frame) {}
+void FrameTreeDelegate::OnWindowEmbeddedInFrameDisconnected(Frame* frame) {}
void FrameTreeDelegate::OnFindInFrameCountUpdated(int32_t request_id,
Frame* frame,
int32_t count,
diff --git a/components/web_view/frame_tree_delegate.h b/components/web_view/frame_tree_delegate.h
index 4b317a7..55be561 100644
--- a/components/web_view/frame_tree_delegate.h
+++ b/components/web_view/frame_tree_delegate.h
@@ -86,7 +86,7 @@ class FrameTreeDelegate {
// . The app is still alive, but is shutting down.
// Frame does nothing in response to this, but the delegate may wish to take
// action.
- virtual void OnViewEmbeddedInFrameDisconnected(Frame* frame);
+ virtual void OnWindowEmbeddedInFrameDisconnected(Frame* frame);
// Reports the current find state back to our owner.
virtual void OnFindInFrameCountUpdated(int32_t request_id,
diff --git a/components/web_view/public/cpp/web_view.cc b/components/web_view/public/cpp/web_view.cc
index d2ae310..51fd1d6 100644
--- a/components/web_view/public/cpp/web_view.cc
+++ b/components/web_view/public/cpp/web_view.cc
@@ -5,7 +5,7 @@
#include "components/web_view/public/cpp/web_view.h"
#include "base/bind.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/application/public/cpp/application_impl.h"
namespace web_view {
@@ -20,7 +20,7 @@ void OnEmbed(bool success, uint16 connection_id) {
WebView::WebView(mojom::WebViewClient* client) : binding_(client) {}
WebView::~WebView() {}
-void WebView::Init(mojo::ApplicationImpl* app, mus::View* view) {
+void WebView::Init(mojo::ApplicationImpl* app, mus::Window* window) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:web_view";
@@ -35,8 +35,8 @@ void WebView::Init(mojo::ApplicationImpl* app, mus::View* view) {
mojo::ViewTreeClientPtr view_tree_client;
web_view_->GetViewTreeClient(GetProxy(&view_tree_client));
- view->Embed(view_tree_client.Pass(), mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT,
- base::Bind(&OnEmbed));
+ window->Embed(view_tree_client.Pass(),
+ mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT, base::Bind(&OnEmbed));
}
} // namespace web_view
diff --git a/components/web_view/public/cpp/web_view.h b/components/web_view/public/cpp/web_view.h
index b10c0d3..0eae5ed 100644
--- a/components/web_view/public/cpp/web_view.h
+++ b/components/web_view/public/cpp/web_view.h
@@ -15,7 +15,7 @@ class ApplicationImpl;
}
namespace mus {
-class View;
+class Window;
}
namespace web_view {
@@ -25,7 +25,7 @@ class WebView {
explicit WebView(mojom::WebViewClient* client);
~WebView();
- void Init(mojo::ApplicationImpl* app, mus::View* view);
+ void Init(mojo::ApplicationImpl* app, mus::Window* window);
mojom::WebView* web_view() { return web_view_.get(); }
diff --git a/components/web_view/test_frame_tree_delegate.cc b/components/web_view/test_frame_tree_delegate.cc
index 2b7ee8cc..8c439b2 100644
--- a/components/web_view/test_frame_tree_delegate.cc
+++ b/components/web_view/test_frame_tree_delegate.cc
@@ -98,7 +98,7 @@ void TestFrameTreeDelegate::DidDestroyFrame(Frame* frame) {
}
}
-void TestFrameTreeDelegate::OnViewEmbeddedInFrameDisconnected(Frame* frame) {
+void TestFrameTreeDelegate::OnWindowEmbeddedInFrameDisconnected(Frame* frame) {
if (waiting_for_frame_disconnected_ == frame) {
waiting_for_frame_disconnected_ = nullptr;
run_loop_->Quit();
diff --git a/components/web_view/test_frame_tree_delegate.h b/components/web_view/test_frame_tree_delegate.h
index 1f021ee..21cb581 100644
--- a/components/web_view/test_frame_tree_delegate.h
+++ b/components/web_view/test_frame_tree_delegate.h
@@ -33,7 +33,7 @@ class TestFrameTreeDelegate : public FrameTreeDelegate {
// Waits for DidDestroyFrame() to be called with |frame|.
void WaitForDestroyFrame(Frame* frame);
- // Waits for OnViewEmbeddedInFrameDisconnected() to be called with |frame|.
+ // Waits for OnWindowEmbeddedInFrameDisconnected() to be called with |frame|.
void WaitForFrameDisconnected(Frame* frame);
// TestFrameTreeDelegate:
@@ -53,7 +53,7 @@ class TestFrameTreeDelegate : public FrameTreeDelegate {
void DidNavigateLocally(Frame* source, const GURL& url) override;
void DidCreateFrame(Frame* frame) override;
void DidDestroyFrame(Frame* frame) override;
- void OnViewEmbeddedInFrameDisconnected(Frame* frame) override;
+ void OnWindowEmbeddedInFrameDisconnected(Frame* frame) override;
private:
bool is_waiting() const { return run_loop_.get(); }
diff --git a/components/web_view/test_runner/test_runner_application_delegate.cc b/components/web_view/test_runner/test_runner_application_delegate.cc
index 24d2c51..76e5bc4 100644
--- a/components/web_view/test_runner/test_runner_application_delegate.cc
+++ b/components/web_view/test_runner/test_runner_application_delegate.cc
@@ -15,10 +15,10 @@
#include "base/path_service.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "components/test_runner/blink_test_platform_support.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
@@ -40,7 +40,7 @@ TestRunnerApplicationDelegate::TestRunnerApplicationDelegate()
TestRunnerApplicationDelegate::~TestRunnerApplicationDelegate() {
if (root_)
- mus::ScopedViewPtr::DeleteViewOrViewManager(root_);
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
}
void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) {
@@ -55,7 +55,7 @@ void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) {
void TestRunnerApplicationDelegate::Terminate() {
if (root_)
- mus::ScopedViewPtr::DeleteViewOrViewManager(root_);
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
}
////////////////////////////////////////////////////////////////////////////////
@@ -66,7 +66,7 @@ void TestRunnerApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
NOTREACHED() << "Test environment could not be properly set up for blink.";
}
app_ = app;
- mus::CreateSingleViewTreeHost(app_, this, &host_);
+ mus::CreateSingleWindowTreeHost(app_, this, &host_);
}
bool TestRunnerApplicationDelegate::ConfigureIncomingConnection(
@@ -78,7 +78,7 @@ bool TestRunnerApplicationDelegate::ConfigureIncomingConnection(
////////////////////////////////////////////////////////////////////////////////
// mus::ViewTreeDelegate implementation:
-void TestRunnerApplicationDelegate::OnEmbed(mus::View* root) {
+void TestRunnerApplicationDelegate::OnEmbed(mus::Window* root) {
root_ = root;
// If this is a sys-check, then terminate in the next cycle.
@@ -94,7 +94,7 @@ void TestRunnerApplicationDelegate::OnEmbed(mus::View* root) {
const gfx::Size kViewportSize(800, 600);
host_->SetSize(mojo::Size::From(kViewportSize));
- content_ = root_->connection()->CreateView();
+ content_ = root_->connection()->CreateWindow();
root_->AddChild(content_);
content_->SetBounds(*mojo::Rect::From(gfx::Rect(kViewportSize)));
content_->SetVisible(true);
@@ -111,7 +111,7 @@ void TestRunnerApplicationDelegate::OnEmbed(mus::View* root) {
}
void TestRunnerApplicationDelegate::OnConnectionLost(
- mus::ViewTreeConnection* connection) {
+ mus::WindowTreeConnection* connection) {
root_ = nullptr;
app_->Quit();
}
diff --git a/components/web_view/test_runner/test_runner_application_delegate.h b/components/web_view/test_runner/test_runner_application_delegate.h
index 03d5b5e..6299580 100644
--- a/components/web_view/test_runner/test_runner_application_delegate.h
+++ b/components/web_view/test_runner/test_runner_application_delegate.h
@@ -7,7 +7,7 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/view_tree_host.mojom.h"
#include "components/test_runner/test_info_extractor.h"
#include "components/web_view/public/cpp/web_view.h"
@@ -27,7 +27,7 @@ namespace web_view {
class TestRunnerApplicationDelegate
: public mojo::ApplicationDelegate,
- public mus::ViewTreeDelegate,
+ public mus::WindowTreeDelegate,
public mojom::WebViewClient,
public LayoutTestRunner,
public mojo::InterfaceFactory<LayoutTestRunner> {
@@ -44,9 +44,9 @@ class TestRunnerApplicationDelegate
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// mojom::WebViewClient:
void TopLevelNavigateRequest(mojo::URLRequestPtr request) override;
@@ -71,8 +71,8 @@ class TestRunnerApplicationDelegate
mojo::ApplicationImpl* app_;
mojo::ViewTreeHostPtr host_;
- mus::View* root_;
- mus::View* content_;
+ mus::Window* root_;
+ mus::Window* content_;
scoped_ptr<WebView> web_view_;
scoped_ptr<test_runner::TestInfoExtractor> test_extractor_;
diff --git a/components/web_view/web_view_apptest.cc b/components/web_view/web_view_apptest.cc
index 05faf55..63e42da 100644
--- a/components/web_view/web_view_apptest.cc
+++ b/components/web_view/web_view_apptest.cc
@@ -10,10 +10,10 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-#include "components/mus/public/cpp/tests/view_manager_test_base.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+#include "components/mus/public/cpp/tests/window_server_test_base.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "mojo/util/filename_util.h"
#include "url/gurl.h"
@@ -40,7 +40,7 @@ GURL GetTestFileURL(const std::string& file) {
}
}
-class WebViewTest : public mus::ViewManagerTestBase,
+class WebViewTest : public mus::WindowServerTestBase,
public mojom::WebViewClient {
public:
WebViewTest()
@@ -94,25 +94,26 @@ class WebViewTest : public mus::ViewManagerTestBase,
// Overridden from ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override {
- ViewManagerTestBase::Initialize(app);
+ WindowServerTestBase::Initialize(app);
app_ = app;
}
// Overridden from ViewTreeDelegate:
- void OnEmbed(mus::View* root) override {
- content_ = root->connection()->CreateView();
+ void OnEmbed(mus::Window* root) override {
+ content_ = root->connection()->CreateWindow();
content_->SetBounds(root->bounds());
root->AddChild(content_);
content_->SetVisible(true);
web_view_.Init(app_, content_);
- ViewManagerTestBase::OnEmbed(root);
+ WindowServerTestBase::OnEmbed(root);
}
void TearDown() override {
- mus::ScopedViewPtr::DeleteViewOrViewManager(window_manager()->GetRoot());
- ViewManagerTestBase::TearDown();
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(
+ window_manager()->GetRoot());
+ WindowServerTestBase::TearDown();
}
// Overridden from web_view::mojom::WebViewClient:
@@ -148,7 +149,7 @@ class WebViewTest : public mus::ViewManagerTestBase,
mojo::ApplicationImpl* app_;
- mus::View* content_;
+ mus::Window* content_;
web_view::WebView web_view_;
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc
index cb0078a..b590e0f 100644
--- a/components/web_view/web_view_impl.cc
+++ b/components/web_view/web_view_impl.cc
@@ -9,9 +9,9 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "components/devtools_service/public/cpp/switches.h"
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/web_view/client_initiated_frame_connection.h"
#include "components/web_view/frame.h"
#include "components/web_view/frame_connection.h"
@@ -59,7 +59,7 @@ WebViewImpl::~WebViewImpl() {
content_->RemoveObserver(this);
if (root_) {
root_->RemoveObserver(this);
- mus::ScopedViewPtr::DeleteViewOrViewManager(root_);
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
}
}
@@ -74,7 +74,7 @@ void WebViewImpl::OnLoad(const GURL& pending_url) {
client_->TopLevelNavigationStarted(pending_url.spec());
- content_ = root_->connection()->CreateView();
+ content_ = root_->connection()->CreateWindow();
content_->SetBounds(*mojo::Rect::From(
gfx::Rect(0, 0, root_->bounds().width, root_->bounds().height)));
root_->AddChild(content_);
@@ -119,9 +119,9 @@ void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) {
void WebViewImpl::GetViewTreeClient(
mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) {
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection::Create(
this, view_tree_client.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
void WebViewImpl::Find(const mojo::String& search_text,
@@ -146,9 +146,9 @@ void WebViewImpl::GoForward() {
}
////////////////////////////////////////////////////////////////////////////////
-// WebViewImpl, mus::ViewTreeDelegate implementation:
+// WebViewImpl, mus::WindowTreeDelegate implementation:
-void WebViewImpl::OnEmbed(mus::View* root) {
+void WebViewImpl::OnEmbed(mus::Window* root) {
// We must have been granted embed root priviledges, otherwise we can't
// Embed() in any descendants.
DCHECK(root->connection()->IsEmbedRoot());
@@ -159,16 +159,16 @@ void WebViewImpl::OnEmbed(mus::View* root) {
OnLoad(pending_load_->pending_url());
}
-void WebViewImpl::OnConnectionLost(mus::ViewTreeConnection* connection) {
+void WebViewImpl::OnConnectionLost(mus::WindowTreeConnection* connection) {
root_ = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// WebViewImpl, mus::ViewObserver implementation:
-void WebViewImpl::OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
+void WebViewImpl::OnWindowBoundsChanged(mus::Window* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
if (view != content_) {
mojo::Rect rect;
rect.width = new_bounds.width;
@@ -178,7 +178,7 @@ void WebViewImpl::OnViewBoundsChanged(mus::View* view,
}
}
-void WebViewImpl::OnViewDestroyed(mus::View* view) {
+void WebViewImpl::OnWindowDestroyed(mus::Window* view) {
// |FrameTree| cannot outlive the content view.
if (view == content_) {
frame_tree_.reset();
diff --git a/components/web_view/web_view_impl.h b/components/web_view/web_view_impl.h
index 534c5aa..1e2125e 100644
--- a/components/web_view/web_view_impl.h
+++ b/components/web_view/web_view_impl.h
@@ -10,8 +10,8 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/web_view/find_controller.h"
#include "components/web_view/find_controller_delegate.h"
#include "components/web_view/frame_devtools_agent_delegate.h"
@@ -39,8 +39,8 @@ class HTMLMessageEvent;
}
class WebViewImpl : public mojom::WebView,
- public mus::ViewTreeDelegate,
- public mus::ViewObserver,
+ public mus::WindowTreeDelegate,
+ public mus::WindowObserver,
public FrameTreeDelegate,
public FrameDevToolsAgentDelegate,
public NavigationControllerDelegate,
@@ -70,15 +70,15 @@ class WebViewImpl : public mojom::WebView,
void GoBack() override;
void GoForward() override;
- // Overridden from mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // Overridden from mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
- // Overridden from mus::ViewObserver:
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override;
- void OnViewDestroyed(mus::View* view) override;
+ // Overridden from mus::WindowObserver:
+ void OnWindowBoundsChanged(mus::Window* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override;
+ void OnWindowDestroyed(mus::Window* view) override;
// Overridden from FrameTreeDelegate:
scoped_ptr<FrameUserData> CreateUserDataForNewFrame(
@@ -118,8 +118,8 @@ class WebViewImpl : public mojom::WebView,
mojo::ApplicationImpl* app_;
mojom::WebViewClientPtr client_;
mojo::StrongBinding<WebView> binding_;
- mus::View* root_;
- mus::View* content_;
+ mus::Window* root_;
+ mus::Window* content_;
scoped_ptr<FrameTree> frame_tree_;
// When LoadRequest() is called a PendingWebViewLoad is created to wait for
diff --git a/mandoline/ui/desktop_ui/browser_manager.cc b/mandoline/ui/desktop_ui/browser_manager.cc
index 54d2558..bef4dd5 100644
--- a/mandoline/ui/desktop_ui/browser_manager.cc
+++ b/mandoline/ui/desktop_ui/browser_manager.cc
@@ -5,8 +5,8 @@
#include "mandoline/ui/desktop_ui/browser_manager.h"
#include "base/command_line.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_observer.h"
#include "mandoline/ui/desktop_ui/browser_window.h"
namespace mandoline {
diff --git a/mandoline/ui/desktop_ui/browser_window.cc b/mandoline/ui/desktop_ui/browser_window.cc
index 769e5da..363320e 100644
--- a/mandoline/ui/desktop_ui/browser_window.cc
+++ b/mandoline/ui/desktop_ui/browser_window.cc
@@ -8,8 +8,8 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
-#include "components/mus/public/cpp/scoped_view_ptr.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/scoped_window_ptr.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "mandoline/ui/desktop_ui/browser_commands.h"
#include "mandoline/ui/desktop_ui/browser_manager.h"
#include "mandoline/ui/desktop_ui/find_bar_view.h"
@@ -84,7 +84,7 @@ BrowserWindow::BrowserWindow(mojo::ApplicationImpl* app,
web_view_(this) {
mojo::ViewTreeHostClientPtr host_client;
host_client_binding_.Bind(GetProxy(&host_client));
- mus::CreateViewTreeHost(host_factory, host_client.Pass(), this, &host_);
+ mus::CreateWindowTreeHost(host_factory, host_client.Pass(), this, &host_);
}
void BrowserWindow::LoadURL(const GURL& url) {
@@ -107,7 +107,7 @@ void BrowserWindow::LoadURL(const GURL& url) {
void BrowserWindow::Close() {
if (root_)
- mus::ScopedViewPtr::DeleteViewOrViewManager(root_);
+ mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
else
delete this;
}
@@ -154,7 +154,7 @@ float BrowserWindow::DIPSToPixels(float value) const {
////////////////////////////////////////////////////////////////////////////////
// BrowserWindow, mus::ViewTreeDelegate implementation:
-void BrowserWindow::OnEmbed(mus::View* root) {
+void BrowserWindow::OnEmbed(mus::Window* root) {
// BrowserWindow does not support being embedded more than once.
CHECK(!root_);
@@ -165,7 +165,7 @@ void BrowserWindow::OnEmbed(mus::View* root) {
host_->SetTitle("Mandoline");
- content_ = root_->connection()->CreateView();
+ content_ = root_->connection()->CreateWindow();
Init(root_);
host_->SetSize(mojo::Size::From(gfx::Size(1280, 800)));
@@ -211,7 +211,7 @@ void BrowserWindow::OnEmbed(mus::View* root) {
}
}
-void BrowserWindow::OnConnectionLost(mus::ViewTreeConnection* connection) {
+void BrowserWindow::OnConnectionLost(mus::WindowTreeConnection* connection) {
root_ = nullptr;
delete this;
}
@@ -369,13 +369,13 @@ void BrowserWindow::OnHideFindBar() {
////////////////////////////////////////////////////////////////////////////////
// BrowserWindow, private:
-void BrowserWindow::Init(mus::View* root) {
+void BrowserWindow::Init(mus::Window* root) {
DCHECK_GT(root->viewport_metrics().device_pixel_ratio, 0);
if (!aura_init_)
aura_init_.reset(new views::AuraInit(app_, "mandoline_ui.pak", root));
root_ = root;
- omnibox_view_ = root_->connection()->CreateView();
+ omnibox_view_ = root_->connection()->CreateWindow();
root_->AddChild(omnibox_view_);
views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
diff --git a/mandoline/ui/desktop_ui/browser_window.h b/mandoline/ui/desktop_ui/browser_window.h
index 0d487a4..2824c42 100644
--- a/mandoline/ui/desktop_ui/browser_window.h
+++ b/mandoline/ui/desktop_ui/browser_window.h
@@ -5,8 +5,8 @@
#ifndef MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_
#define MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/view_tree_host.mojom.h"
#include "components/web_view/public/cpp/web_view.h"
#include "components/web_view/public/interfaces/web_view.mojom.h"
@@ -32,7 +32,7 @@ class FindBarView;
class ProgressView;
class ToolbarView;
-class BrowserWindow : public mus::ViewTreeDelegate,
+class BrowserWindow : public mus::WindowTreeDelegate,
public mojo::ViewTreeHostClient,
public web_view::mojom::WebViewClient,
public ViewEmbedder,
@@ -57,9 +57,9 @@ class BrowserWindow : public mus::ViewTreeDelegate,
float DIPSToPixels(float value) const;
- // Overridden from mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // Overridden from mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// Overridden from ViewTreeHostClient:
void OnAccelerator(uint32_t id, mojo::EventPtr event) override;
@@ -93,7 +93,7 @@ class BrowserWindow : public mus::ViewTreeDelegate,
void OnDoFind(const std::string& find, bool forward) override;
void OnHideFindBar() override;
- void Init(mus::View* root);
+ void Init(mus::Window* root);
void EmbedOmnibox();
mojo::ApplicationImpl* app_;
@@ -104,9 +104,9 @@ class BrowserWindow : public mus::ViewTreeDelegate,
ToolbarView* toolbar_view_;
ProgressView* progress_bar_;
FindBarView* find_bar_view_;
- mus::View* root_;
- mus::View* content_;
- mus::View* omnibox_view_;
+ mus::Window* root_;
+ mus::Window* content_;
+ mus::Window* omnibox_view_;
mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_;
diff --git a/mandoline/ui/omnibox/omnibox_application.cc b/mandoline/ui/omnibox/omnibox_application.cc
index ddbb5af80..3c5491d 100644
--- a/mandoline/ui/omnibox/omnibox_application.cc
+++ b/mandoline/ui/omnibox/omnibox_application.cc
@@ -6,9 +6,9 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/url_formatter/url_fixer.h"
#include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h"
#include "mojo/application/public/cpp/application_impl.h"
@@ -27,7 +27,7 @@ namespace mandoline {
////////////////////////////////////////////////////////////////////////////////
// OmniboxImpl
-class OmniboxImpl : public mus::ViewTreeDelegate,
+class OmniboxImpl : public mus::WindowTreeDelegate,
public views::LayoutManager,
public views::TextfieldController,
public Omnibox {
@@ -38,9 +38,9 @@ class OmniboxImpl : public mus::ViewTreeDelegate,
~OmniboxImpl() override;
private:
- // Overridden from mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // Overridden from mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// Overridden from views::LayoutManager:
gfx::Size GetPreferredSize(const views::View* view) const override;
@@ -60,7 +60,7 @@ class OmniboxImpl : public mus::ViewTreeDelegate,
scoped_ptr<views::AuraInit> aura_init_;
mojo::ApplicationImpl* app_;
- mus::View* root_;
+ mus::Window* root_;
mojo::String url_;
views::Textfield* edit_;
mojo::Binding<Omnibox> binding_;
@@ -111,9 +111,9 @@ OmniboxImpl::OmniboxImpl(mojo::ApplicationImpl* app,
OmniboxImpl::~OmniboxImpl() {}
////////////////////////////////////////////////////////////////////////////////
-// OmniboxImpl, mus::ViewTreeDelegate implementation:
+// OmniboxImpl, mus::WindowTreeDelegate implementation:
-void OmniboxImpl::OnEmbed(mus::View* root) {
+void OmniboxImpl::OnEmbed(mus::Window* root) {
root_ = root;
if (!aura_init_.get()) {
@@ -149,7 +149,7 @@ void OmniboxImpl::OnEmbed(mus::View* root) {
ShowWindow();
}
-void OmniboxImpl::OnConnectionLost(mus::ViewTreeConnection* connection) {
+void OmniboxImpl::OnConnectionLost(mus::WindowTreeConnection* connection) {
root_ = nullptr;
}
@@ -191,9 +191,9 @@ bool OmniboxImpl::HandleKeyEvent(views::Textfield* sender,
void OmniboxImpl::GetViewTreeClient(
mojo::InterfaceRequest<mojo::ViewTreeClient> request) {
- mus::ViewTreeConnection::Create(
+ mus::WindowTreeConnection::Create(
this, request.Pass(),
- mus::ViewTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
}
void OmniboxImpl::ShowForURL(const mojo::String& url) {
diff --git a/mandoline/ui/phone_ui/phone_browser_application_delegate.cc b/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
index d2ac75b..ef3758d 100644
--- a/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
+++ b/mandoline/ui/phone_ui/phone_browser_application_delegate.cc
@@ -5,9 +5,9 @@
#include "mandoline/ui/phone_ui/phone_browser_application_delegate.h"
#include "base/command_line.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
-#include "components/mus/public/cpp/view_tree_host_factory.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_host_factory.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
@@ -47,7 +47,7 @@ void PhoneBrowserApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
break;
}
}
- mus::CreateSingleViewTreeHost(app_, this, &host_);
+ mus::CreateSingleWindowTreeHost(app_, this, &host_);
}
bool PhoneBrowserApplicationDelegate::ConfigureIncomingConnection(
@@ -66,12 +66,12 @@ void PhoneBrowserApplicationDelegate::LaunchURL(const mojo::String& url) {
}
////////////////////////////////////////////////////////////////////////////////
-// PhoneBrowserApplicationDelegate, mus::ViewTreeDelegate implementation:
+// PhoneBrowserApplicationDelegate, mus::WindowTreeDelegate implementation:
-void PhoneBrowserApplicationDelegate::OnEmbed(mus::View* root) {
+void PhoneBrowserApplicationDelegate::OnEmbed(mus::Window* root) {
CHECK(!root_);
root_ = root;
- content_ = root->connection()->CreateView();
+ content_ = root->connection()->CreateWindow();
root->AddChild(content_);
content_->SetBounds(root->bounds());
content_->SetVisible(true);
@@ -83,13 +83,13 @@ void PhoneBrowserApplicationDelegate::OnEmbed(mus::View* root) {
}
void PhoneBrowserApplicationDelegate::OnConnectionLost(
- mus::ViewTreeConnection* connection) {}
+ mus::WindowTreeConnection* connection) {}
////////////////////////////////////////////////////////////////////////////////
-// PhoneBrowserApplicationDelegate, mus::ViewObserver implementation:
+// PhoneBrowserApplicationDelegate, mus::WindowObserver implementation:
-void PhoneBrowserApplicationDelegate::OnViewBoundsChanged(
- mus::View* view,
+void PhoneBrowserApplicationDelegate::OnWindowBoundsChanged(
+ mus::Window* view,
const mojo::Rect& old_bounds,
const mojo::Rect& new_bounds) {
CHECK_EQ(view, root_);
diff --git a/mandoline/ui/phone_ui/phone_browser_application_delegate.h b/mandoline/ui/phone_ui/phone_browser_application_delegate.h
index f310259..e21c225 100644
--- a/mandoline/ui/phone_ui/phone_browser_application_delegate.h
+++ b/mandoline/ui/phone_ui/phone_browser_application_delegate.h
@@ -7,8 +7,8 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-#include "components/mus/public/cpp/view_observer.h"
-#include "components/mus/public/cpp/view_tree_delegate.h"
+#include "components/mus/public/cpp/window_observer.h"
+#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/view_tree_host.mojom.h"
#include "components/web_view/public/cpp/web_view.h"
#include "components/web_view/public/interfaces/web_view.mojom.h"
@@ -27,8 +27,8 @@ namespace mandoline {
class PhoneBrowserApplicationDelegate
: public mojo::ApplicationDelegate,
public LaunchHandler,
- public mus::ViewTreeDelegate,
- public mus::ViewObserver,
+ public mus::WindowTreeDelegate,
+ public mus::WindowObserver,
public web_view::mojom::WebViewClient,
public mojo::InterfaceFactory<LaunchHandler> {
public:
@@ -44,14 +44,14 @@ class PhoneBrowserApplicationDelegate
// Overridden from LaunchHandler:
void LaunchURL(const mojo::String& url) override;
- // Overridden from mus::ViewTreeDelegate:
- void OnEmbed(mus::View* root) override;
- void OnConnectionLost(mus::ViewTreeConnection* connection) override;
+ // Overridden from mus::WindowTreeDelegate:
+ void OnEmbed(mus::Window* root) override;
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override;
- // Overridden from mus::ViewObserver:
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override;
+ // Overridden from mus::WindowObserver:
+ void OnWindowBoundsChanged(mus::Window* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override;
// Overridden from web_view::mojom::WebViewClient:
void TopLevelNavigateRequest(mojo::URLRequestPtr request) override;
@@ -73,8 +73,8 @@ class PhoneBrowserApplicationDelegate
mojo::ApplicationImpl* app_;
mojo::ViewTreeHostPtr host_;
- mus::View* root_;
- mus::View* content_;
+ mus::Window* root_;
+ mus::Window* content_;
web_view::WebView web_view_;
mojo::String default_url_;
diff --git a/ui/views/mus/aura_init.cc b/ui/views/mus/aura_init.cc
index 98e1602..ddbab0d 100644
--- a/ui/views/mus/aura_init.cc
+++ b/ui/views/mus/aura_init.cc
@@ -7,7 +7,7 @@
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "components/resource_provider/public/cpp/resource_loader.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
@@ -31,13 +31,13 @@ std::set<std::string> GetResourcePaths(const std::string& resource_file) {
return paths;
}
-std::vector<gfx::Display> GetDisplaysFromView(mus::View* view) {
+std::vector<gfx::Display> GetDisplaysFromWindow(mus::Window* window) {
static int64 synthesized_display_id = 2000;
gfx::Display display;
display.set_id(synthesized_display_id++);
display.SetScaleAndBounds(
- view->viewport_metrics().device_pixel_ratio,
- gfx::Rect(view->viewport_metrics().size_in_pixels.To<gfx::Size>()));
+ window->viewport_metrics().device_pixel_ratio,
+ gfx::Rect(window->viewport_metrics().size_in_pixels.To<gfx::Size>()));
std::vector<gfx::Display> displays;
displays.push_back(display);
return displays;
@@ -47,8 +47,8 @@ std::vector<gfx::Display> GetDisplaysFromView(mus::View* view) {
AuraInit::AuraInit(mojo::ApplicationImpl* app,
const std::string& resource_file,
- mus::View* view)
- : AuraInit(app, resource_file, GetDisplaysFromView(view)) {}
+ mus::Window* window)
+ : AuraInit(app, resource_file, GetDisplaysFromWindow(window)) {}
AuraInit::AuraInit(mojo::ApplicationImpl* app,
const std::string& resource_file,
diff --git a/ui/views/mus/aura_init.h b/ui/views/mus/aura_init.h
index 5b37a55..daa1b3c 100644
--- a/ui/views/mus/aura_init.h
+++ b/ui/views/mus/aura_init.h
@@ -24,7 +24,7 @@ class ApplicationImpl;
}
namespace mus {
-class View;
+class Window;
}
namespace views {
@@ -34,10 +34,10 @@ namespace views {
class AuraInit {
public:
// This constructor builds the set of Displays from the ViewportMetrics of
- // |view|.
+ // |window|.
AuraInit(mojo::ApplicationImpl* app,
const std::string& resource_file,
- mus::View* view);
+ mus::Window* window);
AuraInit(mojo::ApplicationImpl* app,
const std::string& resource_file,
const std::vector<gfx::Display>& displays);
diff --git a/ui/views/mus/input_method_mus.cc b/ui/views/mus/input_method_mus.cc
index a7222dd..cea183c 100644
--- a/ui/views/mus/input_method_mus.cc
+++ b/ui/views/mus/input_method_mus.cc
@@ -4,7 +4,7 @@
#include "ui/views/mus/input_method_mus.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/converters/ime/ime_type_converters.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/events/event.h"
@@ -16,8 +16,8 @@ namespace views {
// InputMethodMUS, public:
InputMethodMUS::InputMethodMUS(ui::internal::InputMethodDelegate* delegate,
- mus::View* view)
- : view_(view) {
+ mus::Window* window)
+ : window_(window) {
SetDelegate(delegate);
}
@@ -96,9 +96,9 @@ void InputMethodMUS::UpdateTextInputType() {
mojo::TextInputStatePtr state = mojo::TextInputState::New();
state->type = mojo::ConvertTo<mojo::TextInputType>(type);
if (type != ui::TEXT_INPUT_TYPE_NONE)
- view_->SetImeVisibility(true, state.Pass());
+ window_->SetImeVisibility(true, state.Pass());
else
- view_->SetTextInputState(state.Pass());
+ window_->SetTextInputState(state.Pass());
}
} // namespace mandoline
diff --git a/ui/views/mus/input_method_mus.h b/ui/views/mus/input_method_mus.h
index da17efa..a9be768 100644
--- a/ui/views/mus/input_method_mus.h
+++ b/ui/views/mus/input_method_mus.h
@@ -8,14 +8,15 @@
#define UI_VIEWS_MUS_INPUT_METHOD_MUS_H_
namespace mus {
-class View;
+class Window;
} // namespace mojo
namespace views {
class InputMethodMUS : public ui::InputMethodBase {
public:
- InputMethodMUS(ui::internal::InputMethodDelegate* delegate, mus::View* view);
+ InputMethodMUS(ui::internal::InputMethodDelegate* delegate,
+ mus::Window* window);
~InputMethodMUS() override;
private:
@@ -38,8 +39,8 @@ class InputMethodMUS : public ui::InputMethodBase {
void UpdateTextInputType();
- // The toplevel view which is not owned by this class.
- mus::View* view_;
+ // The toplevel window which is not owned by this class.
+ mus::Window* window_;
DISALLOW_COPY_AND_ASSIGN(InputMethodMUS);
};
diff --git a/ui/views/mus/native_widget_view_manager.cc b/ui/views/mus/native_widget_view_manager.cc
index 43bdb2d..a08080d 100644
--- a/ui/views/mus/native_widget_view_manager.cc
+++ b/ui/views/mus/native_widget_view_manager.cc
@@ -4,7 +4,7 @@
#include "ui/views/mus/native_widget_view_manager.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/input_events/input_events_type_converters.h"
#include "ui/aura/client/default_capture_client.h"
@@ -34,44 +34,45 @@ class FocusRulesImpl : public wm::BaseFocusRules {
DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl);
};
-class NativeWidgetViewObserver : public mus::ViewObserver {
+class NativeWidgetWindowObserver : public mus::WindowObserver {
public:
- NativeWidgetViewObserver(NativeWidgetViewManager* view_manager)
+ NativeWidgetWindowObserver(NativeWidgetViewManager* view_manager)
: view_manager_(view_manager) {
- view_manager_->view_->AddObserver(this);
+ view_manager_->window_->AddObserver(this);
}
- ~NativeWidgetViewObserver() override {
- if (view_manager_->view_)
- view_manager_->view_->RemoveObserver(this);
+ ~NativeWidgetWindowObserver() override {
+ if (view_manager_->window_)
+ view_manager_->window_->RemoveObserver(this);
}
private:
- // ViewObserver:
- void OnViewDestroyed(mus::View* view) override {
- DCHECK_EQ(view, view_manager_->view_);
+ // WindowObserver:
+ void OnWindowDestroyed(mus::Window* view) override {
+ DCHECK_EQ(view, view_manager_->window_);
view->RemoveObserver(this);
- view_manager_->view_ = nullptr;
+ view_manager_->window_ = nullptr;
// TODO(sky): WindowTreeHostMojo assumes the View outlives it.
- // NativeWidgetViewObserver needs to deal, likely by deleting this.
+ // NativeWidgetWindowObserver needs to deal, likely by deleting this.
}
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override {
+ void OnWindowBoundsChanged(mus::Window* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override {
gfx::Rect view_rect = view->bounds().To<gfx::Rect>();
view_manager_->SetBounds(gfx::Rect(view_rect.size()));
}
- void OnViewFocusChanged(mus::View* gained_focus,
- mus::View* lost_focus) override {
- if (gained_focus == view_manager_->view_)
+ void OnWindowFocusChanged(mus::Window* gained_focus,
+ mus::Window* lost_focus) override {
+ if (gained_focus == view_manager_->window_)
view_manager_->window_tree_host_->GetInputMethod()->OnFocus();
- else if (lost_focus == view_manager_->view_)
+ else if (lost_focus == view_manager_->window_)
view_manager_->window_tree_host_->GetInputMethod()->OnBlur();
}
- void OnViewInputEvent(mus::View* view, const mojo::EventPtr& event) override {
+ void OnWindowInputEvent(mus::Window* view,
+ const mojo::EventPtr& event) override {
scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
if (!ui_event)
return;
@@ -86,7 +87,7 @@ class NativeWidgetViewObserver : public mus::ViewObserver {
NativeWidgetViewManager* const view_manager_;
- DISALLOW_COPY_AND_ASSIGN(NativeWidgetViewObserver);
+ DISALLOW_COPY_AND_ASSIGN(NativeWidgetWindowObserver);
};
} // namespace
@@ -94,9 +95,9 @@ class NativeWidgetViewObserver : public mus::ViewObserver {
NativeWidgetViewManager::NativeWidgetViewManager(
views::internal::NativeWidgetDelegate* delegate,
mojo::Shell* shell,
- mus::View* view)
- : NativeWidgetAura(delegate), view_(view) {
- window_tree_host_.reset(new WindowTreeHostMojo(shell, view_));
+ mus::Window* window)
+ : NativeWidgetAura(delegate), window_(window) {
+ window_tree_host_.reset(new WindowTreeHostMojo(shell, window_));
window_tree_host_->InitHost();
focus_client_.reset(new wm::FocusController(new FocusRulesImpl));
@@ -110,7 +111,7 @@ NativeWidgetViewManager::NativeWidgetViewManager(
capture_client_.reset(
new aura::client::DefaultCaptureClient(window_tree_host_->window()));
- view_observer_.reset(new NativeWidgetViewObserver(this));
+ window_observer_.reset(new NativeWidgetWindowObserver(this));
}
NativeWidgetViewManager::~NativeWidgetViewManager() {}
@@ -124,7 +125,7 @@ void NativeWidgetViewManager::InitNativeWidget(
void NativeWidgetViewManager::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
- view_->SetVisible(visible);
+ window_->SetVisible(visible);
// NOTE: We could also update aura::Window's visibility when the View's
// visibility changes, but this code isn't going to be around for very long so
// I'm not bothering.
diff --git a/ui/views/mus/native_widget_view_manager.h b/ui/views/mus/native_widget_view_manager.h
index 0c9df02..9c3247e 100644
--- a/ui/views/mus/native_widget_view_manager.h
+++ b/ui/views/mus/native_widget_view_manager.h
@@ -18,7 +18,7 @@ class Shell;
}
namespace mus {
-class View;
+class Window;
}
namespace ui {
@@ -34,7 +34,7 @@ class FocusController;
namespace views {
namespace {
-class NativeWidgetViewObserver;
+class NativeWidgetWindowObserver;
}
class WindowTreeHostMojo;
@@ -43,22 +43,22 @@ class NativeWidgetViewManager : public views::NativeWidgetAura {
public:
NativeWidgetViewManager(views::internal::NativeWidgetDelegate* delegate,
mojo::Shell* shell,
- mus::View* view);
+ mus::Window* window);
~NativeWidgetViewManager() override;
private:
- friend class NativeWidgetViewObserver;
+ friend class NativeWidgetWindowObserver;
// Overridden from internal::NativeWidgetAura:
void InitNativeWidget(const views::Widget::InitParams& in_params) override;
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
scoped_ptr<WindowTreeHostMojo> window_tree_host_;
- scoped_ptr<NativeWidgetViewObserver> view_observer_;
+ scoped_ptr<NativeWidgetWindowObserver> window_observer_;
scoped_ptr<wm::FocusController> focus_client_;
- mus::View* view_;
+ mus::Window* window_;
scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
diff --git a/ui/views/mus/surface_binding.cc b/ui/views/mus/surface_binding.cc
index c622698..168ff50 100644
--- a/ui/views/mus/surface_binding.cc
+++ b/ui/views/mus/surface_binding.cc
@@ -16,8 +16,8 @@
#include "cc/resources/shared_bitmap_manager.h"
#include "components/mus/public/cpp/context_provider.h"
#include "components/mus/public/cpp/output_surface.h"
-#include "components/mus/public/cpp/view.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/interfaces/gpu.mojom.h"
#include "mojo/application/public/cpp/connect.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
@@ -42,26 +42,26 @@ class SurfaceBinding::PerConnectionState
: public base::RefCounted<PerConnectionState> {
public:
static PerConnectionState* Get(mojo::Shell* shell,
- mus::ViewTreeConnection* connection);
+ mus::WindowTreeConnection* connection);
- scoped_ptr<cc::OutputSurface> CreateOutputSurface(mus::View* view);
+ scoped_ptr<cc::OutputSurface> CreateOutputSurface(mus::Window* window);
private:
- typedef std::map<mus::ViewTreeConnection*, PerConnectionState*>
+ typedef std::map<mus::WindowTreeConnection*, PerConnectionState*>
ConnectionToStateMap;
friend class base::RefCounted<PerConnectionState>;
- PerConnectionState(mojo::Shell* shell, mus::ViewTreeConnection* connection);
+ PerConnectionState(mojo::Shell* shell, mus::WindowTreeConnection* connection);
~PerConnectionState();
void Init();
static base::LazyInstance<
- base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky view_states;
+ base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky window_states;
mojo::Shell* shell_;
- mus::ViewTreeConnection* connection_;
+ mus::WindowTreeConnection* connection_;
// Set of state needed to create an OutputSurface.
mojo::GpuPtr gpu_;
@@ -72,26 +72,26 @@ class SurfaceBinding::PerConnectionState
// static
base::LazyInstance<base::ThreadLocalPointer<
SurfaceBinding::PerConnectionState::ConnectionToStateMap>>::Leaky
- SurfaceBinding::PerConnectionState::view_states;
+ SurfaceBinding::PerConnectionState::window_states;
// static
SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get(
mojo::Shell* shell,
- mus::ViewTreeConnection* connection) {
- ConnectionToStateMap* view_map = view_states.Pointer()->Get();
- if (!view_map) {
- view_map = new ConnectionToStateMap;
- view_states.Pointer()->Set(view_map);
+ mus::WindowTreeConnection* connection) {
+ ConnectionToStateMap* window_map = window_states.Pointer()->Get();
+ if (!window_map) {
+ window_map = new ConnectionToStateMap;
+ window_states.Pointer()->Set(window_map);
}
- if (!(*view_map)[connection]) {
- (*view_map)[connection] = new PerConnectionState(shell, connection);
- (*view_map)[connection]->Init();
+ if (!(*window_map)[connection]) {
+ (*window_map)[connection] = new PerConnectionState(shell, connection);
+ (*window_map)[connection]->Init();
}
- return (*view_map)[connection];
+ return (*window_map)[connection];
}
scoped_ptr<cc::OutputSurface>
-SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::View* view) {
+SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::Window* window) {
// TODO(sky): figure out lifetime here. Do I need to worry about the return
// value outliving this?
mojo::CommandBufferPtr cb;
@@ -100,22 +100,22 @@ SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::View* view) {
scoped_refptr<cc::ContextProvider> context_provider(
new mus::ContextProvider(cb.PassInterface().PassHandle()));
return make_scoped_ptr(
- new mus::OutputSurface(context_provider, view->RequestSurface()));
+ new mus::OutputSurface(context_provider, window->RequestSurface()));
}
SurfaceBinding::PerConnectionState::PerConnectionState(
mojo::Shell* shell,
- mus::ViewTreeConnection* connection)
+ mus::WindowTreeConnection* connection)
: shell_(shell), connection_(connection) {}
SurfaceBinding::PerConnectionState::~PerConnectionState() {
- ConnectionToStateMap* view_map = view_states.Pointer()->Get();
- DCHECK(view_map);
- DCHECK_EQ(this, (*view_map)[connection_]);
- view_map->erase(connection_);
- if (view_map->empty()) {
- delete view_map;
- view_states.Pointer()->Set(nullptr);
+ ConnectionToStateMap* window_map = window_states.Pointer()->Get();
+ DCHECK(window_map);
+ DCHECK_EQ(this, (*window_map)[connection_]);
+ window_map->erase(connection_);
+ if (window_map->empty()) {
+ delete window_map;
+ window_states.Pointer()->Set(nullptr);
}
}
@@ -131,13 +131,14 @@ void SurfaceBinding::PerConnectionState::Init() {
// SurfaceBinding --------------------------------------------------------------
-SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mus::View* view)
- : view_(view), state_(PerConnectionState::Get(shell, view->connection())) {}
+SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mus::Window* window)
+ : window_(window),
+ state_(PerConnectionState::Get(shell, window->connection())) {}
SurfaceBinding::~SurfaceBinding() {}
scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
- return state_->CreateOutputSurface(view_);
+ return state_->CreateOutputSurface(window_);
}
} // namespace views
diff --git a/ui/views/mus/surface_binding.h b/ui/views/mus/surface_binding.h
index 9d3984d..3fd0c60 100644
--- a/ui/views/mus/surface_binding.h
+++ b/ui/views/mus/surface_binding.h
@@ -17,22 +17,22 @@ class Shell;
}
namespace mus {
-class View;
+class Window;
}
namespace views {
// SurfaceBinding is responsible for managing the connections necessary to
-// bind a View to the surfaces service.
+// bind a Window to the surfaces service.
// Internally SurfaceBinding manages one connection (and related structures) per
// ViewTreeConnection. That is, all Views from a particular ViewTreeConnection
// share the same connection.
class SurfaceBinding {
public:
- SurfaceBinding(mojo::Shell* shell, mus::View* view);
+ SurfaceBinding(mojo::Shell* shell, mus::Window* window);
~SurfaceBinding();
- // Creates an OutputSurface that renders to the View supplied to the
+ // Creates an OutputSurface that renders to the Window supplied to the
// constructor.
scoped_ptr<cc::OutputSurface> CreateOutputSurface();
@@ -40,7 +40,7 @@ class SurfaceBinding {
class PerConnectionState;
mojo::Shell* shell_;
- mus::View* view_;
+ mus::Window* window_;
scoped_refptr<PerConnectionState> state_;
DISALLOW_COPY_AND_ASSIGN(SurfaceBinding);
diff --git a/ui/views/mus/surface_context_factory.cc b/ui/views/mus/surface_context_factory.cc
index e6c8b52..4ed3da6 100644
--- a/ui/views/mus/surface_context_factory.cc
+++ b/ui/views/mus/surface_context_factory.cc
@@ -7,7 +7,7 @@
#include "cc/output/output_surface.h"
#include "cc/resources/shared_bitmap_manager.h"
#include "cc/surfaces/surface_id_allocator.h"
-#include "components/mus/public/cpp/view.h"
+#include "components/mus/public/cpp/window.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "ui/compositor/reflector.h"
#include "ui/gl/gl_bindings.h"
@@ -26,8 +26,8 @@ class FakeReflector : public ui::Reflector {
}
SurfaceContextFactory::SurfaceContextFactory(mojo::Shell* shell,
- mus::View* view)
- : surface_binding_(shell, view), next_surface_id_namespace_(1u) {}
+ mus::Window* window)
+ : surface_binding_(shell, window), next_surface_id_namespace_(1u) {}
SurfaceContextFactory::~SurfaceContextFactory() {}
diff --git a/ui/views/mus/surface_context_factory.h b/ui/views/mus/surface_context_factory.h
index 5c34bb5..e20e83a 100644
--- a/ui/views/mus/surface_context_factory.h
+++ b/ui/views/mus/surface_context_factory.h
@@ -15,14 +15,14 @@ class Shell;
}
namespace mus {
-class View;
+class Window;
}
namespace views {
class SurfaceContextFactory : public ui::ContextFactory {
public:
- SurfaceContextFactory(mojo::Shell* shell, mus::View* view);
+ SurfaceContextFactory(mojo::Shell* shell, mus::Window* window);
~SurfaceContextFactory() override;
private:
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc
index 2d59489..4e69d0a 100644
--- a/ui/views/mus/window_tree_host_mus.cc
+++ b/ui/views/mus/window_tree_host_mus.cc
@@ -4,7 +4,7 @@
#include "ui/views/mus/window_tree_host_mus.h"
-#include "components/mus/public/cpp/view_tree_connection.h"
+#include "components/mus/public/cpp/window_tree_connection.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "ui/aura/env.h"
@@ -20,11 +20,11 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMojo, public:
-WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mus::View* view)
- : view_(view), bounds_(view->bounds().To<gfx::Rect>()) {
- view_->AddObserver(this);
+WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mus::Window* window)
+ : window_(window), bounds_(window->bounds().To<gfx::Rect>()) {
+ window_->AddObserver(this);
- context_factory_.reset(new SurfaceContextFactory(shell, view_));
+ context_factory_.reset(new SurfaceContextFactory(shell, window_));
// WindowTreeHost creates the compositor using the ContextFactory from
// aura::Env. Install |context_factory_| there so that |context_factory_| is
// picked up.
@@ -36,12 +36,12 @@ WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mus::View* view)
aura::Env::GetInstance()->set_context_factory(default_context_factory);
DCHECK_EQ(context_factory_.get(), compositor()->context_factory());
- input_method_.reset(new InputMethodMUS(this, view_));
+ input_method_.reset(new InputMethodMUS(this, window_));
SetSharedInputMethod(input_method_.get());
}
WindowTreeHostMojo::~WindowTreeHostMojo() {
- view_->RemoveObserver(this);
+ window_->RemoveObserver(this);
DestroyCompositor();
DestroyDispatcher();
}
@@ -98,9 +98,9 @@ void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) {
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMojo, ViewObserver implementation:
-void WindowTreeHostMojo::OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
+void WindowTreeHostMojo::OnWindowBoundsChanged(mus::Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>();
gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>();
bounds_ = new_bounds2;
diff --git a/ui/views/mus/window_tree_host_mus.h b/ui/views/mus/window_tree_host_mus.h
index a535195..4de4a01 100644
--- a/ui/views/mus/window_tree_host_mus.h
+++ b/ui/views/mus/window_tree_host_mus.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_MUS_WINDOW_TREE_HOST_MUS_H_
#include "base/macros.h"
-#include "components/mus/public/cpp/view_observer.h"
+#include "components/mus/public/cpp/window_observer.h"
#include "ui/aura/window_tree_host.h"
#include "ui/events/event_source.h"
#include "ui/gfx/geometry/rect.h"
@@ -27,9 +27,9 @@ class InputMethodMUS;
class SurfaceContextFactory;
class WindowTreeHostMojo : public aura::WindowTreeHost,
- public mus::ViewObserver {
+ public mus::WindowObserver {
public:
- WindowTreeHostMojo(mojo::Shell* shell, mus::View* view);
+ WindowTreeHostMojo(mojo::Shell* shell, mus::Window* window);
~WindowTreeHostMojo() override;
const gfx::Rect& bounds() const { return bounds_; }
@@ -53,12 +53,12 @@ class WindowTreeHostMojo : public aura::WindowTreeHost,
void MoveCursorToNative(const gfx::Point& location) override;
void OnCursorVisibilityChangedNative(bool show) override;
- // mus::ViewObserver:
- void OnViewBoundsChanged(mus::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) override;
+ // mus::WindowObserver:
+ void OnWindowBoundsChanged(mus::Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) override;
- mus::View* view_;
+ mus::Window* window_;
gfx::Rect bounds_;