Skip to content

Commit

Permalink
[0.74] [Fabric] Port various fabric fixes (#13454)
Browse files Browse the repository at this point in the history
* [Fabric] Move to WinAppSDK types for KeyStatus, and ensure usages account for locked flag (#13435)

* [Fabric] Move to WinAppSDK types for KeyStatus, and ensure usages account for locked flag

* Change files

* Use scrollEnabled flag to enable/disable the ScrollView (#13427)

* Fix scrollview

* Change files

* Address feedback

* Return false for scroll event handlers when scroll is disabled

* Update scrollbar color based on scrollEnabled

* Rename OnThemeChanged to UpdateColorForScrollBarRegions

* [Fabric] Fix image component reference cycle (#13440)

* [Fabric] Fix image component reference cycle

* Change files

* format

* disable aggressive component deleted assert

* Use weak_ref for image didReceiveImage callback

* typo

* Unsubscribe from imageresponseobserver when deleted - aligns with core

* format

* [Fabric] call reportMount to implement UIManagerMountHook support (#13443)

* [Fabric] call reportMount to implement UIManagerMountHook support

* Change files

* Resolve Transform Matrix before Animation (#13450)

* Resolve transform before animation

* Change files

* Minor naming fix

* noexcept

* [Fabric] Text renders borders twice (#13445)

* [Fabric] Text renders borders twice

* Change files

* Add fabric test for text borders

* snapshot updates

* snapshots

* fix change file types

---------

Co-authored-by: Sharath Manchala <10109130+sharath2727@users.noreply.github.com>
  • Loading branch information
acoates-ms and sharath2727 authored Jul 16, 2024
1 parent 3aa4b32 commit 7d828ea
Show file tree
Hide file tree
Showing 25 changed files with 300 additions and 130 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Fabric] call reportMount to implement UIManagerMountHook support",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Fabric] Move to WinAppSDK types for KeyStatus, and ensure usages account for locked flag",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Fabric] Text renders borders twice",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix scrollview",
"packageName": "react-native-windows",
"email": "10109130+sharath2727@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Resolve transform before animation",
"packageName": "react-native-windows",
"email": "10109130+sharath2727@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Fabric] Fix image component reference cycle",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
6 changes: 3 additions & 3 deletions vnext/Microsoft.ReactNative/Composition.Input.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.ReactNative.Composition.Input
{
interface KeyboardSource
{
Windows.UI.Core.CoreVirtualKeyStates GetKeyState(Windows.System.VirtualKey key);
Microsoft.UI.Input.VirtualKeyStates GetKeyState(Windows.System.VirtualKey key);
}

interface RoutedEventArgs
Expand All @@ -21,14 +21,14 @@ namespace Microsoft.ReactNative.Composition.Input
String DeviceId { get; };
Boolean Handled { get; set; };
Windows.System.VirtualKey Key { get; };
Windows.UI.Core.CorePhysicalKeyStatus KeyStatus { get; };
Microsoft.UI.Input.PhysicalKeyStatus KeyStatus { get; };
Windows.System.VirtualKey OriginalKey { get; };
}

interface CharacterReceivedRoutedEventArgs requires RoutedEventArgs
{
Boolean Handled { get; set; };
Windows.UI.Core.CorePhysicalKeyStatus KeyStatus { get; };
Microsoft.UI.Input.PhysicalKeyStatus KeyStatus { get; };
Int32 KeyCode { get; };
};

Expand Down
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/CompositionSwitcher.idl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace Microsoft.ReactNative.Composition.Experimental
interface IScrollVisual requires IVisual
{
void Brush(IBrush brush);
void ScrollEnabled(Boolean isScrollEnabled);
event Windows.Foundation.EventHandler<IScrollPositionChangedArgs> ScrollPositionChanged;
void ContentSize(Windows.Foundation.Numerics.Vector2 size);
Windows.Foundation.Numerics.Vector3 ScrollPosition { get; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ void ComponentViewRegistry::enqueueComponentViewWithComponentHandle(
ComponentViewDescriptor componentViewDescriptor) noexcept {
assert(m_registry.find(tag) != m_registry.end());

winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(componentViewDescriptor.view)
->prepareForRecycle();

m_registry.erase(tag);
}
} // namespace Microsoft::ReactNative
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ winrt::Windows::System::VirtualKey KeyRoutedEventArgs::Key() noexcept {
return m_key;
}

winrt::Windows::UI::Core::CorePhysicalKeyStatus KeyRoutedEventArgs::KeyStatus() noexcept {
winrt::Microsoft::UI::Input::PhysicalKeyStatus KeyRoutedEventArgs::KeyStatus() noexcept {
return m_keyStatus;
}

Expand Down Expand Up @@ -118,7 +118,7 @@ void CharacterReceivedRoutedEventArgs::Handled(bool value) noexcept {
int32_t CharacterReceivedRoutedEventArgs::KeyCode() noexcept {
return m_keycode;
}
winrt::Windows::UI::Core::CorePhysicalKeyStatus CharacterReceivedRoutedEventArgs::KeyStatus() noexcept {
winrt::Microsoft::UI::Input::PhysicalKeyStatus CharacterReceivedRoutedEventArgs::KeyStatus() noexcept {
return m_keyStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ struct KeyRoutedEventArgs : winrt::implements<
bool Handled() noexcept;
void Handled(bool value) noexcept;
winrt::Windows::System::VirtualKey Key() noexcept;
winrt::Windows::UI::Core::CorePhysicalKeyStatus KeyStatus() noexcept;
winrt::Microsoft::UI::Input::PhysicalKeyStatus KeyStatus() noexcept;
winrt::Windows::System::VirtualKey OriginalKey() noexcept;

private:
facebook::react::Tag m_tag{-1};
bool m_handled{false};
winrt::Windows::System::VirtualKey m_key;
winrt::Windows::UI::Core::CorePhysicalKeyStatus m_keyStatus;
winrt::Microsoft::UI::Input::PhysicalKeyStatus m_keyStatus;
};

struct CharacterReceivedRoutedEventArgs
Expand All @@ -57,13 +57,13 @@ struct CharacterReceivedRoutedEventArgs
bool Handled() noexcept;
void Handled(bool value) noexcept;
int32_t KeyCode() noexcept;
winrt::Windows::UI::Core::CorePhysicalKeyStatus KeyStatus() noexcept;
winrt::Microsoft::UI::Input::PhysicalKeyStatus KeyStatus() noexcept;

private:
facebook::react::Tag m_tag{-1};
bool m_handled{false};
int32_t m_keycode;
winrt::Windows::UI::Core::CorePhysicalKeyStatus m_keyStatus;
winrt::Microsoft::UI::Input::PhysicalKeyStatus m_keyStatus;
};

struct Pointer : PointerT<Pointer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,16 @@ struct CompScrollerVisual : winrt::implements<
m_visual.Brush(TTypeRedirects::CompositionContextHelper::InnerBrush(brush));
}

void ScrollEnabled(bool isScrollEnabled) noexcept {
if (isScrollEnabled) {
m_visualInteractionSource.ManipulationRedirectionMode(
TTypeRedirects::VisualInteractionSourceRedirectionMode::CapableTouchpadAndPointerWheel);
} else {
m_visualInteractionSource.ManipulationRedirectionMode(
TTypeRedirects::VisualInteractionSourceRedirectionMode::Off);
}
}

void Opacity(float opacity) noexcept {
m_visual.Opacity(opacity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ struct CompositionKeyboardSource
: winrt::implements<CompositionKeyboardSource, winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource> {
CompositionKeyboardSource(CompositionEventHandler *outer) : m_outer(outer) {}

winrt::Windows::UI::Core::CoreVirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept {
winrt::Microsoft::UI::Input::VirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept {
if (!m_outer)
return winrt::Windows::UI::Core::CoreVirtualKeyStates::None;
return winrt::Microsoft::UI::Input::VirtualKeyStates::None;
return m_outer->GetKeyState(key);
}

Expand All @@ -121,23 +121,11 @@ struct CompositionInputKeyboardSource : winrt::implements<
winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource> {
CompositionInputKeyboardSource(winrt::Microsoft::UI::Input::InputKeyboardSource source) : m_source(source) {}

winrt::Windows::UI::Core::CoreVirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept {
winrt::Microsoft::UI::Input::VirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept {
if (!m_source)
return winrt::Windows::UI::Core::CoreVirtualKeyStates::None;

static_assert(
static_cast<winrt::Windows::UI::Core::CoreVirtualKeyStates>(
winrt::Microsoft::UI::Input::VirtualKeyStates::Down) ==
winrt::Windows::UI::Core::CoreVirtualKeyStates::Down);
static_assert(
static_cast<winrt::Windows::UI::Core::CoreVirtualKeyStates>(
winrt::Microsoft::UI::Input::VirtualKeyStates::Locked) ==
winrt::Windows::UI::Core::CoreVirtualKeyStates::Locked);
static_assert(
static_cast<winrt::Windows::UI::Core::CoreVirtualKeyStates>(
winrt::Microsoft::UI::Input::VirtualKeyStates::None) ==
winrt::Windows::UI::Core::CoreVirtualKeyStates::None);
return static_cast<winrt::Windows::UI::Core::CoreVirtualKeyStates>(m_source.GetKeyState(key));
return winrt::Microsoft::UI::Input::VirtualKeyStates::None;

return m_source.GetKeyState(key);
}

void Disconnect() noexcept {
Expand Down Expand Up @@ -360,16 +348,15 @@ void CompositionEventHandler::onPointerWheelChanged(
}
}

winrt::Windows::UI::Core::CoreVirtualKeyStates CompositionEventHandler::GetKeyState(
winrt::Microsoft::UI::Input::VirtualKeyStates CompositionEventHandler::GetKeyState(
winrt::Windows::System::VirtualKey key) noexcept {
winrt::Windows::UI::Core::CoreVirtualKeyStates coreKeyState = winrt::Windows::UI::Core::CoreVirtualKeyStates::None;
winrt::Microsoft::UI::Input::VirtualKeyStates coreKeyState = winrt::Microsoft::UI::Input::VirtualKeyStates::None;
SHORT keyState = ::GetKeyState(static_cast<int>(key));
if (keyState & 0x01) {
coreKeyState = winrt::Windows::UI::Core::CoreVirtualKeyStates::Locked;
coreKeyState = winrt::Microsoft::UI::Input::VirtualKeyStates::Locked;
}
if (keyState & 0x8000) {
coreKeyState = static_cast<winrt::Windows::UI::Core::CoreVirtualKeyStates>(
static_cast<int>(coreKeyState) | static_cast<int>(winrt::Windows::UI::Core::CoreVirtualKeyStates::Down));
coreKeyState = coreKeyState | winrt::Microsoft::UI::Input::VirtualKeyStates::Down;
}

return coreKeyState;
Expand Down Expand Up @@ -510,10 +497,12 @@ void CompositionEventHandler::onKeyDown(
return;
}

bool fShift = source.GetKeyState(winrt::Windows::System::VirtualKey::Shift) ==
winrt::Windows::UI::Core::CoreVirtualKeyStates::Down;
bool fCtrl = source.GetKeyState(winrt::Windows::System::VirtualKey::Control) ==
winrt::Windows::UI::Core::CoreVirtualKeyStates::Down;
bool fShift =
(source.GetKeyState(winrt::Windows::System::VirtualKey::Shift) &
winrt::Microsoft::UI::Input::VirtualKeyStates::Down) == winrt::Microsoft::UI::Input::VirtualKeyStates::Down;
bool fCtrl =
(source.GetKeyState(winrt::Windows::System::VirtualKey::Control) &
winrt::Microsoft::UI::Input::VirtualKeyStates::Down) == winrt::Microsoft::UI::Input::VirtualKeyStates::Down;

if (fShift && fCtrl && args.Key() == static_cast<winrt::Windows::System::VirtualKey>(VkKeyScanA('d')) &&
Mso::React::ReactOptions::UseDeveloperSupport(m_context.Properties().Handle())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CompositionEventHandler {

int64_t SendMessage(HWND hwnd, uint32_t msg, uint64_t wParam, int64_t lParam) noexcept;
void RemoveTouchHandlers();
winrt::Windows::UI::Core::CoreVirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept;
winrt::Microsoft::UI::Input::VirtualKeyStates GetKeyState(winrt::Windows::System::VirtualKey key) noexcept;

bool CapturePointer(
const winrt::Microsoft::ReactNative::Composition::Input::Pointer &pointer,
Expand Down
Loading

0 comments on commit 7d828ea

Please sign in to comment.