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

Side by Side Diff: services/ui/view_manager/view_tree_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, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/view_manager/view_tree_state.h"
6
5 #include "base/logging.h" 7 #include "base/logging.h"
6 #include "services/ui/view_manager/view_tree_state.h"
7 8
8 namespace view_manager { 9 namespace view_manager {
9 10
10 ViewTreeState::ViewTreeState(mojo::ui::ViewTreePtr view_tree) 11 ViewTreeState::ViewTreeState(mojo::ui::ViewTreePtr view_tree,
12 mojo::ui::ViewTreeTokenPtr view_tree_token,
13 const std::string& label)
11 : view_tree_(view_tree.Pass()), 14 : view_tree_(view_tree.Pass()),
12 root_(nullptr), 15 view_tree_token_(view_tree_token.Pass()),
13 explicit_root_(false), 16 label_(label),
14 layout_request_pending_(false),
15 layout_request_issued_(false),
16 weak_factory_(this) { 17 weak_factory_(this) {
17 DCHECK(view_tree_); 18 DCHECK(view_tree_);
19 DCHECK(view_tree_token_);
18 } 20 }
19 21
20 ViewTreeState::~ViewTreeState() {} 22 ViewTreeState::~ViewTreeState() {}
21 23
22 void ViewTreeState::SetRoot(ViewState* root, uint32_t key) { 24 void ViewTreeState::SetRoot(ViewState* root, uint32_t key) {
23 DCHECK(root); 25 DCHECK(root);
24 if (root_ != root) { 26 if (root_ != root) {
25 ResetRoot(); 27 ResetRoot();
26 root->SetTree(this, key); 28 root->SetTree(this, key);
27 root_ = root; 29 root_ = root;
28 } 30 }
29 } 31 }
30 32
31 void ViewTreeState::ResetRoot() { 33 void ViewTreeState::ResetRoot() {
32 if (root_) { 34 if (root_) {
33 root_->ResetContainer(); 35 root_->ResetContainer();
34 } 36 }
35 root_ = nullptr; 37 root_ = nullptr;
36 } 38 }
37 39
40 std::string ViewTreeState::FormattedLabel() {
41 if (formatted_label_cache_.empty()) {
42 std::ostringstream s;
43 s << "<" << view_tree_token_->value;
44 if (!label_.empty())
45 s << ":" << label_;
46 s << ">";
47 formatted_label_cache_ = s.str();
48 }
49 return formatted_label_cache_;
50 }
51
52 std::ostream& operator<<(std::ostream& os, ViewTreeState* view_tree_state) {
53 if (!view_tree_state)
54 return os << "null";
55 return os << view_tree_state->FormattedLabel();
56 }
57
38 } // namespace view_manager 58 } // namespace view_manager
OLDNEW
« services/ui/view_manager/view_tree_state.h ('K') | « services/ui/view_manager/view_tree_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698