react-native-windows 0.75.0-preview.4 → 0.75.0-preview.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/Common/Common.vcxproj +1 -1
  2. package/Common/packages.lock.json +3 -3
  3. package/Folly/Folly.vcxproj +1 -1
  4. package/Folly/packages.lock.json +3 -3
  5. package/Libraries/Text/Text.windows.js +1 -0
  6. package/Microsoft.ReactNative/Composition.Input.idl +3 -3
  7. package/Microsoft.ReactNative/CompositionSwitcher.idl +1 -0
  8. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +3 -0
  9. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +2 -2
  10. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +4 -4
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +10 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +16 -27
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -1
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +85 -48
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +4 -0
  16. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +19 -15
  17. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +4 -2
  18. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +10 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +3 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +42 -17
  21. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +3 -1
  22. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +42 -5
  23. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +22 -16
  24. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +30 -6
  25. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -0
  26. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +5 -0
  27. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
  28. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +3 -2
  29. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppApp.targets +1 -1
  30. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.targets +2 -2
  31. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  32. package/ReactCommon/ReactCommon.vcxproj +1 -1
  33. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +2396 -0
  34. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +136 -0
  35. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +92 -0
  36. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +48 -0
  37. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +122 -0
  38. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +388 -0
  39. package/ReactCommon/packages.lock.json +5 -5
  40. package/package.json +1 -1
@@ -0,0 +1,388 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #include <algorithm>
9
+ #include <cstddef>
10
+ #include <iostream>
11
+
12
+ #include <yoga/debug/AssertFatal.h>
13
+ #include <yoga/debug/Log.h>
14
+ #include <yoga/node/Node.h>
15
+ #include <yoga/numeric/Comparison.h>
16
+
17
+ namespace facebook::yoga {
18
+
19
+ Node::Node() : Node{&Config::getDefault()} {}
20
+
21
+ Node::Node(const yoga::Config* config) : config_{config} {
22
+ yoga::assertFatal(
23
+ config != nullptr, "Attempting to construct Node with null config");
24
+
25
+ if (config->useWebDefaults()) {
26
+ useWebDefaults();
27
+ }
28
+ }
29
+
30
+ Node::Node(Node&& node) noexcept
31
+ : hasNewLayout_(node.hasNewLayout_),
32
+ isReferenceBaseline_(node.isReferenceBaseline_),
33
+ isDirty_(node.isDirty_),
34
+ alwaysFormsContainingBlock_(node.alwaysFormsContainingBlock_),
35
+ nodeType_(node.nodeType_),
36
+ context_(node.context_),
37
+ measureFunc_(node.measureFunc_),
38
+ baselineFunc_(node.baselineFunc_),
39
+ dirtiedFunc_(node.dirtiedFunc_),
40
+ style_(std::move(node.style_)),
41
+ layout_(node.layout_),
42
+ lineIndex_(node.lineIndex_),
43
+ owner_(node.owner_),
44
+ children_(std::move(node.children_)),
45
+ config_(node.config_),
46
+ resolvedDimensions_(node.resolvedDimensions_) {
47
+ for (auto c : children_) {
48
+ c->setOwner(this);
49
+ }
50
+ }
51
+
52
+ YGSize Node::measure(
53
+ float availableWidth,
54
+ MeasureMode widthMode,
55
+ float availableHeight,
56
+ MeasureMode heightMode) {
57
+ const auto size = measureFunc_(
58
+ this,
59
+ availableWidth,
60
+ unscopedEnum(widthMode),
61
+ availableHeight,
62
+ unscopedEnum(heightMode));
63
+
64
+ if (yoga::isUndefined(size.height) || size.height < 0 ||
65
+ yoga::isUndefined(size.width) || size.width < 0) {
66
+ yoga::log(
67
+ this,
68
+ LogLevel::Warn,
69
+ "Measure function returned an invalid dimension to Yoga: [width=%f, height=%f]",
70
+ size.width,
71
+ size.height);
72
+ return {
73
+ .width = maxOrDefined(0.0f, size.width),
74
+ .height = maxOrDefined(0.0f, size.height)};
75
+ }
76
+
77
+ return size;
78
+ }
79
+
80
+ float Node::baseline(float width, float height) const {
81
+ return baselineFunc_(this, width, height);
82
+ }
83
+
84
+ float Node::dimensionWithMargin(
85
+ const FlexDirection axis,
86
+ const float widthSize) {
87
+ return getLayout().measuredDimension(dimension(axis)) +
88
+ style_.computeMarginForAxis(axis, widthSize);
89
+ }
90
+
91
+ bool Node::isLayoutDimensionDefined(const FlexDirection axis) {
92
+ const float value = getLayout().measuredDimension(dimension(axis));
93
+ return yoga::isDefined(value) && value >= 0.0f;
94
+ }
95
+
96
+ // Setters
97
+
98
+ void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
99
+ if (measureFunc == nullptr) {
100
+ // TODO: t18095186 Move nodeType to opt-in function and mark appropriate
101
+ // places in Litho
102
+ setNodeType(NodeType::Default);
103
+ } else {
104
+ yoga::assertFatalWithNode(
105
+ this,
106
+ children_.empty(),
107
+ "Cannot set measure function: Nodes with measure functions cannot have "
108
+ "children.");
109
+ // TODO: t18095186 Move nodeType to opt-in function and mark appropriate
110
+ // places in Litho
111
+ setNodeType(NodeType::Text);
112
+ }
113
+
114
+ measureFunc_ = measureFunc;
115
+ }
116
+
117
+ void Node::replaceChild(Node* child, size_t index) {
118
+ children_[index] = child;
119
+ }
120
+
121
+ void Node::replaceChild(Node* oldChild, Node* newChild) {
122
+ std::replace(children_.begin(), children_.end(), oldChild, newChild);
123
+ }
124
+
125
+ void Node::insertChild(Node* child, size_t index) {
126
+ children_.insert(children_.begin() + static_cast<ptrdiff_t>(index), child);
127
+ }
128
+
129
+ void Node::setConfig(yoga::Config* config) {
130
+ yoga::assertFatal(
131
+ config != nullptr, "Attempting to set a null config on a Node");
132
+ yoga::assertFatalWithConfig(
133
+ config,
134
+ config->useWebDefaults() == config_->useWebDefaults(),
135
+ "UseWebDefaults may not be changed after constructing a Node");
136
+
137
+ if (yoga::configUpdateInvalidatesLayout(*config_, *config)) {
138
+ markDirtyAndPropagate();
139
+ layout_.configVersion = 0; // [Windows #13409]
140
+ } else { // [Windows #13409]
141
+ // If the config is functionally the same, then align the configVersion so
142
+ // that we can reuse the layout cache
143
+ layout_.configVersion = config->getVersion(); // [Windows #13409]
144
+ }
145
+ config_ = config;
146
+ }
147
+
148
+ void Node::setDirty(bool isDirty) {
149
+ if (static_cast<int>(isDirty) == isDirty_) {
150
+ return;
151
+ }
152
+ isDirty_ = isDirty;
153
+ if (isDirty && (dirtiedFunc_ != nullptr)) {
154
+ dirtiedFunc_(this);
155
+ }
156
+ }
157
+
158
+ bool Node::removeChild(Node* child) {
159
+ auto p = std::find(children_.begin(), children_.end(), child);
160
+ if (p != children_.end()) {
161
+ children_.erase(p);
162
+ return true;
163
+ }
164
+ return false;
165
+ }
166
+
167
+ void Node::removeChild(size_t index) {
168
+ children_.erase(children_.begin() + static_cast<ptrdiff_t>(index));
169
+ }
170
+
171
+ void Node::setLayoutDirection(Direction direction) {
172
+ layout_.setDirection(direction);
173
+ }
174
+
175
+ void Node::setLayoutMargin(float margin, PhysicalEdge edge) {
176
+ layout_.setMargin(edge, margin);
177
+ }
178
+
179
+ void Node::setLayoutBorder(float border, PhysicalEdge edge) {
180
+ layout_.setBorder(edge, border);
181
+ }
182
+
183
+ void Node::setLayoutPadding(float padding, PhysicalEdge edge) {
184
+ layout_.setPadding(edge, padding);
185
+ }
186
+
187
+ void Node::setLayoutLastOwnerDirection(Direction direction) {
188
+ layout_.lastOwnerDirection = direction;
189
+ }
190
+
191
+ void Node::setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis) {
192
+ layout_.computedFlexBasis = computedFlexBasis;
193
+ }
194
+
195
+ void Node::setLayoutPosition(float position, PhysicalEdge edge) {
196
+ layout_.setPosition(edge, position);
197
+ }
198
+
199
+ void Node::setLayoutComputedFlexBasisGeneration(
200
+ uint32_t computedFlexBasisGeneration) {
201
+ layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
202
+ }
203
+
204
+ void Node::setLayoutMeasuredDimension(
205
+ float measuredDimension,
206
+ Dimension dimension) {
207
+ layout_.setMeasuredDimension(dimension, measuredDimension);
208
+ }
209
+
210
+ void Node::setLayoutHadOverflow(bool hadOverflow) {
211
+ layout_.setHadOverflow(hadOverflow);
212
+ }
213
+
214
+ void Node::setLayoutDimension(float LengthValue, Dimension dimension) {
215
+ layout_.setDimension(dimension, LengthValue);
216
+ }
217
+
218
+ // If both left and right are defined, then use left. Otherwise return +left or
219
+ // -right depending on which is defined. Ignore statically positioned nodes as
220
+ // insets do not apply to them.
221
+ float Node::relativePosition(
222
+ FlexDirection axis,
223
+ Direction direction,
224
+ float axisSize) const {
225
+ if (style_.positionType() == PositionType::Static) {
226
+ return 0;
227
+ }
228
+ if (style_.isInlineStartPositionDefined(axis, direction)) {
229
+ return style_.computeInlineStartPosition(axis, direction, axisSize);
230
+ }
231
+
232
+ return -1 * style_.computeInlineEndPosition(axis, direction, axisSize);
233
+ }
234
+
235
+ void Node::setPosition(
236
+ const Direction direction,
237
+ const float ownerWidth,
238
+ const float ownerHeight) {
239
+ /* Root nodes should be always layouted as LTR, so we don't return negative
240
+ * values. */
241
+ const Direction directionRespectingRoot =
242
+ owner_ != nullptr ? direction : Direction::LTR;
243
+ const FlexDirection mainAxis =
244
+ yoga::resolveDirection(style_.flexDirection(), directionRespectingRoot);
245
+ const FlexDirection crossAxis =
246
+ yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
247
+
248
+ // In the case of position static these are just 0. See:
249
+ // https://www.w3.org/TR/css-position-3/#valdef-position-static
250
+ const float relativePositionMain = relativePosition(
251
+ mainAxis,
252
+ directionRespectingRoot,
253
+ isRow(mainAxis) ? ownerWidth : ownerHeight);
254
+ const float relativePositionCross = relativePosition(
255
+ crossAxis,
256
+ directionRespectingRoot,
257
+ isRow(mainAxis) ? ownerHeight : ownerWidth);
258
+
259
+ const auto mainAxisLeadingEdge = inlineStartEdge(mainAxis, direction);
260
+ const auto mainAxisTrailingEdge = inlineEndEdge(mainAxis, direction);
261
+ const auto crossAxisLeadingEdge = inlineStartEdge(crossAxis, direction);
262
+ const auto crossAxisTrailingEdge = inlineEndEdge(crossAxis, direction);
263
+
264
+ setLayoutPosition(
265
+ (style_.computeInlineStartMargin(mainAxis, direction, ownerWidth) +
266
+ relativePositionMain),
267
+ mainAxisLeadingEdge);
268
+ setLayoutPosition(
269
+ (style_.computeInlineEndMargin(mainAxis, direction, ownerWidth) +
270
+ relativePositionMain),
271
+ mainAxisTrailingEdge);
272
+ setLayoutPosition(
273
+ (style_.computeInlineStartMargin(crossAxis, direction, ownerWidth) +
274
+ relativePositionCross),
275
+ crossAxisLeadingEdge);
276
+ setLayoutPosition(
277
+ (style_.computeInlineEndMargin(crossAxis, direction, ownerWidth) +
278
+ relativePositionCross),
279
+ crossAxisTrailingEdge);
280
+ }
281
+
282
+ Style::Length Node::resolveFlexBasisPtr() const {
283
+ Style::Length flexBasis = style_.flexBasis();
284
+ if (flexBasis.unit() != Unit::Auto && flexBasis.unit() != Unit::Undefined) {
285
+ return flexBasis;
286
+ }
287
+ if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
288
+ return config_->useWebDefaults() ? value::ofAuto() : value::points(0);
289
+ }
290
+ return value::ofAuto();
291
+ }
292
+
293
+ void Node::resolveDimension() {
294
+ for (auto dim : {Dimension::Width, Dimension::Height}) {
295
+ if (style_.maxDimension(dim).isDefined() &&
296
+ yoga::inexactEquals(
297
+ style_.maxDimension(dim), style_.minDimension(dim))) {
298
+ resolvedDimensions_[yoga::to_underlying(dim)] = style_.maxDimension(dim);
299
+ } else {
300
+ resolvedDimensions_[yoga::to_underlying(dim)] = style_.dimension(dim);
301
+ }
302
+ }
303
+ }
304
+
305
+ Direction Node::resolveDirection(const Direction ownerDirection) {
306
+ if (style_.direction() == Direction::Inherit) {
307
+ return ownerDirection != Direction::Inherit ? ownerDirection
308
+ : Direction::LTR;
309
+ } else {
310
+ return style_.direction();
311
+ }
312
+ }
313
+
314
+ void Node::clearChildren() {
315
+ children_.clear();
316
+ children_.shrink_to_fit();
317
+ }
318
+
319
+ // Other Methods
320
+
321
+ void Node::cloneChildrenIfNeeded() {
322
+ size_t i = 0;
323
+ for (Node*& child : children_) {
324
+ if (child->getOwner() != this) {
325
+ child = resolveRef(config_->cloneNode(child, this, i));
326
+ child->setOwner(this);
327
+ }
328
+ i += 1;
329
+ }
330
+ }
331
+
332
+ void Node::markDirtyAndPropagate() {
333
+ if (!isDirty_) {
334
+ setDirty(true);
335
+ setLayoutComputedFlexBasis(FloatOptional());
336
+ if (owner_ != nullptr) {
337
+ owner_->markDirtyAndPropagate();
338
+ }
339
+ }
340
+ }
341
+
342
+ float Node::resolveFlexGrow() const {
343
+ // Root nodes flexGrow should always be 0
344
+ if (owner_ == nullptr) {
345
+ return 0.0;
346
+ }
347
+ if (style_.flexGrow().isDefined()) {
348
+ return style_.flexGrow().unwrap();
349
+ }
350
+ if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
351
+ return style_.flex().unwrap();
352
+ }
353
+ return Style::DefaultFlexGrow;
354
+ }
355
+
356
+ float Node::resolveFlexShrink() const {
357
+ if (owner_ == nullptr) {
358
+ return 0.0;
359
+ }
360
+ if (style_.flexShrink().isDefined()) {
361
+ return style_.flexShrink().unwrap();
362
+ }
363
+ if (!config_->useWebDefaults() && style_.flex().isDefined() &&
364
+ style_.flex().unwrap() < 0.0f) {
365
+ return -style_.flex().unwrap();
366
+ }
367
+ return config_->useWebDefaults() ? Style::WebDefaultFlexShrink
368
+ : Style::DefaultFlexShrink;
369
+ }
370
+
371
+ bool Node::isNodeFlexible() {
372
+ return (
373
+ (style_.positionType() != PositionType::Absolute) &&
374
+ (resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
375
+ }
376
+
377
+ void Node::reset() {
378
+ yoga::assertFatalWithNode(
379
+ this,
380
+ children_.empty(),
381
+ "Cannot reset a node which still has children attached");
382
+ yoga::assertFatalWithNode(
383
+ this, owner_ == nullptr, "Cannot reset a node still attached to a owner");
384
+
385
+ *this = Node{getConfig()};
386
+ }
387
+
388
+ } // namespace facebook::yoga
@@ -4,9 +4,9 @@
4
4
  "native,Version=v0.0": {
5
5
  "boost": {
6
6
  "type": "Direct",
7
- "requested": "[1.76.0, )",
8
- "resolved": "1.76.0",
9
- "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
7
+ "requested": "[1.83.0, )",
8
+ "resolved": "1.83.0",
9
+ "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ=="
10
10
  },
11
11
  "fmt": {
12
12
  "type": "Project"
@@ -14,8 +14,8 @@
14
14
  "folly": {
15
15
  "type": "Project",
16
16
  "dependencies": {
17
- "boost": "[1.76.0, )",
18
- "fmt": "[1.0.0, )"
17
+ "Fmt": "[1.0.0, )",
18
+ "boost": "[1.83.0, )"
19
19
  }
20
20
  }
21
21
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.75.0-preview.4",
3
+ "version": "0.75.0-preview.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",