Bug 570258: Some more atom usage cleanup. r=jst

This commit is contained in:
Jonas Sicking 2010-06-08 16:25:27 -07:00
Родитель 353634e233
Коммит 512a658259
12 изменённых файлов: 34 добавлений и 53 удалений

Просмотреть файл

@ -2199,8 +2199,7 @@ nsContentUtils::SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
nameStart = (uriEnd + 1);
if (nameEnd) {
const PRUnichar *prefixStart = nameEnd + 1;
*aPrefix = NS_NewAtom(NS_ConvertUTF16toUTF8(prefixStart,
pos - prefixStart));
*aPrefix = NS_NewAtom(Substring(prefixStart, pos));
}
else {
nameEnd = pos;
@ -2213,8 +2212,7 @@ nsContentUtils::SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
nameEnd = pos;
*aPrefix = nsnull;
}
*aLocalName = NS_NewAtom(NS_ConvertUTF16toUTF8(nameStart,
nameEnd - nameStart));
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd));
}
// static

Просмотреть файл

@ -529,10 +529,9 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
nsCOMPtr<nsINodeInfo> nodeInfo;
if (aNodeType == eHTMLTag_userdefined) {
NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
nsAutoString lower;
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML);
}
else if (mNodeInfoCache[aNodeType]) {

Просмотреть файл

@ -352,10 +352,9 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
nsCOMPtr<nsINodeInfo> nodeInfo;
if (nodeType == eHTMLTag_userdefined) {
NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
nsAutoString lower;
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
nodeInfo = mNodeInfoManager->GetNodeInfo(name,
nsnull,
kNameSpaceID_XHTML);
@ -447,10 +446,9 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
nsCOMPtr<nsINodeInfo> nodeInfo;
if (nodeType == eHTMLTag_userdefined) {
NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
nsAutoString lower;
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
@ -727,7 +725,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
return NS_OK;
}
nsCAutoString k;
nsAutoString k;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
// The attributes are on the parser node in the order they came in in the
@ -741,12 +739,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
for (PRInt32 i = ac - 1; i >= 0; i--) {
// Get lower-cased key
const nsAString& key = aNode.GetKeyAt(i);
// Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
// at the same time since that's what the atom table uses).
CopyUTF16toUTF8(key, k);
ToLowerCase(k);
nsContentUtils::ASCIIToLower(aNode.GetKeyAt(i), k);
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
// Get value and remove mandatory quotes
@ -938,7 +931,7 @@ nsHTMLParanoidFragmentSink::AddAttributes(const nsIParserNode& aNode,
return NS_OK;
}
nsCAutoString k;
nsAutoString k;
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
nsresult rv;
@ -948,10 +941,7 @@ nsHTMLParanoidFragmentSink::AddAttributes(const nsIParserNode& aNode,
for (PRInt32 i = ac - 1; i >= 0; i--) {
rv = NS_OK;
const nsAString& key = aNode.GetKeyAt(i);
CopyUTF16toUTF8(key, k);
ToLowerCase(k);
nsContentUtils::ASCIIToLower(aNode.GetKeyAt(i), k);
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
// not an allowed attribute

Просмотреть файл

@ -122,11 +122,12 @@ nsSVGTransformListParser::GetTransformToken(nsIAtom** aKeyAtom,
char holdingChar = *delimiterStart;
*delimiterStart = '\0';
if (mTokenPos != 0 && nsCRT::strlen(mTokenPos) > 0) {
*aKeyAtom = NS_NewAtom(mTokenPos);
PRUint32 len;
if (mTokenPos != 0 && (len = nsCRT::strlen(mTokenPos)) > 0) {
*aKeyAtom = NS_NewAtom(Substring(mTokenPos, mTokenPos + len));
if (aAdvancePos) {
mInputPos = mTokenPos + nsCRT::strlen(mTokenPos);
mInputPos = mTokenPos + len;
mTokenPos = mInputPos;
}
} else {

Просмотреть файл

@ -121,8 +121,7 @@ XMLUtils::splitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
nameStart = (uriEnd + 1);
if (nameEnd) {
const PRUnichar *prefixStart = nameEnd + 1;
*aPrefix = NS_NewAtom(NS_ConvertUTF16toUTF8(prefixStart,
pos - prefixStart));
*aPrefix = NS_NewAtom(Substring(prefixStart, pos));
if (!*aPrefix) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -139,8 +138,7 @@ XMLUtils::splitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
*aPrefix = nsnull;
}
*aLocalName = NS_NewAtom(NS_ConvertUTF16toUTF8(nameStart,
nameEnd - nameStart));
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd));
return *aLocalName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -326,17 +326,17 @@ txExprLexer::parse(const nsASingleFragmentString& aPattern)
break;
case L_PAREN:
if (prevToken->mType == Token::CNAME) {
NS_ConvertUTF16toUTF8 utf8Value(prevToken->Value());
if (txXPathAtoms::comment->EqualsUTF8(utf8Value)) {
const nsDependentSubstring& val = prevToken->Value();
if (val.EqualsLiteral("comment")) {
prevToken->mType = Token::COMMENT_AND_PAREN;
}
else if (txXPathAtoms::node->EqualsUTF8(utf8Value)) {
else if (val.EqualsLiteral("node")) {
prevToken->mType = Token::NODE_AND_PAREN;
}
else if (txXPathAtoms::processingInstruction->EqualsUTF8(utf8Value)) {
else if (val.EqualsLiteral("processing-instruction")) {
prevToken->mType = Token::PROC_INST_AND_PAREN;
}
else if (txXPathAtoms::text->EqualsUTF8(utf8Value)) {
else if (val.EqualsLiteral("text")) {
prevToken->mType = Token::TEXT_AND_PAREN;
}
else {

Просмотреть файл

@ -369,8 +369,8 @@ ForEachPing(nsIContent *content, ForEachPingCallback callback, void *closure)
if (!content->IsHTML())
return;
nsIAtom *nameAtom = content->Tag();
if (!nameAtom->EqualsUTF8(NS_LITERAL_CSTRING("a")) &&
!nameAtom->EqualsUTF8(NS_LITERAL_CSTRING("area")))
if (!nameAtom->Equals(NS_LITERAL_STRING("a")) &&
!nameAtom->Equals(NS_LITERAL_STRING("area")))
return;
nsCOMPtr<nsIAtom> pingAtom = do_GetAtom("ping");

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsUnicharUtils.h"
#include "nsCRT.h"
#include "nsIAtom.h"
#include "nsGkAtoms.h"
#define kNullCh (PRUnichar('\0'))
@ -325,10 +326,7 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::GetTxnDescription(nsAString& aString)
PRBool
ChangeCSSInlineStyleTxn::AcceptsMoreThanOneValue(nsIAtom *aCSSProperty)
{
nsIAtom * textDecorationAtom = NS_NewAtom("text-decoration");
PRBool res = (textDecorationAtom == aCSSProperty);
NS_IF_RELEASE(textDecorationAtom);
return res;
return aCSSProperty == nsGkAtoms::text_decoration;
}
// adds the value aNewValue to the list of white-space separated values aValues

Просмотреть файл

@ -745,7 +745,6 @@ nsHTMLCSSUtils::ParseLength(const nsAString & aString, float * aValue, nsIAtom *
PRInt8 sign = 1;
PRInt32 i = 0, j = aString.Length();
PRUnichar c;
nsAutoString unit;
PRBool floatingPointFound = PR_FALSE;
c = *iter;
if (PRUnichar('-') == c) { sign = -1; iter++; i++; }
@ -773,9 +772,8 @@ nsHTMLCSSUtils::ParseLength(const nsAString & aString, float * aValue, nsIAtom *
iter++;
i++;
}
unit = Substring(aString, aString.Length() - (j-i), j-i);
*aValue = value * sign;
*aUnit = NS_NewAtom(unit);
*aUnit = NS_NewAtom(StringTail(aString, j-i));
}
void

Просмотреть файл

@ -222,7 +222,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) {
// Now we know the FROM and TO types are represented as keys in the hashtable.
// Let's "connect" the verticies, making an edge.
nsCOMPtr<nsIAtom> vertex = do_GetAtom(toStr.get());
nsCOMPtr<nsIAtom> vertex = do_GetAtom(toStr);
if (!vertex) return NS_ERROR_OUT_OF_MEMORY;
NS_ASSERTION(fromEdges, "something wrong in adjacency list construction");

Просмотреть файл

@ -1377,8 +1377,7 @@ RDFContentSinkImpl::SplitExpatName(const PRUnichar *aExpatName,
}
const nsDependentSubstring& nameSpaceURI = Substring(aExpatName, uriEnd);
*aLocalName = NS_NewAtom(NS_ConvertUTF16toUTF8(nameStart,
pos - nameStart));
*aLocalName = NS_NewAtom(Substring(nameStart, pos));
return nameSpaceURI;
}

Просмотреть файл

@ -221,7 +221,7 @@ rdf_BlockingWrite(nsIOutputStream* stream, const nsAString& s)
already_AddRefed<nsIAtom>
nsRDFXMLSerializer::EnsureNewPrefix()
{
nsCAutoString qname;
nsAutoString qname;
nsCOMPtr<nsIAtom> prefix;
PRBool isNewPrefix;
do {