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

Unified Diff: services/ui/view_manager/view_state.cc

Issue 1552043002: Make Mozart view manager use the new compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-12
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/view_manager/view_state.cc
diff --git a/services/ui/view_manager/view_state.cc b/services/ui/view_manager/view_state.cc
index cfccc564cdfe7cbf6e68340639928fce425a55db..f106bec3c3c6860ce5126654cc4d691948791c13 100644
--- a/services/ui/view_manager/view_state.cc
+++ b/services/ui/view_manager/view_state.cc
@@ -2,20 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "services/ui/view_manager/view_state.h"
+
+#include "base/logging.h"
#include "services/ui/view_manager/view_tree_state.h"
namespace view_manager {
-ViewState::ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value)
+ViewState::ViewState(mojo::ui::ViewPtr view,
+ mojo::ui::ViewTokenPtr view_token,
+ const std::string& label)
: view_(view.Pass()),
- view_token_value_(view_token_value),
- tree_(nullptr),
- parent_(nullptr),
- key_(0),
+ view_token_(view_token.Pass()),
+ label_(label),
weak_factory_(this) {
DCHECK(view_);
+ DCHECK(view_token_);
}
ViewState::~ViewState() {}
@@ -49,7 +51,32 @@ void ViewState::ResetContainer() {
SetTreeUnchecked(nullptr);
}
-void ViewState::GetServiceProvider(
- mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) {}
+mojo::ui::ViewLayoutInfoPtr ViewState::CreateLayoutInfo() {
abarth 2016/01/10 01:42:55 The difference between ViewLayoutInfo and ViewLayo
jeffbrown 2016/01/26 05:59:13 Agreed. The whole layout protocol is going to be
+ if (!layout_result_ || !scene_token_)
+ return nullptr;
+
+ auto info = mojo::ui::ViewLayoutInfo::New();
+ info->size = layout_result_->size.Clone();
+ info->scene_token = scene_token_.Clone();
+ return info;
+}
+
+std::string ViewState::FormattedLabel() {
+ if (formatted_label_cache_.empty()) {
+ std::ostringstream s;
+ s << "<" << view_token_->value;
+ if (!label_.empty())
+ s << ":" << label_;
+ s << ">";
+ formatted_label_cache_ = s.str();
abarth 2016/01/10 01:42:55 There's base::StringPrintf if you'd like something
jeffbrown 2016/01/26 05:59:13 Done.
+ }
+ return formatted_label_cache_;
+}
+
+std::ostream& operator<<(std::ostream& os, ViewState* view_state) {
+ if (!view_state)
+ return os << "null";
+ return os << view_state->FormattedLabel();
+}
} // namespace view_manager

Powered by Google App Engine
This is Rietveld 408576698