From c474ad09134d2d3e5bdeff8be114cbb4a003ec0f Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 6 Apr 2016 10:16:41 -0700 Subject: [PATCH 1/2] Revert "Remove custom WM_GETOBJECT" This reverts commit 705001a50e3790c3c3e232dcb5be2ebf187b9417. --- atom/browser/native_window_views_win.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index e5ed1975f8..b395c4dd9b 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -84,6 +84,20 @@ bool NativeWindowViews::PreHandleMSG( NotifyWindowMessage(message, w_param, l_param); switch (message) { + // Screen readers send WM_GETOBJECT in order to get the accessibility + // object, so take this opportunity to push Chromium into accessible + // mode if it isn't already, always say we didn't handle the message + // because we still want Chromium to handle returning the actual + // accessibility object. + case WM_GETOBJECT: { + const DWORD obj_id = static_cast(l_param); + if (obj_id == OBJID_CLIENT) { + const auto axState = content::BrowserAccessibilityState::GetInstance(); + if (axState && !axState->IsAccessibleBrowser()) + axState->OnScreenReaderDetected(); + } + return false; + } case WM_COMMAND: // Handle thumbar button click message. if (HIWORD(w_param) == THBN_CLICKED) From 6e7aa6d299f5c4e5a7a2b59781c01778a03a5942 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 6 Apr 2016 10:36:39 -0700 Subject: [PATCH 2/2] Even though this call is probably fast, it can potentially happen a lot, make it _really_ fast --- atom/browser/native_window_views.h | 4 ++++ atom/browser/native_window_views_win.cc | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 862cd5458b..bcf3ca8bd1 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -199,6 +199,10 @@ class NativeWindowViews : public NativeWindow, // In charge of running taskbar related APIs. TaskbarHost taskbar_host_; + + // If true we have enabled a11y + bool enabled_a11y_support_; + #endif // Handles unhandled keyboard messages coming back from the renderer process. diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index b395c4dd9b..038ab10522 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -91,11 +91,16 @@ bool NativeWindowViews::PreHandleMSG( // accessibility object. case WM_GETOBJECT: { const DWORD obj_id = static_cast(l_param); + if (enabled_a11y_support_) return false; + if (obj_id == OBJID_CLIENT) { const auto axState = content::BrowserAccessibilityState::GetInstance(); - if (axState && !axState->IsAccessibleBrowser()) + if (axState && !axState->IsAccessibleBrowser()) { axState->OnScreenReaderDetected(); + enabled_a11y_support_ = true; + } } + return false; } case WM_COMMAND: