Browse Source

Merge pull request #7659 from electron/jacob/ally

Fire a11y event on touch screens using screen readers
Kevin Sawicki 8 years ago
parent
commit
104f8d6057
1 changed files with 11 additions and 6 deletions
  1. 11 6
      atom/browser/native_window_views_win.cc

+ 11 - 6
atom/browser/native_window_views_win.cc

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