forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShadowViewMutation.cpp
More file actions
123 lines (111 loc) · 3.73 KB
/
ShadowViewMutation.cpp
File metadata and controls
123 lines (111 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "ShadowViewMutation.h"
namespace facebook {
namespace react {
ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) {
return {
/* .type = */ Create,
/* .parentShadowView = */ {},
/* .oldChildShadowView = */ {},
/* .newChildShadowView = */ shadowView,
/* .index = */ -1,
};
}
ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) {
return {
/* .type = */ Delete,
/* .parentShadowView = */ {},
/* .oldChildShadowView = */ shadowView,
/* .newChildShadowView = */ {},
/* .index = */ -1,
};
}
ShadowViewMutation ShadowViewMutation::InsertMutation(
ShadowView parentShadowView,
ShadowView childShadowView,
int index) {
return {
/* .type = */ Insert,
/* .parentShadowView = */ parentShadowView,
/* .oldChildShadowView = */ {},
/* .newChildShadowView = */ childShadowView,
/* .index = */ index,
};
}
ShadowViewMutation ShadowViewMutation::RemoveMutation(
ShadowView parentShadowView,
ShadowView childShadowView,
int index) {
return {
/* .type = */ Remove,
/* .parentShadowView = */ parentShadowView,
/* .oldChildShadowView = */ childShadowView,
/* .newChildShadowView = */ {},
/* .index = */ index,
};
}
ShadowViewMutation ShadowViewMutation::UpdateMutation(
ShadowView parentShadowView,
ShadowView oldChildShadowView,
ShadowView newChildShadowView,
int index) {
return {
/* .type = */ Update,
/* .parentShadowView = */ parentShadowView,
/* .oldChildShadowView = */ oldChildShadowView,
/* .newChildShadowView = */ newChildShadowView,
/* .index = */ index,
};
}
#if RN_DEBUG_STRING_CONVERTIBLE
std::string getDebugName(ShadowViewMutation const &mutation) {
switch (mutation.type) {
case ShadowViewMutation::Create:
return "Create";
case ShadowViewMutation::Delete:
return "Delete";
case ShadowViewMutation::Insert:
return "Insert";
case ShadowViewMutation::Remove:
return "Remove";
case ShadowViewMutation::Update:
return "Update";
}
}
std::vector<DebugStringConvertibleObject> getDebugProps(
ShadowViewMutation const &mutation,
DebugStringConvertibleOptions options) {
return {
mutation.oldChildShadowView.componentHandle
? DebugStringConvertibleObject{"oldChild",
getDebugDescription(
mutation.oldChildShadowView,
options)}
: DebugStringConvertibleObject{},
mutation.newChildShadowView.componentHandle
? DebugStringConvertibleObject{"newChild",
getDebugDescription(
mutation.newChildShadowView,
options)}
: DebugStringConvertibleObject{},
mutation.parentShadowView.componentHandle
? DebugStringConvertibleObject{"parent",
getDebugDescription(
mutation.parentShadowView,
options)}
: DebugStringConvertibleObject{},
mutation.index != -1
? DebugStringConvertibleObject{"index",
getDebugDescription(
mutation.index, options)}
: DebugStringConvertibleObject{},
};
}
#endif
} // namespace react
} // namespace facebook