-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[0.74] Allow portals to have independent layout constraints and scale…
… factor (#14318) * Fix crash when currently focused element gets marked as enableFocusRing=false (#14306) * Fix crash when currently focused element gets marked as enableFocusRing=false * Change files * [Fabric] Use PopupWindowSiteBridge for Modal when USE_EXPERIMENTAL_WINUI3 is true (#14284) * add modal implementation with PopupWindowSiteBridge * Change files * add conditional * feedback * Initial support for UIA and tab navigation for a child Island (#14305) * Basic support for stitching the UIA tree for a ContentIslandComponentView's child * Updated comment * Change files * Support shift+tab, and move Automation event handlers to ContentIslandComponentView * Allow portals to have independent layout constraints and scale factor (#14315) * Allow portals to have independent layout constraints and scale factor * format * change files * fix * Round Focus visuals by default, fix nudge rendering (#14312) * Round Focus visuals by default, fix nudge rendering * Change files * change files * fix * fix * fix --------- Co-authored-by: Tatiana Kapos <[email protected]> Co-authored-by: JesseCol <[email protected]>
- Loading branch information
1 parent
8d61583
commit 1b4cbdc
Showing
44 changed files
with
889 additions
and
308 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@react-native-windows-codegen-e7b6a9a3-a6de-499d-95bb-1510e5009dd2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Fix UpdateState on generated base class", | ||
"packageName": "@react-native-windows/codegen", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-56595f43-5a8f-443b-9594-7de92ea7e45c.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Allow portals to have independent layout constraints and scale factor", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-6667ac90-8a6f-422f-917d-bba7f01145b6.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "add modal implementation with PopupWindowSiteBridge", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-96dd8a87-4b77-4f7e-bf40-fb214350e0f3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Basic support for stitching the UIA tree for a ContentIslandComponentView's child", | ||
"packageName": "react-native-windows", | ||
"email": "email not defined", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-9fae9acd-d5a6-48d1-9d63-c333ad09ca76.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Fix crash when currently focused element gets marked as enableFocusRing=false", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-ca3eff01-d91f-4d53-80fe-5ce6cfdf0727.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Round Focus visuals by default, fix nudge rendering", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
vnext/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#include "AbiPortalShadowNode.h" | ||
|
||
#include <Fabric/Composition/ReactCompositionViewComponentBuilder.h> | ||
#include <react/debug/react_native_assert.h> | ||
#include <react/renderer/core/LayoutConstraints.h> | ||
#include <react/renderer/core/LayoutContext.h> | ||
#include <react/renderer/core/conversions.h> | ||
|
||
#include <utility> | ||
|
||
namespace Microsoft::ReactNative { | ||
|
||
extern const char AbiPortalComponentName[] = "AbiPortal"; | ||
|
||
facebook::react::Size AbiPortalShadowNode::measureContent( | ||
const facebook::react::LayoutContext &layoutContext, | ||
const facebook::react::LayoutConstraints &layoutConstraints) const { | ||
return {0, 0}; // The portal placeholder node shouldn't take up any space | ||
} | ||
|
||
void AbiPortalShadowNode::layout(facebook::react::LayoutContext layoutContext) { | ||
ensureUnsealed(); | ||
auto layoutMetrics = getLayoutMetrics(); | ||
|
||
auto portalOwningShadowNode = ShadowNode::Unshared{}; | ||
|
||
if (getChildren().empty()) { | ||
return; | ||
} | ||
|
||
// A Portal should only have a single child | ||
react_native_assert(getChildren().size() == 1); | ||
|
||
const auto &childNode = getChildren()[0]; | ||
|
||
auto clonedShadowNode = ShadowNode::Unshared{}; | ||
|
||
portalOwningShadowNode = cloneTree(childNode->getFamily(), [&](const ShadowNode &oldShadowNode) { | ||
clonedShadowNode = oldShadowNode.clone({}); | ||
return clonedShadowNode; | ||
}); | ||
auto portalShadowNode = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get()); | ||
|
||
auto &layoutableShadowNode = dynamic_cast<LayoutableShadowNode &>(*clonedShadowNode); | ||
|
||
auto &state = getStateData(); | ||
|
||
facebook::react::LayoutConstraints layoutConstraints; | ||
layoutConstraints.layoutDirection = layoutMetrics.layoutDirection; | ||
|
||
if (state.userdata) { | ||
// If the portal component set a state of type IPortalStateData, | ||
// extract constraint information from it, and use that for layout | ||
if (auto portalState = state.userdata.try_as<winrt::Microsoft::ReactNative::Composition::IPortalStateData>()) { | ||
auto stateConstraints = portalState.LayoutConstraints(); | ||
|
||
layoutConstraints.minimumSize = {stateConstraints.MinimumSize.Width, stateConstraints.MinimumSize.Height}; | ||
layoutConstraints.maximumSize = {stateConstraints.MaximumSize.Width, stateConstraints.MaximumSize.Height}; | ||
if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight) { | ||
layoutConstraints.layoutDirection = facebook::react::LayoutDirection::LeftToRight; | ||
} else if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::RightToLeft) { | ||
layoutConstraints.layoutDirection = facebook::react::LayoutDirection::RightToLeft; | ||
} | ||
} | ||
} | ||
|
||
// Laying out the `ShadowNode` and the subtree starting from it. | ||
layoutableShadowNode.layoutTree(layoutContext, layoutConstraints); | ||
|
||
auto childLayoutMetrics = layoutableShadowNode.getLayoutMetrics(); | ||
childLayoutMetrics.frame.origin = {0, 0}; | ||
layoutableShadowNode.setLayoutMetrics(childLayoutMetrics); | ||
|
||
// Update the list of children to reflect the changes that we made. | ||
this->children_ = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get())->children_; | ||
} | ||
|
||
void AbiPortalShadowNode::Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept { | ||
m_builder = builder; | ||
} | ||
|
||
winrt::Microsoft::ReactNative::IReactViewComponentBuilder AbiPortalShadowNode::Builder() const noexcept { | ||
return m_builder; | ||
} | ||
|
||
void AbiPortalShadowNode::Proxy(winrt::Microsoft::ReactNative::ShadowNode proxy) noexcept { | ||
m_proxy = proxy; | ||
} | ||
|
||
winrt::Microsoft::ReactNative::ShadowNode AbiPortalShadowNode::Proxy() const noexcept { | ||
return m_proxy; | ||
} | ||
|
||
} // namespace Microsoft::ReactNative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include <react/components/rnwcore/EventEmitters.h> | ||
#include <unordered_map> | ||
#include "AbiShadowNode.h" | ||
#include "AbiState.h" | ||
#include "AbiViewProps.h" | ||
|
||
#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
#include <react/renderer/core/LayoutContext.h> | ||
|
||
namespace Microsoft::ReactNative { | ||
|
||
extern const char AbiPortalComponentName[]; | ||
|
||
class AbiPortalShadowNode final : public facebook::react::ConcreteViewShadowNode< | ||
AbiPortalComponentName, | ||
AbiViewProps, | ||
facebook::react::ViewEventEmitter, | ||
Microsoft::ReactNative::AbiStateData> { | ||
public: | ||
using ConcreteViewShadowNode::ConcreteViewShadowNode; | ||
|
||
static facebook::react::ShadowNodeTraits BaseTraits() { | ||
auto traits = facebook::react::ShadowNode::BaseTraits(); | ||
traits.set(facebook::react::ShadowNodeTraits::Trait::FormsStackingContext); | ||
traits.set(facebook::react::ShadowNodeTraits::Trait::FormsView); | ||
traits.set(facebook::react::ShadowNodeTraits::Trait::RootNodeKind); | ||
traits.set(facebook::react::ShadowNodeTraits::Trait::LeafYogaNode); | ||
traits.set(facebook::react::ShadowNodeTraits::Trait::MeasurableYogaNode); | ||
return traits; | ||
} | ||
|
||
facebook::react::Size measureContent( | ||
const facebook::react::LayoutContext &layoutContext, | ||
const facebook::react::LayoutConstraints &layoutConstraints) const override; | ||
void layout(facebook::react::LayoutContext layoutContext) override; | ||
|
||
void OnClone(const facebook::react::ShadowNode &sourceShadowNode) noexcept; | ||
void Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept; | ||
winrt::Microsoft::ReactNative::IReactViewComponentBuilder Builder() const noexcept; | ||
void Proxy(winrt::Microsoft::ReactNative::ShadowNode handle) noexcept; | ||
winrt::Microsoft::ReactNative::ShadowNode Proxy() const noexcept; | ||
|
||
private: | ||
winrt::Microsoft::ReactNative::ShadowNode m_proxy{nullptr}; | ||
winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr}; | ||
}; | ||
|
||
} // namespace Microsoft::ReactNative |
Oops, something went wrong.