bug 874483 - get rid of some static constructors in accessible/ r=surkov

This commit is contained in:
Trevor Saunders 2013-05-21 12:03:33 -04:00
parent 382f7130e7
commit 4a93ef6c5d
4 changed files with 23 additions and 19 deletions

View File

@ -7,6 +7,9 @@
#include "nsAccUtils.h"
#include "mozilla/StaticPtr.h"
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
@ -61,4 +64,4 @@ nsEventShell::GetEventAttributes(nsINode *aNode,
// nsEventShell: private
bool nsEventShell::sEventFromUserInput = false;
nsCOMPtr<nsINode> nsEventShell::sEventTargetNode;
StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;

View File

@ -8,6 +8,9 @@
#include "AccEvent.h"
namespace mozilla {
template<typename T> class StaticRefPtr;
}
class nsIPersistentProperties;
/**
@ -43,7 +46,7 @@ public:
nsIPersistentProperties *aAttributes);
private:
static nsCOMPtr<nsINode> sEventTargetNode;
static mozilla::StaticRefPtr<nsINode> sEventTargetNode;
static bool sEventFromUserInput;
};

View File

@ -19,6 +19,13 @@
using namespace mozilla::a11y;
/**
* The accessible for which we are computing a text equivalent. It is useful
* for bailing out during recursive text computation, or for special cases
* like step f. of the ARIA implementation guide.
*/
static Accessible* sInitiatorAcc = nullptr;
////////////////////////////////////////////////////////////////////////////////
// nsTextEquivUtils. Public.
@ -28,10 +35,10 @@ nsTextEquivUtils::GetNameFromSubtree(Accessible* aAccessible,
{
aName.Truncate();
if (gInitiatorAcc)
if (sInitiatorAcc)
return NS_OK;
gInitiatorAcc = aAccessible;
sInitiatorAcc = aAccessible;
if (GetRoleRule(aAccessible->Role()) == eNameFromSubtreeRule) {
//XXX: is it necessary to care the accessible is not a document?
if (aAccessible->IsContent()) {
@ -43,7 +50,7 @@ nsTextEquivUtils::GetNameFromSubtree(Accessible* aAccessible,
}
}
gInitiatorAcc = nullptr;
sInitiatorAcc = nullptr;
return NS_OK;
}
@ -92,10 +99,10 @@ nsTextEquivUtils::AppendTextEquivFromContent(Accessible* aInitiatorAcc,
nsAString *aString)
{
// Prevent recursion which can cause infinite loops.
if (gInitiatorAcc)
if (sInitiatorAcc)
return NS_OK;
gInitiatorAcc = aInitiatorAcc;
sInitiatorAcc = aInitiatorAcc;
// If the given content is not visible or isn't accessible then go down
// through the DOM subtree otherwise go down through accessible subtree and
@ -108,7 +115,7 @@ nsTextEquivUtils::AppendTextEquivFromContent(Accessible* aInitiatorAcc,
if (isVisible) {
Accessible* accessible =
gInitiatorAcc->Document()->GetAccessible(aContent);
sInitiatorAcc->Document()->GetAccessible(aContent);
if (accessible) {
rv = AppendFromAccessible(accessible, aString);
goThroughDOMSubtree = false;
@ -118,7 +125,7 @@ nsTextEquivUtils::AppendTextEquivFromContent(Accessible* aInitiatorAcc,
if (goThroughDOMSubtree)
rv = AppendFromDOMNode(aContent, aString);
gInitiatorAcc = nullptr;
sInitiatorAcc = nullptr;
return rv;
}
@ -176,8 +183,6 @@ nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent *aContent,
////////////////////////////////////////////////////////////////////////////////
// nsTextEquivUtils. Private.
nsRefPtr<Accessible> nsTextEquivUtils::gInitiatorAcc;
nsresult
nsTextEquivUtils::AppendFromAccessibleChildren(Accessible* aAccessible,
nsAString *aString)
@ -257,7 +262,7 @@ nsTextEquivUtils::AppendFromValue(Accessible* aAccessible,
// value if and only if the given accessible is in the middle of its parent.
nsAutoString text;
if (aAccessible != gInitiatorAcc) {
if (aAccessible != sInitiatorAcc) {
aAccessible->Value(text);
return AppendString(aString, text) ?

View File

@ -153,13 +153,6 @@ private:
* Returns the rule (constant of ETextEquivRule) for a given role.
*/
static uint32_t GetRoleRule(mozilla::a11y::roles::Role aRole);
/**
* The accessible for which we are computing a text equivalent. It is useful
* for bailing out during recursive text computation, or for special cases
* like step f. of the ARIA implementation guide.
*/
static nsRefPtr<Accessible> gInitiatorAcc;
};
#endif