Fire a11y event on touch screens using screen readers

This commit is contained in:
Jacob Groundwater 2016-10-18 13:28:32 +09:00
parent cbe9768529
commit 9c9ba80978

View file

@ -72,6 +72,12 @@ const char* AppCommandToString(int command_id) {
} }
} }
bool IsScreenReaderActive() {
UINT screenReader = 0;
SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenReader, 0);
return screenReader && UiaClientsAreListening();
}
} // namespace } // namespace
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
@ -91,21 +97,20 @@ bool NativeWindowViews::PreHandleMSG(
// because we still want Chromium to handle returning the actual // because we still want Chromium to handle returning the actual
// accessibility object. // accessibility object.
case WM_GETOBJECT: { case WM_GETOBJECT: {
if (checked_for_a11y_support_) return false;
const DWORD obj_id = static_cast<DWORD>(l_param); const DWORD obj_id = static_cast<DWORD>(l_param);
if (obj_id != OBJID_CLIENT) { if (obj_id != OBJID_CLIENT) {
return false; return false;
} }
if (checked_for_a11y_support_) return false; if (!IsScreenReaderActive()) {
checked_for_a11y_support_ = true;
UINT screenReader = 0;
SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenReader, 0);
if (!screenReader || !UiaClientsAreListening()) {
return false; return false;
} }
checked_for_a11y_support_ = true;
const auto axState = content::BrowserAccessibilityState::GetInstance(); const auto axState = content::BrowserAccessibilityState::GetInstance();
if (axState && !axState->IsAccessibleBrowser()) { if (axState && !axState->IsAccessibleBrowser()) {
axState->OnScreenReaderDetected(); axState->OnScreenReaderDetected();