@@ -448,14 +448,14 @@ protected void RootChanged(Visual oldRoot, Visual newRoot)
448
448
// Always clear the RootSourceProperty on the old root.
449
449
if ( oldRoot != null )
450
450
{
451
- oldSource = CriticalGetPresentationSourceFromElement ( oldRoot , RootSourceProperty ) ;
451
+ oldSource = ( PresentationSource ) oldRoot . GetValue ( RootSourceProperty ) ;
452
452
oldRoot . ClearValue ( RootSourceProperty ) ;
453
453
}
454
454
455
455
// Always set the SourceProperty on the new root.
456
456
if ( newRoot != null )
457
457
{
458
- newRoot . SetValue ( RootSourceProperty , new SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ( this ) ) ;
458
+ newRoot . SetValue ( RootSourceProperty , this ) ;
459
459
}
460
460
461
461
UIElement oldRootUIElement = oldRoot as UIElement ;
@@ -493,7 +493,7 @@ protected void RootChanged(Visual oldRoot, Visual newRoot)
493
493
// same context as this presentation source.
494
494
if ( element . Dispatcher == Dispatcher )
495
495
{
496
- PresentationSource testSource = CriticalGetPresentationSourceFromElement ( element , CachedSourceProperty ) ;
496
+ PresentationSource testSource = ( PresentationSource ) element . GetValue ( CachedSourceProperty ) ;
497
497
// 1) If we are removing the rootvisual, then fire on any node whos old
498
498
// PresetationSource was the oldSource.
499
499
// 2) If we are attaching a rootvisual then fire on any node whos old
@@ -669,29 +669,11 @@ internal static WeakReferenceList CriticalCurrentSources
669
669
}
670
670
}
671
671
672
- private static PresentationSource CriticalGetPresentationSourceFromElement ( DependencyObject dObject , DependencyProperty dp )
673
- {
674
- PresentationSource testSource ;
675
- SecurityCriticalDataForMultipleGetAndSet < PresentationSource > tempCriticalDataWrapper =
676
- ( SecurityCriticalDataForMultipleGetAndSet < PresentationSource > )
677
- dObject . GetValue ( dp ) ;
678
- if ( tempCriticalDataWrapper == null || tempCriticalDataWrapper . Value == null )
679
- {
680
- testSource = null ;
681
- }
682
- else
683
- {
684
- testSource = tempCriticalDataWrapper . Value ;
685
- }
686
- return testSource ;
687
- }
688
-
689
672
private static void AddElementToWatchList ( DependencyObject element )
690
673
{
691
674
if ( _watchers . Add ( element ) )
692
675
{
693
- element . SetValue ( CachedSourceProperty , new
694
- SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ( PresentationSource . FindSource ( element ) ) ) ;
676
+ element . SetValue ( CachedSourceProperty , PresentationSource . FindSource ( element ) ) ;
695
677
element . SetValue ( GetsSourceChangedEventProperty , true ) ;
696
678
}
697
679
}
@@ -727,7 +709,7 @@ private static PresentationSource FindSource(DependencyObject o, bool enable2DTo
727
709
DependencyObject v = InputElement . GetRootVisual ( o , enable2DTo3DTransition ) ;
728
710
if ( v != null )
729
711
{
730
- source = CriticalGetPresentationSourceFromElement ( v , RootSourceProperty ) ;
712
+ source = ( PresentationSource ) v . GetValue ( RootSourceProperty ) ;
731
713
}
732
714
return source ;
733
715
}
@@ -739,10 +721,10 @@ private static bool UpdateSourceOfElement(DependencyObject doTarget,
739
721
bool calledOut = false ;
740
722
741
723
PresentationSource realSource = FindSource ( doTarget ) ;
742
- PresentationSource cachedSource = CriticalGetPresentationSourceFromElement ( doTarget , CachedSourceProperty ) ;
724
+ PresentationSource cachedSource = ( PresentationSource ) doTarget . GetValue ( CachedSourceProperty ) ;
743
725
if ( cachedSource != realSource )
744
726
{
745
- doTarget . SetValue ( CachedSourceProperty , new SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ( realSource ) ) ;
727
+ doTarget . SetValue ( CachedSourceProperty , realSource ) ;
746
728
747
729
SourceChangedEventArgs args = new SourceChangedEventArgs ( cachedSource , realSource ) ;
748
730
@@ -783,16 +765,16 @@ private static bool UpdateSourceOfElement(DependencyObject doTarget,
783
765
// element in a tree to the source it is displayed in). Use the public
784
766
// API FromVisual to get the source that a visual is displayed in.
785
767
private static readonly DependencyProperty RootSourceProperty
786
- = DependencyProperty . RegisterAttached ( "RootSource" , typeof ( SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ) , typeof ( PresentationSource ) ,
787
- new PropertyMetadata ( ( SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ) null ) ) ;
768
+ = DependencyProperty . RegisterAttached ( "RootSource" , typeof ( PresentationSource ) , typeof ( PresentationSource ) ,
769
+ new PropertyMetadata ( ( PresentationSource ) null ) ) ;
788
770
789
771
// We use a private DP for the CachedSource (stored on the elements
790
772
// that we are watching, so that we can send a change notification).
791
773
// Use the public API FromVisual to get the source that a visual is
792
774
// displayed in.
793
775
private static readonly DependencyProperty CachedSourceProperty
794
- = DependencyProperty . RegisterAttached ( "CachedSource" , typeof ( SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ) , typeof ( PresentationSource ) ,
795
- new PropertyMetadata ( ( SecurityCriticalDataForMultipleGetAndSet < PresentationSource > ) null ) ) ;
776
+ = DependencyProperty . RegisterAttached ( "CachedSource" , typeof ( PresentationSource ) , typeof ( PresentationSource ) ,
777
+ new PropertyMetadata ( ( PresentationSource ) null ) ) ;
796
778
797
779
// We use a private DP to mark elements that we are watchin.
798
780
private static readonly DependencyProperty GetsSourceChangedEventProperty = DependencyProperty . RegisterAttached ( "IsBeingWatched" , typeof ( bool ) , typeof ( PresentationSource ) , new PropertyMetadata ( ( bool ) false ) ) ;
0 commit comments