]> khamidou — GitHub mirrors - electron.git/commitdiff
Re-enable accessibility in Electron on Windows
authorRyan Molden <rmolden@microsoft.com>
Wed, 4 Nov 2015 19:42:35 +0000 (11:42 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 5 Nov 2015 11:49:48 +0000 (19:49 +0800)
In conjunction with commit 7c41f0e.

atom/browser/native_window_views_win.cc

index d49683acb3cf80ce859d044b93c48a781e0d6f71..02ebd2ef32fceda976021bffa25ea2df72042688 100644 (file)
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "atom/browser/native_window_views.h"
+#include "content/public/browser/browser_accessibility_state.h"
 
 namespace atom {
 
@@ -83,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<DWORD>(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)