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

Side by Side Diff: components/mus/public/cpp/lib/in_flight_change.cc

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/mus/public/cpp/lib/in_flight_change.h"
6
7 #include "components/mus/public/cpp/lib/window_private.h"
8 #include "components/mus/public/cpp/window_tree_client.h"
9
10 namespace mus {
11
12 // InFlightChange -------------------------------------------------------------
13
14 InFlightChange::InFlightChange(Window* window, ChangeType type)
15 : window_(window), change_type_(type) {}
16
17 InFlightChange::~InFlightChange() {}
18
19 bool InFlightChange::Matches(const InFlightChange& change) const {
20 DCHECK(change.window_ == window_ && change.change_type_ == change_type_);
21 return true;
22 }
23
24 void InFlightChange::ChangeFailed() {}
25
26 // InFlightBoundsChange -------------------------------------------------------
27
28 InFlightBoundsChange::InFlightBoundsChange(Window* window,
29 const gfx::Rect& revert_bounds)
30 : InFlightChange(window, ChangeType::BOUNDS),
31 revert_bounds_(revert_bounds) {}
32
33 void InFlightBoundsChange::SetRevertValueFrom(const InFlightChange& change) {
34 revert_bounds_ =
35 static_cast<const InFlightBoundsChange&>(change).revert_bounds_;
36 }
37
38 void InFlightBoundsChange::Revert() {
39 WindowPrivate(window()).LocalSetBounds(window()->bounds(), revert_bounds_);
40 }
41
42 // CrashInFlightChange --------------------------------------------------------
43
44 CrashInFlightChange::CrashInFlightChange(Window* window, ChangeType type)
45 : InFlightChange(window, type) {}
46
47 CrashInFlightChange::~CrashInFlightChange() {}
48
49 void CrashInFlightChange::SetRevertValueFrom(const InFlightChange& change) {
50 CHECK(false);
51 }
52
53 void CrashInFlightChange::ChangeFailed() {
54 DLOG(ERROR) << "changed failed, type=" << static_cast<int>(change_type());
55 CHECK(false);
56 }
57
58 void CrashInFlightChange::Revert() {
59 CHECK(false);
60 }
61
62 // InFlightWindowChange -------------------------------------------------------
63
64 InFlightWindowTreeClientChange::InFlightWindowTreeClientChange(
65 WindowTreeClient* client,
66 Window* revert_value,
67 ChangeType type)
68 : InFlightChange(nullptr, type),
69 client_(client),
70 revert_window_(nullptr) {
71 SetRevertWindow(revert_value);
72 }
73
74 InFlightWindowTreeClientChange::~InFlightWindowTreeClientChange() {
75 SetRevertWindow(nullptr);
76 }
77
78 void InFlightWindowTreeClientChange::SetRevertValueFrom(
79 const InFlightChange& change) {
80 SetRevertWindow(static_cast<const InFlightWindowTreeClientChange&>(change)
81 .revert_window_);
82 }
83
84 void InFlightWindowTreeClientChange::SetRevertWindow(Window* window) {
85 if (revert_window_)
86 revert_window_->RemoveObserver(this);
87 revert_window_ = window;
88 if (revert_window_)
89 revert_window_->AddObserver(this);
90 }
91
92 void InFlightWindowTreeClientChange::OnWindowDestroying(Window* window) {
93 SetRevertWindow(nullptr);
94 }
95
96 // InFlightCaptureChange ------------------------------------------------------
97
98 InFlightCaptureChange::InFlightCaptureChange(
99 WindowTreeClient* client, Window* revert_value)
100 : InFlightWindowTreeClientChange(client,
101 revert_value,
102 ChangeType::CAPTURE) {}
103
104 InFlightCaptureChange::~InFlightCaptureChange() {}
105
106 void InFlightCaptureChange::Revert() {
107 client()->LocalSetCapture(revert_window());
108 }
109
110 // InFlightFocusChange --------------------------------------------------------
111
112 InFlightFocusChange::InFlightFocusChange(
113 WindowTreeClient* client,
114 Window* revert_value)
115 : InFlightWindowTreeClientChange(client,
116 revert_value,
117 ChangeType::FOCUS) {}
118
119 InFlightFocusChange::~InFlightFocusChange() {}
120
121 void InFlightFocusChange::Revert() {
122 client()->LocalSetFocus(revert_window());
123 }
124
125 // InFlightPropertyChange -----------------------------------------------------
126
127 InFlightPropertyChange::InFlightPropertyChange(
128 Window* window,
129 const std::string& property_name,
130 const mojo::Array<uint8_t>& revert_value)
131 : InFlightChange(window, ChangeType::PROPERTY),
132 property_name_(property_name),
133 revert_value_(revert_value.Clone()) {}
134
135 InFlightPropertyChange::~InFlightPropertyChange() {}
136
137 bool InFlightPropertyChange::Matches(const InFlightChange& change) const {
138 return static_cast<const InFlightPropertyChange&>(change).property_name_ ==
139 property_name_;
140 }
141
142 void InFlightPropertyChange::SetRevertValueFrom(const InFlightChange& change) {
143 revert_value_ =
144 static_cast<const InFlightPropertyChange&>(change).revert_value_.Clone();
145 }
146
147 void InFlightPropertyChange::Revert() {
148 WindowPrivate(window())
149 .LocalSetSharedProperty(property_name_, std::move(revert_value_));
150 }
151
152 // InFlightPredefinedCursorChange ---------------------------------------------
153
154 InFlightPredefinedCursorChange::InFlightPredefinedCursorChange(
155 Window* window,
156 mojom::Cursor revert_value)
157 : InFlightChange(window, ChangeType::PREDEFINED_CURSOR),
158 revert_cursor_(revert_value) {}
159
160 InFlightPredefinedCursorChange::~InFlightPredefinedCursorChange() {}
161
162 void InFlightPredefinedCursorChange::SetRevertValueFrom(
163 const InFlightChange& change) {
164 revert_cursor_ =
165 static_cast<const InFlightPredefinedCursorChange&>(change).revert_cursor_;
166 }
167
168 void InFlightPredefinedCursorChange::Revert() {
169 WindowPrivate(window()).LocalSetPredefinedCursor(revert_cursor_);
170 }
171
172 // InFlightVisibleChange -------------------------------------------------------
173
174 InFlightVisibleChange::InFlightVisibleChange(Window* window,
175 bool revert_value)
176 : InFlightChange(window, ChangeType::VISIBLE),
177 revert_visible_(revert_value) {}
178
179 InFlightVisibleChange::~InFlightVisibleChange() {}
180
181 void InFlightVisibleChange::SetRevertValueFrom(const InFlightChange& change) {
182 revert_visible_ =
183 static_cast<const InFlightVisibleChange&>(change).revert_visible_;
184 }
185
186 void InFlightVisibleChange::Revert() {
187 WindowPrivate(window()).LocalSetVisible(revert_visible_);
188 }
189
190 // InFlightOpacityChange -------------------------------------------------------
191
192 InFlightOpacityChange::InFlightOpacityChange(Window* window, float revert_value)
193 : InFlightChange(window, ChangeType::OPACITY),
194 revert_opacity_(revert_value) {}
195
196 InFlightOpacityChange::~InFlightOpacityChange() {}
197
198 void InFlightOpacityChange::SetRevertValueFrom(const InFlightChange& change) {
199 revert_opacity_ =
200 static_cast<const InFlightOpacityChange&>(change).revert_opacity_;
201 }
202
203 void InFlightOpacityChange::Revert() {
204 WindowPrivate(window()).LocalSetOpacity(revert_opacity_);
205 }
206
207 // InFlightSetModalChange ------------------------------------------------------
208
209 InFlightSetModalChange::InFlightSetModalChange(Window* window)
210 : InFlightChange(window, ChangeType::SET_MODAL) {}
211
212 InFlightSetModalChange::~InFlightSetModalChange() {}
213
214 void InFlightSetModalChange::SetRevertValueFrom(const InFlightChange& change) {}
215
216 void InFlightSetModalChange::Revert() {
217 WindowPrivate(window()).LocalUnsetModal();
218 }
219
220 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/in_flight_change.h ('k') | components/mus/public/cpp/lib/output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698