Bug 1388113 - Hold on to pseudo-element atoms longer. r=bholley

MozReview-Commit-ID: 98eW8VwVFPT

--HG--
extra : rebase_source : dc0b80d9cc693da3abe858ba52d691416332dee7
This commit is contained in:
Cameron McCormack 2017-08-17 14:37:32 -04:00
parent 8914671bb9
commit c8564a9ea5
3 changed files with 8 additions and 6 deletions

View File

@ -3002,7 +3002,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(nsIDOMElement* aElement,
return NS_ERROR_FAILURE;
}
nsIAtom* pseudo = nsCSSPseudoElements::GetPseudoAtom(aPseudoElement);
nsCOMPtr<nsIAtom> pseudo = nsCSSPseudoElements::GetPseudoAtom(aPseudoElement);
RefPtr<nsStyleContext> styleContext =
nsComputedDOMStyle::GetUnanimatedStyleContextNoFlush(element,
pseudo, shell);

View File

@ -118,7 +118,7 @@ nsCSSPseudoElements::GetPseudoAtom(Type aType)
static_cast<CSSPseudoElementTypeBase>(aType)].mAtom;
}
/* static */ nsIAtom*
/* static */ already_AddRefed<nsIAtom>
nsCSSPseudoElements::GetPseudoAtom(const nsAString& aPseudoElement)
{
if (DOMStringIsNull(aPseudoElement) || aPseudoElement.IsEmpty() ||
@ -148,7 +148,7 @@ nsCSSPseudoElements::GetPseudoAtom(const nsAString& aPseudoElement)
return nullptr;
}
return pseudo;
return pseudo.forget();
}
/* static */ bool

View File

@ -102,11 +102,13 @@ public:
static Type GetPseudoType(nsIAtom* aAtom, EnabledState aEnabledState);
// Get the atom for a given Type. aType must be < CSSPseudoElementType::Count
// Get the atom for a given Type. aType must be < CSSPseudoElementType::Count.
// This only ever returns static atoms, so it's fine to return a raw pointer.
static nsIAtom* GetPseudoAtom(Type aType);
// Get the atom for a given nsAString. (e.g. "::before")
static nsIAtom* GetPseudoAtom(const nsAString& aPseudoElement);
// Get the atom for a given pseudo-element string (e.g. "::before"). This can
// return dynamic atoms, for unrecognized pseudo-elements.
static already_AddRefed<nsIAtom> GetPseudoAtom(const nsAString& aPseudoElement);
static bool PseudoElementContainsElements(const Type aType) {
return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS);