22// Licensed under the MIT License.
33
44#include " pch.h"
5- #include " NodeSimpleFragment .h"
5+ #include " AutomationFragment .h"
66
7- using unique_safearray = wil::unique_any<SAFEARRAY*, decltype (&::SafeArrayDestroy), ::SafeArrayDestroy>;
7+ using unique_safearray =
8+ wil::unique_any<SAFEARRAY*, decltype (&::SafeArrayDestroy), ::SafeArrayDestroy>;
89
910namespace winrt ::DrawingIslandComponents
1011{
11- void NodeSimpleFragment ::AddChildToEnd (
12- _In_ winrt::com_ptr<NodeSimpleFragment > const & child)
12+ void AutomationFragment ::AddChildToEnd (
13+ _In_ winrt::com_ptr<AutomationFragment > const & child)
1314 {
1415 std::unique_lock lock{ m_mutex };
1516
@@ -37,8 +38,8 @@ namespace winrt::DrawingIslandComponents
3738 m_children.push_back (child);
3839 }
3940
40- void NodeSimpleFragment ::RemoveChild (
41- _In_ winrt::com_ptr<NodeSimpleFragment > const & child)
41+ void AutomationFragment ::RemoveChild (
42+ _In_ winrt::com_ptr<AutomationFragment > const & child)
4243 {
4344 std::unique_lock lock{ m_mutex };
4445
@@ -79,7 +80,7 @@ namespace winrt::DrawingIslandComponents
7980 m_children.erase (iterator);
8081 }
8182
82- void NodeSimpleFragment ::RemoveAllChildren ()
83+ void AutomationFragment ::RemoveAllChildren ()
8384 {
8485 std::unique_lock lock{ m_mutex };
8586
@@ -95,56 +96,56 @@ namespace winrt::DrawingIslandComponents
9596 m_children.clear ();
9697 }
9798
98- void NodeSimpleFragment ::SetCallbackHandler (
99+ void AutomationFragment ::SetCallbackHandler (
99100 _In_opt_ IAutomationCallbackHandler const * const owner)
100101 {
101102 std::unique_lock lock{ m_mutex };
102103 m_ownerNoRef = owner;
103104 }
104105
105- void NodeSimpleFragment ::SetProviderOptions (
106+ void AutomationFragment ::SetProviderOptions (
106107 _In_ ProviderOptions const & providerOptions)
107108 {
108109 std::unique_lock lock{ m_mutex };
109110 m_providerOptions = providerOptions;
110111 }
111112
112- void NodeSimpleFragment ::SetName (
113+ void AutomationFragment ::SetName (
113114 _In_ std::wstring_view const & name)
114115 {
115116 std::unique_lock lock{ m_mutex };
116117 m_name = name;
117118 }
118119
119- void NodeSimpleFragment ::SetIsContent (
120+ void AutomationFragment ::SetIsContent (
120121 _In_ bool const & isContent)
121122 {
122123 std::unique_lock lock{ m_mutex };
123124 m_isContent = isContent;
124125 }
125126
126- void NodeSimpleFragment ::SetIsControl (
127+ void AutomationFragment ::SetIsControl (
127128 _In_ bool const & isControl)
128129 {
129130 std::unique_lock lock{ m_mutex };
130131 m_isControl = isControl;
131132 }
132133
133- void NodeSimpleFragment ::SetUiaControlTypeId (
134+ void AutomationFragment ::SetUiaControlTypeId (
134135 _In_ long const & uiaControlTypeId)
135136 {
136137 std::unique_lock lock{ m_mutex };
137138 m_uiaControlTypeId = uiaControlTypeId;
138139 }
139140
140- void NodeSimpleFragment ::SetHostProvider (
141+ void AutomationFragment ::SetHostProvider (
141142 _In_ winrt::com_ptr<IRawElementProviderSimple> const & hostProvider)
142143 {
143144 std::unique_lock lock{ m_mutex };
144145 m_hostProvider = hostProvider;
145146 }
146147
147- HRESULT __stdcall NodeSimpleFragment ::get_ProviderOptions (
148+ HRESULT __stdcall AutomationFragment ::get_ProviderOptions (
148149 _Out_ ProviderOptions* providerOptions)
149150 {
150151 try
@@ -159,7 +160,7 @@ namespace winrt::DrawingIslandComponents
159160 return S_OK;
160161 }
161162
162- HRESULT __stdcall NodeSimpleFragment ::GetPatternProvider (
163+ HRESULT __stdcall AutomationFragment ::GetPatternProvider (
163164 _In_ PATTERNID patternId,
164165 _COM_Outptr_opt_result_maybenull_ IUnknown** patternProvider)
165166 {
@@ -186,7 +187,7 @@ namespace winrt::DrawingIslandComponents
186187 return S_OK;
187188 }
188189
189- HRESULT __stdcall NodeSimpleFragment ::GetPropertyValue (
190+ HRESULT __stdcall AutomationFragment ::GetPropertyValue (
190191 _In_ PROPERTYID propertyId,
191192 _Out_ VARIANT* propertyValue)
192193 {
@@ -235,7 +236,7 @@ namespace winrt::DrawingIslandComponents
235236 return S_OK;
236237 }
237238
238- HRESULT __stdcall NodeSimpleFragment ::get_HostRawElementProvider (
239+ HRESULT __stdcall AutomationFragment ::get_HostRawElementProvider (
239240 _COM_Outptr_opt_result_maybenull_ IRawElementProviderSimple** hostRawElementProviderSimple)
240241 {
241242 try
@@ -250,7 +251,7 @@ namespace winrt::DrawingIslandComponents
250251 return S_OK;
251252 }
252253
253- HRESULT __stdcall NodeSimpleFragment ::Navigate (
254+ HRESULT __stdcall AutomationFragment ::Navigate (
254255 _In_ NavigateDirection direction,
255256 _COM_Outptr_opt_result_maybenull_ IRawElementProviderFragment** fragment)
256257 {
@@ -309,7 +310,7 @@ namespace winrt::DrawingIslandComponents
309310 return S_OK;
310311 }
311312
312- HRESULT __stdcall NodeSimpleFragment ::GetRuntimeId (
313+ HRESULT __stdcall AutomationFragment ::GetRuntimeId (
313314 _Outptr_opt_result_maybenull_ SAFEARRAY** runtimeId)
314315 {
315316 try
@@ -319,16 +320,18 @@ namespace winrt::DrawingIslandComponents
319320 {
320321 *runtimeId = nullptr ;
321322
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 ());
324325
325- unique_safearray runtimeIdArray{ ::SafeArrayCreateVector (VT_I4, 0 , arraySizeAsUnsignedLong) };
326+ unique_safearray runtimeIdArray
327+ { ::SafeArrayCreateVector (VT_I4, 0 , arraySizeAsUnsignedLong) };
326328 SAFEARRAY* rawPointerToSafeArray = runtimeIdArray.get ();
327329 winrt::check_pointer (rawPointerToSafeArray);
328330
329331 for (long i = 0 ; i < static_cast <long >(arraySizeAsUnsignedLong); ++i)
330332 {
331- winrt::check_hresult (::SafeArrayPutElement (rawPointerToSafeArray, &i, &(id[i])));
333+ winrt::check_hresult (
334+ ::SafeArrayPutElement (rawPointerToSafeArray, &i, &(m_runtimeId[i])));
332335 }
333336
334337 *runtimeId = runtimeIdArray.release ();
@@ -338,7 +341,7 @@ namespace winrt::DrawingIslandComponents
338341 return S_OK;
339342 }
340343
341- HRESULT __stdcall NodeSimpleFragment ::get_BoundingRectangle (
344+ HRESULT __stdcall AutomationFragment ::get_BoundingRectangle (
342345 _Out_ UiaRect* boundingRectangle)
343346 {
344347 try
@@ -348,12 +351,14 @@ namespace winrt::DrawingIslandComponents
348351 {
349352 *boundingRectangle = { 0 , 0 , 0 , 0 };
350353
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.
353357 if (nullptr != m_ownerNoRef)
354358 {
355359 auto screenRectangle =
356- m_ownerNoRef->GetScreenBoundsForAutomationFragment (get_strong ().as <::IUnknown>().get ());
360+ m_ownerNoRef->GetScreenBoundsForAutomationFragment (
361+ get_strong ().as <::IUnknown>().get ());
357362
358363 boundingRectangle->left = screenRectangle.X ;
359364 boundingRectangle->top = screenRectangle.Y ;
@@ -366,7 +371,7 @@ namespace winrt::DrawingIslandComponents
366371 return S_OK;
367372 }
368373
369- HRESULT __stdcall NodeSimpleFragment ::GetEmbeddedFragmentRoots (
374+ HRESULT __stdcall AutomationFragment ::GetEmbeddedFragmentRoots (
370375 _Outptr_opt_result_maybenull_ SAFEARRAY** embeddedFragmentRoots)
371376 {
372377 if (nullptr != embeddedFragmentRoots)
@@ -376,12 +381,12 @@ namespace winrt::DrawingIslandComponents
376381 return S_OK;
377382 }
378383
379- HRESULT __stdcall NodeSimpleFragment ::SetFocus ()
384+ HRESULT __stdcall AutomationFragment ::SetFocus ()
380385 {
381386 return S_OK;
382387 }
383388
384- HRESULT __stdcall NodeSimpleFragment ::get_FragmentRoot (
389+ HRESULT __stdcall AutomationFragment ::get_FragmentRoot (
385390 _COM_Outptr_opt_result_maybenull_ IRawElementProviderFragmentRoot** fragmentRoot)
386391 {
387392 try
@@ -394,61 +399,64 @@ namespace winrt::DrawingIslandComponents
394399 // Walk up our fragment tree until we find our fragment root.
395400 auto fragmentRootCandidate = get_strong ();
396401 bool currentCandidateIsThisObject = true ;
397- while (nullptr != fragmentRootCandidate && nullptr == fragmentRootCandidate.try_as <IRawElementProviderFragmentRoot>())
402+ while (nullptr != fragmentRootCandidate &&
403+ nullptr == fragmentRootCandidate.try_as <IRawElementProviderFragmentRoot>())
398404 {
399405 // Haven't found the fragment root yet, keep walking up our tree.
400406 fragmentRootCandidate = currentCandidateIsThisObject ?
401407 m_parent.get () : fragmentRootCandidate->GetParent ();
402408
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.
404411 currentCandidateIsThisObject = false ;
405412 }
406413
407414 if (nullptr != fragmentRootCandidate)
408415 {
409416 // Found the fragment root, return it.
410- fragmentRootCandidate.as <IRawElementProviderFragmentRoot>().copy_to (fragmentRoot);
417+ fragmentRootCandidate.as <IRawElementProviderFragmentRoot>().copy_to (
418+ fragmentRoot);
411419 }
412420 }
413421 }
414422 catch (...) { return UIA_E_ELEMENTNOTAVAILABLE; }
415423 return S_OK;
416424 }
417425
418- void NodeSimpleFragment ::SetParent (
419- _In_ winrt::weak_ref<NodeSimpleFragment > const & parent)
426+ void AutomationFragment ::SetParent (
427+ _In_ winrt::weak_ref<AutomationFragment > const & parent)
420428 {
421429 std::unique_lock lock{ m_mutex };
422430 m_parent = parent;
423431 }
424432
425- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetParent () const
433+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetParent () const
426434 {
427435 std::unique_lock lock{ m_mutex };
428436 return m_parent.get ();
429437 }
430438
431- void NodeSimpleFragment ::SetPreviousSibling (
432- _In_ winrt::weak_ref<NodeSimpleFragment > const & previousSibling)
439+ void AutomationFragment ::SetPreviousSibling (
440+ _In_ winrt::weak_ref<AutomationFragment > const & previousSibling)
433441 {
434442 std::unique_lock lock{ m_mutex };
435443 m_previousSibling = previousSibling;
436444 }
437445
438- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetPreviousSibling () const
446+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetPreviousSibling () const
439447 {
440448 std::unique_lock lock{ m_mutex };
441449 return m_previousSibling.get ();
442450 }
443451
444- void NodeSimpleFragment ::SetNextSibling (
445- _In_ winrt::weak_ref<NodeSimpleFragment > const & nextSibling)
452+ void AutomationFragment ::SetNextSibling (
453+ _In_ winrt::weak_ref<AutomationFragment > const & nextSibling)
446454 {
447455 std::unique_lock lock{ m_mutex };
448456 m_nextSibling = nextSibling;
449457 }
450458
451- winrt::com_ptr<NodeSimpleFragment> NodeSimpleFragment ::GetNextSibling () const
459+ winrt::com_ptr<AutomationFragment> AutomationFragment ::GetNextSibling () const
452460 {
453461 std::unique_lock lock{ m_mutex };
454462 return m_nextSibling.get ();
0 commit comments