tokenizer_fixOldUses
author Daniel Holbert <dholbert@cs.stanford.edu>
Sun, 02 May 2010 22:37:16 -0700
changeset 1549 d7586d01c70260b1a48876a0a399f9c7d89a5b49
parent 1544 a50749a9533934ae81aeb871e9032718ab58120b
child 1553 a90c9f5a484093563543bc21cc9a3bad9e5dbdfb
permissions -rw-r--r--
tokenizer_fixOldUses: use parameter instead of template to choose SeparatorChar

From: Daniel Holbert <dholbert@cs.stanford.edu>
Bug 562310 Part 4: Remove nsCommaSeparatedTokenizer typedef, and replace its uses with nsCharSeparatedTokenizer<','>. r=NOT_REVIEWED_YET

diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -1315,17 +1315,17 @@ static CanPlayStatus GetCanPlay(const ns
   rv = parser.GetParameter("codecs", codecs);
   if (NS_FAILED(rv))
     // Parameter not found or whatever
     return CANPLAY_MAYBE;
 
   CanPlayStatus result = CANPLAY_YES;
   // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
   // of the 'codecs' parameter
-  nsCommaSeparatedTokenizer tokenizer(codecs);
+  nsCharSeparatedTokenizer tokenizer(codecs, ',', PR_TRUE);
   PRBool expectMoreTokens = PR_FALSE;
   while (tokenizer.hasMoreTokens()) {
     const nsSubstring& token = tokenizer.nextToken();
 
     if (!CodecListContains(supportedCodecs, token)) {
       // Totally unsupported codec
       return CANPLAY_NO;
     }
diff --git a/content/svg/content/src/nsSVGFeatures.cpp b/content/svg/content/src/nsSVGFeatures.cpp
--- a/content/svg/content/src/nsSVGFeatures.cpp
+++ b/content/svg/content/src/nsSVGFeatures.cpp
@@ -108,21 +108,21 @@ nsSVGFeatures::HaveExtensions(const nsSu
 }
 
 /*static*/ PRBool
 nsSVGFeatures::MatchesLanguagePreferences(const nsSubstring& aAttribute,
                                           const nsSubstring& aAcceptLangs) 
 {
   const nsDefaultStringComparator defaultComparator;
 
-  nsCommaSeparatedTokenizer attributeTokenizer(aAttribute);
+  nsCharSeparatedTokenizer attributeTokenizer(aAttribute, ',', PR_TRUE);
 
   while (attributeTokenizer.hasMoreTokens()) {
     const nsSubstring &attributeToken = attributeTokenizer.nextToken();
-    nsCommaSeparatedTokenizer languageTokenizer(aAcceptLangs);
+    nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',', PR_TRUE);
     while (languageTokenizer.hasMoreTokens()) {
       if (nsStyleUtil::DashMatchCompare(attributeToken,
                                         languageTokenizer.nextToken(),
                                         defaultComparator)) {
         return PR_TRUE;
       }
     }
   }
@@ -130,22 +130,22 @@ nsSVGFeatures::MatchesLanguagePreference
 }
 
 /*static*/ PRInt32
 nsSVGFeatures::GetBestLanguagePreferenceRank(const nsSubstring& aAttribute,
                                              const nsSubstring& aAcceptLangs) 
 {
   const nsDefaultStringComparator defaultComparator;
 
-  nsCommaSeparatedTokenizer attributeTokenizer(aAttribute);
+  nsCharSeparatedTokenizer attributeTokenizer(aAttribute, ',', PR_TRUE);
   PRInt32 lowestRank = -1;
 
   while (attributeTokenizer.hasMoreTokens()) {
     const nsSubstring &attributeToken = attributeTokenizer.nextToken();
-    nsCommaSeparatedTokenizer languageTokenizer(aAcceptLangs);
+    nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',', PR_TRUE);
     PRInt32 index = 0;
     while (languageTokenizer.hasMoreTokens()) {
       const nsSubstring &languageToken = languageTokenizer.nextToken();
       PRBool exactMatch = (languageToken == attributeToken);
       PRBool prefixOnlyMatch =
         !exactMatch &&
         nsStyleUtil::DashMatchCompare(attributeToken,
                                       languageTokenizer.nextToken(),
diff --git a/xpcom/ds/nsCharSeparatedTokenizer.h b/xpcom/ds/nsCharSeparatedTokenizer.h
--- a/xpcom/ds/nsCharSeparatedTokenizer.h
+++ b/xpcom/ds/nsCharSeparatedTokenizer.h
@@ -151,24 +151,16 @@ private:
     PRBool isWhitespace(PRUnichar aChar)
     {
         return aChar <= ' ' &&
                (aChar == ' ' || aChar == '\n' ||
                 aChar == '\r'|| aChar == '\t');
     }
 };
 
-class nsCommaSeparatedTokenizer : public nsCharSeparatedTokenizer
-{
-public:
-    nsCommaSeparatedTokenizer(const nsSubstring& aSource)
-        : nsCharSeparatedTokenizer(aSource, ',', PR_TRUE) {}
-};
-
-
 class nsCCommaSeparatedTokenizer
 {
 public:
     nsCCommaSeparatedTokenizer(const nsCSubstring& aSource)
     {
         aSource.BeginReading(mIter);
         aSource.EndReading(mEnd);