Skip to content

Commit

Permalink
convert PresentationSource from params DependencyObject[] to params R…
Browse files Browse the repository at this point in the history
…eadOnlySpan<DependencyObject>
  • Loading branch information
h3xds1nz committed Sep 23, 2024
1 parent 6dfa53c commit 1217ef8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[FriendAccessAllowed] // To allow internal code paths to access this function
internal static bool UnderSamePresentationSource(params DependencyObject[] visuals)
internal static bool IsUnderSamePresentationSource(params ReadOnlySpan<DependencyObject> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1217ef8

Please # to comment.