Existing callers call IsCSS2PseudoElement on non-pseudo-elements (in particular, anon boxes), so we need to make that not assert and be deterministic. (Bug 521044) r=bzbarsky

This commit is contained in:
L. David Baron 2009-10-07 20:22:42 -07:00
parent 134bc3c1d1
commit c07ac412dc
2 changed files with 21 additions and 3 deletions

View File

@ -42,6 +42,7 @@
#include "nsAtomListUtils.h"
#include "nsStaticAtom.h"
#include "nsMemory.h"
#include "nsCSSAnonBoxes.h"
// define storage for all atoms
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
@ -80,6 +81,25 @@ PRBool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
NS_ARRAY_LENGTH(CSSPseudoElements_info));
}
/* static */ PRBool
nsCSSPseudoElements::IsCSS2PseudoElement(nsIAtom *aAtom)
{
// We don't implement this using PseudoElementHasFlags because callers
// want to pass things that could be anon boxes.
NS_ASSERTION(nsCSSPseudoElements::IsPseudoElement(aAtom) ||
nsCSSAnonBoxes::IsAnonBox(aAtom),
"must be pseudo element or anon box");
PRBool result = aAtom == nsCSSPseudoElements::after ||
aAtom == nsCSSPseudoElements::before ||
aAtom == nsCSSPseudoElements::firstLetter ||
aAtom == nsCSSPseudoElements::firstLine;
NS_ASSERTION(nsCSSAnonBoxes::IsAnonBox(aAtom) ||
result ==
PseudoElementHasFlags(aAtom, CSS_PSEUDO_ELEMENT_IS_CSS2),
"result doesn't match flags");
return result;
}
/* static */ PRUint32
nsCSSPseudoElements::FlagsForPseudoElement(nsIAtom *aAtom)
{

View File

@ -68,9 +68,7 @@ public:
static PRBool IsPseudoElement(nsIAtom *aAtom);
static PRBool IsCSS2PseudoElement(nsIAtom *aAtom) {
return PseudoElementHasFlags(aAtom, CSS_PSEUDO_ELEMENT_IS_CSS2);
}
static PRBool IsCSS2PseudoElement(nsIAtom *aAtom);
static PRBool PseudoElementContainsElements(nsIAtom *aAtom) {
return PseudoElementHasFlags(aAtom, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS);