react-native-windows 0.74.10 → 0.74.11
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.
- package/Libraries/Components/TextInput/TextInput.js +6 -3
- package/Libraries/Components/TextInput/TextInput.windows.js +6 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +10 -0
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +42 -17
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +3 -1
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +5 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +140 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +92 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +48 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +122 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +366 -0
- package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +6 -6
- package/package.json +13 -13
|
@@ -1135,12 +1135,14 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1135
1135
|
};
|
|
1136
1136
|
|
|
1137
1137
|
const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
|
|
1138
|
-
|
|
1139
1138
|
const [lastNativeText, setLastNativeText] = useState<?Stringish>(props.value);
|
|
1140
1139
|
const [lastNativeSelectionState, setLastNativeSelection] = useState<{|
|
|
1141
|
-
selection:
|
|
1140
|
+
selection: Selection,
|
|
1142
1141
|
mostRecentEventCount: number,
|
|
1143
|
-
|}>({
|
|
1142
|
+
|}>({
|
|
1143
|
+
selection: {start: -1, end: -1},
|
|
1144
|
+
mostRecentEventCount: mostRecentEventCount,
|
|
1145
|
+
});
|
|
1144
1146
|
|
|
1145
1147
|
const lastNativeSelection = lastNativeSelectionState.selection;
|
|
1146
1148
|
|
|
@@ -1498,6 +1500,7 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1498
1500
|
onSelectionChange={_onSelectionChange}
|
|
1499
1501
|
onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
|
|
1500
1502
|
selection={selection}
|
|
1503
|
+
selectionColor={selectionColor}
|
|
1501
1504
|
style={StyleSheet.compose(
|
|
1502
1505
|
useMultilineDefaultStyle ? styles.multilineDefault : null,
|
|
1503
1506
|
style,
|
|
@@ -1212,12 +1212,14 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1212
1212
|
};
|
|
1213
1213
|
|
|
1214
1214
|
const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
|
|
1215
|
-
|
|
1216
1215
|
const [lastNativeText, setLastNativeText] = useState<?Stringish>(props.value);
|
|
1217
1216
|
const [lastNativeSelectionState, setLastNativeSelection] = useState<{|
|
|
1218
|
-
selection:
|
|
1217
|
+
selection: Selection,
|
|
1219
1218
|
mostRecentEventCount: number,
|
|
1220
|
-
|}>({
|
|
1219
|
+
|}>({
|
|
1220
|
+
selection: {start: -1, end: -1},
|
|
1221
|
+
mostRecentEventCount: mostRecentEventCount,
|
|
1222
|
+
});
|
|
1221
1223
|
|
|
1222
1224
|
const lastNativeSelection = lastNativeSelectionState.selection;
|
|
1223
1225
|
|
|
@@ -1649,6 +1651,7 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1649
1651
|
onSelectionChange={_onSelectionChange}
|
|
1650
1652
|
onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
|
|
1651
1653
|
selection={selection}
|
|
1654
|
+
selectionColor={selectionColor}
|
|
1652
1655
|
style={StyleSheet.compose(
|
|
1653
1656
|
useMultilineDefaultStyle ? styles.multilineDefault : null,
|
|
1654
1657
|
style,
|
|
@@ -602,6 +602,8 @@ void SetBorderLayerPropertiesCommon(
|
|
|
602
602
|
facebook::react::BorderStyle borderStyle) {
|
|
603
603
|
layer.Offset({anchorOffset.x, anchorOffset.y, 0}, {anchorPoint.x, anchorPoint.y, 0});
|
|
604
604
|
layer.RelativeSizeWithOffset(size, relativeSizeAdjustment);
|
|
605
|
+
layer.as<::Microsoft::ReactNative::Composition::Experimental::IVisualInterop>()->SetClippingPath(nullptr);
|
|
606
|
+
|
|
605
607
|
if ((textureRect.right - textureRect.left) <= 0 || (textureRect.bottom - textureRect.top) <= 0)
|
|
606
608
|
return;
|
|
607
609
|
|
|
@@ -703,7 +705,8 @@ void SetBorderLayerProperties(
|
|
|
703
705
|
// if (VisualVersion::IsUseWinCompClippingRegionEnabled())
|
|
704
706
|
{
|
|
705
707
|
layer.Offset({anchorOffset.x, anchorOffset.y, 0}, {anchorPoint.x, anchorPoint.y, 0});
|
|
706
|
-
layer.
|
|
708
|
+
layer.RelativeSizeWithOffset(
|
|
709
|
+
{textureRect.right - textureRect.left, textureRect.bottom - textureRect.top}, {0.0f, 0.0f});
|
|
707
710
|
|
|
708
711
|
layer.Brush(theme->Brush(*borderColor));
|
|
709
712
|
|
|
@@ -83,6 +83,16 @@ void ParagraphComponentView::updateState(
|
|
|
83
83
|
m_textLayout = nullptr;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
void ParagraphComponentView::updateLayoutMetrics(
|
|
87
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
88
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
|
|
89
|
+
Super::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
|
|
90
|
+
|
|
91
|
+
if (layoutMetrics.pointScaleFactor != oldLayoutMetrics.pointScaleFactor) {
|
|
92
|
+
m_textLayout = nullptr;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
void ParagraphComponentView::FinalizeUpdates(
|
|
87
97
|
winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept {
|
|
88
98
|
ensureVisual();
|
|
@@ -34,6 +34,9 @@ struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView,
|
|
|
34
34
|
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
|
|
35
35
|
override;
|
|
36
36
|
void updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept override;
|
|
37
|
+
void updateLayoutMetrics(
|
|
38
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
39
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
37
40
|
void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept
|
|
38
41
|
override;
|
|
39
42
|
void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
|
|
@@ -125,6 +125,15 @@ inline Mso::Future<void> CompositionReactViewInstance::PostInUIQueue(TAction &&a
|
|
|
125
125
|
return promise.AsFuture();
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
void ApplyConstraints(
|
|
129
|
+
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraintsIn,
|
|
130
|
+
facebook::react::LayoutConstraints &layoutConstraintsOut) noexcept {
|
|
131
|
+
layoutConstraintsOut.minimumSize = {layoutConstraintsIn.MinimumSize.Width, layoutConstraintsIn.MinimumSize.Height};
|
|
132
|
+
layoutConstraintsOut.maximumSize = {layoutConstraintsIn.MaximumSize.Width, layoutConstraintsIn.MaximumSize.Height};
|
|
133
|
+
layoutConstraintsOut.layoutDirection =
|
|
134
|
+
static_cast<facebook::react::LayoutDirection>(layoutConstraintsIn.LayoutDirection);
|
|
135
|
+
}
|
|
136
|
+
|
|
128
137
|
ReactNativeIsland::ReactNativeIsland() noexcept {}
|
|
129
138
|
|
|
130
139
|
#ifdef USE_WINUI3
|
|
@@ -136,6 +145,7 @@ ReactNativeIsland::~ReactNativeIsland() noexcept {
|
|
|
136
145
|
#ifdef USE_WINUI3
|
|
137
146
|
if (m_island && m_island.IsConnected()) {
|
|
138
147
|
m_island.AutomationProviderRequested(m_islandAutomationProviderRequestedToken);
|
|
148
|
+
m_island.StateChanged(m_islandStateChangedToken);
|
|
139
149
|
}
|
|
140
150
|
#endif
|
|
141
151
|
|
|
@@ -251,6 +261,7 @@ void ReactNativeIsland::ScaleFactor(float value) noexcept {
|
|
|
251
261
|
rootView.Scale({invScale, invScale, invScale});
|
|
252
262
|
}
|
|
253
263
|
UpdateRootVisualSize();
|
|
264
|
+
Arrange(m_layoutConstraints, m_viewportOffset);
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
|
|
@@ -471,10 +482,14 @@ void ReactNativeIsland::ShowInstanceLoaded() noexcept {
|
|
|
471
482
|
initProps = folly::dynamic::object();
|
|
472
483
|
}
|
|
473
484
|
initProps["concurrentRoot"] = true;
|
|
485
|
+
|
|
486
|
+
facebook::react::LayoutConstraints fbLayoutConstraints;
|
|
487
|
+
ApplyConstraints(m_layoutConstraints, fbLayoutConstraints);
|
|
488
|
+
|
|
474
489
|
uiManager->startSurface(
|
|
475
490
|
*this,
|
|
476
491
|
static_cast<facebook::react::SurfaceId>(m_rootTag),
|
|
477
|
-
|
|
492
|
+
fbLayoutConstraints,
|
|
478
493
|
to_string(m_reactViewOptions.ComponentName()),
|
|
479
494
|
initProps);
|
|
480
495
|
|
|
@@ -491,16 +506,21 @@ facebook::react::AttributedStringBox CreateLoadingAttributedString() noexcept {
|
|
|
491
506
|
return facebook::react::AttributedStringBox{attributedString};
|
|
492
507
|
}
|
|
493
508
|
|
|
494
|
-
facebook::react::Size MeasureLoading(
|
|
509
|
+
facebook::react::Size MeasureLoading(
|
|
510
|
+
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
511
|
+
float scaleFactor) {
|
|
512
|
+
facebook::react::LayoutConstraints fbLayoutConstraints;
|
|
513
|
+
ApplyConstraints(layoutConstraints, fbLayoutConstraints);
|
|
514
|
+
|
|
495
515
|
auto attributedStringBox = CreateLoadingAttributedString();
|
|
496
516
|
winrt::com_ptr<::IDWriteTextLayout> textLayout;
|
|
497
517
|
facebook::react::TextLayoutManager::GetTextLayout(
|
|
498
|
-
attributedStringBox, {} /*paragraphAttributes*/,
|
|
518
|
+
attributedStringBox, {} /*paragraphAttributes*/, fbLayoutConstraints, textLayout);
|
|
499
519
|
|
|
500
520
|
DWRITE_TEXT_METRICS tm;
|
|
501
521
|
textLayout->GetMetrics(&tm);
|
|
502
522
|
|
|
503
|
-
return
|
|
523
|
+
return fbLayoutConstraints.clamp(
|
|
504
524
|
{loadingActivityHorizontalOffset * scaleFactor + tm.width, loadingBarHeight * scaleFactor});
|
|
505
525
|
}
|
|
506
526
|
|
|
@@ -625,15 +645,6 @@ void ReactNativeIsland::ShowInstanceLoading() noexcept {
|
|
|
625
645
|
InternalRootVisual().InsertAt(m_loadingVisual, m_hasRenderedVisual ? 1 : 0);
|
|
626
646
|
}
|
|
627
647
|
|
|
628
|
-
void ApplyConstraints(
|
|
629
|
-
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraintsIn,
|
|
630
|
-
facebook::react::LayoutConstraints &layoutConstraintsOut) noexcept {
|
|
631
|
-
layoutConstraintsOut.minimumSize = {layoutConstraintsIn.MinimumSize.Width, layoutConstraintsIn.MinimumSize.Height};
|
|
632
|
-
layoutConstraintsOut.maximumSize = {layoutConstraintsIn.MaximumSize.Width, layoutConstraintsIn.MaximumSize.Height};
|
|
633
|
-
layoutConstraintsOut.layoutDirection =
|
|
634
|
-
static_cast<facebook::react::LayoutDirection>(layoutConstraintsIn.LayoutDirection);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
648
|
winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
638
649
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
639
650
|
const winrt::Windows::Foundation::Point &viewportOffset) const noexcept {
|
|
@@ -654,7 +665,7 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
|
654
665
|
size = fabricuiManager->measureSurface(static_cast<facebook::react::SurfaceId>(m_rootTag), constraints, context);
|
|
655
666
|
}
|
|
656
667
|
} else if (m_loadingVisual) {
|
|
657
|
-
size = MeasureLoading(
|
|
668
|
+
size = MeasureLoading(layoutConstraints, m_scaleFactor);
|
|
658
669
|
}
|
|
659
670
|
|
|
660
671
|
auto clampedSize = constraints.clamp(size);
|
|
@@ -664,7 +675,10 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
|
|
|
664
675
|
void ReactNativeIsland::Arrange(
|
|
665
676
|
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
|
|
666
677
|
const winrt::Windows::Foundation::Point &viewportOffset) noexcept {
|
|
667
|
-
|
|
678
|
+
m_layoutConstraints = layoutConstraints;
|
|
679
|
+
m_viewportOffset = viewportOffset;
|
|
680
|
+
facebook::react::LayoutConstraints fbLayoutConstraints;
|
|
681
|
+
ApplyConstraints(layoutConstraints, fbLayoutConstraints);
|
|
668
682
|
|
|
669
683
|
if (m_isInitialized && m_rootTag != -1) {
|
|
670
684
|
if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
|
|
@@ -675,11 +689,11 @@ void ReactNativeIsland::Arrange(
|
|
|
675
689
|
context.viewportOffset = {viewportOffset.X, viewportOffset.Y};
|
|
676
690
|
|
|
677
691
|
fabricuiManager->constraintSurfaceLayout(
|
|
678
|
-
static_cast<facebook::react::SurfaceId>(m_rootTag),
|
|
692
|
+
static_cast<facebook::react::SurfaceId>(m_rootTag), fbLayoutConstraints, context);
|
|
679
693
|
}
|
|
680
694
|
} else if (m_loadingVisual) {
|
|
681
695
|
// TODO: Resize to align loading
|
|
682
|
-
auto s =
|
|
696
|
+
auto s = fbLayoutConstraints.clamp(MeasureLoading(layoutConstraints, m_scaleFactor));
|
|
683
697
|
NotifySizeChanged();
|
|
684
698
|
}
|
|
685
699
|
}
|
|
@@ -729,6 +743,17 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
|
|
|
729
743
|
pThis->m_island = nullptr;
|
|
730
744
|
}
|
|
731
745
|
});
|
|
746
|
+
|
|
747
|
+
m_islandStateChangedToken =
|
|
748
|
+
m_island.StateChanged([weakThis = get_weak()](
|
|
749
|
+
winrt::Microsoft::UI::Content::ContentIsland const &island,
|
|
750
|
+
winrt::Microsoft::UI::Content::ContentIslandStateChangedEventArgs const &args) {
|
|
751
|
+
if (auto pThis = weakThis.get()) {
|
|
752
|
+
if (args.DidRasterizationScaleChange()) {
|
|
753
|
+
pThis->ScaleFactor(island.RasterizationScale());
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
});
|
|
732
757
|
}
|
|
733
758
|
return m_island;
|
|
734
759
|
}
|
|
@@ -125,6 +125,7 @@ struct ReactNativeIsland
|
|
|
125
125
|
winrt::Microsoft::UI::Content::ContentIsland m_island{nullptr};
|
|
126
126
|
winrt::event_token m_islandFrameworkClosedToken;
|
|
127
127
|
winrt::event_token m_islandAutomationProviderRequestedToken;
|
|
128
|
+
winrt::event_token m_islandStateChangedToken;
|
|
128
129
|
#endif
|
|
129
130
|
|
|
130
131
|
HWND m_hwnd{0};
|
|
@@ -147,7 +148,8 @@ struct ReactNativeIsland
|
|
|
147
148
|
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader m_resources{nullptr};
|
|
148
149
|
winrt::Microsoft::ReactNative::Composition::Theme m_theme{nullptr};
|
|
149
150
|
winrt::Microsoft::ReactNative::Composition::Theme::ThemeChanged_revoker m_themeChangedRevoker;
|
|
150
|
-
|
|
151
|
+
winrt::Microsoft::ReactNative::LayoutConstraints m_layoutConstraints;
|
|
152
|
+
winrt::Windows::Foundation::Point m_viewportOffset{0, 0};
|
|
151
153
|
winrt::event<winrt::Windows::Foundation::EventHandler<winrt::Microsoft::ReactNative::RootViewSizeChangedEventArgs>>
|
|
152
154
|
m_sizeChangedEvent;
|
|
153
155
|
|
|
@@ -87,6 +87,11 @@ WindowsImageManager::GetImageRandomAccessStreamAsync(ReactImageSource source) co
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
winrt::Windows::Storage::StorageFile file(co_await getFileSync);
|
|
90
|
+
|
|
91
|
+
if (!file) {
|
|
92
|
+
co_return winrt::Microsoft::ReactNative::Composition::ImageFailedResponse(L"Failed to get file.");
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
co_return winrt::Microsoft::ReactNative::Composition::StreamImageResponse(co_await file.OpenReadAsync());
|
|
91
96
|
}
|
|
92
97
|
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.74.
|
|
13
|
+
<ReactNativeWindowsVersion>0.74.11</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>11</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>71a102ac500541f38b7b8bf3b919c5cc8f3494a6</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -2120,6 +2120,7 @@ bool calculateLayoutInternal(
|
|
|
2120
2120
|
|
|
2121
2121
|
const bool needToVisitNode =
|
|
2122
2122
|
(node->isDirty() && layout->generationCount != generationCount) ||
|
|
2123
|
+
layout->configVersion != node->getConfig()->getVersion() || // [Windows]
|
|
2123
2124
|
layout->lastOwnerDirection != ownerDirection;
|
|
2124
2125
|
|
|
2125
2126
|
if (needToVisitNode) {
|
|
@@ -2235,6 +2236,7 @@ bool calculateLayoutInternal(
|
|
|
2235
2236
|
reason);
|
|
2236
2237
|
|
|
2237
2238
|
layout->lastOwnerDirection = ownerDirection;
|
|
2239
|
+
layout->configVersion = node->getConfig()->getVersion(); // [Windows]
|
|
2238
2240
|
|
|
2239
2241
|
if (cachedResults == nullptr) {
|
|
2240
2242
|
layoutMarkerData.maxMeasureCache = std::max(
|
|
@@ -0,0 +1,140 @@
|
|
|
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 <yoga/config/Config.h>
|
|
9
|
+
#include <yoga/debug/Log.h>
|
|
10
|
+
#include <yoga/node/Node.h>
|
|
11
|
+
|
|
12
|
+
namespace facebook::yoga {
|
|
13
|
+
|
|
14
|
+
bool configUpdateInvalidatesLayout(
|
|
15
|
+
const Config& oldConfig,
|
|
16
|
+
const Config& newConfig) {
|
|
17
|
+
return oldConfig.getErrata() != newConfig.getErrata() ||
|
|
18
|
+
oldConfig.getEnabledExperiments() != newConfig.getEnabledExperiments() ||
|
|
19
|
+
oldConfig.getPointScaleFactor() != newConfig.getPointScaleFactor() ||
|
|
20
|
+
oldConfig.useWebDefaults() != newConfig.useWebDefaults();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Config::Config(YGLogger logger) : cloneNodeCallback_{nullptr} {
|
|
24
|
+
setLogger(logger);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void Config::setUseWebDefaults(bool useWebDefaults) {
|
|
28
|
+
useWebDefaults_ = useWebDefaults;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
bool Config::useWebDefaults() const {
|
|
32
|
+
return useWebDefaults_;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void Config::setExperimentalFeatureEnabled(
|
|
36
|
+
ExperimentalFeature feature,
|
|
37
|
+
bool enabled) {
|
|
38
|
+
if (isExperimentalFeatureEnabled(feature) != enabled) {
|
|
39
|
+
experimentalFeatures_.set(static_cast<size_t>(feature), enabled);
|
|
40
|
+
version_++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
bool Config::isExperimentalFeatureEnabled(ExperimentalFeature feature) const {
|
|
45
|
+
return experimentalFeatures_.test(static_cast<size_t>(feature));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ExperimentalFeatureSet Config::getEnabledExperiments() const {
|
|
49
|
+
return experimentalFeatures_;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void Config::setErrata(Errata errata) {
|
|
53
|
+
if (errata_ != errata) {
|
|
54
|
+
errata_ = errata;
|
|
55
|
+
version_++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void Config::addErrata(Errata errata) {
|
|
60
|
+
if (!hasErrata(errata)) {
|
|
61
|
+
errata_ |= errata;
|
|
62
|
+
version_++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void Config::removeErrata(Errata errata) {
|
|
67
|
+
if (hasErrata(errata)) {
|
|
68
|
+
errata_ &= (~errata);
|
|
69
|
+
version_++;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Errata Config::getErrata() const {
|
|
74
|
+
return errata_;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
bool Config::hasErrata(Errata errata) const {
|
|
78
|
+
return (errata_ & errata) != Errata::None;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void Config::setPointScaleFactor(float pointScaleFactor) {
|
|
82
|
+
if (pointScaleFactor_ != pointScaleFactor) {
|
|
83
|
+
pointScaleFactor_ = pointScaleFactor;
|
|
84
|
+
version_++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
float Config::getPointScaleFactor() const {
|
|
89
|
+
return pointScaleFactor_;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void Config::setContext(void* context) {
|
|
93
|
+
context_ = context;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void* Config::getContext() const {
|
|
97
|
+
return context_;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// [Windows #13409]
|
|
101
|
+
uint32_t Config::getVersion() const noexcept {
|
|
102
|
+
return version_;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void Config::setLogger(YGLogger logger) {
|
|
106
|
+
logger_ = logger;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void Config::log(
|
|
110
|
+
const yoga::Node* node,
|
|
111
|
+
LogLevel logLevel,
|
|
112
|
+
const char* format,
|
|
113
|
+
va_list args) const {
|
|
114
|
+
logger_(this, node, unscopedEnum(logLevel), format, args);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void Config::setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
|
118
|
+
cloneNodeCallback_ = cloneNode;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
YGNodeRef Config::cloneNode(
|
|
122
|
+
YGNodeConstRef node,
|
|
123
|
+
YGNodeConstRef owner,
|
|
124
|
+
size_t childIndex) const {
|
|
125
|
+
YGNodeRef clone = nullptr;
|
|
126
|
+
if (cloneNodeCallback_ != nullptr) {
|
|
127
|
+
clone = cloneNodeCallback_(node, owner, childIndex);
|
|
128
|
+
}
|
|
129
|
+
if (clone == nullptr) {
|
|
130
|
+
clone = YGNodeClone(node);
|
|
131
|
+
}
|
|
132
|
+
return clone;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/*static*/ const Config& Config::getDefault() {
|
|
136
|
+
static Config config{getDefaultLogger()};
|
|
137
|
+
return config;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
} // namespace facebook::yoga
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <bitset>
|
|
11
|
+
|
|
12
|
+
#include <yoga/Yoga.h>
|
|
13
|
+
#include <yoga/enums/Errata.h>
|
|
14
|
+
#include <yoga/enums/ExperimentalFeature.h>
|
|
15
|
+
#include <yoga/enums/LogLevel.h>
|
|
16
|
+
|
|
17
|
+
// Tag struct used to form the opaque YGConfigRef for the public C API
|
|
18
|
+
struct YGConfig {};
|
|
19
|
+
|
|
20
|
+
namespace facebook::yoga {
|
|
21
|
+
|
|
22
|
+
class Config;
|
|
23
|
+
class Node;
|
|
24
|
+
|
|
25
|
+
using ExperimentalFeatureSet = std::bitset<ordinalCount<ExperimentalFeature>()>;
|
|
26
|
+
|
|
27
|
+
// Whether moving a node from an old to new config should dirty previously
|
|
28
|
+
// calculated layout results.
|
|
29
|
+
bool configUpdateInvalidatesLayout(
|
|
30
|
+
const Config& oldConfig,
|
|
31
|
+
const Config& newConfig);
|
|
32
|
+
|
|
33
|
+
class YG_EXPORT Config : public ::YGConfig {
|
|
34
|
+
public:
|
|
35
|
+
Config(YGLogger logger);
|
|
36
|
+
|
|
37
|
+
void setUseWebDefaults(bool useWebDefaults);
|
|
38
|
+
bool useWebDefaults() const;
|
|
39
|
+
|
|
40
|
+
void setExperimentalFeatureEnabled(ExperimentalFeature feature, bool enabled);
|
|
41
|
+
bool isExperimentalFeatureEnabled(ExperimentalFeature feature) const;
|
|
42
|
+
ExperimentalFeatureSet getEnabledExperiments() const;
|
|
43
|
+
|
|
44
|
+
void setErrata(Errata errata);
|
|
45
|
+
void addErrata(Errata errata);
|
|
46
|
+
void removeErrata(Errata errata);
|
|
47
|
+
Errata getErrata() const;
|
|
48
|
+
bool hasErrata(Errata errata) const;
|
|
49
|
+
|
|
50
|
+
void setPointScaleFactor(float pointScaleFactor);
|
|
51
|
+
float getPointScaleFactor() const;
|
|
52
|
+
|
|
53
|
+
void setContext(void* context);
|
|
54
|
+
void* getContext() const;
|
|
55
|
+
|
|
56
|
+
uint32_t getVersion() const noexcept; // [Windows #13409]
|
|
57
|
+
|
|
58
|
+
void setLogger(YGLogger logger);
|
|
59
|
+
void log(
|
|
60
|
+
const yoga::Node* node,
|
|
61
|
+
LogLevel logLevel,
|
|
62
|
+
const char* format,
|
|
63
|
+
va_list args) const;
|
|
64
|
+
|
|
65
|
+
void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
|
|
66
|
+
YGNodeRef
|
|
67
|
+
cloneNode(YGNodeConstRef node, YGNodeConstRef owner, size_t childIndex) const;
|
|
68
|
+
|
|
69
|
+
static const Config& getDefault();
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
YGCloneNodeFunc cloneNodeCallback_;
|
|
73
|
+
YGLogger logger_;
|
|
74
|
+
|
|
75
|
+
bool useWebDefaults_ : 1 = false;
|
|
76
|
+
|
|
77
|
+
uint32_t version_ = 0; // [Windows #13409]
|
|
78
|
+
ExperimentalFeatureSet experimentalFeatures_{};
|
|
79
|
+
Errata errata_ = Errata::None;
|
|
80
|
+
float pointScaleFactor_ = 1.0f;
|
|
81
|
+
void* context_ = nullptr;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
inline Config* resolveRef(const YGConfigRef ref) {
|
|
85
|
+
return static_cast<Config*>(ref);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
inline const Config* resolveRef(const YGConfigConstRef ref) {
|
|
89
|
+
return static_cast<const Config*>(ref);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} // namespace facebook::yoga
|
|
@@ -0,0 +1,48 @@
|
|
|
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 <cmath>
|
|
9
|
+
|
|
10
|
+
#include <yoga/node/LayoutResults.h>
|
|
11
|
+
#include <yoga/numeric/Comparison.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook::yoga {
|
|
14
|
+
|
|
15
|
+
bool LayoutResults::operator==(LayoutResults layout) const {
|
|
16
|
+
bool isEqual = yoga::inexactEquals(position_, layout.position_) &&
|
|
17
|
+
yoga::inexactEquals(dimensions_, layout.dimensions_) &&
|
|
18
|
+
yoga::inexactEquals(margin_, layout.margin_) &&
|
|
19
|
+
yoga::inexactEquals(border_, layout.border_) &&
|
|
20
|
+
yoga::inexactEquals(padding_, layout.padding_) &&
|
|
21
|
+
direction() == layout.direction() &&
|
|
22
|
+
hadOverflow() == layout.hadOverflow() &&
|
|
23
|
+
lastOwnerDirection == layout.lastOwnerDirection &&
|
|
24
|
+
configVersion == layout.configVersion && // [Windows #13409]
|
|
25
|
+
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
|
|
26
|
+
cachedLayout == layout.cachedLayout &&
|
|
27
|
+
computedFlexBasis == layout.computedFlexBasis;
|
|
28
|
+
|
|
29
|
+
for (uint32_t i = 0; i < LayoutResults::MaxCachedMeasurements && isEqual;
|
|
30
|
+
++i) {
|
|
31
|
+
isEqual = isEqual && cachedMeasurements[i] == layout.cachedMeasurements[i];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!yoga::isUndefined(measuredDimensions_[0]) ||
|
|
35
|
+
!yoga::isUndefined(layout.measuredDimensions_[0])) {
|
|
36
|
+
isEqual =
|
|
37
|
+
isEqual && (measuredDimensions_[0] == layout.measuredDimensions_[0]);
|
|
38
|
+
}
|
|
39
|
+
if (!yoga::isUndefined(measuredDimensions_[1]) ||
|
|
40
|
+
!yoga::isUndefined(layout.measuredDimensions_[1])) {
|
|
41
|
+
isEqual =
|
|
42
|
+
isEqual && (measuredDimensions_[1] == layout.measuredDimensions_[1]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return isEqual;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
} // namespace facebook::yoga
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <array>
|
|
11
|
+
|
|
12
|
+
#include <yoga/debug/AssertFatal.h>
|
|
13
|
+
#include <yoga/enums/Dimension.h>
|
|
14
|
+
#include <yoga/enums/Direction.h>
|
|
15
|
+
#include <yoga/enums/Edge.h>
|
|
16
|
+
#include <yoga/enums/PhysicalEdge.h>
|
|
17
|
+
#include <yoga/node/CachedMeasurement.h>
|
|
18
|
+
#include <yoga/numeric/FloatOptional.h>
|
|
19
|
+
|
|
20
|
+
namespace facebook::yoga {
|
|
21
|
+
|
|
22
|
+
struct LayoutResults {
|
|
23
|
+
// This value was chosen based on empirical data:
|
|
24
|
+
// 98% of analyzed layouts require less than 8 entries.
|
|
25
|
+
static constexpr int32_t MaxCachedMeasurements = 8;
|
|
26
|
+
|
|
27
|
+
uint32_t computedFlexBasisGeneration = 0;
|
|
28
|
+
FloatOptional computedFlexBasis = {};
|
|
29
|
+
|
|
30
|
+
// Instead of recomputing the entire layout every single time, we cache some
|
|
31
|
+
// information to break early when nothing changed
|
|
32
|
+
uint32_t generationCount = 0;
|
|
33
|
+
uint32_t configVersion = 0; // [Windows #13409]
|
|
34
|
+
Direction lastOwnerDirection = Direction::Inherit;
|
|
35
|
+
|
|
36
|
+
uint32_t nextCachedMeasurementsIndex = 0;
|
|
37
|
+
std::array<CachedMeasurement, MaxCachedMeasurements> cachedMeasurements = {};
|
|
38
|
+
|
|
39
|
+
CachedMeasurement cachedLayout{};
|
|
40
|
+
|
|
41
|
+
Direction direction() const {
|
|
42
|
+
return direction_;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void setDirection(Direction direction) {
|
|
46
|
+
direction_ = direction;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
bool hadOverflow() const {
|
|
50
|
+
return hadOverflow_;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void setHadOverflow(bool hadOverflow) {
|
|
54
|
+
hadOverflow_ = hadOverflow;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
float dimension(Dimension axis) const {
|
|
58
|
+
return dimensions_[yoga::to_underlying(axis)];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void setDimension(Dimension axis, float dimension) {
|
|
62
|
+
dimensions_[yoga::to_underlying(axis)] = dimension;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
float measuredDimension(Dimension axis) const {
|
|
66
|
+
return measuredDimensions_[yoga::to_underlying(axis)];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void setMeasuredDimension(Dimension axis, float dimension) {
|
|
70
|
+
measuredDimensions_[yoga::to_underlying(axis)] = dimension;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
float position(PhysicalEdge physicalEdge) const {
|
|
74
|
+
return position_[yoga::to_underlying(physicalEdge)];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void setPosition(PhysicalEdge physicalEdge, float dimension) {
|
|
78
|
+
position_[yoga::to_underlying(physicalEdge)] = dimension;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
float margin(PhysicalEdge physicalEdge) const {
|
|
82
|
+
return margin_[yoga::to_underlying(physicalEdge)];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void setMargin(PhysicalEdge physicalEdge, float dimension) {
|
|
86
|
+
margin_[yoga::to_underlying(physicalEdge)] = dimension;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
float border(PhysicalEdge physicalEdge) const {
|
|
90
|
+
return border_[yoga::to_underlying(physicalEdge)];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void setBorder(PhysicalEdge physicalEdge, float dimension) {
|
|
94
|
+
border_[yoga::to_underlying(physicalEdge)] = dimension;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
float padding(PhysicalEdge physicalEdge) const {
|
|
98
|
+
return padding_[yoga::to_underlying(physicalEdge)];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void setPadding(PhysicalEdge physicalEdge, float dimension) {
|
|
102
|
+
padding_[yoga::to_underlying(physicalEdge)] = dimension;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
bool operator==(LayoutResults layout) const;
|
|
106
|
+
bool operator!=(LayoutResults layout) const {
|
|
107
|
+
return !(*this == layout);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private:
|
|
111
|
+
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
|
112
|
+
bool hadOverflow_ : 1 = false;
|
|
113
|
+
|
|
114
|
+
std::array<float, 2> dimensions_ = {{YGUndefined, YGUndefined}};
|
|
115
|
+
std::array<float, 2> measuredDimensions_ = {{YGUndefined, YGUndefined}};
|
|
116
|
+
std::array<float, 4> position_ = {};
|
|
117
|
+
std::array<float, 4> margin_ = {};
|
|
118
|
+
std::array<float, 4> border_ = {};
|
|
119
|
+
std::array<float, 4> padding_ = {};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
} // namespace facebook::yoga
|
|
@@ -0,0 +1,366 @@
|
|
|
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/node/Node.h>
|
|
14
|
+
#include <yoga/numeric/Comparison.h>
|
|
15
|
+
|
|
16
|
+
namespace facebook::yoga {
|
|
17
|
+
|
|
18
|
+
Node::Node() : Node{&Config::getDefault()} {}
|
|
19
|
+
|
|
20
|
+
Node::Node(const yoga::Config* config) : config_{config} {
|
|
21
|
+
yoga::assertFatal(
|
|
22
|
+
config != nullptr, "Attempting to construct Node with null config");
|
|
23
|
+
|
|
24
|
+
if (config->useWebDefaults()) {
|
|
25
|
+
useWebDefaults();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Node::Node(Node&& node) {
|
|
30
|
+
hasNewLayout_ = node.hasNewLayout_;
|
|
31
|
+
isReferenceBaseline_ = node.isReferenceBaseline_;
|
|
32
|
+
isDirty_ = node.isDirty_;
|
|
33
|
+
alwaysFormsContainingBlock_ = node.alwaysFormsContainingBlock_;
|
|
34
|
+
nodeType_ = node.nodeType_;
|
|
35
|
+
context_ = node.context_;
|
|
36
|
+
measureFunc_ = node.measureFunc_;
|
|
37
|
+
baselineFunc_ = node.baselineFunc_;
|
|
38
|
+
dirtiedFunc_ = node.dirtiedFunc_;
|
|
39
|
+
style_ = node.style_;
|
|
40
|
+
layout_ = node.layout_;
|
|
41
|
+
lineIndex_ = node.lineIndex_;
|
|
42
|
+
owner_ = node.owner_;
|
|
43
|
+
children_ = std::move(node.children_);
|
|
44
|
+
config_ = node.config_;
|
|
45
|
+
resolvedDimensions_ = node.resolvedDimensions_;
|
|
46
|
+
for (auto c : children_) {
|
|
47
|
+
c->setOwner(this);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
YGSize Node::measure(
|
|
52
|
+
float width,
|
|
53
|
+
MeasureMode widthMode,
|
|
54
|
+
float height,
|
|
55
|
+
MeasureMode heightMode) {
|
|
56
|
+
return measureFunc_(
|
|
57
|
+
this, width, unscopedEnum(widthMode), height, unscopedEnum(heightMode));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
float Node::baseline(float width, float height) const {
|
|
61
|
+
return baselineFunc_(this, width, height);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
float Node::dimensionWithMargin(
|
|
65
|
+
const FlexDirection axis,
|
|
66
|
+
const float widthSize) {
|
|
67
|
+
return getLayout().measuredDimension(dimension(axis)) +
|
|
68
|
+
style_.computeMarginForAxis(axis, widthSize);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
bool Node::isLayoutDimensionDefined(const FlexDirection axis) {
|
|
72
|
+
const float value = getLayout().measuredDimension(dimension(axis));
|
|
73
|
+
return yoga::isDefined(value) && value >= 0.0f;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Setters
|
|
77
|
+
|
|
78
|
+
void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
|
|
79
|
+
if (measureFunc == nullptr) {
|
|
80
|
+
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
|
81
|
+
// places in Litho
|
|
82
|
+
setNodeType(NodeType::Default);
|
|
83
|
+
} else {
|
|
84
|
+
yoga::assertFatalWithNode(
|
|
85
|
+
this,
|
|
86
|
+
children_.size() == 0,
|
|
87
|
+
"Cannot set measure function: Nodes with measure functions cannot have "
|
|
88
|
+
"children.");
|
|
89
|
+
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
|
90
|
+
// places in Litho
|
|
91
|
+
setNodeType(NodeType::Text);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
measureFunc_ = measureFunc;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void Node::replaceChild(Node* child, size_t index) {
|
|
98
|
+
children_[index] = child;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void Node::replaceChild(Node* oldChild, Node* newChild) {
|
|
102
|
+
std::replace(children_.begin(), children_.end(), oldChild, newChild);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void Node::insertChild(Node* child, size_t index) {
|
|
106
|
+
children_.insert(children_.begin() + static_cast<ptrdiff_t>(index), child);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void Node::setConfig(yoga::Config* config) {
|
|
110
|
+
yoga::assertFatal(
|
|
111
|
+
config != nullptr, "Attempting to set a null config on a Node");
|
|
112
|
+
yoga::assertFatalWithConfig(
|
|
113
|
+
config,
|
|
114
|
+
config->useWebDefaults() == config_->useWebDefaults(),
|
|
115
|
+
"UseWebDefaults may not be changed after constructing a Node");
|
|
116
|
+
|
|
117
|
+
if (yoga::configUpdateInvalidatesLayout(*config_, *config)) {
|
|
118
|
+
markDirtyAndPropagate();
|
|
119
|
+
layout_.configVersion = 0; // [Windows #13409]
|
|
120
|
+
} else { // [Windows #13409]
|
|
121
|
+
// If the config is functionally the same, then align the configVersion so
|
|
122
|
+
// that we can reuse the layout cache
|
|
123
|
+
layout_.configVersion = config->getVersion(); // [Windows #13409]
|
|
124
|
+
}
|
|
125
|
+
config_ = config;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void Node::setDirty(bool isDirty) {
|
|
129
|
+
if (isDirty == isDirty_) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
isDirty_ = isDirty;
|
|
133
|
+
if (isDirty && dirtiedFunc_) {
|
|
134
|
+
dirtiedFunc_(this);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
bool Node::removeChild(Node* child) {
|
|
139
|
+
std::vector<Node*>::iterator p =
|
|
140
|
+
std::find(children_.begin(), children_.end(), child);
|
|
141
|
+
if (p != children_.end()) {
|
|
142
|
+
children_.erase(p);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void Node::removeChild(size_t index) {
|
|
149
|
+
children_.erase(children_.begin() + static_cast<ptrdiff_t>(index));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void Node::setLayoutDirection(Direction direction) {
|
|
153
|
+
layout_.setDirection(direction);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void Node::setLayoutMargin(float margin, PhysicalEdge edge) {
|
|
157
|
+
layout_.setMargin(edge, margin);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
void Node::setLayoutBorder(float border, PhysicalEdge edge) {
|
|
161
|
+
layout_.setBorder(edge, border);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void Node::setLayoutPadding(float padding, PhysicalEdge edge) {
|
|
165
|
+
layout_.setPadding(edge, padding);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void Node::setLayoutLastOwnerDirection(Direction direction) {
|
|
169
|
+
layout_.lastOwnerDirection = direction;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void Node::setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis) {
|
|
173
|
+
layout_.computedFlexBasis = computedFlexBasis;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void Node::setLayoutPosition(float position, PhysicalEdge edge) {
|
|
177
|
+
layout_.setPosition(edge, position);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void Node::setLayoutComputedFlexBasisGeneration(
|
|
181
|
+
uint32_t computedFlexBasisGeneration) {
|
|
182
|
+
layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
void Node::setLayoutMeasuredDimension(
|
|
186
|
+
float measuredDimension,
|
|
187
|
+
Dimension dimension) {
|
|
188
|
+
layout_.setMeasuredDimension(dimension, measuredDimension);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void Node::setLayoutHadOverflow(bool hadOverflow) {
|
|
192
|
+
layout_.setHadOverflow(hadOverflow);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void Node::setLayoutDimension(float LengthValue, Dimension dimension) {
|
|
196
|
+
layout_.setDimension(dimension, LengthValue);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// If both left and right are defined, then use left. Otherwise return +left or
|
|
200
|
+
// -right depending on which is defined. Ignore statically positioned nodes as
|
|
201
|
+
// insets do not apply to them.
|
|
202
|
+
float Node::relativePosition(
|
|
203
|
+
FlexDirection axis,
|
|
204
|
+
Direction direction,
|
|
205
|
+
float axisSize) const {
|
|
206
|
+
if (style_.positionType() == PositionType::Static) {
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
if (style_.isInlineStartPositionDefined(axis, direction)) {
|
|
210
|
+
return style_.computeInlineStartPosition(axis, direction, axisSize);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return -1 * style_.computeInlineEndPosition(axis, direction, axisSize);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void Node::setPosition(
|
|
217
|
+
const Direction direction,
|
|
218
|
+
const float mainSize,
|
|
219
|
+
const float crossSize,
|
|
220
|
+
const float ownerWidth) {
|
|
221
|
+
/* Root nodes should be always layouted as LTR, so we don't return negative
|
|
222
|
+
* values. */
|
|
223
|
+
const Direction directionRespectingRoot =
|
|
224
|
+
owner_ != nullptr ? direction : Direction::LTR;
|
|
225
|
+
const FlexDirection mainAxis =
|
|
226
|
+
yoga::resolveDirection(style_.flexDirection(), directionRespectingRoot);
|
|
227
|
+
const FlexDirection crossAxis =
|
|
228
|
+
yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
|
|
229
|
+
|
|
230
|
+
// In the case of position static these are just 0. See:
|
|
231
|
+
// https://www.w3.org/TR/css-position-3/#valdef-position-static
|
|
232
|
+
const float relativePositionMain =
|
|
233
|
+
relativePosition(mainAxis, directionRespectingRoot, mainSize);
|
|
234
|
+
const float relativePositionCross =
|
|
235
|
+
relativePosition(crossAxis, directionRespectingRoot, crossSize);
|
|
236
|
+
|
|
237
|
+
const auto mainAxisLeadingEdge = inlineStartEdge(mainAxis, direction);
|
|
238
|
+
const auto mainAxisTrailingEdge = inlineEndEdge(mainAxis, direction);
|
|
239
|
+
const auto crossAxisLeadingEdge = inlineStartEdge(crossAxis, direction);
|
|
240
|
+
const auto crossAxisTrailingEdge = inlineEndEdge(crossAxis, direction);
|
|
241
|
+
|
|
242
|
+
setLayoutPosition(
|
|
243
|
+
(style_.computeInlineStartMargin(mainAxis, direction, ownerWidth) +
|
|
244
|
+
relativePositionMain),
|
|
245
|
+
mainAxisLeadingEdge);
|
|
246
|
+
setLayoutPosition(
|
|
247
|
+
(style_.computeInlineEndMargin(mainAxis, direction, ownerWidth) +
|
|
248
|
+
relativePositionMain),
|
|
249
|
+
mainAxisTrailingEdge);
|
|
250
|
+
setLayoutPosition(
|
|
251
|
+
(style_.computeInlineStartMargin(crossAxis, direction, ownerWidth) +
|
|
252
|
+
relativePositionCross),
|
|
253
|
+
crossAxisLeadingEdge);
|
|
254
|
+
setLayoutPosition(
|
|
255
|
+
(style_.computeInlineEndMargin(crossAxis, direction, ownerWidth) +
|
|
256
|
+
relativePositionCross),
|
|
257
|
+
crossAxisTrailingEdge);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
Style::Length Node::resolveFlexBasisPtr() const {
|
|
261
|
+
Style::Length flexBasis = style_.flexBasis();
|
|
262
|
+
if (flexBasis.unit() != Unit::Auto && flexBasis.unit() != Unit::Undefined) {
|
|
263
|
+
return flexBasis;
|
|
264
|
+
}
|
|
265
|
+
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
|
266
|
+
return config_->useWebDefaults() ? value::ofAuto() : value::points(0);
|
|
267
|
+
}
|
|
268
|
+
return value::ofAuto();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
void Node::resolveDimension() {
|
|
272
|
+
for (auto dim : {Dimension::Width, Dimension::Height}) {
|
|
273
|
+
if (style_.maxDimension(dim).isDefined() &&
|
|
274
|
+
yoga::inexactEquals(
|
|
275
|
+
style_.maxDimension(dim), style_.minDimension(dim))) {
|
|
276
|
+
resolvedDimensions_[yoga::to_underlying(dim)] = style_.maxDimension(dim);
|
|
277
|
+
} else {
|
|
278
|
+
resolvedDimensions_[yoga::to_underlying(dim)] = style_.dimension(dim);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
Direction Node::resolveDirection(const Direction ownerDirection) {
|
|
284
|
+
if (style_.direction() == Direction::Inherit) {
|
|
285
|
+
return ownerDirection != Direction::Inherit ? ownerDirection
|
|
286
|
+
: Direction::LTR;
|
|
287
|
+
} else {
|
|
288
|
+
return style_.direction();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
void Node::clearChildren() {
|
|
293
|
+
children_.clear();
|
|
294
|
+
children_.shrink_to_fit();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Other Methods
|
|
298
|
+
|
|
299
|
+
void Node::cloneChildrenIfNeeded() {
|
|
300
|
+
size_t i = 0;
|
|
301
|
+
for (Node*& child : children_) {
|
|
302
|
+
if (child->getOwner() != this) {
|
|
303
|
+
child = resolveRef(config_->cloneNode(child, this, i));
|
|
304
|
+
child->setOwner(this);
|
|
305
|
+
}
|
|
306
|
+
i += 1;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
void Node::markDirtyAndPropagate() {
|
|
311
|
+
if (!isDirty_) {
|
|
312
|
+
setDirty(true);
|
|
313
|
+
setLayoutComputedFlexBasis(FloatOptional());
|
|
314
|
+
if (owner_) {
|
|
315
|
+
owner_->markDirtyAndPropagate();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
float Node::resolveFlexGrow() const {
|
|
321
|
+
// Root nodes flexGrow should always be 0
|
|
322
|
+
if (owner_ == nullptr) {
|
|
323
|
+
return 0.0;
|
|
324
|
+
}
|
|
325
|
+
if (style_.flexGrow().isDefined()) {
|
|
326
|
+
return style_.flexGrow().unwrap();
|
|
327
|
+
}
|
|
328
|
+
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
|
329
|
+
return style_.flex().unwrap();
|
|
330
|
+
}
|
|
331
|
+
return Style::DefaultFlexGrow;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
float Node::resolveFlexShrink() const {
|
|
335
|
+
if (owner_ == nullptr) {
|
|
336
|
+
return 0.0;
|
|
337
|
+
}
|
|
338
|
+
if (style_.flexShrink().isDefined()) {
|
|
339
|
+
return style_.flexShrink().unwrap();
|
|
340
|
+
}
|
|
341
|
+
if (!config_->useWebDefaults() && style_.flex().isDefined() &&
|
|
342
|
+
style_.flex().unwrap() < 0.0f) {
|
|
343
|
+
return -style_.flex().unwrap();
|
|
344
|
+
}
|
|
345
|
+
return config_->useWebDefaults() ? Style::WebDefaultFlexShrink
|
|
346
|
+
: Style::DefaultFlexShrink;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
bool Node::isNodeFlexible() {
|
|
350
|
+
return (
|
|
351
|
+
(style_.positionType() != PositionType::Absolute) &&
|
|
352
|
+
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
void Node::reset() {
|
|
356
|
+
yoga::assertFatalWithNode(
|
|
357
|
+
this,
|
|
358
|
+
children_.size() == 0,
|
|
359
|
+
"Cannot reset a node which still has children attached");
|
|
360
|
+
yoga::assertFatalWithNode(
|
|
361
|
+
this, owner_ == nullptr, "Cannot reset a node still attached to a owner");
|
|
362
|
+
|
|
363
|
+
*this = Node{getConfig()};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
} // namespace facebook::yoga
|
|
@@ -49,12 +49,12 @@ Copy-Item -Force -Recurse -Path $ReactWindowsRoot\codegen -Destination $TargetRo
|
|
|
49
49
|
Copy-Item -Force -Recurse -Path $ReactCommonOverrideRoot\* -Destination $ReactNativeRoot\ReactCommon\
|
|
50
50
|
|
|
51
51
|
# Microsoft.ReactNative.CXX project JSI files
|
|
52
|
-
Copy-Item -Force -Path $
|
|
53
|
-
Copy-Item -Force -Path $
|
|
54
|
-
Copy-Item -Force -Path $
|
|
55
|
-
Copy-Item -Force -Path $
|
|
56
|
-
Copy-Item -Force -Path $
|
|
57
|
-
Copy-Item -Force -Path $
|
|
52
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\decorator.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
53
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\instrumentation.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
54
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\jsi.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
55
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\jsi.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
56
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\jsi-inl.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
57
|
+
Copy-Item -Force -Path $NodeApiJsiRoot\jsi\jsi\threadsafe.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
|
|
58
58
|
|
|
59
59
|
# Microsoft.ReactNative.CXX project Node-API files
|
|
60
60
|
New-Item $TargetRoot\Microsoft.ReactNative.Cxx\node-api -ItemType Directory -Force
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/runtime": "^7.0.0",
|
|
25
25
|
"@jest/create-cache-key-function": "^29.6.3",
|
|
26
|
-
"@react-native-community/cli": "13.6.
|
|
27
|
-
"@react-native-community/cli-platform-android": "13.6.
|
|
28
|
-
"@react-native-community/cli-platform-ios": "13.6.
|
|
26
|
+
"@react-native-community/cli": "13.6.9",
|
|
27
|
+
"@react-native-community/cli-platform-android": "13.6.9",
|
|
28
|
+
"@react-native-community/cli-platform-ios": "13.6.9",
|
|
29
29
|
"@react-native-windows/cli": "0.74.1",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
|
-
"@react-native/assets-registry": "0.74.
|
|
32
|
-
"@react-native/codegen": "0.74.
|
|
33
|
-
"@react-native/community-cli-plugin": "0.74.
|
|
34
|
-
"@react-native/gradle-plugin": "0.74.
|
|
35
|
-
"@react-native/js-polyfills": "0.74.
|
|
36
|
-
"@react-native/normalize-colors": "0.74.
|
|
37
|
-
"@react-native/virtualized-lists": "0.74.
|
|
31
|
+
"@react-native/assets-registry": "0.74.85",
|
|
32
|
+
"@react-native/codegen": "0.74.85",
|
|
33
|
+
"@react-native/community-cli-plugin": "0.74.85",
|
|
34
|
+
"@react-native/gradle-plugin": "0.74.85",
|
|
35
|
+
"@react-native/js-polyfills": "0.74.85",
|
|
36
|
+
"@react-native/normalize-colors": "0.74.85",
|
|
37
|
+
"@react-native/virtualized-lists": "0.74.85",
|
|
38
38
|
"abort-controller": "^3.0.0",
|
|
39
39
|
"anser": "^1.4.9",
|
|
40
40
|
"ansi-regex": "^5.0.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@react-native-windows/codegen": "0.74.1",
|
|
68
|
-
"@react-native/metro-config": "0.74.
|
|
68
|
+
"@react-native/metro-config": "0.74.85",
|
|
69
69
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
70
70
|
"@rnw-scripts/eslint-config": "1.2.9",
|
|
71
71
|
"@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.1.13",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"just-scripts": "^1.3.3",
|
|
82
82
|
"prettier": "2.8.8",
|
|
83
83
|
"react": "18.2.0",
|
|
84
|
-
"react-native": "0.74.
|
|
84
|
+
"react-native": "0.74.3",
|
|
85
85
|
"react-native-platform-override": "^1.9.25",
|
|
86
86
|
"react-refresh": "^0.14.0",
|
|
87
87
|
"typescript": "5.0.4"
|