mozilla-a11y.patch
changeset 369 04fc00b85b21
parent 358 b28670af14d5
equal deleted inserted replaced
368:8891dd9439a1 369:04fc00b85b21
     1 # HG changeset patch
     1 # HG changeset patch
     2 # User Michael Gorse <mgorse@suse.com>
     2 # User Michael Gorse <mgorse@suse.com>
     3 # Parent d02253d1e8217008dfa26e6e2a901b6a8b75e989
     3 # Parent 2c115988d04c0a0a8cb75b3a597ecdb2c4c001c9
     4 a11y only enabled from Gnome 2's GConf setting
     4 a11y only enabled from Gnome 2's GConf setting
     5 https://bugzilla.novell.com/show_bug.cgi?id=732898
     5 https://bugzilla.novell.com/show_bug.cgi?id=732898
     6 https://bugzilla.mozilla.org/show_bug.cgi?id=693343
     6 https://bugzilla.mozilla.org/show_bug.cgi?id=693343
     7 
     7 
     8 diff --git a/accessible/src/atk/Makefile.in b/accessible/src/atk/Makefile.in
     8 diff --git a/accessible/src/atk/Makefile.in b/accessible/src/atk/Makefile.in
    29    -I$(topsrcdir)/other-licenses/atk-1.0 \
    29    -I$(topsrcdir)/other-licenses/atk-1.0 \
    30    $(NULL)
    30    $(NULL)
    31 diff --git a/accessible/src/atk/nsApplicationAccessibleWrap.cpp b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    31 diff --git a/accessible/src/atk/nsApplicationAccessibleWrap.cpp b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    32 --- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    32 --- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    33 +++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    33 +++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
    34 @@ -47,29 +47,27 @@
    34 @@ -47,29 +47,29 @@
    35  #include "nsIPrefBranch.h"
    35  #include "nsIPrefBranch.h"
    36  #include "nsIServiceManager.h"
    36  #include "nsIServiceManager.h"
    37  #include "nsAutoPtr.h"
    37  #include "nsAutoPtr.h"
    38  #include "nsAccessibilityService.h"
    38  #include "nsAccessibilityService.h"
    39  #include "AtkSocketAccessible.h"
    39  #include "AtkSocketAccessible.h"
    40  
    40  
    41  #include <gtk/gtk.h>
    41  #include <gtk/gtk.h>
    42  #include <atk/atk.h>
    42  #include <atk/atk.h>
       
    43 +#ifdef MOZ_ENABLE_DBUS
    43 +#include <dbus/dbus.h>
    44 +#include <dbus/dbus.h>
       
    45 +#endif
    44 +
    46 +
    45 +using namespace mozilla::a11y;
    47 +using namespace mozilla::a11y;
    46  
    48  
    47  typedef GType (* AtkGetTypeType) (void);
    49  typedef GType (* AtkGetTypeType) (void);
    48  GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
    50  GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
    49 -static bool sATKChecked = false;
    51  static bool sATKChecked = false;
    50 +static PRBool sATKChecked = PR_FALSE;
       
    51  static PRLibrary *sATKLib = nsnull;
    52  static PRLibrary *sATKLib = nsnull;
    52  static const char sATKLibName[] = "libatk-1.0.so.0";
    53  static const char sATKLibName[] = "libatk-1.0.so.0";
    53  static const char sATKHyperlinkImplGetTypeSymbol[] =
    54  static const char sATKHyperlinkImplGetTypeSymbol[] =
    54      "atk_hyperlink_impl_get_type";
    55      "atk_hyperlink_impl_get_type";
    55 -static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
    56 -static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
    63                                                   const gchar *event_type);
    64                                                   const gchar *event_type);
    64  static void (* gail_remove_global_event_listener) (guint remove_listener);
    65  static void (* gail_remove_global_event_listener) (guint remove_listener);
    65  static void (* gail_remove_key_event_listener) (guint remove_listener);
    66  static void (* gail_remove_key_event_listener) (guint remove_listener);
    66  static AtkObject * (*gail_get_root) (void);
    67  static AtkObject * (*gail_get_root) (void);
    67  
    68  
    68 @@ -609,36 +607,17 @@ toplevel_event_watcher(GSignalInvocation
    69 @@ -609,36 +609,17 @@ toplevel_event_watcher(GSignalInvocation
    69    }
    70    }
    70  
    71  
    71    return TRUE;
    72    return TRUE;
    72  }
    73  }
    73  
    74  
    74  PRBool
    75  bool
    75  nsApplicationAccessibleWrap::Init()
    76  nsApplicationAccessibleWrap::Init()
    76  {
    77  {
    77 -    // XXX following code is copied from widget/src/gtk2/nsWindow.cpp
    78 -    // XXX following code is copied from widget/src/gtk2/nsWindow.cpp
    78 -    // we should put it to somewhere that can be used from both modules
    79 -    // we should put it to somewhere that can be used from both modules
    79 -    // see bug 390761
    80 -    // see bug 390761
    80 -
    81 -
    81 -    // check if accessibility enabled/disabled by environment variable
    82 -    // check if accessibility enabled/disabled by environment variable
    82 -    PRBool isGnomeATEnabled = PR_FALSE;
    83 -    bool isGnomeATEnabled = false;
    83 -    const char *envValue = PR_GetEnv(sAccEnv);
    84 -    const char *envValue = PR_GetEnv(sAccEnv);
    84 -    if (envValue) {
    85 -    if (envValue) {
    85 -        isGnomeATEnabled = !!atoi(envValue);
    86 -        isGnomeATEnabled = !!atoi(envValue);
    86 -    } else {
    87 -    } else {
    87 -        //check gconf-2 setting
    88 -        //check gconf-2 setting
   101              (*sGail.init)();
   102              (*sGail.init)();
   102          }
   103          }
   103          else {
   104          else {
   104              MAI_LOG_DEBUG(("Fail to load lib: %s\n", sGail.libName));
   105              MAI_LOG_DEBUG(("Fail to load lib: %s\n", sGail.libName));
   105          }
   106          }
   106 @@ -877,8 +856,129 @@ LoadGtkModule(GnomeAccessibilityModule& 
   107 @@ -877,8 +858,129 @@ LoadGtkModule(GnomeAccessibilityModule& 
   107                         aModule.init ? aModule.shutdownName : aModule.initName,
   108                         aModule.init ? aModule.shutdownName : aModule.initName,
   108                         aModule.libName));
   109                         aModule.libName));
   109          PR_UnloadLibrary(aModule.lib);
   110          PR_UnloadLibrary(aModule.lib);
   110          aModule.lib = NULL;
   111          aModule.lib = NULL;
   111          return NS_ERROR_FAILURE;
   112          return NS_ERROR_FAILURE;
   115 +
   116 +
   116 +namespace mozilla {
   117 +namespace mozilla {
   117 +namespace a11y {
   118 +namespace a11y {
   118 +
   119 +
   119 +#ifdef MOZ_ENABLE_DBUS
   120 +#ifdef MOZ_ENABLE_DBUS
   120 +static DBusPendingCall *a11yPendingCall = NULL;
   121 +  static DBusPendingCall *a11yPendingCall = NULL;
   121 +#endif
   122 +#endif
   122 +
   123 +
   123 +void
   124 +void
   124 +PreInit()
   125 +PreInit()
   125 +{
   126 +{
   126 +  static PRBool sChecked = FALSE;
   127 +  static bool sChecked = false;
   127 +  if (sChecked)
   128 +  if (sChecked)
   128 +    return;
   129 +    return;
   129 +  sChecked = TRUE;
   130 +  sChecked = true;
   130 +  DBusError error;
   131 +  DBusError error;
   131 +  dbus_error_init(&error);
   132 +  dbus_error_init(&error);
   132 +  DBusConnection* bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
   133 +  DBusConnection* bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
   133 +  if (!bus)
   134 +  if (!bus)
   134 +    return;
   135 +    return;
   135 +  dbus_connection_set_exit_on_disconnect(bus, FALSE);
   136 +  dbus_connection_set_exit_on_disconnect(bus, false);
   136 +
   137 +
   137 +  DBusMessage *message;
   138 +  DBusMessage *message;
   138 +  message = dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
   139 +  message = dbus_message_new_method_call("org.a11y.Bus", "/org/a11y/bus",
   139 +                                         "org.freedesktop.DBus.Properties",
   140 +                                         "org.freedesktop.DBus.Properties",
   140 +                                         "Get");
   141 +                                         "Get");
   153 +  if (bus)
   154 +  if (bus)
   154 +    dbus_connection_unref(bus);
   155 +    dbus_connection_unref(bus);
   155 +  dbus_error_free(&error);
   156 +  dbus_error_free(&error);
   156 +}
   157 +}
   157 +
   158 +
   158 +PRBool
   159 +bool
   159 +ShouldA11yBeEnabled()
   160 +ShouldA11yBeEnabled()
   160 +{
   161 +{
   161 +  static PRBool sChecked = PR_FALSE, sShouldEnable = PR_FALSE;
   162 +  static bool sChecked = false, sShouldEnable = false;
   162 +  if (sChecked)
   163 +  if (sChecked)
   163 +    return sShouldEnable;
   164 +    return sShouldEnable;
   164 +
   165 +
   165 +  sChecked = PR_TRUE;
   166 +  sChecked = true;
   166 +
   167 +
   167 +  // check if accessibility enabled/disabled by environment variable
   168 +  // check if accessibility enabled/disabled by environment variable
   168 +  static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
   169 +  static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
   169 +  const char* envValue = PR_GetEnv(sAccEnv);
   170 +  const char* envValue = PR_GetEnv(sAccEnv);
   170 +  if (envValue)
   171 +  if (envValue)
   171 +    return sShouldEnable = !!atoi(envValue);
   172 +    return sShouldEnable = !!atoi(envValue);
   172 +
   173 +
   173 +#ifdef MOZ_ENABLE_DBUS
   174 +#ifdef MOZ_ENABLE_DBUS
   174 +  PreInit();
   175 +  PreInit();
   175 +  PRBool dbusSuccess = PR_FALSE;
   176 +  bool dbusSuccess = false;
   176 +  DBusMessage *reply = nsnull;
   177 +  DBusMessage *reply = nsnull;
   177 +  if (a11yPendingCall) {
   178 +  if (a11yPendingCall) {
   178 +    dbus_pending_call_block(a11yPendingCall);
   179 +    dbus_pending_call_block(a11yPendingCall);
   179 +    reply = dbus_pending_call_steal_reply(a11yPendingCall);
   180 +    reply = dbus_pending_call_steal_reply(a11yPendingCall);
   180 +    dbus_pending_call_unref(a11yPendingCall);
   181 +    dbus_pending_call_unref(a11yPendingCall);
   234 +} // namespace mozilla
   235 +} // namespace mozilla
   235 +
   236 +
   236 diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h
   237 diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h
   237 --- a/accessible/src/base/nsAccessibilityService.h
   238 --- a/accessible/src/base/nsAccessibilityService.h
   238 +++ b/accessible/src/base/nsAccessibilityService.h
   239 +++ b/accessible/src/base/nsAccessibilityService.h
   239 @@ -41,16 +41,36 @@
   240 @@ -46,16 +46,33 @@
   240  
   241  
   241  #include "nsIAccessibilityService.h"
   242  #include "mozilla/a11y/FocusManager.h"
   242  
       
   243  #include "a11yGeneric.h"
       
   244  #include "nsAccDocManager.h"
       
   245  
   243  
   246  #include "nsIObserver.h"
   244  #include "nsIObserver.h"
   247  
   245  
   248 +namespace mozilla {
   246  namespace mozilla {
   249 +namespace a11y {
   247  namespace a11y {
       
   248  
   250 +#ifdef MOZ_ACCESSIBILITY_ATK
   249 +#ifdef MOZ_ACCESSIBILITY_ATK
   251 +/**
   250 +/**
   252 + * Perform initialization that should be done as soon as possible, in order
   251 + * + * Perform initialization that should be done as soon as possible, in
   253 + * to minimize startup time.
   252 + * order
   254 + * XXX: this function and the next defined in nsApplicationAccessibleWrap.cpp
   253 + * + * to minimize startup time.
   255 + */
   254 + * + * XXX: this function and the next defined in
       
   255 + * nsApplicationAccessibleWrap.cpp
       
   256 + * + */
   256 +void PreInit();
   257 +void PreInit();
   257 +
   258 +
   258 +/**
   259 +/**
   259 + * Is platform accessibility enabled.
   260 + * + * Is platform accessibility enabled.
   260 + * Only used on linux with atk for now.
   261 + * + * Only used on linux with atk for now.
   261 + */
   262 + * + */
   262 +PRBool ShouldA11yBeEnabled();
   263 +bool ShouldA11yBeEnabled();
   263 +#endif
   264 +#endif
   264 +
   265 +
   265 +} // namespace a11y
   266  /**
   266 +} // namespace mozilla
   267   * Return focus manager.
   267 +
   268   */
   268  class nsAccessibilityService : public nsAccDocManager,
   269  FocusManager* FocusMgr();
   269                                 public nsIAccessibilityService,
   270  
   270                                 public nsIObserver
   271  } // namespace a11y
   271  {
   272  } // namespace mozilla
   272  public:
   273  
   273    virtual ~nsAccessibilityService();
       
   274  
       
   275    NS_DECL_ISUPPORTS_INHERITED
       
   276 diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp
   274 diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp
   277 --- a/widget/src/gtk2/nsWindow.cpp
   275 --- a/widget/src/gtk2/nsWindow.cpp
   278 +++ b/widget/src/gtk2/nsWindow.cpp
   276 +++ b/widget/src/gtk2/nsWindow.cpp
   279 @@ -103,29 +103,20 @@
   277 @@ -105,29 +105,21 @@
   280  #include "nsIStringBundle.h"
   278  #include "nsIStringBundle.h"
   281  #include "nsGfxCIID.h"
   279  #include "nsGfxCIID.h"
   282  #include "nsIObserverService.h"
   280  #include "nsIObserverService.h"
   283  
   281  
   284  #include "nsIdleService.h"
   282  #include "nsIdleService.h"
   290  #include "nsIAccessibleDocument.h"
   288  #include "nsIAccessibleDocument.h"
   291 -#include "prenv.h"
   289 -#include "prenv.h"
   292 -#include "stdlib.h"
   290 -#include "stdlib.h"
   293  
   291  
   294  using namespace mozilla;
   292  using namespace mozilla;
   295 -
   293  
   296 -static PRBool sAccessibilityChecked = PR_FALSE;
   294 -static bool sAccessibilityChecked = false;
   297 -/* static */
   295 -/* static */
   298 -PRBool nsWindow::sAccessibilityEnabled = PR_FALSE;
   296 -bool nsWindow::sAccessibilityEnabled = false;
   299 -static const char sSysPrefService [] = "@mozilla.org/system-preference-service;1";
   297 -static const char sSysPrefService [] = "@mozilla.org/system-preference-service;1";
   300 -static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
   298 -static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
   301 -static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility";
   299 -static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility";
   302  #endif
   300  #endif
   303  
   301  
   305  #include "nsAppDirectoryServiceDefs.h"
   303  #include "nsAppDirectoryServiceDefs.h"
   306  #include "nsXPIDLString.h"
   304  #include "nsXPIDLString.h"
   307  #include "nsIFile.h"
   305  #include "nsIFile.h"
   308  #include "nsILocalFile.h"
   306  #include "nsILocalFile.h"
   309  
   307  
   310 @@ -1109,19 +1100,18 @@ nsWindow::Show(PRBool aState)
   308 @@ -1111,19 +1103,18 @@ nsWindow::Show(bool aState)
   311              NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height,
   309              NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height,
   312                           PR_FALSE);
   310                           false);
   313          } else if (mNeedsResize) {
   311          } else if (mNeedsResize) {
   314              NativeResize(mBounds.width, mBounds.height, PR_FALSE);
   312              NativeResize(mBounds.width, mBounds.height, false);
   315          }
   313          }
   316      }
   314      }
   317  
   315  
   318  #ifdef ACCESSIBILITY
   316  #ifdef ACCESSIBILITY
   319 -    if (aState && sAccessibilityEnabled) {
   317 -    if (aState && sAccessibilityEnabled) {
   326  
   324  
   327      return NS_OK;
   325      return NS_OK;
   328  }
   326  }
   329  
   327  
   330  NS_IMETHODIMP
   328  NS_IMETHODIMP
   331 @@ -3887,16 +3877,21 @@ nsWindow::Create(nsIWidget        *aPare
   329 @@ -3885,16 +3876,21 @@ nsWindow::Create(nsIWidget        *aPare
   332      nsIWidget *baseParent = aInitData &&
   330      nsIWidget *baseParent = aInitData &&
   333          (aInitData->mWindowType == eWindowType_dialog ||
   331          (aInitData->mWindowType == eWindowType_dialog ||
   334           aInitData->mWindowType == eWindowType_toplevel ||
   332           aInitData->mWindowType == eWindowType_toplevel ||
   335           aInitData->mWindowType == eWindowType_invisible) ?
   333           aInitData->mWindowType == eWindowType_invisible) ?
   336          nsnull : aParent;
   334          nsnull : aParent;
   340 +#ifdef ACCESSIBILITY
   338 +#ifdef ACCESSIBILITY
   341 +    // Send a DBus message to check whether a11y is enabled
   339 +    // Send a DBus message to check whether a11y is enabled
   342 +    a11y::PreInit();
   340 +    a11y::PreInit();
   343 +#endif
   341 +#endif
   344 +
   342 +
       
   343      // Ensure that the toolkit is created.
       
   344      nsGTKToolkit::GetToolkit();
       
   345  
   345      // initialize all the common bits of this class
   346      // initialize all the common bits of this class
   346      BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
   347      BaseCreate(baseParent, aRect, aHandleEventFunction, aContext, aInitData);
   347                 aAppShell, aToolkit, aInitData);
       
   348  
   348  
   349      // Do we need to listen for resizes?
   349      // Do we need to listen for resizes?
   350      PRBool listenForResizes = PR_FALSE;;
   350      bool listenForResizes = false;;
   351      if (aNativeParent || (aInitData && aInitData->mListenForResizes))
   351 @@ -4278,43 +4274,16 @@ nsWindow::Create(nsIWidget        *aPare
   352          listenForResizes = PR_TRUE;
       
   353 @@ -4278,43 +4273,16 @@ nsWindow::Create(nsIWidget        *aPare
       
   354          LOG(("\tmGdkWindow %p %lx\n", (void *)mGdkWindow,
   352          LOG(("\tmGdkWindow %p %lx\n", (void *)mGdkWindow,
   355               gdk_x11_window_get_xid(mGdkWindow)));
   353               gdk_x11_window_get_xid(mGdkWindow)));
   356      }
   354      }
   357  
   355  
   358      // resize so that everything is set to the right dimensions
   356      // resize so that everything is set to the right dimensions
   359      if (!mIsTopLevel)
   357      if (!mIsTopLevel)
   360          Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, PR_FALSE);
   358          Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, false);
   361  
   359  
   362 -#ifdef ACCESSIBILITY
   360 -#ifdef ACCESSIBILITY
   363 -    nsresult rv;
   361 -    nsresult rv;
   364 -    if (!sAccessibilityChecked) {
   362 -    if (!sAccessibilityChecked) {
   365 -        sAccessibilityChecked = PR_TRUE;
   363 -        sAccessibilityChecked = true;
   366 -
   364 -
   367 -        //check if accessibility enabled/disabled by environment variable
   365 -        //check if accessibility enabled/disabled by environment variable
   368 -        const char *envValue = PR_GetEnv(sAccEnv);
   366 -        const char *envValue = PR_GetEnv(sAccEnv);
   369 -        if (envValue) {
   367 -        if (envValue) {
   370 -            sAccessibilityEnabled = atoi(envValue) != 0;
   368 -            sAccessibilityEnabled = atoi(envValue) != 0;
   392  
   390  
   393           D_ASSUME( mDFB != NULL );
   391           D_ASSUME( mDFB != NULL );
   394  
   392  
   395           if (mDFB)
   393           if (mDFB)
   396                mDFB->GetDisplayLayer( mDFB, DLID_PRIMARY, &mDFBLayer );
   394                mDFB->GetDisplayLayer( mDFB, DLID_PRIMARY, &mDFBLayer );
   397 @@ -6504,19 +6472,18 @@ nsWindow::DispatchAccessibleEvent()
   395 @@ -6504,19 +6473,18 @@ nsWindow::DispatchAccessibleEvent()
   398      DispatchEvent(&event, status);
   396      DispatchEvent(&event, status);
   399  
   397  
   400      return event.mAccessible;
   398      return event.mAccessible;
   401  }
   399  }
   402  
   400