diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs index ec0ca345fab..5009a557828 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs @@ -598,25 +598,20 @@ internal static object FireContentRendered(object arg) /// Helper method which returns true when all the given visuals /// are in the same presentation source. /// - [FriendAccessAllowed] // To allow internal code paths to access this function - internal static bool UnderSamePresentationSource(params DependencyObject[] visuals) + internal static bool IsUnderSamePresentationSource(params ReadOnlySpan visuals) { - if (visuals == null || visuals.Length == 0) - { + if (visuals.IsEmpty) return true; - } PresentationSource baseSource = CriticalFromVisual(visuals[0]); - - int count = visuals.Length; - for (int i = 1; i < count; i++) + for (int i = 1; i < visuals.Length; i++) { - PresentationSource currentSource = CriticalFromVisual(visuals[i]); - if (currentSource != baseSource) + if (baseSource != CriticalFromVisual(visuals[i])) { return false; } } + return true; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridDetailsPresenter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridDetailsPresenter.cs index d3a17df613d..04077973eeb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridDetailsPresenter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridDetailsPresenter.cs @@ -109,7 +109,7 @@ private static void OnAnyMouseLeftButtonDownThunk(object sender, MouseButtonEven private void OnAnyMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e) { // Ignore actions if the button down arises from a different presentation source - if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) + if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) { return; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ScrollViewer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ScrollViewer.cs index e9e1160d139..ea4157aa30d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ScrollViewer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ScrollViewer.cs @@ -1654,7 +1654,7 @@ private bool ShouldManipulateScroll(ManipulationStartingEventArgs e, ScrollConte { // If the original source is not from the same PresentationSource as of ScrollViewer, // then do not start the manipulation. - if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) + if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) { return false; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs index 91dabdb5ac6..08c8c9d0c0c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs @@ -7053,7 +7053,7 @@ protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedb // If the original source is not from the same PresentationSource as of the Window, // then do not act on the PanningFeedback. - if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) + if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this)) { return; }