diff options
Diffstat (limited to 'components/mus/public/cpp')
33 files changed, 257 insertions, 277 deletions
diff --git a/components/mus/public/cpp/args.h b/components/mus/public/cpp/args.h index 863bbb5..a737fd7 100644 --- a/components/mus/public/cpp/args.h +++ b/components/mus/public/cpp/args.h @@ -5,13 +5,13 @@ #ifndef COMPONENTS_MUS_PUBLIC_CPP_ARGS_H_ #define COMPONENTS_MUS_PUBLIC_CPP_ARGS_H_ -namespace mus { +namespace mojo { // All args in alphabetical order. The switches should be documented // alongside the definition of their values in the .cc file. extern const char kUseHeadlessConfig[]; extern const char kUseX11TestConfig[]; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_ARGS_H_ diff --git a/components/mus/public/cpp/keys.cc b/components/mus/public/cpp/keys.cc index 623bb82..7c664ba 100644 --- a/components/mus/public/cpp/keys.cc +++ b/components/mus/public/cpp/keys.cc @@ -4,9 +4,9 @@ #include "components/mus/public/cpp/keys.h" -namespace mus { +namespace mojo { extern const char kViewManagerKeyWantsTouchEvents[] = "view-manager-key-wants-touch-events"; -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/keys.h b/components/mus/public/cpp/keys.h index cf3713a..2285c31 100644 --- a/components/mus/public/cpp/keys.h +++ b/components/mus/public/cpp/keys.h @@ -5,10 +5,10 @@ #ifndef COMPONENTS_MUS_PUBLIC_CPP_KEYS_H_ #define COMPONENTS_MUS_PUBLIC_CPP_KEYS_H_ -namespace mus { +namespace mojo { extern const char kViewManagerKeyWantsTouchEvents[]; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_KEYS_H_ diff --git a/components/mus/public/cpp/lib/args.cc b/components/mus/public/cpp/lib/args.cc index e17ada3..d23478b 100644 --- a/components/mus/public/cpp/lib/args.cc +++ b/components/mus/public/cpp/lib/args.cc @@ -4,7 +4,7 @@ #include "components/mus/public/cpp/args.h" -namespace mus { +namespace mojo { // Create native viewport in headless mode. const char kUseHeadlessConfig[] = "use-headless-config"; @@ -13,4 +13,4 @@ const char kUseHeadlessConfig[] = "use-headless-config"; // creating X11 windows. const char kUseX11TestConfig[] = "use-x11-test-config"; -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/scoped_view_ptr.cc b/components/mus/public/cpp/lib/scoped_view_ptr.cc index 4c41709..79401fa 100644 --- a/components/mus/public/cpp/lib/scoped_view_ptr.cc +++ b/components/mus/public/cpp/lib/scoped_view_ptr.cc @@ -8,7 +8,7 @@ #include "components/mus/public/cpp/view_observer.h" #include "components/mus/public/cpp/view_tree_connection.h" -namespace mus { +namespace mojo { ScopedViewPtr::ScopedViewPtr(View* view) : view_(view) { view_->AddObserver(this); @@ -41,4 +41,4 @@ void ScopedViewPtr::OnViewDestroying(View* view) { DetachFromView(); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view.cc b/components/mus/public/cpp/lib/view.cc index 88228eb..fe780365 100644 --- a/components/mus/public/cpp/lib/view.cc +++ b/components/mus/public/cpp/lib/view.cc @@ -15,7 +15,7 @@ #include "components/mus/public/cpp/view_tracker.h" #include "mojo/application/public/cpp/service_provider_impl.h" -namespace mus { +namespace mojo { namespace { @@ -88,7 +88,7 @@ class ScopedOrderChangedNotifier { public: ScopedOrderChangedNotifier(View* view, View* relative_view, - mojo::OrderDirection direction) + OrderDirection direction) : view_(view), relative_view_(relative_view), direction_(direction) { FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view_).observers(), OnViewReordering(view_, relative_view_, direction_)); @@ -101,7 +101,7 @@ class ScopedOrderChangedNotifier { private: View* view_; View* relative_view_; - mojo::OrderDirection direction_; + OrderDirection direction_; MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier); }; @@ -110,7 +110,7 @@ class ScopedOrderChangedNotifier { bool ReorderImpl(View::Children* children, View* view, View* relative, - mojo::OrderDirection direction) { + OrderDirection direction) { DCHECK(relative); DCHECK_NE(view, relative); DCHECK_EQ(view->parent(), relative->parent()); @@ -120,14 +120,14 @@ bool ReorderImpl(View::Children* children, const size_t target_i = std::find(children->begin(), children->end(), relative) - children->begin(); - if ((direction == mojo::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || - (direction == mojo::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { + if ((direction == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || + (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { return false; } ScopedOrderChangedNotifier notifier(view, relative, direction); - const size_t dest_i = direction == mojo::ORDER_DIRECTION_ABOVE + const size_t dest_i = direction == 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); @@ -139,8 +139,8 @@ bool ReorderImpl(View::Children* children, class ScopedSetBoundsNotifier { public: ScopedSetBoundsNotifier(View* view, - const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) + const Rect& old_bounds, + const 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_)); @@ -152,8 +152,8 @@ class ScopedSetBoundsNotifier { private: View* view_; - const mojo::Rect old_bounds_; - const mojo::Rect new_bounds_; + const Rect old_bounds_; + const Rect new_bounds_; MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); }; @@ -191,7 +191,7 @@ void View::Destroy() { LocalDestroy(); } -void View::SetBounds(const mojo::Rect& bounds) { +void View::SetBounds(const Rect& bounds) { if (!OwnsView(connection_, this)) return; @@ -212,15 +212,14 @@ void View::SetVisible(bool value) { LocalSetVisible(value); } -scoped_ptr<ViewSurface> View::RequestSurface() { +scoped_ptr<mojo::ViewSurface> View::RequestSurface() { mojo::SurfacePtr surface; mojo::SurfaceClientPtr client; - mojo::InterfaceRequest<mojo::SurfaceClient> client_request = - GetProxy(&client); + mojo::InterfaceRequest<SurfaceClient> client_request = GetProxy(&client); static_cast<ViewTreeClientImpl*>(connection_) ->RequestSurface(id_, GetProxy(&surface), client.Pass()); return make_scoped_ptr( - new ViewSurface(surface.PassInterface(), client_request.Pass())); + new mojo::ViewSurface(surface.PassInterface(), client_request.Pass())); } void View::SetSharedProperty(const std::string& name, @@ -248,7 +247,7 @@ void View::SetSharedProperty(const std::string& name, // TODO: add test coverage of this (450303). if (connection_) { - mojo::Array<uint8_t> transport_value; + Array<uint8_t> transport_value; if (value) { transport_value.resize(value->size()); if (value->size()) @@ -309,16 +308,16 @@ void View::RemoveChild(View* child) { void View::MoveToFront() { if (!parent_ || parent_->children_.back() == this) return; - Reorder(parent_->children_.back(), mojo::ORDER_DIRECTION_ABOVE); + Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE); } void View::MoveToBack() { if (!parent_ || parent_->children_.front() == this) return; - Reorder(parent_->children_.front(), mojo::ORDER_DIRECTION_BELOW); + Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW); } -void View::Reorder(View* relative, mojo::OrderDirection direction) { +void View::Reorder(View* relative, OrderDirection direction) { if (!LocalReorder(relative, direction)) return; if (connection_) { @@ -354,16 +353,16 @@ View* View::GetChildById(Id id) { return NULL; } -void View::SetTextInputState(mojo::TextInputStatePtr state) { +void View::SetTextInputState(TextInputStatePtr state) { if (connection_) { static_cast<ViewTreeClientImpl*>(connection_) ->SetViewTextInputState(id_, state.Pass()); } } -void View::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { +void View::SetImeVisibility(bool visible, TextInputStatePtr state) { // SetImeVisibility() shouldn't be used if the view is not editable. - DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); + DCHECK(state.is_null() || state->type != TEXT_INPUT_TYPE_NONE); if (connection_) { static_cast<ViewTreeClientImpl*>(connection_) ->SetImeVisibility(id_, visible, state.Pass()); @@ -379,12 +378,12 @@ bool View::HasFocus() const { return connection_ && connection_->GetFocusedView() == this; } -void View::Embed(mojo::ViewTreeClientPtr client) { - Embed(client.Pass(), mojo::ViewTree::ACCESS_POLICY_DEFAULT, +void View::Embed(ViewTreeClientPtr client) { + Embed(client.Pass(), ViewTree::ACCESS_POLICY_DEFAULT, base::Bind(&EmptyEmbedCallback)); } -void View::Embed(mojo::ViewTreeClientPtr client, +void View::Embed(ViewTreeClientPtr client, uint32_t policy_bitmask, const EmbedCallback& callback) { if (PrepareForEmbed()) { @@ -400,9 +399,9 @@ void View::Embed(mojo::ViewTreeClientPtr client, namespace { -mojo::ViewportMetricsPtr CreateEmptyViewportMetrics() { - mojo::ViewportMetricsPtr metrics = mojo::ViewportMetrics::New(); - metrics->size_in_pixels = mojo::Size::New(); +ViewportMetricsPtr CreateEmptyViewportMetrics() { + ViewportMetricsPtr metrics = ViewportMetrics::New(); + metrics->size_in_pixels = Size::New(); // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it // once that's fixed. return metrics.Pass(); @@ -506,12 +505,11 @@ void View::LocalRemoveChild(View* child) { RemoveChildImpl(child, &children_); } -bool View::LocalReorder(View* relative, mojo::OrderDirection direction) { +bool View::LocalReorder(View* relative, OrderDirection direction) { return ReorderImpl(&parent_->children_, this, relative, direction); } -void View::LocalSetBounds(const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) { +void View::LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds) { DCHECK(old_bounds.x == bounds_.x); DCHECK(old_bounds.y == bounds_.y); DCHECK(old_bounds.width == bounds_.width); @@ -520,8 +518,8 @@ 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 View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics, + const ViewportMetrics& new_metrics) { // TODO(eseidel): We could check old_metrics against viewport_metrics_. viewport_metrics_ = new_metrics.Clone(); FOR_EACH_OBSERVER( @@ -612,4 +610,4 @@ bool View::PrepareForEmbed() { return true; } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_observer.cc b/components/mus/public/cpp/lib/view_observer.cc index 40367ea..a216da9 100644 --- a/components/mus/public/cpp/lib/view_observer.cc +++ b/components/mus/public/cpp/lib/view_observer.cc @@ -4,7 +4,7 @@ #include "components/mus/public/cpp/view_observer.h" -namespace mus { +namespace mojo { //////////////////////////////////////////////////////////////////////////////// // ViewObserver, public: @@ -15,4 +15,4 @@ ViewObserver::TreeChangeParams::TreeChangeParams() new_parent(nullptr), receiver(nullptr) {} -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_private.cc b/components/mus/public/cpp/lib/view_private.cc index 8cee1cc..12eef3c 100644 --- a/components/mus/public/cpp/lib/view_private.cc +++ b/components/mus/public/cpp/lib/view_private.cc @@ -4,7 +4,7 @@ #include "components/mus/public/cpp/lib/view_private.h" -namespace mus { +namespace mojo { ViewPrivate::ViewPrivate(View* view) : view_(view) { CHECK(view); @@ -17,4 +17,4 @@ View* ViewPrivate::LocalCreate() { return new View; } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_private.h b/components/mus/public/cpp/lib/view_private.h index 56b20aa..4938d70 100644 --- a/components/mus/public/cpp/lib/view_private.h +++ b/components/mus/public/cpp/lib/view_private.h @@ -7,7 +7,7 @@ #include "components/mus/public/cpp/view.h" -namespace mus { +namespace mojo { // This class is a friend of a View and contains functions to mutate internal // state of View. @@ -37,19 +37,18 @@ class ViewPrivate { view_->properties_ = data; } - void LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics) { + void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, + const 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) { + void LocalReorder(View* relative, OrderDirection direction) { view_->LocalReorder(relative, direction); } - void LocalSetBounds(const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) { + void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds) { view_->LocalSetBounds(old_bounds, new_bounds); } void LocalSetDrawn(bool drawn) { view_->LocalSetDrawn(drawn); } @@ -61,6 +60,6 @@ class ViewPrivate { MOJO_DISALLOW_COPY_AND_ASSIGN(ViewPrivate); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_ diff --git a/components/mus/public/cpp/lib/view_surface.cc b/components/mus/public/cpp/lib/view_surface.cc index f5d9a26..bdd5c32 100644 --- a/components/mus/public/cpp/lib/view_surface.cc +++ b/components/mus/public/cpp/lib/view_surface.cc @@ -7,7 +7,7 @@ #include "components/mus/public/cpp/view_surface_client.h" #include "mojo/converters/surfaces/surfaces_type_converters.h" -namespace mus { +namespace mojo { ViewSurface::~ViewSurface() {} @@ -41,4 +41,4 @@ void ViewSurface::ReturnResources( client_->OnResourcesReturned(this, resources.Pass()); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_tree_client_impl.cc b/components/mus/public/cpp/lib/view_tree_client_impl.cc index 43a1935..ceac2ee 100644 --- a/components/mus/public/cpp/lib/view_tree_client_impl.cc +++ b/components/mus/public/cpp/lib/view_tree_client_impl.cc @@ -14,7 +14,7 @@ #include "mojo/application/public/cpp/service_provider_impl.h" #include "mojo/application/public/interfaces/service_provider.mojom.h" -namespace mus { +namespace mojo { Id MakeTransportId(ConnectionSpecificId connection_id, ConnectionSpecificId local_id) { @@ -24,7 +24,7 @@ Id MakeTransportId(ConnectionSpecificId connection_id, // Helper called to construct a local view object from transport data. View* AddViewToConnection(ViewTreeClientImpl* client, View* parent, - const mojo::ViewDataPtr& view_data) { + const 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(); @@ -33,19 +33,19 @@ View* AddViewToConnection(ViewTreeClientImpl* 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(), + private_view.LocalSetViewportMetrics(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); + private_view.LocalSetBounds(Rect(), *view_data->bounds); if (parent) ViewPrivate(parent).LocalAddChild(view); return view; } View* BuildViewTree(ViewTreeClientImpl* client, - const mojo::Array<mojo::ViewDataPtr>& views, + const Array<ViewDataPtr>& views, View* initial_parent) { std::vector<View*> parents; View* root = NULL; @@ -70,13 +70,12 @@ View* BuildViewTree(ViewTreeClientImpl* client, ViewTreeConnection* ViewTreeConnection::Create( ViewTreeDelegate* delegate, - mojo::InterfaceRequest<mojo::ViewTreeClient> request) { + InterfaceRequest<ViewTreeClient> request) { return new ViewTreeClientImpl(delegate, request.Pass()); } -ViewTreeClientImpl::ViewTreeClientImpl( - ViewTreeDelegate* delegate, - mojo::InterfaceRequest<mojo::ViewTreeClient> request) +ViewTreeClientImpl::ViewTreeClientImpl(ViewTreeDelegate* delegate, + InterfaceRequest<ViewTreeClient> request) : connection_id_(0), next_id_(1), delegate_(delegate), @@ -129,7 +128,7 @@ void ViewTreeClientImpl::RemoveChild(Id child_id, Id parent_id) { void ViewTreeClientImpl::Reorder(Id view_id, Id relative_view_id, - mojo::OrderDirection direction) { + OrderDirection direction) { DCHECK(tree_); tree_->ReorderView(view_id, relative_view_id, direction, ActionCompletedCallback()); @@ -139,7 +138,7 @@ bool ViewTreeClientImpl::OwnsView(Id id) const { return HiWord(id) == connection_id_; } -void ViewTreeClientImpl::SetBounds(Id view_id, const mojo::Rect& bounds) { +void ViewTreeClientImpl::SetBounds(Id view_id, const Rect& bounds) { DCHECK(tree_); tree_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback()); } @@ -160,36 +159,34 @@ 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), + tree_->SetViewProperty(view_id, String(name), Array<uint8_t>::From(data), ActionCompletedCallback()); } void ViewTreeClientImpl::SetViewTextInputState(Id view_id, - mojo::TextInputStatePtr state) { + TextInputStatePtr state) { DCHECK(tree_); tree_->SetViewTextInputState(view_id, state.Pass()); } void ViewTreeClientImpl::SetImeVisibility(Id view_id, bool visible, - mojo::TextInputStatePtr state) { + TextInputStatePtr state) { DCHECK(tree_); tree_->SetImeVisibility(view_id, visible, state.Pass()); } void ViewTreeClientImpl::Embed(Id view_id, - mojo::ViewTreeClientPtr client, + ViewTreeClientPtr client, uint32_t policy_bitmask, - const mojo::ViewTree::EmbedCallback& callback) { + const 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) { +void ViewTreeClientImpl::RequestSurface(Id view_id, + InterfaceRequest<Surface> surface, + SurfaceClientPtr client) { DCHECK(tree_); tree_->RequestSurface(view_id, surface.Pass(), client.Pass()); } @@ -223,8 +220,8 @@ void ViewTreeClientImpl::OnRootDestroyed(View* root) { 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); + tree_->CreateView(view_id, [this](ErrorCode code) { + OnActionCompleted(code == ERROR_CODE_NONE); }); return view_id; } @@ -260,8 +257,8 @@ ConnectionSpecificId ViewTreeClientImpl::GetConnectionId() { // ViewTreeClientImpl, ViewTreeClient implementation: void ViewTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, - mojo::ViewDataPtr root_data, - mojo::ViewTreePtr tree, + ViewDataPtr root_data, + ViewTreePtr tree, Id focused_view_id, uint32 access_policy) { if (tree) { @@ -296,8 +293,8 @@ void ViewTreeClientImpl::OnUnembed() { } void ViewTreeClientImpl::OnViewBoundsChanged(Id view_id, - mojo::RectPtr old_bounds, - mojo::RectPtr new_bounds) { + RectPtr old_bounds, + RectPtr new_bounds) { View* view = GetViewById(view_id); ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); } @@ -305,8 +302,8 @@ void ViewTreeClientImpl::OnViewBoundsChanged(Id view_id, namespace { void SetViewportMetricsOnDecendants(View* root, - const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics) { + const ViewportMetrics& old_metrics, + const 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) @@ -315,8 +312,8 @@ void SetViewportMetricsOnDecendants(View* root, } void ViewTreeClientImpl::OnViewViewportMetricsChanged( - mojo::ViewportMetricsPtr old_metrics, - mojo::ViewportMetricsPtr new_metrics) { + ViewportMetricsPtr old_metrics, + ViewportMetricsPtr new_metrics) { View* view = GetRoot(); if (view) SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics); @@ -326,7 +323,7 @@ void ViewTreeClientImpl::OnViewHierarchyChanged( Id view_id, Id new_parent_id, Id old_parent_id, - mojo::Array<mojo::ViewDataPtr> views) { + mojo::Array<ViewDataPtr> views) { View* initial_parent = views.size() ? GetViewById(views[0]->parent_id) : NULL; const bool was_view_known = GetViewById(view_id) != nullptr; @@ -349,7 +346,7 @@ void ViewTreeClientImpl::OnViewHierarchyChanged( void ViewTreeClientImpl::OnViewReordered(Id view_id, Id relative_view_id, - mojo::OrderDirection direction) { + OrderDirection direction) { View* view = GetViewById(view_id); View* relative_view = GetViewById(relative_view_id); if (view && relative_view) @@ -377,10 +374,9 @@ void ViewTreeClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) { ViewPrivate(view).LocalSetDrawn(drawn); } -void ViewTreeClientImpl::OnViewSharedPropertyChanged( - Id view_id, - const mojo::String& name, - mojo::Array<uint8_t> new_data) { +void ViewTreeClientImpl::OnViewSharedPropertyChanged(Id view_id, + const String& name, + Array<uint8_t> new_data) { View* view = GetViewById(view_id); if (view) { std::vector<uint8_t> data; @@ -396,8 +392,8 @@ void ViewTreeClientImpl::OnViewSharedPropertyChanged( void ViewTreeClientImpl::OnViewInputEvent( Id view_id, - mojo::EventPtr event, - const mojo::Callback<void()>& ack_callback) { + EventPtr event, + const Callback<void()>& ack_callback) { View* view = GetViewById(view_id); if (view) { FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(), @@ -431,8 +427,8 @@ void ViewTreeClientImpl::OnActionCompleted(bool success) { change_acked_callback_.Run(); } -mojo::Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() { +Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() { return [this](bool success) { OnActionCompleted(success); }; } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_tree_client_impl.h b/components/mus/public/cpp/lib/view_tree_client_impl.h index 95e5593..458e6ec 100644 --- a/components/mus/public/cpp/lib/view_tree_client_impl.h +++ b/components/mus/public/cpp/lib/view_tree_client_impl.h @@ -11,16 +11,15 @@ #include "components/mus/public/interfaces/view_tree.mojom.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" -namespace mus { +namespace mojo { class ViewTreeConnection; class ViewTreeDelegate; // Manages the connection with the View Manager service. -class ViewTreeClientImpl : public ViewTreeConnection, - public mojo::ViewTreeClient { +class ViewTreeClientImpl : public ViewTreeConnection, public ViewTreeClient { public: ViewTreeClientImpl(ViewTreeDelegate* delegate, - mojo::InterfaceRequest<mojo::ViewTreeClient> request); + InterfaceRequest<ViewTreeClient> request); ~ViewTreeClientImpl() override; bool connected() const { return tree_; } @@ -36,32 +35,30 @@ class ViewTreeClientImpl : public ViewTreeConnection, 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); + void Reorder(Id view_id, Id relative_view_id, 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 SetBounds(Id view_id, const 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 SetViewTextInputState(Id view_id, TextInputStatePtr state); + void SetImeVisibility(Id view_id, bool visible, TextInputStatePtr state); void Embed(Id view_id, - mojo::ViewTreeClientPtr client, + ViewTreeClientPtr client, uint32_t policy_bitmask, - const mojo::ViewTree::EmbedCallback& callback); + const ViewTree::EmbedCallback& callback); void RequestSurface(Id view_id, - mojo::InterfaceRequest<mojo::Surface> surface, - mojo::SurfaceClientPtr client); + InterfaceRequest<Surface> surface, + SurfaceClientPtr client); - void set_change_acked_callback(const mojo::Callback<void(void)>& callback) { + void set_change_acked_callback(const Callback<void(void)>& callback) { change_acked_callback_ = callback; } void ClearChangeAckedCallback() { change_acked_callback_.reset(); } @@ -93,46 +90,45 @@ class ViewTreeClientImpl : public ViewTreeConnection, // Overridden from ViewTreeClient: void OnEmbed(ConnectionSpecificId connection_id, - mojo::ViewDataPtr root, - mojo::ViewTreePtr tree, + ViewDataPtr root, + 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; + RectPtr old_bounds, + RectPtr new_bounds) override; + void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics, + ViewportMetricsPtr new_metrics) override; void OnViewHierarchyChanged(Id view_id, Id new_parent_id, Id old_parent_id, - mojo::Array<mojo::ViewDataPtr> views) override; + Array<ViewDataPtr> views) override; void OnViewReordered(Id view_id, Id relative_view_id, - mojo::OrderDirection direction) override; + 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; + const String& name, + Array<uint8_t> new_data) override; void OnViewInputEvent(Id view_id, - mojo::EventPtr event, - const mojo::Callback<void()>& callback) override; + EventPtr event, + const Callback<void()>& callback) override; void OnViewFocused(Id focused_view_id) override; void RootDestroyed(View* root); void OnActionCompleted(bool success); - mojo::Callback<void(bool)> ActionCompletedCallback(); + Callback<void(bool)> ActionCompletedCallback(); ConnectionSpecificId connection_id_; ConnectionSpecificId next_id_; - mojo::Callback<void(void)> change_acked_callback_; + Callback<void(void)> change_acked_callback_; ViewTreeDelegate* delegate_; @@ -144,8 +140,8 @@ class ViewTreeClientImpl : public ViewTreeConnection, View* focused_view_; View* activated_view_; - mojo::Binding<ViewTreeClient> binding_; - mojo::ViewTreePtr tree_; + Binding<ViewTreeClient> binding_; + ViewTreePtr tree_; bool is_embed_root_; @@ -154,6 +150,6 @@ class ViewTreeClientImpl : public ViewTreeConnection, MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ diff --git a/components/mus/public/cpp/lib/view_tree_delegate.cc b/components/mus/public/cpp/lib/view_tree_delegate.cc index c134414..870da6e 100644 --- a/components/mus/public/cpp/lib/view_tree_delegate.cc +++ b/components/mus/public/cpp/lib/view_tree_delegate.cc @@ -4,8 +4,8 @@ #include "components/mus/public/cpp/view_tree_delegate.h" -namespace mus { +namespace mojo { void ViewTreeDelegate::OnUnembed() {} -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/lib/view_tree_host_factory.cc b/components/mus/public/cpp/lib/view_tree_host_factory.cc index 1da65c9..7259d4a 100644 --- a/components/mus/public/cpp/lib/view_tree_host_factory.cc +++ b/components/mus/public/cpp/lib/view_tree_host_factory.cc @@ -8,21 +8,21 @@ #include "components/mus/public/cpp/view_tree_delegate.h" #include "mojo/application/public/cpp/application_impl.h" -namespace mus { +namespace mojo { -void CreateViewTreeHost(mojo::ViewTreeHostFactory* factory, - mojo::ViewTreeHostClientPtr host_client, +void CreateViewTreeHost(ViewTreeHostFactory* factory, + ViewTreeHostClientPtr host_client, ViewTreeDelegate* delegate, - mojo::ViewTreeHostPtr* host) { - mojo::ViewTreeClientPtr tree_client; + ViewTreeHostPtr* host) { + ViewTreeClientPtr tree_client; ViewTreeConnection::Create(delegate, GetProxy(&tree_client)); factory->CreateViewTreeHost(GetProxy(host), host_client.Pass(), tree_client.Pass()); } -void CreateSingleViewTreeHost(mojo::ApplicationImpl* app, +void CreateSingleViewTreeHost(ApplicationImpl* app, ViewTreeDelegate* delegate, - mojo::ViewTreeHostPtr* host) { + ViewTreeHostPtr* host) { mojo::ViewTreeHostFactoryPtr factory; mojo::URLRequestPtr request(mojo::URLRequest::New()); request->url = "mojo:mus"; @@ -31,4 +31,4 @@ void CreateSingleViewTreeHost(mojo::ApplicationImpl* app, host); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/scoped_view_ptr.h b/components/mus/public/cpp/scoped_view_ptr.h index 92c12f2..47e50ba 100644 --- a/components/mus/public/cpp/scoped_view_ptr.h +++ b/components/mus/public/cpp/scoped_view_ptr.h @@ -7,7 +7,7 @@ #include "components/mus/public/cpp/view_observer.h" -namespace mus { +namespace mojo { // Wraps a View, taking overship of the View. Also deals with View being // destroyed while ScopedViewPtr still exists. @@ -33,6 +33,6 @@ class ScopedViewPtr : public ViewObserver { DISALLOW_COPY_AND_ASSIGN(ScopedViewPtr); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_SCOPED_VIEW_PTR_H_ diff --git a/components/mus/public/cpp/tests/run_all_unittests.cc b/components/mus/public/cpp/tests/run_all_unittests.cc index ee82a07..3d191d4 100644 --- a/components/mus/public/cpp/tests/run_all_unittests.cc +++ b/components/mus/public/cpp/tests/run_all_unittests.cc @@ -7,9 +7,9 @@ #include "components/mus/public/cpp/tests/view_manager_test_suite.h" int main(int argc, char** argv) { - mus::ViewManagerTestSuite test_suite(argc, argv); + mojo::ViewManagerTestSuite test_suite(argc, argv); return base::LaunchUnitTests(argc, argv, - base::Bind(&mus::ViewManagerTestSuite::Run, + base::Bind(&mojo::ViewManagerTestSuite::Run, base::Unretained(&test_suite))); } diff --git a/components/mus/public/cpp/tests/view_manager_test_base.cc b/components/mus/public/cpp/tests/view_manager_test_base.cc index 508cd82..8ed4204 100644 --- a/components/mus/public/cpp/tests/view_manager_test_base.cc +++ b/components/mus/public/cpp/tests/view_manager_test_base.cc @@ -13,7 +13,7 @@ #include "components/mus/public/cpp/view_tree_host_factory.h" #include "mojo/application/public/cpp/application_impl.h" -namespace mus { +namespace mojo { namespace { base::RunLoop* current_run_loop = nullptr; @@ -73,13 +73,13 @@ void ViewManagerTestBase::TearDown() { ApplicationTestBase::TearDown(); } -mojo::ApplicationDelegate* ViewManagerTestBase::GetApplicationDelegate() { +ApplicationDelegate* ViewManagerTestBase::GetApplicationDelegate() { return this; } bool ViewManagerTestBase::ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) { - connection->AddService<mojo::ViewTreeClient>(this); + ApplicationConnection* connection) { + connection->AddService<ViewTreeClient>(this); return true; } @@ -92,10 +92,9 @@ void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) { view_tree_connection_destroyed_ = true; } -void ViewManagerTestBase::Create( - mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<mojo::ViewTreeClient> request) { +void ViewManagerTestBase::Create(ApplicationConnection* connection, + InterfaceRequest<ViewTreeClient> request) { ViewTreeConnection::Create(this, request.Pass()); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/tests/view_manager_test_base.h b/components/mus/public/cpp/tests/view_manager_test_base.h index a1529f3..15a802c 100644 --- a/components/mus/public/cpp/tests/view_manager_test_base.h +++ b/components/mus/public/cpp/tests/view_manager_test_base.h @@ -13,17 +13,16 @@ #include "mojo/application/public/cpp/application_test_base.h" #include "mojo/application/public/cpp/interface_factory.h" -namespace mus { +namespace mojo { // 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 // established as part of SetUp(). -class ViewManagerTestBase - : public mojo::test::ApplicationTestBase, - public mojo::ApplicationDelegate, - public ViewTreeDelegate, - public mojo::InterfaceFactory<mojo::ViewTreeClient> { +class ViewManagerTestBase : public test::ApplicationTestBase, + public ApplicationDelegate, + public ViewTreeDelegate, + public InterfaceFactory<ViewTreeClient> { public: ViewManagerTestBase(); ~ViewManagerTestBase() override; @@ -54,26 +53,25 @@ class ViewManagerTestBase void TearDown() override; // test::ApplicationTestBase: - mojo::ApplicationDelegate* GetApplicationDelegate() override; + ApplicationDelegate* GetApplicationDelegate() override; // ApplicationDelegate: - bool ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) override; + bool ConfigureIncomingConnection(ApplicationConnection* connection) override; // ViewTreeDelegate: void OnEmbed(View* root) override; void OnConnectionLost(ViewTreeConnection* connection) override; // InterfaceFactory<ViewTreeClient>: - void Create(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<mojo::ViewTreeClient> request) override; + void Create(ApplicationConnection* connection, + InterfaceRequest<ViewTreeClient> request) override; // Used to receive the most recent view tree connection loaded by an embed // action. ViewTreeConnection* most_recent_connection_; private: - mojo::ViewTreeHostPtr host_; + ViewTreeHostPtr host_; // The View Manager connection held by the window manager (app running at the // root view). @@ -84,6 +82,6 @@ class ViewManagerTestBase MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ diff --git a/components/mus/public/cpp/tests/view_manager_test_suite.cc b/components/mus/public/cpp/tests/view_manager_test_suite.cc index a1e0c98..a349ea6 100644 --- a/components/mus/public/cpp/tests/view_manager_test_suite.cc +++ b/components/mus/public/cpp/tests/view_manager_test_suite.cc @@ -10,7 +10,7 @@ #include "ui/gfx/x/x11_connection.h" #endif -namespace mus { +namespace mojo { ViewManagerTestSuite::ViewManagerTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} @@ -30,4 +30,4 @@ void ViewManagerTestSuite::Initialize() { base::i18n::AllowMultipleInitializeCallsForTesting(); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/tests/view_manager_test_suite.h b/components/mus/public/cpp/tests/view_manager_test_suite.h index b68bb2f..7010631 100644 --- a/components/mus/public/cpp/tests/view_manager_test_suite.h +++ b/components/mus/public/cpp/tests/view_manager_test_suite.h @@ -8,7 +8,7 @@ #include "base/test/test_suite.h" #include "third_party/mojo/src/mojo/public/cpp/system/macros.h" -namespace mus { +namespace mojo { class ViewManagerTestSuite : public base::TestSuite { public: @@ -22,6 +22,6 @@ class ViewManagerTestSuite : public base::TestSuite { MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestSuite); }; -} // namespace mus +} // namespace mojo #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 index c991ca3..ca5c3b7 100644 --- a/components/mus/public/cpp/tests/view_unittest.cc +++ b/components/mus/public/cpp/tests/view_unittest.cc @@ -12,7 +12,7 @@ #include "components/mus/public/cpp/view_property.h" #include "testing/gtest/include/gtest/gtest.h" -namespace mus { +namespace mojo { // View ------------------------------------------------------------------------ @@ -423,7 +423,7 @@ class OrderChangeObserver : public ViewObserver { struct Change { View* view; View* relative_view; - mojo::OrderDirection direction; + OrderDirection direction; }; typedef std::vector<Change> Changes; @@ -442,13 +442,13 @@ class OrderChangeObserver : public ViewObserver { // Overridden from ViewObserver: void OnViewReordering(View* view, View* relative_view, - mojo::OrderDirection direction) override { + OrderDirection direction) override { OnViewReordered(view, relative_view, direction); } void OnViewReordered(View* view, View* relative_view, - mojo::OrderDirection direction) override { + OrderDirection direction) override { Change change; change.view = view; change.relative_view = relative_view; @@ -488,11 +488,11 @@ TEST_F(ViewObserverTest, Order) { 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(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); + EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction); } { @@ -508,11 +508,11 @@ TEST_F(ViewObserverTest, Order) { 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(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); + EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction); } { @@ -520,7 +520,7 @@ TEST_F(ViewObserverTest, Order) { // Move v11 above v12. // Resulting order: v12. v11, v13 - v11.Reorder(&v12, mojo::ORDER_DIRECTION_ABOVE); + v11.Reorder(&v12, ORDER_DIRECTION_ABOVE); EXPECT_EQ(&v12, v1.children().front()); EXPECT_EQ(&v13, v1.children().back()); @@ -528,11 +528,11 @@ TEST_F(ViewObserverTest, Order) { 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(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); + EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction); } { @@ -540,7 +540,7 @@ TEST_F(ViewObserverTest, Order) { // Move v11 below v12. // Resulting order: v11, v12, v13 - v11.Reorder(&v12, mojo::ORDER_DIRECTION_BELOW); + v11.Reorder(&v12, ORDER_DIRECTION_BELOW); EXPECT_EQ(&v11, v1.children().front()); EXPECT_EQ(&v13, v1.children().back()); @@ -548,11 +548,11 @@ TEST_F(ViewObserverTest, Order) { 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(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); + EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction); } } @@ -565,7 +565,7 @@ std::string ViewIdToString(Id id) { : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); } -std::string RectToString(const mojo::Rect& rect) { +std::string RectToString(const Rect& rect) { return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width, rect.height); } @@ -586,16 +586,16 @@ class BoundsChangeObserver : public ViewObserver { private: // Overridden from ViewObserver: void OnViewBoundsChanging(View* view, - const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) override { + const Rect& old_bounds, + const 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 { + const Rect& old_bounds, + const 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(), @@ -614,7 +614,7 @@ TEST_F(ViewObserverTest, SetBounds) { TestView v1; { BoundsChangeObserver observer(&v1); - mojo::Rect rect; + Rect rect; rect.width = rect.height = 100; v1.SetBounds(rect); @@ -871,4 +871,4 @@ TEST_F(ViewObserverTest, LocalPropertyChanged) { o.PropertyChangeInfoAndClear()); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/types.h b/components/mus/public/cpp/types.h index a81a0bc7..3e7f07f 100644 --- a/components/mus/public/cpp/types.h +++ b/components/mus/public/cpp/types.h @@ -10,7 +10,7 @@ // Typedefs for the transport types. These typedefs match that of the mojom // file, see it for specifics. -namespace mus { +namespace mojo { // Used to identify views and change ids. typedef uint32_t Id; @@ -20,6 +20,6 @@ typedef uint32_t Id; // connection and the ConnectionSpecificId of the view. typedef uint16_t ConnectionSpecificId; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_TYPES_H_ diff --git a/components/mus/public/cpp/util.h b/components/mus/public/cpp/util.h index c9cd91f..96f8eeb 100644 --- a/components/mus/public/cpp/util.h +++ b/components/mus/public/cpp/util.h @@ -15,7 +15,7 @@ #undef LoWord #endif -namespace mus { +namespace mojo { inline uint16_t HiWord(uint32_t id) { return static_cast<uint16_t>((id >> 16) & 0xFFFF); @@ -25,6 +25,6 @@ inline uint16_t LoWord(uint32_t id) { return static_cast<uint16_t>(id & 0xFFFF); } -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_UTIL_H_ diff --git a/components/mus/public/cpp/view.h b/components/mus/public/cpp/view.h index f65f79a..e2cded9 100644 --- a/components/mus/public/cpp/view.h +++ b/components/mus/public/cpp/view.h @@ -11,15 +11,15 @@ #include "base/callback.h" #include "base/observer_list.h" #include "components/mus/public/cpp/types.h" -#include "components/mus/public/interfaces/mus_constants.mojom.h" #include "components/mus/public/interfaces/surface_id.mojom.h" +#include "components/mus/public/interfaces/view_manager_constants.mojom.h" #include "components/mus/public/interfaces/view_tree.mojom.h" #include "mojo/application/public/interfaces/service_provider.mojom.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" #include "third_party/mojo/src/mojo/public/cpp/system/macros.h" #include "ui/mojo/geometry/geometry.mojom.h" -namespace mus { +namespace mojo { class ServiceProviderImpl; class View; @@ -55,14 +55,14 @@ class View { Id id() const { return id_; } // Geometric disposition. - const mojo::Rect& bounds() const { return bounds_; } - void SetBounds(const mojo::Rect& bounds); + const Rect& bounds() const { return bounds_; } + void SetBounds(const Rect& bounds); // Visibility (also see IsDrawn()). When created views are hidden. bool visible() const { return visible_; } void SetVisible(bool value); - const mojo::ViewportMetrics& viewport_metrics() { return *viewport_metrics_; } + const ViewportMetrics& viewport_metrics() { return *viewport_metrics_; } scoped_ptr<ViewSurface> RequestSurface(); @@ -120,7 +120,7 @@ class View { void AddChild(View* child); void RemoveChild(View* child); - void Reorder(View* relative, mojo::OrderDirection direction); + void Reorder(View* relative, OrderDirection direction); void MoveToFront(); void MoveToBack(); @@ -128,19 +128,19 @@ class View { View* GetChildById(Id id); - void SetTextInputState(mojo::TextInputStatePtr state); - void SetImeVisibility(bool visible, mojo::TextInputStatePtr state); + void SetTextInputState(TextInputStatePtr state); + void SetImeVisibility(bool visible, TextInputStatePtr state); // Focus. void SetFocus(); bool HasFocus() const; // Embedding. See view_tree.mojom for details. - void Embed(mojo::ViewTreeClientPtr client); + void Embed(ViewTreeClientPtr client); // NOTE: callback is run synchronously if Embed() is not allowed on this // View. - void Embed(mojo::ViewTreeClientPtr client, + void Embed(ViewTreeClientPtr client, uint32_t policy_bitmask, const EmbedCallback& callback); @@ -168,11 +168,10 @@ class View { void LocalAddChild(View* child); void LocalRemoveChild(View* child); // Returns true if the order actually changed. - bool LocalReorder(View* relative, mojo::OrderDirection direction); - void LocalSetBounds(const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds); - void LocalSetViewportMetrics(const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics); + bool LocalReorder(View* relative, OrderDirection direction); + void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds); + void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, + const ViewportMetrics& new_metrics); void LocalSetDrawn(bool drawn); void LocalSetVisible(bool visible); @@ -199,8 +198,8 @@ class View { base::ObserverList<ViewObserver> observers_; - mojo::Rect bounds_; - mojo::ViewportMetricsPtr viewport_metrics_; + Rect bounds_; + ViewportMetricsPtr viewport_metrics_; bool visible_; @@ -224,6 +223,6 @@ class View { MOJO_DISALLOW_COPY_AND_ASSIGN(View); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_H_ diff --git a/components/mus/public/cpp/view_observer.h b/components/mus/public/cpp/view_observer.h index 2bd541b..8c0dd25 100644 --- a/components/mus/public/cpp/view_observer.h +++ b/components/mus/public/cpp/view_observer.h @@ -10,7 +10,7 @@ #include "components/mus/public/cpp/view.h" #include "ui/mojo/events/input_events.mojom.h" -namespace mus { +namespace mojo { class View; @@ -39,29 +39,29 @@ class ViewObserver { virtual void OnViewReordering(View* view, View* relative_view, - mojo::OrderDirection direction) {} + OrderDirection direction) {} virtual void OnViewReordered(View* view, View* relative_view, - mojo::OrderDirection direction) {} + 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) {} + const Rect& old_bounds, + const Rect& new_bounds) {} virtual void OnViewBoundsChanged(View* view, - const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) {} + const Rect& old_bounds, + const Rect& new_bounds) {} virtual void OnViewViewportMetricsChanged( View* view, - const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics) {} + const ViewportMetrics& old_metrics, + const ViewportMetrics& new_metrics) {} virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {} - virtual void OnViewInputEvent(View* view, const mojo::EventPtr& event) {} + virtual void OnViewInputEvent(View* view, const EventPtr& event) {} virtual void OnViewVisibilityChanging(View* view) {} virtual void OnViewVisibilityChanged(View* view) {} @@ -97,6 +97,6 @@ class ViewObserver { virtual ~ViewObserver() {} }; -} // namespace mus +} // namespace mojo #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 index ccebb7c..fee92e7 100644 --- a/components/mus/public/cpp/view_property.h +++ b/components/mus/public/cpp/view_property.h @@ -40,7 +40,7 @@ // 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 mojo { namespace { // No single new-style cast works for every conversion to/from int64_t, so we @@ -99,41 +99,41 @@ void View::ClearLocalProperty(const ViewProperty<T>* property) { SetLocalProperty(property, property->default_value); } -} // namespace mus +} // namespace mojo // 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_EXPORTED_VIEW_PROPERTY_TYPE(EXPORT, T) \ + template EXPORT void mojo::View::SetLocalProperty( \ + const mojo::ViewProperty<T>*, T); \ + template EXPORT T mojo::View::GetLocalProperty(const mojo::ViewProperty<T>*) \ + const; \ + template EXPORT void mojo::View::ClearLocalProperty( \ + const mojo::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 mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ } \ - const mus::ViewProperty<TYPE>* const NAME = &NAME##_Value; + const mojo::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; \ + const mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ + const mojo::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; +#define DEFINE_OWNED_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ + namespace { \ + void Deallocator##NAME(int64_t p) { \ + enum { type_must_be_complete = sizeof(TYPE) }; \ + delete mojo::ViewPropertyCaster<TYPE*>::FromInt64(p); \ + } \ + const mojo::ViewProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ + &Deallocator##NAME}; \ + } \ + const mojo::ViewProperty<TYPE*>* const NAME = &NAME##_Value; #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_PROPERTY_H_ diff --git a/components/mus/public/cpp/view_surface.h b/components/mus/public/cpp/view_surface.h index 91b0a482..f29bb92 100644 --- a/components/mus/public/cpp/view_surface.h +++ b/components/mus/public/cpp/view_surface.h @@ -10,7 +10,7 @@ #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr_info.h" -namespace mus { +namespace mojo { class ViewSurfaceClient; class View; @@ -28,10 +28,10 @@ class ViewSurface : public mojo::SurfaceClient { // TODO(fsamuel): Add a callback. void SubmitCompositorFrame(mojo::CompositorFramePtr frame); - void set_client(ViewSurfaceClient* client) { client_ = client; } + void set_client(mojo::ViewSurfaceClient* client) { client_ = client; } private: - friend class View; + friend class mojo::View; ViewSurface(mojo::InterfacePtrInfo<mojo::Surface> surface_info, mojo::InterfaceRequest<mojo::SurfaceClient> client_request); @@ -40,7 +40,7 @@ class ViewSurface : public mojo::SurfaceClient { void ReturnResources( mojo::Array<mojo::ReturnedResourcePtr> resources) override; - ViewSurfaceClient* client_; + mojo::ViewSurfaceClient* client_; mojo::InterfacePtrInfo<mojo::Surface> surface_info_; mojo::InterfaceRequest<mojo::SurfaceClient> client_request_; mojo::SurfacePtr surface_; @@ -48,6 +48,6 @@ class ViewSurface : public mojo::SurfaceClient { bool bound_to_thread_; }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_H_ diff --git a/components/mus/public/cpp/view_surface_client.h b/components/mus/public/cpp/view_surface_client.h index 0ac2c54..e8724c8 100644 --- a/components/mus/public/cpp/view_surface_client.h +++ b/components/mus/public/cpp/view_surface_client.h @@ -5,7 +5,7 @@ #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_CLIENT_H_ #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_CLIENT_H_ -namespace mus { +namespace mojo { class ViewSurface; @@ -19,6 +19,6 @@ class ViewSurfaceClient { ~ViewSurfaceClient() {} }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_SURFACE_CLIENT_H_ diff --git a/components/mus/public/cpp/view_tracker.cc b/components/mus/public/cpp/view_tracker.cc index 3d97857..111c9e6 100644 --- a/components/mus/public/cpp/view_tracker.cc +++ b/components/mus/public/cpp/view_tracker.cc @@ -4,7 +4,7 @@ #include "components/mus/public/cpp/view_tracker.h" -namespace mus { +namespace mojo { ViewTracker::ViewTracker() {} @@ -37,4 +37,4 @@ void ViewTracker::OnViewDestroying(View* view) { Remove(view); } -} // namespace mus +} // namespace mojo diff --git a/components/mus/public/cpp/view_tracker.h b/components/mus/public/cpp/view_tracker.h index f551d5a..39d715b 100644 --- a/components/mus/public/cpp/view_tracker.h +++ b/components/mus/public/cpp/view_tracker.h @@ -11,7 +11,7 @@ #include "components/mus/public/cpp/view_observer.h" #include "third_party/mojo/src/mojo/public/cpp/system/macros.h" -namespace mus { +namespace mojo { class ViewTracker : public ViewObserver { public: @@ -42,6 +42,6 @@ class ViewTracker : public ViewObserver { MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTracker); }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TRACKER_H_ diff --git a/components/mus/public/cpp/view_tree_connection.h b/components/mus/public/cpp/view_tree_connection.h index 984e664..36b8588 100644 --- a/components/mus/public/cpp/view_tree_connection.h +++ b/components/mus/public/cpp/view_tree_connection.h @@ -11,8 +11,7 @@ #include "components/mus/public/interfaces/view_tree.mojom.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" -namespace mus { - +namespace mojo { class View; class ViewTreeDelegate; @@ -24,9 +23,8 @@ class ViewTreeConnection { // The returned ViewTreeConnection 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, - mojo::InterfaceRequest<mojo::ViewTreeClient> request); + static ViewTreeConnection* Create(ViewTreeDelegate* delegate, + InterfaceRequest<ViewTreeClient> request); // Returns the root of this connection. virtual View* GetRoot() = 0; @@ -49,6 +47,6 @@ class ViewTreeConnection { virtual ConnectionSpecificId GetConnectionId() = 0; }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_CONNECTION_H_ diff --git a/components/mus/public/cpp/view_tree_delegate.h b/components/mus/public/cpp/view_tree_delegate.h index 2e2115e..4d58f6f 100644 --- a/components/mus/public/cpp/view_tree_delegate.h +++ b/components/mus/public/cpp/view_tree_delegate.h @@ -11,7 +11,7 @@ #include "mojo/application/public/interfaces/service_provider.mojom.h" #include "mojo/services/network/public/interfaces/url_loader.mojom.h" -namespace mus { +namespace mojo { class View; class ViewTreeConnection; @@ -58,6 +58,6 @@ class ViewTreeDelegate { virtual ~ViewTreeDelegate() {} }; -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_DELEGATE_H_ diff --git a/components/mus/public/cpp/view_tree_host_factory.h b/components/mus/public/cpp/view_tree_host_factory.h index 0e44441..d4ac5eb 100644 --- a/components/mus/public/cpp/view_tree_host_factory.h +++ b/components/mus/public/cpp/view_tree_host_factory.h @@ -12,26 +12,23 @@ #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" namespace mojo { -class ApplicationImpl; -} - -namespace mus { +class ApplicationImpl; class ViewTreeDelegate; // 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, +void CreateViewTreeHost(ViewTreeHostFactory* factory, + ViewTreeHostClientPtr host_client, ViewTreeDelegate* delegate, - mojo::ViewTreeHostPtr* host); + 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, +void CreateSingleViewTreeHost(ApplicationImpl* app, ViewTreeDelegate* delegate, - mojo::ViewTreeHostPtr* host); + ViewTreeHostPtr* host); -} // namespace mus +} // namespace mojo #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_TREE_HOST_FACTORY_H_ |