Commit a2af2b05 authored by Mark Capella's avatar Mark Capella
Browse files

Bug 750295 - don't cache gStringBundle in nsAccessNode, r=surkov, f=tbsaunde

parent ff3edec5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()

void nsAccessNodeWrap::InitAccessibility()
{
  nsAccessNode::InitXPAccessibility();
}

void nsAccessNodeWrap::ShutdownAccessibility()
+0 −16
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsFocusManager.h"
#include "nsPresContext.h"
#include "mozilla/Services.h"
@@ -62,8 +61,6 @@ using namespace mozilla::a11y;
 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
 */

nsIStringBundle *nsAccessNode::gStringBundle = 0;

ApplicationAccessible* nsAccessNode::gApplicationAccessible = nsnull;

/*
@@ -149,25 +146,12 @@ nsAccessNode::GetApplicationAccessible()
  return gApplicationAccessible;
}

void nsAccessNode::InitXPAccessibility()
{
  nsCOMPtr<nsIStringBundleService> stringBundleService =
    mozilla::services::GetStringBundleService();
  if (stringBundleService) {
    // Static variables are released in ShutdownAllXPAccessibility();
    stringBundleService->CreateBundle(ACCESSIBLE_BUNDLE_URL, 
                                      &gStringBundle);
  }
}

void nsAccessNode::ShutdownXPAccessibility()
{
  // Called by nsAccessibilityService::Shutdown()
  // which happens when xpcom is shutting down
  // at exit of program

  NS_IF_RELEASE(gStringBundle);

  // Release gApplicationAccessible after everything else is shutdown
  // so we don't accidently create it again while tearing down root accessibles
  ApplicationAccessibleWrap::Unload();
+3 −10
Original line number Diff line number Diff line
@@ -69,9 +69,6 @@ class nsPresContext;
class nsIFrame;
class nsIDocShellTreeItem;

#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"

class nsAccessNode: public nsISupports
{
public:
@@ -82,7 +79,6 @@ public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)

    static void InitXPAccessibility();
  static void ShutdownXPAccessibility();

  /**
@@ -164,9 +160,6 @@ protected:
  nsCOMPtr<nsIContent> mContent;
  nsDocAccessible* mDoc;

  // Static data, we do our own refcounting for our static data.
  static nsIStringBundle* gStringBundle;

private:
  nsAccessNode() MOZ_DELETE;
  nsAccessNode(const nsAccessNode&) MOZ_DELETE;
+20 −6
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@

#include "nsLayoutUtils.h"
#include "nsIPresShell.h"
#include "nsIStringBundle.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIView.h"
@@ -626,11 +627,23 @@ nsAccessible::GetIndexInParent(PRInt32 *aIndexInParent)
}

void 
nsAccessible::TranslateString(const nsAString& aKey, nsAString& aStringOut)
nsAccessible::TranslateString(const nsString& aKey, nsAString& aStringOut)
{
  nsXPIDLString xsValue;
  nsCOMPtr<nsIStringBundleService> stringBundleService =
    services::GetStringBundleService();
  if (!stringBundleService)
    return;

  gStringBundle->GetStringFromName(PromiseFlatString(aKey).get(), getter_Copies(xsValue));
  nsCOMPtr<nsIStringBundle> stringBundle;
  stringBundleService->CreateBundle(
    "chrome://global-platform/locale/accessible.properties", 
    getter_AddRefs(stringBundle));
  if (!stringBundle)
    return;

  nsXPIDLString xsValue;
  nsresult rv = stringBundle->GetStringFromName(aKey.get(), getter_Copies(xsValue));
  if (NS_SUCCEEDED(rv))
    aStringOut.Assign(xsValue);
}

@@ -3293,7 +3306,8 @@ KeyBinding::ToPlatformFormat(nsAString& aValue) const
  nsCOMPtr<nsIStringBundleService> stringBundleService =
      mozilla::services::GetStringBundleService();
  if (stringBundleService)
    stringBundleService->CreateBundle(PLATFORM_KEYS_BUNDLE_URL,
    stringBundleService->CreateBundle(
      "chrome://global-platform/locale/platformKeys.properties",
      getter_AddRefs(keyStringBundle));

  if (!keyStringBundle)
+1 −1
Original line number Diff line number Diff line
@@ -662,7 +662,7 @@ public:
  /**
   * Return the localized string for the given key.
   */
  static void TranslateString(const nsAString& aKey, nsAString& aStringOut);
  static void TranslateString(const nsString& aKey, nsAString& aStringOut);

  /**
   * Return true if the accessible is defunct.
Loading