Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds QuirkSetting to use YGExperimentalFeatureWebFlexBasis #10661

Merged
3 commits merged into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Adds QuirkSetting to use YGExperimentalFeatureWebFlexBasis",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 2 additions & 0 deletions vnext/Microsoft.ReactNative/Modules/NativeUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ XamlView NativeUIManager::reactPeerOrContainerFrom(xaml::FrameworkElement fe) {
NativeUIManager::NativeUIManager(winrt::Microsoft::ReactNative::ReactContext const &reactContext)
: m_context(reactContext) {
m_yogaConfig = YGConfigNew();
if (React::implementation::QuirkSettings::GetUseWebFlexBasisBehavior(m_context.Properties()))
YGConfigSetExperimentalFeatureEnabled(m_yogaConfig, YGExperimentalFeatureWebFlexBasis, true);
if (React::implementation::QuirkSettings::GetMatchAndroidAndIOSStretchBehavior(m_context.Properties()))
YGConfigSetUseLegacyStretchBehaviour(m_yogaConfig, true);

Expand Down
22 changes: 22 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ winrt::Microsoft::ReactNative::ReactPropertyId<bool> MatchAndroidAndIOSStretchBe
properties.Set(MatchAndroidAndIOSStretchBehaviorProperty(), value);
}

winrt::Microsoft::ReactNative::ReactPropertyId<bool> UseWebFlexBasisBehaviorProperty() noexcept {
static winrt::Microsoft::ReactNative::ReactPropertyId<bool> propId{
L"ReactNative.QuirkSettings", L"UseWebFlexBasisBehavior"};
return propId;
}

/*static*/ void QuirkSettings::SetUseWebFlexBasisBehavior(
winrt::Microsoft::ReactNative::ReactPropertyBag properties,
bool value) noexcept {
properties.Set(UseWebFlexBasisBehaviorProperty(), value);
}

winrt::Microsoft::ReactNative::ReactPropertyId<bool> AcceptSelfSignedCertsProperty() noexcept {
winrt::Microsoft::ReactNative::ReactPropertyId<bool> propId{
L"ReactNative.QuirkSettings", L"Networking.AcceptSelfSigned"};
Expand Down Expand Up @@ -60,6 +72,12 @@ winrt::Microsoft::ReactNative::ReactPropertyId<bool> MapWindowDeactivatedToAppSt
SetMatchAndroidAndIOSStretchBehavior(ReactPropertyBag(settings.Properties()), value);
}

/*static*/ void QuirkSettings::SetUseWebFlexBasisBehavior(
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
bool value) noexcept {
SetUseWebFlexBasisBehavior(ReactPropertyBag(settings.Properties()), value);
}

/*static*/ void QuirkSettings::SetAcceptSelfSigned(
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
bool value) noexcept {
Expand All @@ -84,6 +102,10 @@ winrt::Microsoft::ReactNative::ReactPropertyId<bool> MapWindowDeactivatedToAppSt
return properties.Get(MatchAndroidAndIOSStretchBehaviorProperty()).value_or(true);
}

/*static*/ bool QuirkSettings::GetUseWebFlexBasisBehavior(ReactPropertyBag properties) noexcept {
return properties.Get(MatchAndroidAndIOSStretchBehaviorProperty()).value_or(true);
}

/*static*/ bool QuirkSettings::GetAcceptSelfSigned(ReactPropertyBag properties) noexcept {
return properties.Get(AcceptSelfSignedCertsProperty()).value_or(false);
}
Expand Down
9 changes: 9 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ struct QuirkSettings : QuirkSettingsT<QuirkSettings> {
bool value) noexcept;
static bool GetMatchAndroidAndIOSStretchBehavior(winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;

static void SetUseWebFlexBasisBehavior(
winrt::Microsoft::ReactNative::ReactPropertyBag properties,
bool value) noexcept;
static bool GetUseWebFlexBasisBehavior(winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;

static bool GetAcceptSelfSigned(winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;
static winrt::Microsoft::ReactNative::BackNavigationHandlerKind GetBackHandlerKind(
winrt::Microsoft::ReactNative::ReactPropertyBag properties) noexcept;
Expand All @@ -37,6 +42,10 @@ struct QuirkSettings : QuirkSettingsT<QuirkSettings> {
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
bool value) noexcept;

static void SetUseWebFlexBasisBehavior(
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
bool value) noexcept;

static void SetAcceptSelfSigned(winrt::Microsoft::ReactNative::ReactInstanceSettings settings, bool value) noexcept;
static void SetBackHandlerKind(
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
Expand Down
7 changes: 7 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace Microsoft.ReactNative
DOC_DEFAULT("true")
static void SetMatchAndroidAndIOSStretchBehavior(ReactInstanceSettings settings, Boolean value);

DOC_STRING(
"There is a chance that cached flex basis values can cause text truncation in some re-layout scenarios. "
"Enabling [Yoga](https://github.com/facebook/yoga)'s experimental web flex basis behavior fixes this issue, "
"however using it may result in perfomance regressions due to additional layout passes.")
DOC_DEFAULT("false")
static void SetUseWebFlexBasisBehavior(ReactInstanceSettings settings, Boolean value);

DOC_STRING("Runtime setting allowing Networking (HTTP, WebSocket) connections to skip certificate validation.")
static void SetAcceptSelfSigned(ReactInstanceSettings settings, Boolean value);

Expand Down