2
2
// Licensed under the MIT License.
3
3
4
4
#include " pch.h"
5
- #include " NodeSimpleFragment .h"
5
+ #include " AutomationFragment .h"
6
6
7
- using unique_safearray = wil::unique_any<SAFEARRAY*, decltype (&::SafeArrayDestroy), ::SafeArrayDestroy>;
7
+ using unique_safearray =
8
+ wil::unique_any<SAFEARRAY*, decltype (&::SafeArrayDestroy), ::SafeArrayDestroy>;
8
9
9
10
namespace winrt ::DrawingIslandComponents
10
11
{
11
- void NodeSimpleFragment ::AddChildToEnd (
12
- _In_ winrt::com_ptr<NodeSimpleFragment > const & child)
12
+ void AutomationFragment ::AddChildToEnd (
13
+ _In_ winrt::com_ptr<AutomationFragment > const & child)
13
14
{
14
15
std::unique_lock lock{ m_mutex };
15
16
@@ -37,8 +38,8 @@ namespace winrt::DrawingIslandComponents
37
38
m_children.push_back (child);
38
39
}
39
40
40
- void NodeSimpleFragment ::RemoveChild (
41
- _In_ winrt::com_ptr<NodeSimpleFragment > const & child)
41
+ void AutomationFragment ::RemoveChild (
42
+ _In_ winrt::com_ptr<AutomationFragment > const & child)
42
43
{
43
44
std::unique_lock lock{ m_mutex };
44
45
@@ -79,7 +80,7 @@ namespace winrt::DrawingIslandComponents
79
80
m_children.erase (iterator);
80
81
}
81
82
82
- void NodeSimpleFragment ::RemoveAllChildren ()
83
+ void AutomationFragment ::RemoveAllChildren ()
83
84
{
84
85
std::unique_lock lock{ m_mutex };
85
86
@@ -95,56 +96,56 @@ namespace winrt::DrawingIslandComponents
95
96
m_children.clear ();
96
97
}
97
98
98
- void NodeSimpleFragment ::SetCallbackHandler (
99
+ void AutomationFragment ::SetCallbackHandler (
99
100
_In_opt_ IAutomationCallbackHandler const * const owner)
100
101
{
101
102
std::unique_lock lock{ m_mutex };
102
103
m_ownerNoRef = owner;
103
104
}
104
105
105
- void NodeSimpleFragment ::SetProviderOptions (
106
+ void AutomationFragment ::SetProviderOptions (
106
107
_In_ ProviderOptions const & providerOptions)
107
108
{
108
109
std::unique_lock lock{ m_mutex };
109
110
m_providerOptions = providerOptions;
110
111
}
111
112
112
- void NodeSimpleFragment ::SetName (
113
+ void AutomationFragment ::SetName (
113
114
_In_ std::wstring_view const & name)
114
115
{
115
116
std::unique_lock lock{ m_mutex };
116
117
m_name = name;
117
118
}
118
119
119
- void NodeSimpleFragment ::SetIsContent (
120
+ void AutomationFragment ::SetIsContent (
120
121
_In_ bool const & isContent)
121
122
{
122
123
std::unique_lock lock{ m_mutex };
123
124
m_isContent = isContent;
124
125
}
125
126
126
- void NodeSimpleFragment ::SetIsControl (
127
+ void AutomationFragment ::SetIsControl (
127
128
_In_ bool const & isControl)
128
129
{
129
130
std::unique_lock lock{ m_mutex };
130
131
m_isControl = isControl;
131
132
}
132
133
133
- void NodeSimpleFragment ::SetUiaControlTypeId (
134
+ void AutomationFragment ::SetUiaControlTypeId (
134
135
_In_ long const & uiaControlTypeId)
135
136
{
136
137
std::unique_lock lock{ m_mutex };
137
138
m_uiaControlTypeId = uiaControlTypeId;
138
139
}
139
140
140
- void NodeSimpleFragment ::SetHostProvider (
141
+ void AutomationFragment ::SetHostProvider (
141
142
_In_ winrt::com_ptr<IRawElementProviderSimple> const & hostProvider)
142
143
{
143
144
std::unique_lock lock{ m_mutex };
144
145
m_hostProvider = hostProvider;
145
146
}
146
147
147
- HRESULT __stdcall NodeSimpleFragment ::get_ProviderOptions (
148
+ HRESULT __stdcall AutomationFragment ::get_ProviderOptions (
148
149
_Out_ ProviderOptions* providerOptions)
149
150
{
150
151
try
@@ -159,7 +160,7 @@ namespace winrt::DrawingIslandComponents
159
160
return S_OK;
160
161
}
161
162
162
- HRESULT __stdcall NodeSimpleFragment ::GetPatternProvider (
163
+ HRESULT __stdcall AutomationFragment ::GetPatternProvider (
163
164
_In_ PATTERNID patternId,
164
165
_COM_Outptr_opt_result_maybenull_ IUnknown** patternProvider)
165
166
{
@@ -186,7 +187,7 @@ namespace winrt::DrawingIslandComponents
186
187
return S_OK;
187
188
}
188
189
189
- HRESULT __stdcall NodeSimpleFragment ::GetPropertyValue (
190
+ HRESULT __stdcall AutomationFragment ::GetPropertyValue (
190
191
_In_ PROPERTYID propertyId,
191
192
_Out_ VARIANT* propertyValue)
192
193
{
@@ -235,7 +236,7 @@ namespace winrt::DrawingIslandComponents
235
236
return S_OK;
236
237
}
237
238
238
- HRESULT __stdcall NodeSimpleFragment ::get_HostRawElementProvider (
239
+ HRESULT __stdcall AutomationFragment ::get_HostRawElementProvider (
239
240
_COM_Outptr_opt_result_maybenull_ IRawElementProviderSimple** hostRawElementProviderSimple)
240
241
{
241
242
try
@@ -250,7 +251,7 @@ namespace winrt::DrawingIslandComponents
250
251
return S_OK;
251
252
}
252
253
253
- HRESULT __stdcall NodeSimpleFragment ::Navigate (
254
+ HRESULT __stdcall AutomationFragment ::Navigate (
254
255
_In_ NavigateDirection direction,
255
256
_COM_Outptr_opt_result_maybenull_ IRawElementProviderFragment** fragment)
256
257
{
@@ -309,7 +310,7 @@ namespace winrt::DrawingIslandComponents
309
310
return S_OK;
310
311
}
311
312
312
- HRESULT __stdcall NodeSimpleFragment ::GetRuntimeId (
313
+ HRESULT __stdcall AutomationFragment ::GetRuntimeId (
313
314
_Outptr_opt_result_maybenull_ SAFEARRAY** runtimeId)
314
315
{
315
316
try
@@ -319,16 +320,18 @@ namespace winrt::DrawingIslandComponents
319
320
{
320
321
*runtimeId = nullptr ;
321
322
322
- std::array< unsigned __int32, 2 > id{ UiaAppendRuntimeId, m_internalRuntimeId };
323
- unsigned long arraySizeAsUnsignedLong = static_cast <unsigned long >(id .size ());
323
+ unsigned long arraySizeAsUnsignedLong =
324
+ static_cast <unsigned long >(m_runtimeId .size ());
324
325
325
- unique_safearray runtimeIdArray{ ::SafeArrayCreateVector (VT_I4, 0 , arraySizeAsUnsignedLong) };
326
+ unique_safearray runtimeIdArray
327
+ { ::SafeArrayCreateVector (VT_I4, 0 , arraySizeAsUnsignedLong) };
326
328
SAFEARRAY* rawPointerToSafeArray = runtimeIdArray.get ();
327
329
winrt::check_pointer (rawPointerToSafeArray);
328
330
329
331
for (long i = 0 ; i < static_cast <long >(arraySizeAsUnsignedLong); ++i)
330
332
{
331
- winrt::check_hresult (::SafeArrayPutElement (rawPointerToSafeArray, &i, &(id[i])));
333
+ winrt::check_hresult (
334
+ ::SafeArrayPutElement (rawPointerToSafeArray, &i, &(m_runtimeId[i])));
332
335
}
333
336
334
337
*runtimeId = runtimeIdArray.release ();
@@ -338,7 +341,7 @@ namespace winrt::DrawingIslandComponents
338
341
return S_OK;
339
342
}
340
343
341
- HRESULT __stdcall NodeSimpleFragment ::get_BoundingRectangle (
344
+ HRESULT __stdcall AutomationFragment ::get_BoundingRectangle (
342
345
_Out_ UiaRect* boundingRectangle)
343
346
{
344
347
try
@@ -348,12 +351,14 @@ namespace winrt::DrawingIslandComponents
348
351
{
349
352
*boundingRectangle = { 0 , 0 , 0 , 0 };
350
353
351
- // This provider might still be alive in a UIA callback when the DrawingIsland is being torn down.
352
- // Make sure we still have a valid owner before proceeding to query the DrawingIsland for this information.
354
+ // This provider might still be alive in a UIA callback when the DrawingIsland
355
+ // is being torn down. Make sure we still have a valid owner before proceeding
356
+ // to query the DrawingIsland for this information.
353
357
if (nullptr != m_ownerNoRef)
354
358
{
355
359
auto screenRectangle =
356
- m_ownerNoRef->GetScreenBoundsForAutomationFragment (get_strong ().as <::IUnknown>().get ());
360
+ m_ownerNoRef->GetScreenBoundsForAutomationFragment (
361
+ get_strong ().as <::IUnknown>().get ());
357
362
358
363
boundingRectangle->left = screenRectangle.X ;
359
364
boundingRectangle->top = screenRectangle.Y ;
@@ -366,7 +371,7 @@ namespace winrt::DrawingIslandComponents
366
371
return S_OK;
367
372
}
368
373
369
- HRESULT __stdcall NodeSimpleFragment ::GetEmbeddedFragmentRoots (
374
+ HRESULT __stdcall AutomationFragment ::GetEmbeddedFragmentRoots (
370
375
_Outptr_opt_result_maybenull_ SAFEARRAY** embeddedFragmentRoots)
371
376
{
372
377
if (nullptr != embeddedFragmentRoots)
@@ -376,12 +381,12 @@ namespace winrt::DrawingIslandComponents
376
381
return S_OK;
377
382
}
378
383
379
- HRESULT __stdcall NodeSimpleFragment ::SetFocus ()
384
+ HRESULT __stdcall AutomationFragment ::SetFocus ()
380
385
{
381
386
return S_OK;
382
387
}
383
388
384
- HRESULT __stdcall NodeSimpleFragment ::get_FragmentRoot (
389
+ HRESULT __stdcall AutomationFragment ::get_FragmentRoot (
385
390
_COM_Outptr_opt_result_maybenull_ IRawElementProviderFragmentRoot** fragmentRoot)
386
391
{
387
392
try
@@ -394,61 +399,64 @@ namespace winrt::DrawingIslandComponents
394
399
// Walk up our fragment tree until we find our fragment root.
395
400
auto fragmentRootCandidate = get_strong ();
396
401
bool currentCandidateIsThisObject = true ;
397
- while (nullptr != fragmentRootCandidate && nullptr == fragmentRootCandidate.try_as <IRawElementProviderFragmentRoot>())
402
+ while (nullptr != fragmentRootCandidate &&
403
+ nullptr == fragmentRootCandidate.try_as <IRawElementProviderFragmentRoot>())
398
404
{
399
405
// Haven't found the fragment root yet, keep walking up our tree.
400
406
fragmentRootCandidate = currentCandidateIsThisObject ?
401
407
m_parent.get () : fragmentRootCandidate->GetParent ();
402
408
403
- // Once we start walking up the tree, we must ensure we're thread-safe and call through GetParent on the other objects.
409
+ // Once we start walking up the tree, we must ensure we're thread-safe
410
+ // and call through GetParent on the other objects.
404
411
currentCandidateIsThisObject = false ;
405
412
}
406
413
407
414
if (nullptr != fragmentRootCandidate)
408
415
{
409
416
// Found the fragment root, return it.
410
- fragmentRootCandidate.as <IRawElementProviderFragmentRoot>().copy_to (fragmentRoot);
417
+ fragmentRootCandidate.as <IRawElementProviderFragmentRoot>().copy_to (
418
+ fragmentRoot);
411
419
}
412
420
}
413
421
}
414
422
catch (...) { return UIA_E_ELEMENTNOTAVAILABLE; }
415
423
return S_OK;
416
424
}
417
425
418
- void NodeSimpleFragment ::SetParent (
419
- _In_ winrt::weak_ref<NodeSimpleFragment > const & parent)
426
+ void AutomationFragment ::SetParent (
427
+ _In_ winrt::weak_ref<AutomationFragment > const & parent)
420
428
{
421
429
std::unique_lock lock{ m_mutex };
422
430
m_parent = parent;
423
431
}
424
432
425
- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetParent () const
433
+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetParent () const
426
434
{
427
435
std::unique_lock lock{ m_mutex };
428
436
return m_parent.get ();
429
437
}
430
438
431
- void NodeSimpleFragment ::SetPreviousSibling (
432
- _In_ winrt::weak_ref<NodeSimpleFragment > const & previousSibling)
439
+ void AutomationFragment ::SetPreviousSibling (
440
+ _In_ winrt::weak_ref<AutomationFragment > const & previousSibling)
433
441
{
434
442
std::unique_lock lock{ m_mutex };
435
443
m_previousSibling = previousSibling;
436
444
}
437
445
438
- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetPreviousSibling () const
446
+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetPreviousSibling () const
439
447
{
440
448
std::unique_lock lock{ m_mutex };
441
449
return m_previousSibling.get ();
442
450
}
443
451
444
- void NodeSimpleFragment ::SetNextSibling (
445
- _In_ winrt::weak_ref<NodeSimpleFragment > const & nextSibling)
452
+ void AutomationFragment ::SetNextSibling (
453
+ _In_ winrt::weak_ref<AutomationFragment > const & nextSibling)
446
454
{
447
455
std::unique_lock lock{ m_mutex };
448
456
m_nextSibling = nextSibling;
449
457
}
450
458
451
- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetNextSibling () const
459
+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetNextSibling () const
452
460
{
453
461
std::unique_lock lock{ m_mutex };
454
462
return m_nextSibling.get ();
0 commit comments