@@ -34,24 +34,11 @@ enum NotificationType
34
34
VisualElement m_VisualTree ;
35
35
IVisualElementScheduledItem m_UpdateJob ;
36
36
UITkAccessibilityService m_AccessibilityService ;
37
- AccessibilitySubHierarchy m_SubHierarchy ;
38
37
39
38
/// <summary>
40
39
/// The sub-hierarchy this updater is managing.
41
40
/// </summary>
42
- public AccessibilitySubHierarchy hierarchy
43
- {
44
- get => m_SubHierarchy ;
45
- set
46
- {
47
- m_SubHierarchy = value ;
48
-
49
- if ( m_SubHierarchy . isValid && visualTree != null )
50
- {
51
- DirtyRootFrame ( ) ;
52
- }
53
- }
54
- }
41
+ public AccessibilitySubHierarchy hierarchy { get ; set ; }
55
42
56
43
/// <summary>
57
44
/// The panel of the visual tree being managed.
@@ -111,14 +98,10 @@ public VisualTreeAccessibilityUpdater(IPanel panel, VisualElement visualTree, UI
111
98
m_AccessibilityService = service ;
112
99
visualTree . RegisterCallback < AttachToPanelEvent > ( OnAttachmentToPanel ) ;
113
100
visualTree . RegisterCallback < GeometryChangedEvent > ( OnGeometryChanged ) ;
114
-
115
- DirtyRootFrame ( ) ;
116
101
}
117
102
118
103
void OnGeometryChanged ( GeometryChangedEvent evt )
119
104
{
120
- DirtyRootFrame ( ) ;
121
-
122
105
// OnScreenDebug.Log("OnGeometryChanged " + evt.target);
123
106
124
107
OnVersionChanged ( evt . target as VisualElement , VersionChangeType . Size | VersionChangeType . Transform ) ;
@@ -187,11 +170,10 @@ VisualElementAccessibilityHandler CreateHandler(VisualElement element)
187
170
188
171
void InsertNode ( VisualElementAccessibilityHandler parentHandler , VisualElementAccessibilityHandler accHandler )
189
172
{
190
- var p = parentHandler ;
191
- var parentNode = p ? . node ;
173
+ var parentNode = parentHandler ? . node ;
192
174
193
175
// Keep track of insertion index for each parent node.
194
- var index = p ? . nextInsertionIndex ?? m_RootNextInsertionIndex ;
176
+ var index = parentHandler ? . nextInsertionIndex ?? m_RootNextInsertionIndex ;
195
177
var node = hierarchy . InsertNode ( index , accHandler . ownerElement . name , parentNode ) ;
196
178
197
179
accHandler . node = node ;
@@ -202,9 +184,9 @@ void InsertNode(VisualElementAccessibilityHandler parentHandler, VisualElementAc
202
184
203
185
m_HandlersForNodes [ node ] = accHandler ;
204
186
205
- if ( p != null )
187
+ if ( parentHandler != null )
206
188
{
207
- p . nextInsertionIndex ++ ;
189
+ parentHandler . nextInsertionIndex ++ ;
208
190
}
209
191
else
210
192
{
@@ -216,14 +198,13 @@ void InsertNode(VisualElementAccessibilityHandler parentHandler, VisualElementAc
216
198
217
199
bool MoveNode ( VisualElementAccessibilityHandler parentElement , VisualElementAccessibilityHandler accHandler )
218
200
{
219
- var p = parentElement ;
220
- var parentNode = p ? . node ;
221
- var index = p ? . nextInsertionIndex ?? m_RootNextInsertionIndex ;
201
+ var parentNode = parentElement ? . node ;
202
+ var index = parentElement ? . nextInsertionIndex ?? m_RootNextInsertionIndex ;
222
203
var moved = hierarchy . MoveNode ( accHandler . node , parentNode , index ) ;
223
204
224
- if ( p != null )
205
+ if ( parentElement != null )
225
206
{
226
- p . nextInsertionIndex ++ ;
207
+ parentElement . nextInsertionIndex ++ ;
227
208
}
228
209
else
229
210
{
@@ -431,19 +412,6 @@ void GetMinMaxY(Vector3[] vector, out float min, out float max)
431
412
}
432
413
}
433
414
434
- void DirtyRootFrame ( )
435
- {
436
- m_AccessibilityService . DirtyRootFrames ( ) ;
437
- }
438
-
439
- public void UpdateRootFrame ( )
440
- {
441
- if ( hierarchy . isValid )
442
- {
443
- hierarchy . rootNode . frame = GetScreenPosition ( visualTree ) ;
444
- }
445
- }
446
-
447
415
void UpdateNode ( VisualElementAccessibilityHandler accElement )
448
416
{
449
417
if ( ! IsNodeValid ( accElement . node ) )
@@ -528,30 +496,9 @@ public void Update()
528
496
Update ( visualTree ) ;
529
497
}
530
498
531
- string GetPanelName ( VisualElement ve )
532
- {
533
- // Try to get the name of the panel using reflection.
534
- var panel = ve . panel ;
535
-
536
- if ( panel == null )
537
- {
538
- return null ;
539
- }
540
-
541
- var panelType = panel . GetType ( ) ;
542
- var nameProperty = panelType . GetProperty ( "name" ) ;
543
-
544
- if ( nameProperty != null )
545
- {
546
- return nameProperty . GetValue ( panel , null ) as string ;
547
- }
548
-
549
- return null ;
550
- }
551
-
552
499
NotificationType m_Notification = NotificationType . None ;
553
500
554
- void Update ( VisualElement visualTree )
501
+ void Update ( VisualElement ve )
555
502
{
556
503
var shouldSendNotification = false ;
557
504
@@ -563,13 +510,8 @@ void Update(VisualElement visualTree)
563
510
{
564
511
if ( ! hierarchy . isValid )
565
512
{
566
- var panelName = GetPanelName ( visualTree ) ;
567
- var rootNode = m_AccessibilityService . hierarchy . AddNode ( string . IsNullOrEmpty ( panelName ) ?
568
- visualTree . name : panelName ) ;
569
- rootNode . role = AccessibilityRole . Container ;
570
- rootNode . isActive = Application . platform == RuntimePlatform . OSXPlayer ;
571
- hierarchy = new AccessibilitySubHierarchy ( m_AccessibilityService . hierarchy . mainHierarchy , rootNode ) ;
572
- DirtyRootFrame ( ) ;
513
+ hierarchy = new AccessibilitySubHierarchy ( m_AccessibilityService . hierarchy . mainHierarchy ) ;
514
+
573
515
shouldSendNotification = true ;
574
516
}
575
517
@@ -580,24 +522,24 @@ void Update(VisualElement visualTree)
580
522
581
523
var modalElement = currentModalElement ;
582
524
583
- UpdateAccessibilityHierarchyRecursively ( visualTree , null , false , true ) ;
525
+ UpdateAccessibilityHierarchyRecursively ( ve , null , false , true ) ;
584
526
585
527
// If there is a current modal element or if the current model element has changed then update the
586
528
// active state of all nodes.
587
529
if ( currentModalElement != null || currentModalElement != modalElement )
588
530
{
589
531
OnScreenDebug . Log ( "Updating active state from modality " + currentModalElement ? . name ) ;
590
- UpdateActiveStateFromModalityRecursively ( visualTree ) ;
532
+ UpdateActiveStateFromModalityRecursively ( ve ) ;
591
533
}
592
534
}
593
535
594
536
if ( shouldSendNotification || m_Notification . HasFlag ( NotificationType . ScreenChanged ) )
595
537
{
596
- visualTree . schedule . Execute ( ( ) => AssistiveSupport . notificationDispatcher . SendScreenChanged ( ) ) ;
538
+ ve . schedule . Execute ( ( ) => AssistiveSupport . notificationDispatcher . SendScreenChanged ( ) ) ;
597
539
}
598
540
else if ( m_Notification . HasFlag ( NotificationType . LayoutChanged ) )
599
541
{
600
- visualTree . schedule . Execute ( ( ) => AssistiveSupport . notificationDispatcher . SendLayoutChanged ( ) ) ;
542
+ ve . schedule . Execute ( ( ) => AssistiveSupport . notificationDispatcher . SendLayoutChanged ( ) ) ;
601
543
}
602
544
}
603
545
0 commit comments