Rename nsAtomStringList to nsPseudoClassList, since that's what it's for, and we want to make it more than just atoms and strings. Also remove an unused constructor. b=75375 r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Mon, 02 Jun 2008 20:17:35 -0700
changeset 15211 c5b6d415d822328376500147eaa066ff90ae7cc7
parent 15210 645e72edd5c5aad193d7129a5d739511816f70e6
child 15212 6ea3a422f95e314a356c662c1cf6ed19da95f6e2
push id55
push userdbaron@mozilla.com
push dateTue, 03 Jun 2008 03:18:12 +0000
treeherdermozilla-central@84d1f9d39ac3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs75375
milestone1.9.1a1pre
Rename nsAtomStringList to nsPseudoClassList, since that's what it's for, and we want to make it more than just atoms and strings. Also remove an unused constructor. b=75375 r+sr=bzbarsky
layout/style/nsCSSParser.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSStyleRule.cpp
layout/style/nsICSSStyleRule.h
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -1922,18 +1922,18 @@ PRBool CSSParserImpl::ParseSelectorGroup
         aErrorCode = NS_ERROR_OUT_OF_MEMORY;
         return PR_FALSE;
       }
     }
     list->AddSelector(newSelector);
     nsCSSSelector* listSel = list->mSelectors;
 
     // pull out pseudo elements here
-    nsAtomStringList* prevList = nsnull;
-    nsAtomStringList* pseudoClassList = listSel->mPseudoClassList;
+    nsPseudoClassList* prevList = nsnull;
+    nsPseudoClassList* pseudoClassList = listSel->mPseudoClassList;
     while (nsnull != pseudoClassList) {
       if (! nsCSSPseudoClasses::IsPseudoClass(pseudoClassList->mAtom)) {
         havePseudoElement = PR_TRUE;
         if (IsSinglePseudoClass(*listSel)) {  // convert to pseudo element selector
           nsIAtom* pseudoElement = pseudoClassList->mAtom;  // steal ref count
           pseudoClassList->mAtom = nsnull;
           listSel->Reset();
           if (listSel->mNext) {// more to the selector
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1071,17 +1071,17 @@ static PRBool SelectorMatches(RuleProces
   // generally quick to test, and thus earlier).  If they were later,
   // we'd probably avoid setting those bits in more cases where setting
   // them is unnecessary.
   const PRBool setNodeFlags = aStateMask == 0 && !aAttribute;
 
   // test for pseudo class match
   // first-child, root, lang, active, focus, hover, link, visited...
   // XXX disabled, enabled, selected, selection
-  for (nsAtomStringList* pseudoClass = aSelector->mPseudoClassList;
+  for (nsPseudoClassList* pseudoClass = aSelector->mPseudoClassList;
        pseudoClass && result; pseudoClass = pseudoClass->mNext) {
     PRInt32 stateToCheck = 0;
     if ((nsCSSPseudoClasses::firstChild == pseudoClass->mAtom) ||
         (nsCSSPseudoClasses::firstNode == pseudoClass->mAtom) ) {
       nsIContent *firstChild = nsnull;
       nsIContent *parent = data.mParentContent;
       if (parent) {
         if (setNodeFlags)
@@ -1924,17 +1924,17 @@ nsCSSRuleProcessor::ClearRuleCascades()
 }
 
 
 // This function should return true only for selectors that need to be
 // checked by |HasStateDependentStyle|.
 inline
 PRBool IsStateSelector(nsCSSSelector& aSelector)
 {
-  for (nsAtomStringList* pseudoClass = aSelector.mPseudoClassList;
+  for (nsPseudoClassList* pseudoClass = aSelector.mPseudoClassList;
        pseudoClass; pseudoClass = pseudoClass->mNext) {
     if ((pseudoClass->mAtom == nsCSSPseudoClasses::active) ||
         (pseudoClass->mAtom == nsCSSPseudoClasses::checked) ||
         (pseudoClass->mAtom == nsCSSPseudoClasses::mozDragOver) || 
         (pseudoClass->mAtom == nsCSSPseudoClasses::focus) || 
         (pseudoClass->mAtom == nsCSSPseudoClasses::hover) ||
         (pseudoClass->mAtom == nsCSSPseudoClasses::target) ||
         (pseudoClass->mAtom == nsCSSPseudoClasses::link) ||
--- a/layout/style/nsCSSStyleRule.cpp
+++ b/layout/style/nsCSSStyleRule.cpp
@@ -153,55 +153,43 @@ nsAtomList::Clone(PRBool aDeep) const
 }
 
 nsAtomList::~nsAtomList(void)
 {
   MOZ_COUNT_DTOR(nsAtomList);
   NS_IF_DEEP_DELETE(nsAtomList, mNext);
 }
 
-nsAtomStringList::nsAtomStringList(nsIAtom* aAtom, const PRUnichar* aString)
+nsPseudoClassList::nsPseudoClassList(nsIAtom* aAtom, const PRUnichar* aString)
   : mAtom(aAtom),
     mString(nsnull),
     mNext(nsnull)
 {
-  MOZ_COUNT_CTOR(nsAtomStringList);
+  MOZ_COUNT_CTOR(nsPseudoClassList);
   if (aString)
     mString = NS_strdup(aString);
 }
 
-nsAtomStringList::nsAtomStringList(const nsString& aAtomValue,
-                                   const PRUnichar* aString)
-  : mAtom(nsnull),
-    mString(nsnull),
-    mNext(nsnull)
+nsPseudoClassList*
+nsPseudoClassList::Clone(PRBool aDeep) const
 {
-  MOZ_COUNT_CTOR(nsAtomStringList);
-  mAtom = do_GetAtom(aAtomValue);
-  if (aString)
-    mString = NS_strdup(aString);
-}
-
-nsAtomStringList*
-nsAtomStringList::Clone(PRBool aDeep) const
-{
-  nsAtomStringList *result = new nsAtomStringList(mAtom, mString);
+  nsPseudoClassList *result = new nsPseudoClassList(mAtom, mString);
 
   if (aDeep)
-    NS_IF_DEEP_CLONE(nsAtomStringList, mNext, (PR_FALSE));
+    NS_IF_DEEP_CLONE(nsPseudoClassList, mNext, (PR_FALSE));
 
   return result;
 }
 
-nsAtomStringList::~nsAtomStringList(void)
+nsPseudoClassList::~nsPseudoClassList(void)
 {
-  MOZ_COUNT_DTOR(nsAtomStringList);
+  MOZ_COUNT_DTOR(nsPseudoClassList);
   if (mString)
     NS_Free(mString);
-  NS_IF_DEEP_DELETE(nsAtomStringList, mNext);
+  NS_IF_DEEP_DELETE(nsPseudoClassList, mNext);
 }
 
 nsAttrSelector::nsAttrSelector(PRInt32 aNameSpace, const nsString& aAttr)
   : mNameSpace(aNameSpace),
     mAttr(nsnull),
     mFunction(NS_ATTR_FUNC_SET),
     mCaseSensitive(1),
     mValue(),
@@ -354,37 +342,25 @@ void nsCSSSelector::AddClass(const nsStr
     nsAtomList** list = &mClassList;
     while (nsnull != *list) {
       list = &((*list)->mNext);
     }
     *list = new nsAtomList(aClass);
   }
 }
 
-void nsCSSSelector::AddPseudoClass(const nsString& aPseudoClass,
-                                   const PRUnichar* aString)
-{
-  if (!aPseudoClass.IsEmpty()) {
-    nsAtomStringList** list = &mPseudoClassList;
-    while (nsnull != *list) {
-      list = &((*list)->mNext);
-    }
-    *list = new nsAtomStringList(aPseudoClass, aString);
-  }
-}
-
 void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass,
                                    const PRUnichar* aString)
 {
   if (nsnull != aPseudoClass) {
-    nsAtomStringList** list = &mPseudoClassList;
+    nsPseudoClassList** list = &mPseudoClassList;
     while (nsnull != *list) {
       list = &((*list)->mNext);
     }
-    *list = new nsAtomStringList(aPseudoClass, aString);
+    *list = new nsPseudoClassList(aPseudoClass, aString);
   }
 }
 
 void nsCSSSelector::AddAttribute(PRInt32 aNameSpace, const nsString& aAttr)
 {
   if (!aAttr.IsEmpty()) {
     nsAttrSelector** list = &mAttrList;
     while (nsnull != *list) {
@@ -423,17 +399,17 @@ PRInt32 nsCSSSelector::CalcWeight(void) 
     weight += 0x010000;
     list = list->mNext;
   }
   list = mClassList;
   while (nsnull != list) {
     weight += 0x000100;
     list = list->mNext;
   }
-  nsAtomStringList *plist = mPseudoClassList;
+  nsPseudoClassList *plist = mPseudoClassList;
   while (nsnull != plist) {
     weight += 0x000100;
     plist = plist->mNext;
   }
   nsAttrSelector* attr = mAttrList;
   while (nsnull != attr) {
     weight += 0x000100;
     attr = attr->mNext;
@@ -643,17 +619,17 @@ void nsCSSSelector::ToStringInternal(nsA
       aString.Append(PRUnichar(']'));
       
       list = list->mNext;
     }
   }
 
   // Append each pseudo-class in the linked list
   if (mPseudoClassList) {
-    nsAtomStringList* list = mPseudoClassList;
+    nsPseudoClassList* list = mPseudoClassList;
     while (list != nsnull) {
       list->mAtom->ToString(temp);
       aString.Append(temp);
       if (nsnull != list->mString) {
         aString.Append(PRUnichar('('));
         aString.Append(list->mString);
         aString.Append(PRUnichar(')'));
       }
--- a/layout/style/nsICSSStyleRule.h
+++ b/layout/style/nsICSSStyleRule.h
@@ -70,34 +70,33 @@ public:
 private: 
   nsAtomList* Clone(PRBool aDeep) const;
 
   // These are not supported and are not implemented! 
   nsAtomList(const nsAtomList& aCopy);
   nsAtomList& operator=(const nsAtomList& aCopy); 
 };
 
-struct nsAtomStringList {
+struct nsPseudoClassList {
 public:
-  nsAtomStringList(nsIAtom* aAtom, const PRUnichar *aString = nsnull);
-  nsAtomStringList(const nsString& aAtomValue, const PRUnichar *aString = nsnull);
-  ~nsAtomStringList(void);
+  nsPseudoClassList(nsIAtom* aAtom, const PRUnichar *aString = nsnull);
+  ~nsPseudoClassList(void);
 
   /** Do a deep clone.  Should be used only on the first in the linked list. */
-  nsAtomStringList* Clone() const { return Clone(PR_TRUE); }
+  nsPseudoClassList* Clone() const { return Clone(PR_TRUE); }
 
   nsCOMPtr<nsIAtom> mAtom;
   PRUnichar*        mString;
-  nsAtomStringList* mNext;
+  nsPseudoClassList* mNext;
 private: 
-  nsAtomStringList* Clone(PRBool aDeep) const;
+  nsPseudoClassList* Clone(PRBool aDeep) const;
 
   // These are not supported and are not implemented! 
-  nsAtomStringList(const nsAtomStringList& aCopy);
-  nsAtomStringList& operator=(const nsAtomStringList& aCopy); 
+  nsPseudoClassList(const nsPseudoClassList& aCopy);
+  nsPseudoClassList& operator=(const nsPseudoClassList& aCopy); 
 };
 
 #define NS_ATTR_FUNC_SET        0     // [attr]
 #define NS_ATTR_FUNC_EQUALS     1     // [attr=value]
 #define NS_ATTR_FUNC_INCLUDES   2     // [attr~=value] (space separated)
 #define NS_ATTR_FUNC_DASHMATCH  3     // [attr|=value] ('-' truncated)
 #define NS_ATTR_FUNC_BEGINSMATCH  4   // [attr^=value] (begins with)
 #define NS_ATTR_FUNC_ENDSMATCH  5     // [attr$=value] (ends with)
@@ -137,17 +136,16 @@ public:
   /** Do a deep clone.  Should be used only on the first in the linked list. */
   nsCSSSelector* Clone() const { return Clone(PR_TRUE, PR_TRUE); }
 
   void Reset(void);
   void SetNameSpace(PRInt32 aNameSpace);
   void SetTag(const nsString& aTag);
   void AddID(const nsString& aID);
   void AddClass(const nsString& aClass);
-  void AddPseudoClass(const nsString& aPseudoClass, const PRUnichar* aString = nsnull);
   void AddPseudoClass(nsIAtom* aPseudoClass, const PRUnichar* aString = nsnull);
   void AddAttribute(PRInt32 aNameSpace, const nsString& aAttr);
   void AddAttribute(PRInt32 aNameSpace, const nsString& aAttr, PRUint8 aFunc, 
                     const nsString& aValue, PRBool aCaseSensitive);
   void SetOperator(PRUnichar aOperator);
 
   PRInt32 CalcWeight(void) const;
 
@@ -162,18 +160,18 @@ private:
                         PRBool aIsPseudoElem,
                         PRBool aIsNegated) const;
 
 public:
   PRInt32         mNameSpace;
   nsCOMPtr<nsIAtom> mTag;
   nsAtomList*     mIDList;
   nsAtomList*     mClassList;
-  nsAtomStringList* mPseudoClassList; // atom for the pseudo, string for
-                                      // the argument to functional pseudos
+  nsPseudoClassList* mPseudoClassList; // atom for the pseudo, string for
+                                       // the argument to functional pseudos
   nsAttrSelector* mAttrList;
   PRUnichar       mOperator;
   nsCSSSelector*  mNegations;
 
   nsCSSSelector*  mNext;
 private: 
   // These are not supported and are not implemented! 
   nsCSSSelector(const nsCSSSelector& aCopy);
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -4114,17 +4114,17 @@ nsTreeBodyFrame::GetPseudoStyleContext(n
 NS_IMETHODIMP
 nsTreeBodyFrame::PseudoMatches(nsIAtom* aTag, nsCSSSelector* aSelector, PRBool* aResult)
 {
   if (aSelector->mTag == aTag) {
     // Iterate the pseudoclass list.  For each item in the list, see if
     // it is contained in our scratch array.  If we have a miss, then
     // we aren't a match.  If all items in the pseudoclass list are
     // present in the scratch array, then we have a match.
-    nsAtomStringList* curr = aSelector->mPseudoClassList;
+    nsPseudoClassList* curr = aSelector->mPseudoClassList;
     while (curr) {
       PRInt32 index;
       mScratchArray->GetIndexOf(curr->mAtom, &index);
       if (index == -1) {
         *aResult = PR_FALSE;
         return NS_OK;
       }
       curr = curr->mNext;