-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accessibility: Finalized Shared UIA Tree Model (#1915)
- Loading branch information
1 parent
6a501c1
commit c10a895
Showing
32 changed files
with
2,362 additions
and
2,568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
#include "pch.h" | ||
|
||
#include "WindowUiaProvider.hpp" | ||
#include "../types/ScreenInfoUiaProvider.h" | ||
|
||
#include "../host/renderData.hpp" | ||
|
||
WindowUiaProvider::WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow) : | ||
//_pScreenInfoProvider{ nullptr }, | ||
WindowUiaProviderBase(baseWindow) | ||
{ | ||
} | ||
|
||
WindowUiaProvider::~WindowUiaProvider() | ||
{ | ||
/*if (_pScreenInfoProvider) | ||
{ | ||
_pScreenInfoProvider->Release(); | ||
}*/ | ||
} | ||
|
||
WindowUiaProvider* WindowUiaProvider::Create(Microsoft::Console::Types::IConsoleWindow* baseWindow) | ||
{ | ||
WindowUiaProvider* pWindowProvider = nullptr; | ||
Microsoft::Console::Types::ScreenInfoUiaProvider* pScreenInfoProvider = nullptr; | ||
try | ||
{ | ||
pWindowProvider = new WindowUiaProvider(baseWindow); | ||
|
||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
/*Globals& g = ServiceLocator::LocateGlobals(); | ||
CONSOLE_INFORMATION& gci = g.getConsoleInformation(); | ||
Microsoft::Console::Render::IRenderData* renderData = &gci.renderData; | ||
pScreenInfoProvider = new Microsoft::Console::Types::ScreenInfoUiaProvider(renderData, pWindowProvider); | ||
pWindowProvider->_pScreenInfoProvider = pScreenInfoProvider; | ||
*/ | ||
|
||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree | ||
//Tracing::s_TraceUia(pWindowProvider, ApiCall::Create, nullptr); | ||
|
||
return pWindowProvider; | ||
} | ||
catch (...) | ||
{ | ||
if (nullptr != pWindowProvider) | ||
{ | ||
pWindowProvider->Release(); | ||
} | ||
|
||
if (nullptr != pScreenInfoProvider) | ||
{ | ||
pScreenInfoProvider->Release(); | ||
} | ||
|
||
LOG_CAUGHT_EXCEPTION(); | ||
|
||
return nullptr; | ||
} | ||
} | ||
|
||
[[nodiscard]] HRESULT WindowUiaProvider::SetTextAreaFocus() | ||
{ | ||
try | ||
{ | ||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
//return _pScreenInfoProvider->Signal(UIA_AutomationFocusChangedEventId); | ||
} | ||
CATCH_RETURN(); | ||
} | ||
|
||
[[nodiscard]] HRESULT WindowUiaProvider::Signal(_In_ EVENTID id) | ||
{ | ||
HRESULT hr = S_OK; | ||
|
||
// ScreenInfoUiaProvider is responsible for signaling selection | ||
// changed events and text changed events | ||
if (id == UIA_Text_TextSelectionChangedEventId || | ||
id == UIA_Text_TextChangedEventId) | ||
{ | ||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
/*if (_pScreenInfoProvider) | ||
{ | ||
hr = _pScreenInfoProvider->Signal(id); | ||
} | ||
else | ||
{ | ||
hr = E_POINTER; | ||
}*/ | ||
hr = E_POINTER; | ||
return hr; | ||
} | ||
|
||
if (_signalEventFiring.find(id) != _signalEventFiring.end() && | ||
_signalEventFiring[id] == true) | ||
{ | ||
return hr; | ||
} | ||
|
||
try | ||
{ | ||
_signalEventFiring[id] = true; | ||
} | ||
CATCH_RETURN(); | ||
|
||
IRawElementProviderSimple* pProvider = static_cast<IRawElementProviderSimple*>(this); | ||
hr = UiaRaiseAutomationEvent(pProvider, id); | ||
_signalEventFiring[id] = false; | ||
|
||
return hr; | ||
} | ||
|
||
#pragma region IRawElementProviderFragment | ||
|
||
IFACEMETHODIMP WindowUiaProvider::Navigate(_In_ NavigateDirection direction, _COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) | ||
{ | ||
RETURN_IF_FAILED(_EnsureValidHwnd()); | ||
*ppProvider = nullptr; | ||
HRESULT hr = S_OK; | ||
|
||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
/*if (direction == NavigateDirection_FirstChild || direction == NavigateDirection_LastChild) | ||
{ | ||
*ppProvider = _pScreenInfoProvider; | ||
(*ppProvider)->AddRef(); | ||
// signal that the focus changed | ||
LOG_IF_FAILED(_pScreenInfoProvider->Signal(UIA_AutomationFocusChangedEventId)); | ||
}*/ | ||
|
||
// For the other directions (parent, next, previous) the default of nullptr is correct | ||
return hr; | ||
} | ||
|
||
IFACEMETHODIMP WindowUiaProvider::SetFocus() | ||
{ | ||
RETURN_IF_FAILED(_EnsureValidHwnd()); | ||
return Signal(UIA_AutomationFocusChangedEventId); | ||
} | ||
#pragma endregion | ||
|
||
#pragma region IRawElementProviderFragmentRoot | ||
|
||
IFACEMETHODIMP WindowUiaProvider::ElementProviderFromPoint(_In_ double /*x*/, | ||
_In_ double /*y*/, | ||
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) | ||
{ | ||
RETURN_IF_FAILED(_EnsureValidHwnd()); | ||
|
||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
/**ppProvider = _pScreenInfoProvider; | ||
(*ppProvider)->AddRef();*/ | ||
|
||
return S_OK; | ||
} | ||
|
||
IFACEMETHODIMP WindowUiaProvider::GetFocus(_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) | ||
{ | ||
RETURN_IF_FAILED(_EnsureValidHwnd()); | ||
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider | ||
//return _pScreenInfoProvider->QueryInterface(IID_PPV_ARGS(ppProvider)); | ||
return S_OK; | ||
} | ||
|
||
#pragma endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
Module Name: | ||
- windowUiaProvider.hpp | ||
Abstract: | ||
- This module provides UI Automation access to the console window to | ||
support both automation tests and accessibility (screen reading) | ||
applications. | ||
- Based on examples, sample code, and guidance from | ||
https://msdn.microsoft.com/en-us/library/windows/desktop/ee671596(v=vs.85).aspx | ||
Author(s): | ||
- Michael Niksa (MiNiksa) 2017 | ||
- Austin Diviness (AustDi) 2017 | ||
- Carlos Zamora (CaZamor) 2019 | ||
--*/ | ||
|
||
#pragma once | ||
|
||
#include "../types/WindowUiaProviderBase.hpp" | ||
|
||
class WindowUiaProvider final : | ||
public Microsoft::Console::Types::WindowUiaProviderBase | ||
{ | ||
public: | ||
static WindowUiaProvider* Create(Microsoft::Console::Types::IConsoleWindow* baseWindow); | ||
|
||
[[nodiscard]] HRESULT Signal(_In_ EVENTID id) override; | ||
[[nodiscard]] HRESULT SetTextAreaFocus() override; | ||
|
||
// IRawElementProviderFragment methods | ||
IFACEMETHODIMP Navigate(_In_ NavigateDirection direction, | ||
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override; | ||
IFACEMETHODIMP SetFocus() override; | ||
|
||
// IRawElementProviderFragmentRoot methods | ||
IFACEMETHODIMP ElementProviderFromPoint(_In_ double x, | ||
_In_ double y, | ||
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override; | ||
IFACEMETHODIMP GetFocus(_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) override; | ||
|
||
private: | ||
WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow); | ||
~WindowUiaProvider(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.