mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 602341 part 3. Get rid of the mAtom member of nsPseudoClassList. r=dbaron
This commit is contained in:
parent
f677f9d256
commit
8cdfaea14d
@ -134,10 +134,8 @@ nsAtomList::~nsAtomList(void)
|
|||||||
NS_CSS_DELETE_LIST_MEMBER(nsAtomList, this, mNext);
|
NS_CSS_DELETE_LIST_MEMBER(nsAtomList, this, mNext);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType)
|
||||||
nsCSSPseudoClasses::Type aType)
|
: mType(aType),
|
||||||
: mAtom(aAtom),
|
|
||||||
mType(aType),
|
|
||||||
mNext(nsnull)
|
mNext(nsnull)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!nsCSSPseudoClasses::HasStringArg(aType) &&
|
NS_ASSERTION(!nsCSSPseudoClasses::HasStringArg(aType) &&
|
||||||
@ -147,11 +145,9 @@ nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
|||||||
u.mMemory = nsnull;
|
u.mMemory = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
|
||||||
nsCSSPseudoClasses::Type aType,
|
|
||||||
const PRUnichar* aString)
|
const PRUnichar* aString)
|
||||||
: mAtom(aAtom),
|
: mType(aType),
|
||||||
mType(aType),
|
|
||||||
mNext(nsnull)
|
mNext(nsnull)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(nsCSSPseudoClasses::HasStringArg(aType),
|
NS_ASSERTION(nsCSSPseudoClasses::HasStringArg(aType),
|
||||||
@ -161,11 +157,9 @@ nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
|||||||
u.mString = NS_strdup(aString);
|
u.mString = NS_strdup(aString);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
|
||||||
nsCSSPseudoClasses::Type aType,
|
|
||||||
const PRInt32* aIntPair)
|
const PRInt32* aIntPair)
|
||||||
: mAtom(aAtom),
|
: mType(aType),
|
||||||
mType(aType),
|
|
||||||
mNext(nsnull)
|
mNext(nsnull)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(nsCSSPseudoClasses::HasNthPairArg(aType),
|
NS_ASSERTION(nsCSSPseudoClasses::HasNthPairArg(aType),
|
||||||
@ -177,11 +171,9 @@ nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// adopts aSelectorList
|
// adopts aSelectorList
|
||||||
nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom,
|
nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
|
||||||
nsCSSPseudoClasses::Type aType,
|
|
||||||
nsCSSSelectorList* aSelectorList)
|
nsCSSSelectorList* aSelectorList)
|
||||||
: mAtom(aAtom),
|
: mType(aType),
|
||||||
mType(aType),
|
|
||||||
mNext(nsnull)
|
mNext(nsnull)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(aType),
|
NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(aType),
|
||||||
@ -196,16 +188,16 @@ nsPseudoClassList::Clone(PRBool aDeep) const
|
|||||||
{
|
{
|
||||||
nsPseudoClassList *result;
|
nsPseudoClassList *result;
|
||||||
if (!u.mMemory) {
|
if (!u.mMemory) {
|
||||||
result = new nsPseudoClassList(mAtom, mType);
|
result = new nsPseudoClassList(mType);
|
||||||
} else if (nsCSSPseudoClasses::HasStringArg(mType)) {
|
} else if (nsCSSPseudoClasses::HasStringArg(mType)) {
|
||||||
result = new nsPseudoClassList(mAtom, mType, u.mString);
|
result = new nsPseudoClassList(mType, u.mString);
|
||||||
} else if (nsCSSPseudoClasses::HasNthPairArg(mType)) {
|
} else if (nsCSSPseudoClasses::HasNthPairArg(mType)) {
|
||||||
result = new nsPseudoClassList(mAtom, mType, u.mNumbers);
|
result = new nsPseudoClassList(mType, u.mNumbers);
|
||||||
} else {
|
} else {
|
||||||
NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(mType),
|
NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(mType),
|
||||||
"unexpected pseudo-class");
|
"unexpected pseudo-class");
|
||||||
// This constructor adopts its selector list argument.
|
// This constructor adopts its selector list argument.
|
||||||
result = new nsPseudoClassList(mAtom, mType, u.mSelectors->Clone());
|
result = new nsPseudoClassList(mType, u.mSelectors->Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDeep)
|
if (aDeep)
|
||||||
@ -422,21 +414,21 @@ void nsCSSSelector::AddClass(const nsString& aClass)
|
|||||||
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
||||||
nsCSSPseudoClasses::Type aType)
|
nsCSSPseudoClasses::Type aType)
|
||||||
{
|
{
|
||||||
AddPseudoClassInternal(new nsPseudoClassList(aPseudoClass, aType));
|
AddPseudoClassInternal(new nsPseudoClassList(aType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
||||||
nsCSSPseudoClasses::Type aType,
|
nsCSSPseudoClasses::Type aType,
|
||||||
const PRUnichar* aString)
|
const PRUnichar* aString)
|
||||||
{
|
{
|
||||||
AddPseudoClassInternal(new nsPseudoClassList(aPseudoClass, aType, aString));
|
AddPseudoClassInternal(new nsPseudoClassList(aType, aString));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
||||||
nsCSSPseudoClasses::Type aType,
|
nsCSSPseudoClasses::Type aType,
|
||||||
const PRInt32* aIntPair)
|
const PRInt32* aIntPair)
|
||||||
{
|
{
|
||||||
AddPseudoClassInternal(new nsPseudoClassList(aPseudoClass, aType, aIntPair));
|
AddPseudoClassInternal(new nsPseudoClassList(aType, aIntPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
||||||
@ -444,8 +436,7 @@ void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
|
|||||||
nsCSSSelectorList* aSelectorList)
|
nsCSSSelectorList* aSelectorList)
|
||||||
{
|
{
|
||||||
// Take ownership of nsCSSSelectorList instead of copying.
|
// Take ownership of nsCSSSelectorList instead of copying.
|
||||||
AddPseudoClassInternal(new nsPseudoClassList(aPseudoClass, aType,
|
AddPseudoClassInternal(new nsPseudoClassList(aType, aSelectorList));
|
||||||
aSelectorList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsCSSSelector::AddPseudoClassInternal(nsPseudoClassList *aPseudoClass)
|
void nsCSSSelector::AddPseudoClassInternal(nsPseudoClassList *aPseudoClass)
|
||||||
@ -768,7 +759,7 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
|
|||||||
aString.Append(PRUnichar('('));
|
aString.Append(PRUnichar('('));
|
||||||
for (nsPseudoClassList* list = mPseudoClassList; list;
|
for (nsPseudoClassList* list = mPseudoClassList; list;
|
||||||
list = list->mNext) {
|
list = list->mNext) {
|
||||||
list->mAtom->ToString(temp);
|
nsCSSPseudoClasses::PseudoTypeToString(list->mType, temp);
|
||||||
nsStyleUtil::AppendEscapedCSSIdent(temp, aString);
|
nsStyleUtil::AppendEscapedCSSIdent(temp, aString);
|
||||||
NS_ABORT_IF_FALSE(!list->u.mMemory, "data not expected");
|
NS_ABORT_IF_FALSE(!list->u.mMemory, "data not expected");
|
||||||
aString.Append(PRUnichar(','));
|
aString.Append(PRUnichar(','));
|
||||||
@ -781,7 +772,7 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
for (nsPseudoClassList* list = mPseudoClassList; list; list = list->mNext) {
|
for (nsPseudoClassList* list = mPseudoClassList; list; list = list->mNext) {
|
||||||
list->mAtom->ToString(temp);
|
nsCSSPseudoClasses::PseudoTypeToString(list->mType, temp);
|
||||||
// This should not be escaped since (a) the pseudo-class string
|
// This should not be escaped since (a) the pseudo-class string
|
||||||
// has a ":" that can't be escaped and (b) all pseudo-classes at
|
// has a ":" that can't be escaped and (b) all pseudo-classes at
|
||||||
// this point are known, and therefore we know they don't need
|
// this point are known, and therefore we know they don't need
|
||||||
|
@ -80,19 +80,16 @@ private:
|
|||||||
|
|
||||||
struct nsPseudoClassList {
|
struct nsPseudoClassList {
|
||||||
public:
|
public:
|
||||||
nsPseudoClassList(nsIAtom* aAtom, nsCSSPseudoClasses::Type aType);
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType);
|
||||||
nsPseudoClassList(nsIAtom* aAtom, nsCSSPseudoClasses::Type aType,
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const PRUnichar *aString);
|
||||||
const PRUnichar *aString);
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const PRInt32 *aIntPair);
|
||||||
nsPseudoClassList(nsIAtom* aAtom, nsCSSPseudoClasses::Type aType,
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType,
|
||||||
const PRInt32 *aIntPair);
|
|
||||||
nsPseudoClassList(nsIAtom* aAtom, nsCSSPseudoClasses::Type aType,
|
|
||||||
nsCSSSelectorList *aSelectorList /* takes ownership */);
|
nsCSSSelectorList *aSelectorList /* takes ownership */);
|
||||||
~nsPseudoClassList(void);
|
~nsPseudoClassList(void);
|
||||||
|
|
||||||
/** Do a deep clone. Should be used only on the first in the linked list. */
|
/** Do a deep clone. Should be used only on the first in the linked list. */
|
||||||
nsPseudoClassList* Clone() const { return Clone(PR_TRUE); }
|
nsPseudoClassList* Clone() const { return Clone(PR_TRUE); }
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> mAtom;
|
|
||||||
union {
|
union {
|
||||||
// For a given value of mType, we have either:
|
// For a given value of mType, we have either:
|
||||||
// a. no value, which means mMemory is always null
|
// a. no value, which means mMemory is always null
|
||||||
|
@ -85,6 +85,14 @@ nsCSSPseudoClasses::HasNthPairArg(Type aType)
|
|||||||
aType == ePseudoClass_nthLastOfType;
|
aType == ePseudoClass_nthLastOfType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsCSSPseudoClasses::PseudoTypeToString(Type aType, nsAString& aString)
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(aType < ePseudoClass_Count, "Unexpected type");
|
||||||
|
NS_ABORT_IF_FALSE(aType >= 0, "Very unexpected type");
|
||||||
|
(*CSSPseudoClasses_info[aType].mAtom)->ToString(aString);
|
||||||
|
}
|
||||||
|
|
||||||
nsCSSPseudoClasses::Type
|
nsCSSPseudoClasses::Type
|
||||||
nsCSSPseudoClasses::GetPseudoType(nsIAtom* aAtom)
|
nsCSSPseudoClasses::GetPseudoType(nsIAtom* aAtom)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +72,9 @@ public:
|
|||||||
static PRBool HasSelectorListArg(Type aType) {
|
static PRBool HasSelectorListArg(Type aType) {
|
||||||
return aType == ePseudoClass_any;
|
return aType == ePseudoClass_any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should only be used on types other than Count and NotPseudoClass
|
||||||
|
static void PseudoTypeToString(Type aType, nsAString& aString);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsCSSPseudoClasses_h___ */
|
#endif /* nsCSSPseudoClasses_h___ */
|
||||||
|
Loading…
Reference in New Issue
Block a user