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

This commit is contained in:
Mark Capella 2012-05-10 22:43:04 +09:00
parent 79a2043a54
commit d34ff31bfe
8 changed files with 24 additions and 38 deletions

View File

@ -67,7 +67,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

View File

@ -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();

View File

@ -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:
@ -79,11 +76,10 @@ public:
nsAccessNode(nsIContent* aContent, nsDocAccessible* aDoc);
virtual ~nsAccessNode();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
static void InitXPAccessibility();
static void ShutdownXPAccessibility();
static void ShutdownXPAccessibility();
/**
* Return an application accessible.
@ -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;

View File

@ -82,6 +82,7 @@
#include "nsLayoutUtils.h"
#include "nsIPresShell.h"
#include "nsIStringBundle.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIView.h"
@ -626,12 +627,24 @@ 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));
aStringOut.Assign(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);
}
PRUint64
@ -3293,8 +3306,9 @@ KeyBinding::ToPlatformFormat(nsAString& aValue) const
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
if (stringBundleService)
stringBundleService->CreateBundle(PLATFORM_KEYS_BUNDLE_URL,
getter_AddRefs(keyStringBundle));
stringBundleService->CreateBundle(
"chrome://global-platform/locale/platformKeys.properties",
getter_AddRefs(keyStringBundle));
if (!keyStringBundle)
return;

View File

@ -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.

View File

@ -67,7 +67,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

View File

@ -588,8 +588,6 @@ void nsAccessNodeWrap::InitAccessibility()
Compatibility::Init();
nsWinUtils::MaybeStartWindowEmulation();
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()

View File

@ -66,7 +66,6 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
}
void nsAccessNodeWrap::ShutdownAccessibility()