Skip to content

Commit 10775f7

Browse files
committed
convert PresentationSource from params DependencyObject[] to params ReadOnlySpan<DependencyObject>
1 parent d508b08 commit 10775f7

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/PresentationSource.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,24 +594,20 @@ internal static object FireContentRendered(object arg)
594594
/// Helper method which returns true when all the given visuals
595595
/// are in the same presentation source.
596596
/// </summary>
597-
internal static bool UnderSamePresentationSource(params DependencyObject[] visuals)
597+
internal static bool IsUnderSamePresentationSource(params ReadOnlySpan<DependencyObject> visuals)
598598
{
599-
if (visuals == null || visuals.Length == 0)
600-
{
599+
if (visuals.IsEmpty)
601600
return true;
602-
}
603601

604602
PresentationSource baseSource = CriticalFromVisual(visuals[0]);
605-
606-
int count = visuals.Length;
607-
for (int i = 1; i < count; i++)
603+
for (int i = 1; i < visuals.Length; i++)
608604
{
609-
PresentationSource currentSource = CriticalFromVisual(visuals[i]);
610-
if (currentSource != baseSource)
605+
if (baseSource != CriticalFromVisual(visuals[i]))
611606
{
612607
return false;
613608
}
614609
}
610+
615611
return true;
616612
}
617613

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridDetailsPresenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private static void OnAnyMouseLeftButtonDownThunk(object sender, MouseButtonEven
109109
private void OnAnyMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
110110
{
111111
// Ignore actions if the button down arises from a different presentation source
112-
if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
112+
if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
113113
{
114114
return;
115115
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ScrollViewer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ private bool ShouldManipulateScroll(ManipulationStartingEventArgs e, ScrollConte
16541654
{
16551655
// If the original source is not from the same PresentationSource as of ScrollViewer,
16561656
// then do not start the manipulation.
1657-
if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
1657+
if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
16581658
{
16591659
return false;
16601660
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7053,7 +7053,7 @@ protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedb
70537053

70547054
// If the original source is not from the same PresentationSource as of the Window,
70557055
// then do not act on the PanningFeedback.
7056-
if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
7056+
if (!PresentationSource.IsUnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
70577057
{
70587058
return;
70597059
}

0 commit comments

Comments
 (0)