react-native-windows 0.0.0-canary.658 → 0.0.0-canary.660

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 (32) hide show
  1. package/.flowconfig +1 -1
  2. package/Directory.Build.props +3 -2
  3. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  4. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +1 -0
  5. package/Libraries/Core/ReactNativeVersion.js +2 -2
  6. package/Libraries/Lists/FlatList.d.ts +2 -1
  7. package/Libraries/Lists/FlatList.js +2 -2
  8. package/Libraries/Lists/SectionList.js +4 -0
  9. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  10. package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
  11. package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
  12. package/Libraries/NativeComponent/BaseViewConfig.windows.js +1 -0
  13. package/Libraries/ReactNative/AppRegistry.js +65 -52
  14. package/Libraries/Renderer/shims/ReactFabric.js +4 -4
  15. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
  16. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -20
  17. package/Libraries/Utilities/createPerformanceLogger.js +0 -4
  18. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +46 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +125 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +18 -0
  21. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +3 -2
  22. package/Microsoft.ReactNative/Views/ViewPanel.cpp +20 -189
  23. package/Microsoft.ReactNative/Views/ViewPanel.h +0 -22
  24. package/Microsoft.ReactNative/Views/ViewViewManager.cpp +17 -148
  25. package/Microsoft.ReactNative/Views/cppwinrt/ViewPanel.idl +1 -7
  26. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  27. package/PropertySheets/NuGet.Cpp.props +3 -2
  28. package/ReactCommon/ReactCommon.vcxproj +2 -0
  29. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphLayoutManager.cpp +95 -0
  30. package/ReactCommon/Yoga.cpp +29 -21
  31. package/Shared/Shared.vcxitems +25 -10
  32. package/package.json +12 -12
@@ -89,13 +89,6 @@ class ViewShadowNode : public ShadowNodeBase {
89
89
  m_isControl = isControl;
90
90
  }
91
91
 
92
- bool HasOuterBorder() {
93
- return m_hasOuterBorder;
94
- }
95
- void HasOuterBorder(bool hasOuterBorder) {
96
- m_hasOuterBorder = hasOuterBorder;
97
- }
98
-
99
92
  bool EnableFocusRing() {
100
93
  return m_enableFocusRing;
101
94
  }
@@ -161,12 +154,6 @@ class ViewShadowNode : public ShadowNodeBase {
161
154
  cdebug << "Tearing down, IsControl=true but the control is not a ContentControl, it's a " << name << "\n";
162
155
  }
163
156
  }
164
-
165
- if (HasOuterBorder()) {
166
- if (auto border = current.try_as<xaml::Controls::Border>()) {
167
- border.Child(nullptr);
168
- }
169
- }
170
157
  }
171
158
 
172
159
  void ReplaceChild(const XamlView &oldChildView, const XamlView &newChildView) override {
@@ -200,12 +187,6 @@ class ViewShadowNode : public ShadowNodeBase {
200
187
  }
201
188
  }
202
189
 
203
- if (HasOuterBorder()) {
204
- if (auto border = current.try_as<xaml::Controls::Border>()) {
205
- current = border.Child().try_as<XamlView>();
206
- }
207
- }
208
-
209
190
  auto panel = current.try_as<xaml::Controls::Panel>();
210
191
  assert(panel != nullptr);
211
192
 
@@ -242,8 +223,6 @@ class ViewShadowNode : public ShadowNodeBase {
242
223
 
243
224
  private:
244
225
  bool m_isControl = false;
245
- bool m_hasOuterBorder = false;
246
-
247
226
  bool m_enableFocusRing = true;
248
227
  bool m_onClick = false;
249
228
  int32_t m_tabIndex = std::numeric_limits<std::int32_t>::max();
@@ -252,87 +231,6 @@ class ViewShadowNode : public ShadowNodeBase {
252
231
  xaml::Controls::ContentControl::LostFocus_revoker m_contentControlLostFocusRevoker{};
253
232
  };
254
233
 
255
- // ViewPanel uses a ViewBackground property, not Background, so need to
256
- // specialize
257
- // PropertyUtils' TryUpdateBackgroundBrush to use ViewBackground.
258
- // Issue #2172: Additionally, we need to use
259
- // winrt::Microsoft::ReactNative::ViewPanel::implementation::ViewBackgroundProperty
260
- // rather than the proper projected type, because of how we're using cppwinrt.
261
-
262
- template <>
263
- bool TryUpdateBackgroundBrush(
264
- const winrt::Microsoft::ReactNative::ViewPanel &element,
265
- const std::string &propertyName,
266
- const winrt::Microsoft::ReactNative::JSValue &propertyValue) {
267
- if (propertyName == "backgroundColor") {
268
- if (IsValidColorValue(propertyValue))
269
- element.ViewBackground(BrushFrom(propertyValue));
270
- else if (propertyValue.IsNull())
271
- element.ClearValue(ViewPanel::ViewBackgroundProperty());
272
-
273
- return true;
274
- }
275
-
276
- return false;
277
- }
278
-
279
- // Issue #2172: Calling winrt::Microsoft::ReactNative::ViewPanel::BorderBrushProperty fails
280
- // to call
281
- // down into winrt::Microsoft::ReactNative::implementation::ViewPanel::BorderBrushProperty
282
- // because of how we're using cppwinrt. So we specialize PropertyUtils'
283
- // TryUpdateBorderProperties
284
- // to use winrt::Microsoft::ReactNative::ViewPanel::implementation::BorderBrushProperty
285
-
286
- template <>
287
- bool TryUpdateBorderProperties(
288
- ShadowNodeBase *node,
289
- const winrt::Microsoft::ReactNative::ViewPanel &element,
290
- const std::string &propertyName,
291
- const winrt::Microsoft::ReactNative::JSValue &propertyValue) {
292
- bool isBorderProperty = true;
293
-
294
- if (propertyName == "borderColor") {
295
- if (IsValidColorValue(propertyValue))
296
- element.BorderBrush(BrushFrom(propertyValue));
297
- else if (propertyValue.IsNull())
298
- element.ClearValue(ViewPanel::BorderBrushProperty());
299
- } else if (propertyName == "borderLeftWidth") {
300
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
301
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
302
- SetBorderThickness(node, element, ShadowEdges::Left, propertyValue.AsDouble());
303
- } else if (propertyName == "borderTopWidth") {
304
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
305
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
306
- SetBorderThickness(node, element, ShadowEdges::Top, propertyValue.AsDouble());
307
- } else if (propertyName == "borderRightWidth") {
308
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
309
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
310
- SetBorderThickness(node, element, ShadowEdges::Right, propertyValue.AsDouble());
311
- } else if (propertyName == "borderBottomWidth") {
312
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
313
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
314
- SetBorderThickness(node, element, ShadowEdges::Bottom, propertyValue.AsDouble());
315
- } else if (propertyName == "borderStartWidth") {
316
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
317
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
318
- SetBorderThickness(node, element, ShadowEdges::Start, propertyValue.AsDouble());
319
- } else if (propertyName == "borderEndWidth") {
320
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
321
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
322
- SetBorderThickness(node, element, ShadowEdges::End, propertyValue.AsDouble());
323
- } else if (propertyName == "borderWidth") {
324
- if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
325
- propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
326
- SetBorderThickness(node, element, ShadowEdges::AllEdges, propertyValue.AsDouble());
327
- else if (propertyValue.IsNull())
328
- element.ClearValue(ViewPanel::BorderThicknessProperty());
329
- } else {
330
- isBorderProperty = false;
331
- }
332
-
333
- return isBorderProperty;
334
- }
335
-
336
234
  // ViewViewManager
337
235
 
338
236
  ViewViewManager::ViewViewManager(const Mso::React::IReactContext &context) : Super(context) {}
@@ -364,7 +262,7 @@ XamlView ViewViewManager::CreateViewCore(int64_t /*tag*/, const winrt::Microsoft
364
262
  auto panel = winrt::make<winrt::Microsoft::ReactNative::implementation::ViewPanel>();
365
263
  panel.VerticalAlignment(xaml::VerticalAlignment::Stretch);
366
264
  panel.HorizontalAlignment(xaml::HorizontalAlignment::Stretch);
367
-
265
+ panel.BorderBrush(DefaultBrushStore::Instance().GetDefaultBorderBrush());
368
266
  return panel.as<XamlView>();
369
267
  }
370
268
 
@@ -389,19 +287,18 @@ bool ViewViewManager::UpdateProperty(
389
287
  auto pPanel = pViewShadowNode->GetPanel().as<winrt::Microsoft::ReactNative::ViewPanel>();
390
288
  bool ret = true;
391
289
  if (pPanel != nullptr) {
392
- if (TryUpdateBackgroundBrush(pPanel, propertyName, propertyValue)) {
290
+ if (TryUpdateBackgroundBrush(pPanel.as<xaml::Controls::Panel>(), propertyName, propertyValue)) {
393
291
  } else if (TryUpdateBorderProperties(nodeToUpdate, pPanel, propertyName, propertyValue)) {
394
292
  } else if (TryUpdateCornerRadiusOnNode(nodeToUpdate, pPanel, propertyName, propertyValue)) {
395
293
  // Do not clamp until a size has been set for the View
396
294
  auto maxCornerRadius = std::numeric_limits<double>::max();
397
295
  // The Width and Height properties are not always set on ViewPanel. In
398
- // cases where it is embedded in a Control or outer Border, the values
399
- // dimensions are set on those wrapper elements. We cannot depend on the
400
- // default behavior of `UpdateCornerRadiusOnElement` to check for the
401
- // clamp dimension from only the ViewPanel.
402
- const xaml::FrameworkElement sizingElement = pViewShadowNode->IsControl() ? pViewShadowNode->GetControl()
403
- : pViewShadowNode->HasOuterBorder() ? pPanel.GetOuterBorder().as<xaml::FrameworkElement>()
404
- : pPanel;
296
+ // cases where it is embedded in a Control, the values dimensions are
297
+ // set on those wrapper elements. We cannot depend on the default
298
+ // behavior of `UpdateCornerRadiusOnElement` to check for the clamp
299
+ // dimension from only the ViewPanel.
300
+ const xaml::FrameworkElement sizingElement =
301
+ pViewShadowNode->IsControl() ? pViewShadowNode->GetControl().as<xaml::FrameworkElement>() : pPanel;
405
302
  if (sizingElement.ReadLocalValue(xaml::FrameworkElement::WidthProperty()) !=
406
303
  xaml::DependencyProperty::UnsetValue() &&
407
304
  sizingElement.ReadLocalValue(xaml::FrameworkElement::HeightProperty()) !=
@@ -471,8 +368,6 @@ void ViewViewManager::OnPropertiesUpdated(ShadowNodeBase *node) {
471
368
  shouldBeControl = shouldBeControl || HasDynamicAutomationProperties(view);
472
369
  }
473
370
 
474
- panel.FinalizeProperties();
475
-
476
371
  TryUpdateView(viewShadowNode, panel, shouldBeControl);
477
372
  SyncFocusableAndAccessible(viewShadowNode, shouldBeControl);
478
373
  }
@@ -482,21 +377,19 @@ void ViewViewManager::TryUpdateView(
482
377
  winrt::Microsoft::ReactNative::ViewPanel &pPanel,
483
378
  bool useControl) {
484
379
  bool isControl = pViewShadowNode->IsControl();
485
- bool hadOuterBorder = pViewShadowNode->HasOuterBorder();
486
- bool hasOuterBorder = pPanel.GetOuterBorder() != nullptr;
487
380
 
488
381
  // This short-circuits all of the update code when we have the same hierarchy
489
- if (isControl == useControl && hadOuterBorder == hasOuterBorder)
382
+ if (isControl == useControl)
490
383
  return;
491
384
 
492
385
  //
493
386
  // 1. Ensure we have the new 'root' and do the child replacement
494
- // This is first to ensure that we can re-parent the Border or ViewPanel
387
+ // This is first to ensure that we can re-parent the ViewPanel
495
388
  // we already have
496
389
  // 2. Transfer properties
497
390
  // There are likely some complexities to handle here
498
391
  // 3. Do any sub=parenting
499
- // This means Panel under Border and/or Border under Control
392
+ // This means Panel under Control
500
393
  //
501
394
 
502
395
  XamlView oldXamlView(pViewShadowNode->GetView());
@@ -515,20 +408,15 @@ void ViewViewManager::TryUpdateView(
515
408
  }
516
409
 
517
410
  // Clean up child of Control if needed
518
- if (isControl && (!useControl || (hasOuterBorder != hadOuterBorder))) {
411
+ if (isControl) {
519
412
  pViewShadowNode->GetControl().Content(nullptr);
520
413
  }
521
414
 
522
- // If don't need a control, then set Outer Border or the Panel as the view
523
- // root
415
+ // If don't need a control, then set the Panel as the view root
524
416
  if (!useControl) {
525
- newXamlView = hasOuterBorder ? pPanel.GetOuterBorder().try_as<XamlView>() : pPanel.try_as<XamlView>();
417
+ newXamlView = pPanel;
526
418
  }
527
419
 
528
- // Clean up child of Border if needed
529
- if (hasOuterBorder && !hadOuterBorder)
530
- pPanel.GetOuterBorder().Child(nullptr);
531
-
532
420
  // ASSERT: One of the scenarios should be true, so we should have a root view
533
421
  assert(newXamlView != nullptr);
534
422
 
@@ -541,13 +429,8 @@ void ViewViewManager::TryUpdateView(
541
429
  TransferProperties(oldXamlView, newXamlView);
542
430
  }
543
431
 
544
- // Since we transferred properties to the new view we need to make the call to
545
- // finalize
546
- pPanel.FinalizeProperties();
547
-
548
432
  // Update the meta-data in the shadow node
549
433
  pViewShadowNode->IsControl(useControl);
550
- pViewShadowNode->HasOuterBorder(hasOuterBorder);
551
434
 
552
435
  //
553
436
  // 3. Setup any new parent-child relationships
@@ -574,19 +457,8 @@ void ViewViewManager::TryUpdateView(
574
457
  }
575
458
  }
576
459
 
577
- // Ensure parenting is setup properly
578
- auto visualRoot = pPanel.try_as<xaml::UIElement>();
579
-
580
- if (hasOuterBorder) {
581
- xaml::Controls::Border outerBorder = pPanel.GetOuterBorder();
582
- if (outerBorder.Child() == nullptr)
583
- outerBorder.Child(pPanel.try_as<xaml::UIElement>());
584
-
585
- visualRoot = outerBorder;
586
- }
587
-
588
460
  if (useControl)
589
- pViewShadowNode->GetControl().Content(visualRoot);
461
+ pViewShadowNode->GetControl().Content(pPanel);
590
462
  }
591
463
 
592
464
  void ViewViewManager::SyncFocusableAndAccessible(ViewShadowNode *pViewShadowNode, bool useControl) {
@@ -622,13 +494,10 @@ void ViewViewManager::SetLayoutProps(
622
494
 
623
495
  Super::SetLayoutProps(nodeToUpdate, viewToUpdate, left, top, width, height);
624
496
  if (pPanel.ReadLocalValue(ViewPanel::CornerRadiusProperty()) != xaml::DependencyProperty::UnsetValue()) {
625
- // Rather than use ViewPanel::FinalizeProperties, only perform the explicit
626
- // logic required to propagate the CornerRadius value to the Border parent.
627
- auto border = pPanel.GetOuterBorder();
628
- if (border) {
497
+ if (pPanel.GetValue(React::ViewPanel::CornerRadiusProperty()) != xaml::DependencyProperty::UnsetValue()) {
629
498
  const auto maxCornerRadius = std::min(width, height) / 2;
630
499
  UpdateCornerRadiusOnElement(&nodeToUpdate, pPanel, maxCornerRadius);
631
- border.CornerRadius(pPanel.CornerRadius());
500
+ pPanel.CornerRadius(pPanel.CornerRadius());
632
501
  }
633
502
  }
634
503
  }
@@ -8,7 +8,7 @@ namespace Microsoft.ReactNative
8
8
  {
9
9
  [default_interface]
10
10
  [webhosthidden]
11
- runtimeclass ViewPanel : XAML_NAMESPACE.Controls.Panel
11
+ runtimeclass ViewPanel : XAML_NAMESPACE.Controls.Grid
12
12
  {
13
13
  // Constructors
14
14
  ViewPanel();
@@ -18,14 +18,8 @@ namespace Microsoft.ReactNative
18
18
  void RemoveAt(UInt32 index);
19
19
  void Clear();
20
20
 
21
- void FinalizeProperties();
22
- XAML_NAMESPACE.Controls.Border GetOuterBorder();
23
-
24
21
  // Public Properties
25
22
  XAML_NAMESPACE.Media.Brush ViewBackground { get; set; };
26
- XAML_NAMESPACE.Thickness BorderThickness { get; set; };
27
- XAML_NAMESPACE.Media.Brush BorderBrush { get; set; };
28
- XAML_NAMESPACE.CornerRadius CornerRadius { get; set; };
29
23
 
30
24
  // ViewPanel Properties
31
25
  static XAML_NAMESPACE.DependencyProperty ViewBackgroundProperty { get; };
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.0.0-canary.658</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.0.0-canary.660</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
16
16
  <ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>true</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>684db1330d1a3e933274bd80e42e684a78f8e7c4</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>34cd46235b77dbdc08a4d4f56f7c7d0f0abd65a4</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
@@ -9,8 +9,9 @@
9
9
 
10
10
  <PropertyGroup Label="NuGet">
11
11
  <!-- Should match entry in $(ReactNativeWindowsDir)vnext\Directory.Build.props -->
12
- <!--See https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target-->
13
- <RestoreUseStaticGraphEvaluation Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(DisableRestoreUseStaticGraphEvaluation)' != 'true'">true</RestoreUseStaticGraphEvaluation>
12
+ <!-- See https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target -->
13
+ <!-- RestoreUseStaticGraphEvaluation broke in VS 17.6, see https://github.com/microsoft/react-native-windows/issues/11670 -->
14
+ <RestoreUseStaticGraphEvaluation Condition="'$(BuildingInsideVisualStudio)' == 'true' AND $([MSBuild]::VersionLessThan('$(MSBuildVersion)', '17.6')) AND '$(DisableRestoreUseStaticGraphEvaluation)' != 'true'">true</RestoreUseStaticGraphEvaluation>
14
15
 
15
16
  <!-- Ensure PackageReference compatibility for any consuming projects/apps -->
16
17
  <ResolveNuGetPackages>false</ResolveNuGetPackages>
@@ -160,11 +160,13 @@
160
160
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.h" />
161
161
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleBinding.h" />
162
162
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleUtils.h" />
163
+ <ClInclude Include="$(ReactNativeDir)\ReactCommon\react\renderer\core\PropsParserContext.h" />
163
164
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\bridging\LongLivedObject.cpp" />
164
165
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboCxxModule.cpp" />
165
166
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.cpp" />
166
167
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleBinding.cpp" />
167
168
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleUtils.cpp" />
169
+ <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\core\PropsParserContext.cpp" />
168
170
  <CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\samples\ReactCommon\NativeSampleTurboCxxModuleSpecJSI.cpp" />
169
171
  <CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\samples\ReactCommon\SampleTurboCxxModule.cpp" />
170
172
  </ItemGroup>
@@ -0,0 +1,95 @@
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 "ParagraphLayoutManager.h"
9
+ #include <folly/Hash.h>
10
+ #include <react/renderer/core/CoreFeatures.h>
11
+
12
+ namespace facebook::react {
13
+
14
+ TextMeasurement ParagraphLayoutManager::measure(
15
+ AttributedString const &attributedString,
16
+ ParagraphAttributes const &paragraphAttributes,
17
+ LayoutConstraints layoutConstraints) const {
18
+ if (CoreFeatures::cacheLastTextMeasurement) {
19
+ bool shouldMeasure = shoudMeasureString(
20
+ attributedString, paragraphAttributes, layoutConstraints);
21
+
22
+ if (shouldMeasure) {
23
+ cachedTextMeasurement_ = textLayoutManager_->measure(
24
+ AttributedStringBox(attributedString),
25
+ paragraphAttributes,
26
+ layoutConstraints,
27
+ hostTextStorage_);
28
+ lastAvailableWidth_ = layoutConstraints.maximumSize.width;
29
+ }
30
+
31
+ return cachedTextMeasurement_;
32
+ } else {
33
+ return textLayoutManager_->measure(
34
+ AttributedStringBox(attributedString),
35
+ paragraphAttributes,
36
+ layoutConstraints,
37
+ nullptr);
38
+ }
39
+ }
40
+
41
+ bool ParagraphLayoutManager::shoudMeasureString(
42
+ AttributedString const &attributedString,
43
+ ParagraphAttributes const &paragraphAttributes,
44
+ LayoutConstraints layoutConstraints) const {
45
+ size_t newHash = folly::hash::hash_combine(
46
+ 0,
47
+ textAttributedStringHashLayoutWise(attributedString),
48
+ paragraphAttributes);
49
+
50
+ if (newHash != paragraphInputHash_) {
51
+ // AttributedString or ParagraphAttributes have changed.
52
+ // Must create new host text storage and trigger measure.
53
+ hostTextStorage_ = textLayoutManager_->getHostTextStorage(
54
+ attributedString, paragraphAttributes, layoutConstraints);
55
+ paragraphInputHash_ = newHash;
56
+ return true; // Must measure again.
57
+ }
58
+
59
+ bool hasMaximumSizeChanged =
60
+ layoutConstraints.maximumSize.width != lastAvailableWidth_;
61
+ Float threshold = 0.01f; //Windows needs the "f" as we treat warnings as errors #11686
62
+ bool doesMaximumSizeMatchLastMeasurement =
63
+ std::abs(
64
+ layoutConstraints.maximumSize.width -
65
+ cachedTextMeasurement_.size.width) < threshold;
66
+ if (hasMaximumSizeChanged && !doesMaximumSizeMatchLastMeasurement) {
67
+ hostTextStorage_ = textLayoutManager_->getHostTextStorage(
68
+ attributedString, paragraphAttributes, layoutConstraints);
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+
74
+ LinesMeasurements ParagraphLayoutManager::measureLines(
75
+ AttributedString const &attributedString,
76
+ ParagraphAttributes const &paragraphAttributes,
77
+ Size size) const {
78
+ return textLayoutManager_->measureLines(
79
+ attributedString, paragraphAttributes, size);
80
+ }
81
+
82
+ void ParagraphLayoutManager::setTextLayoutManager(
83
+ std::shared_ptr<TextLayoutManager const> textLayoutManager) const {
84
+ textLayoutManager_ = std::move(textLayoutManager);
85
+ }
86
+
87
+ std::shared_ptr<TextLayoutManager const>
88
+ ParagraphLayoutManager::getTextLayoutManager() const {
89
+ return textLayoutManager_;
90
+ }
91
+
92
+ std::shared_ptr<void> ParagraphLayoutManager::getHostTextStorage() const {
93
+ return hostTextStorage_;
94
+ }
95
+ } // namespace facebook::react
@@ -43,8 +43,8 @@ static int YGDefaultLog(
43
43
  #ifdef ANDROID
44
44
  #include <android/log.h>
45
45
  static int YGAndroidLog(
46
- const YGConfigRef config,
47
- const YGNodeRef node,
46
+ const YGConfigRef /*config*/,
47
+ const YGNodeRef /*node*/,
48
48
  YGLogLevel level,
49
49
  const char *format,
50
50
  va_list args) {
@@ -232,6 +232,10 @@ YOGA_EXPORT void YGNodeFree(const YGNodeRef node) {
232
232
  }
233
233
 
234
234
  node->clearChildren();
235
+ YGNodeDeallocate(node);
236
+ }
237
+
238
+ YOGA_EXPORT void YGNodeDeallocate(const YGNodeRef node) {
235
239
  Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
236
240
  delete node;
237
241
  }
@@ -843,7 +847,7 @@ YOGA_EXPORT void YGNodeStyleSetMinWidthPercent(
843
847
  }
844
848
  YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
845
849
  return node->getStyle().minDimensions()[YGDimensionWidth];
846
- };
850
+ }
847
851
 
848
852
  YOGA_EXPORT void YGNodeStyleSetMinHeight(
849
853
  const YGNodeRef node,
@@ -861,7 +865,7 @@ YOGA_EXPORT void YGNodeStyleSetMinHeightPercent(
861
865
  }
862
866
  YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
863
867
  return node->getStyle().minDimensions()[YGDimensionHeight];
864
- };
868
+ }
865
869
 
866
870
  YOGA_EXPORT void YGNodeStyleSetMaxWidth(
867
871
  const YGNodeRef node,
@@ -879,7 +883,7 @@ YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent(
879
883
  }
880
884
  YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
881
885
  return node->getStyle().maxDimensions()[YGDimensionWidth];
882
- };
886
+ }
883
887
 
884
888
  YOGA_EXPORT void YGNodeStyleSetMaxHeight(
885
889
  const YGNodeRef node,
@@ -897,7 +901,7 @@ YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent(
897
901
  }
898
902
  YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
899
903
  return node->getStyle().maxDimensions()[YGDimensionHeight];
900
- };
904
+ }
901
905
 
902
906
  #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
903
907
  YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node) { \
@@ -931,18 +935,18 @@ YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
931
935
  return node->getLayout().instanceName[edge]; \
932
936
  }
933
937
 
934
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft]);
935
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop]);
936
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]);
937
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]);
938
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
939
- YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
940
- YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction());
941
- YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow());
938
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft])
939
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop])
940
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight])
941
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom])
942
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth])
943
+ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight])
944
+ YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction())
945
+ YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow())
942
946
 
943
- YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
944
- YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
945
- YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
947
+ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin)
948
+ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border)
949
+ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding)
946
950
 
947
951
  std::atomic<uint32_t> gCurrentGenerationCount(0);
948
952
 
@@ -2981,7 +2985,7 @@ static void YGNodelayoutImpl(
2981
2985
  availableInnerMainDim = maxInnerMainDim;
2982
2986
  } else {
2983
2987
  bool useLegacyStretchBehaviour =
2984
- node->getConfig()->getErrata() & YGErrataStretchFlexBasis;
2988
+ node->hasErrata(YGErrataStretchFlexBasis);
2985
2989
 
2986
2990
  if (!useLegacyStretchBehaviour &&
2987
2991
  ((!YGFloatIsUndefined(
@@ -4076,6 +4080,10 @@ YOGA_EXPORT void YGConfigSetPointScaleFactor(
4076
4080
  }
4077
4081
  }
4078
4082
 
4083
+ YOGA_EXPORT float YGConfigGetPointScaleFactor(const YGConfigRef config) {
4084
+ return config->getPointScaleFactor();
4085
+ }
4086
+
4079
4087
  static void YGRoundToPixelGrid(
4080
4088
  const YGNodeRef node,
4081
4089
  const double pointScaleFactor,
@@ -4305,16 +4313,16 @@ YOGA_EXPORT void YGConfigSetUseWebDefaults(
4305
4313
 
4306
4314
  YOGA_EXPORT bool YGConfigGetUseLegacyStretchBehaviour(
4307
4315
  const YGConfigRef config) {
4308
- return config->getErrata() & YGErrataStretchFlexBasis;
4316
+ return config->hasErrata(YGErrataStretchFlexBasis);
4309
4317
  }
4310
4318
 
4311
4319
  YOGA_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
4312
4320
  const YGConfigRef config,
4313
4321
  const bool useLegacyStretchBehaviour) {
4314
4322
  if (useLegacyStretchBehaviour) {
4315
- config->setErrata(config->getErrata() | YGErrataStretchFlexBasis);
4323
+ config->addErrata(YGErrataStretchFlexBasis);
4316
4324
  } else {
4317
- config->setErrata(config->getErrata() & ~YGErrataStretchFlexBasis);
4325
+ config->removeErrata(YGErrataStretchFlexBasis);
4318
4326
  }
4319
4327
  }
4320
4328
 
@@ -36,6 +36,11 @@
36
36
  <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionContext.idl</DependentUpon>
37
37
  <SubType>Code</SubType>
38
38
  </ClCompile>
39
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionContextHelper_emptyimpl.cpp">
40
+ <ExcludedFromBuild Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' != 'true'">true</ExcludedFromBuild>
41
+ <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionContext.idl</DependentUpon>
42
+ <SubType>Code</SubType>
43
+ </ClCompile>
39
44
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ReactCompositionViewComponentBuilder.cpp">
40
45
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
41
46
  <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactCompositionViewComponentBuilder.idl</DependentUpon>
@@ -63,10 +68,20 @@
63
68
  <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionRootView.idl</DependentUpon>
64
69
  <SubType>Code</SubType>
65
70
  </ClCompile>
71
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionRootView_emptyimpl.cpp">
72
+ <ExcludedFromBuild Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' != 'true'">true</ExcludedFromBuild>
73
+ <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionRootView.idl</DependentUpon>
74
+ <SubType>Code</SubType>
75
+ </ClCompile>
66
76
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionUIService.cpp">
67
77
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
68
78
  <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionUIService.idl</DependentUpon>
69
79
  <SubType>Code</SubType>
80
+ </ClCompile>
81
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionUIService_emptyimpl.cpp">
82
+ <ExcludedFromBuild Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' != 'true'">true</ExcludedFromBuild>
83
+ <DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionUIService.idl</DependentUpon>
84
+ <SubType>Code</SubType>
70
85
  </ClCompile>
71
86
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\CompositionViewComponentView.cpp">
72
87
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
@@ -505,15 +520,15 @@
505
520
  <Midl Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeHost.idl" />
506
521
  <Midl Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\RedBoxHandler.idl" />
507
522
  </ItemGroup>
508
- <ItemGroup Condition="'$(UseFabric)' == 'true'">
509
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionContext.idl" />
510
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionHwndHost.idl" />
511
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionRootView.idl" />
512
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionSwitcher.idl" />
513
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionUIService.idl" />
514
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactCompositionViewComponentBuilder.idl" />
515
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactPackageBuilderFabric.idl" />
516
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactViewComponentBuilder.idl" />
517
- <Midl Condition="'$(UseFabric)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\ViewProps.idl" />
523
+ <ItemGroup Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'">
524
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionContext.idl" />
525
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionHwndHost.idl" />
526
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionRootView.idl" />
527
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionSwitcher.idl" />
528
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionUIService.idl" />
529
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactCompositionViewComponentBuilder.idl" />
530
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactPackageBuilderFabric.idl" />
531
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IReactViewComponentBuilder.idl" />
532
+ <Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\ViewProps.idl" />
518
533
  </ItemGroup>
519
534
  </Project>