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

Side by Side Diff: services/ui/public/cpp/in_flight_change.cc

Issue 2651593002: mus: Remove the old client lib. (Closed)
Patch Set: restore test Created 3 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
« no previous file with comments | « services/ui/public/cpp/in_flight_change.h ('k') | services/ui/public/cpp/input_event_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/public/cpp/in_flight_change.h"
6
7 #include "services/ui/public/cpp/window_private.h"
8 #include "services/ui/public/cpp/window_tree_client.h"
9
10 namespace ui {
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 // InFlightDragChange -----------------------------------------------------
43
44 InFlightDragChange::InFlightDragChange(Window* window, ChangeType type)
45 : InFlightChange(window, type) {
46 DCHECK(type == ChangeType::MOVE_LOOP || type == ChangeType::DRAG_LOOP);
47 }
48
49 void InFlightDragChange::SetRevertValueFrom(const InFlightChange& change) {}
50
51 void InFlightDragChange::Revert() {}
52
53 // CrashInFlightChange --------------------------------------------------------
54
55 CrashInFlightChange::CrashInFlightChange(Window* window, ChangeType type)
56 : InFlightChange(window, type) {}
57
58 CrashInFlightChange::~CrashInFlightChange() {}
59
60 void CrashInFlightChange::SetRevertValueFrom(const InFlightChange& change) {
61 CHECK(false);
62 }
63
64 void CrashInFlightChange::ChangeFailed() {
65 DLOG(ERROR) << "changed failed, type=" << static_cast<int>(change_type());
66 CHECK(false);
67 }
68
69 void CrashInFlightChange::Revert() {
70 CHECK(false);
71 }
72
73 // InFlightWindowChange -------------------------------------------------------
74
75 InFlightWindowTreeClientChange::InFlightWindowTreeClientChange(
76 WindowTreeClient* client,
77 Window* revert_value,
78 ChangeType type)
79 : InFlightChange(nullptr, type),
80 client_(client),
81 revert_window_(nullptr) {
82 SetRevertWindow(revert_value);
83 }
84
85 InFlightWindowTreeClientChange::~InFlightWindowTreeClientChange() {
86 SetRevertWindow(nullptr);
87 }
88
89 void InFlightWindowTreeClientChange::SetRevertValueFrom(
90 const InFlightChange& change) {
91 SetRevertWindow(static_cast<const InFlightWindowTreeClientChange&>(change)
92 .revert_window_);
93 }
94
95 void InFlightWindowTreeClientChange::SetRevertWindow(Window* window) {
96 if (revert_window_)
97 revert_window_->RemoveObserver(this);
98 revert_window_ = window;
99 if (revert_window_)
100 revert_window_->AddObserver(this);
101 }
102
103 void InFlightWindowTreeClientChange::OnWindowDestroying(Window* window) {
104 SetRevertWindow(nullptr);
105 }
106
107 // InFlightCaptureChange ------------------------------------------------------
108
109 InFlightCaptureChange::InFlightCaptureChange(
110 WindowTreeClient* client, Window* revert_value)
111 : InFlightWindowTreeClientChange(client,
112 revert_value,
113 ChangeType::CAPTURE) {}
114
115 InFlightCaptureChange::~InFlightCaptureChange() {}
116
117 void InFlightCaptureChange::Revert() {
118 client()->LocalSetCapture(revert_window());
119 }
120
121 // InFlightFocusChange --------------------------------------------------------
122
123 InFlightFocusChange::InFlightFocusChange(
124 WindowTreeClient* client,
125 Window* revert_value)
126 : InFlightWindowTreeClientChange(client,
127 revert_value,
128 ChangeType::FOCUS) {}
129
130 InFlightFocusChange::~InFlightFocusChange() {}
131
132 void InFlightFocusChange::Revert() {
133 client()->LocalSetFocus(revert_window());
134 }
135
136 // InFlightPropertyChange -----------------------------------------------------
137
138 InFlightPropertyChange::InFlightPropertyChange(
139 Window* window,
140 const std::string& property_name,
141 const base::Optional<std::vector<uint8_t>>& revert_value)
142 : InFlightChange(window, ChangeType::PROPERTY),
143 property_name_(property_name),
144 revert_value_(revert_value) {}
145
146 InFlightPropertyChange::~InFlightPropertyChange() {}
147
148 bool InFlightPropertyChange::Matches(const InFlightChange& change) const {
149 return static_cast<const InFlightPropertyChange&>(change).property_name_ ==
150 property_name_;
151 }
152
153 void InFlightPropertyChange::SetRevertValueFrom(const InFlightChange& change) {
154 revert_value_ =
155 static_cast<const InFlightPropertyChange&>(change).revert_value_;
156 }
157
158 void InFlightPropertyChange::Revert() {
159 WindowPrivate(window()).LocalSetSharedProperty(
160 property_name_, revert_value_ ? &revert_value_.value() : nullptr);
161 }
162
163 // InFlightPredefinedCursorChange ---------------------------------------------
164
165 InFlightPredefinedCursorChange::InFlightPredefinedCursorChange(
166 Window* window,
167 mojom::Cursor revert_value)
168 : InFlightChange(window, ChangeType::PREDEFINED_CURSOR),
169 revert_cursor_(revert_value) {}
170
171 InFlightPredefinedCursorChange::~InFlightPredefinedCursorChange() {}
172
173 void InFlightPredefinedCursorChange::SetRevertValueFrom(
174 const InFlightChange& change) {
175 revert_cursor_ =
176 static_cast<const InFlightPredefinedCursorChange&>(change).revert_cursor_;
177 }
178
179 void InFlightPredefinedCursorChange::Revert() {
180 WindowPrivate(window()).LocalSetPredefinedCursor(revert_cursor_);
181 }
182
183 // InFlightVisibleChange -------------------------------------------------------
184
185 InFlightVisibleChange::InFlightVisibleChange(Window* window,
186 bool revert_value)
187 : InFlightChange(window, ChangeType::VISIBLE),
188 revert_visible_(revert_value) {}
189
190 InFlightVisibleChange::~InFlightVisibleChange() {}
191
192 void InFlightVisibleChange::SetRevertValueFrom(const InFlightChange& change) {
193 revert_visible_ =
194 static_cast<const InFlightVisibleChange&>(change).revert_visible_;
195 }
196
197 void InFlightVisibleChange::Revert() {
198 WindowPrivate(window()).LocalSetVisible(revert_visible_);
199 }
200
201 // InFlightOpacityChange -------------------------------------------------------
202
203 InFlightOpacityChange::InFlightOpacityChange(Window* window, float revert_value)
204 : InFlightChange(window, ChangeType::OPACITY),
205 revert_opacity_(revert_value) {}
206
207 InFlightOpacityChange::~InFlightOpacityChange() {}
208
209 void InFlightOpacityChange::SetRevertValueFrom(const InFlightChange& change) {
210 revert_opacity_ =
211 static_cast<const InFlightOpacityChange&>(change).revert_opacity_;
212 }
213
214 void InFlightOpacityChange::Revert() {
215 WindowPrivate(window()).LocalSetOpacity(revert_opacity_);
216 }
217
218 // InFlightSetModalChange ------------------------------------------------------
219
220 InFlightSetModalChange::InFlightSetModalChange(Window* window)
221 : InFlightChange(window, ChangeType::SET_MODAL) {}
222
223 InFlightSetModalChange::~InFlightSetModalChange() {}
224
225 void InFlightSetModalChange::SetRevertValueFrom(const InFlightChange& change) {}
226
227 void InFlightSetModalChange::Revert() {
228 WindowPrivate(window()).LocalUnsetModal();
229 }
230
231 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/in_flight_change.h ('k') | services/ui/public/cpp/input_event_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698