backout my static atom patch for now until I figure out the performance loss! :(
bug 195262
This commit is contained in:
Родитель
04e8d23b24
Коммит
16af458ceb
|
@ -63,6 +63,9 @@
|
|||
#define kGreaterThan NS_LITERAL_STRING(">")
|
||||
#define kEndTag NS_LITERAL_STRING("</")
|
||||
|
||||
static const PRUnichar kMozStr[] = {'m', 'o', 'z', 0};
|
||||
static const PRInt32 kMozStrLength = 3;
|
||||
|
||||
static const PRInt32 kLongLineLen = 128;
|
||||
|
||||
nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
|
@ -253,7 +256,9 @@ nsHTMLContentSerializer::EscapeURI(const nsAString& aURI, nsAString& aEscapedURI
|
|||
|
||||
|
||||
if (mCharSet && !uri.IsASCII()) {
|
||||
mCharSet->ToUTF8String(documentCharset);
|
||||
const PRUnichar *charset;
|
||||
mCharSet->GetUnicode(&charset);
|
||||
documentCharset.Adopt(ToNewUTF8String(nsDependentString(charset)));
|
||||
textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
@ -311,10 +316,6 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
|
||||
aContent->GetAttrCount(count);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(mozCStr1, "_moz");
|
||||
NS_NAMED_LITERAL_CSTRING(mozCStr2, "-moz");
|
||||
NS_NAMED_LITERAL_STRING(mozStr1, "_moz");
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
aContent->GetAttrNameAt(index,
|
||||
namespaceID,
|
||||
|
@ -322,10 +323,13 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
*getter_AddRefs(attrPrefix));
|
||||
|
||||
// Filter out any attribute starting with [-|_]moz
|
||||
if (attrName->EqualsUTF8(mozCStr1) ||
|
||||
attrName->EqualsUTF8(mozCStr2))
|
||||
const PRUnichar* sharedName;
|
||||
attrName->GetUnicode(&sharedName);
|
||||
if ((('_' == *sharedName) || ('-' == *sharedName)) &&
|
||||
!nsCRT::strncmp(sharedName+1, kMozStr, kMozStrLength)) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
aContent->GetAttr(namespaceID, attrName, valueStr);
|
||||
|
||||
//
|
||||
|
@ -334,7 +338,8 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
//
|
||||
if ((aTagName == nsHTMLAtoms::br) &&
|
||||
(attrName.get() == nsHTMLAtoms::type) &&
|
||||
(mozStr1.Equals(Substring(valueStr, 0, mozStr1.Length())))) {
|
||||
!valueStr.IsEmpty() && ('_' == valueStr[0]) &&
|
||||
!nsCRT::strncmp(valueStr.get()+1, kMozStr, kMozStrLength)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -452,9 +457,9 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
|
||||
AppendToString(kLessThan, aStr);
|
||||
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
const PRUnichar* sharedName;
|
||||
name->GetUnicode(&sharedName);
|
||||
AppendToString(sharedName, -1, aStr);
|
||||
|
||||
// Need to keep track of OL and LI elements in order to get ordinal number
|
||||
// for the LI.
|
||||
|
@ -549,12 +554,13 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
|||
}
|
||||
}
|
||||
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
const PRUnichar* sharedName;
|
||||
name->GetUnicode(&sharedName);
|
||||
|
||||
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
||||
|
||||
if (parserService && (name.get() != nsHTMLAtoms::style)) {
|
||||
nsAutoString nameStr(sharedName);
|
||||
PRBool isContainer;
|
||||
PRInt32 id;
|
||||
|
||||
|
@ -576,7 +582,7 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
|||
EndIndentation(name, hasDirtyAttr, aStr);
|
||||
|
||||
AppendToString(kEndTag, aStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
AppendToString(sharedName, -1, aStr);
|
||||
AppendToString(kGreaterThan, aStr);
|
||||
|
||||
if (LineBreakAfterClose(name, hasDirtyAttr)) {
|
||||
|
|
|
@ -107,8 +107,8 @@ nsNodeInfo::GetQualifiedName(nsAString& aQualifiedName) const
|
|||
aQualifiedName.Truncate();
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
mInner.mName->ToString(name);
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
aQualifiedName.Append(name);
|
||||
|
||||
|
@ -183,14 +183,20 @@ nsNodeInfo::GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) const
|
|||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName) const
|
||||
{
|
||||
return mInner.mName->Equals(aName);
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
||||
{
|
||||
if (!mInner.mName->Equals(aName)) {
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!aName.Equals(name)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -198,15 +204,19 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
|||
return aPrefix.IsEmpty();
|
||||
}
|
||||
|
||||
return mInner.mPrefix->Equals(aPrefix);
|
||||
mInner.mPrefix->GetUnicode(&name);
|
||||
|
||||
return aPrefix.Equals(name);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
return mInner.mNamespaceID == aNamespaceID &&
|
||||
mInner.mName->Equals(aName);
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name) && (mInner.mNamespaceID == aNamespaceID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,13 +225,15 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
|
|||
PRInt32 aNamespaceID) const
|
||||
{
|
||||
PRUnichar nullChar = '\0';
|
||||
const PRUnichar *name, *prefix = &nullChar;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!mInner.mNamespaceID == aNamespaceID ||
|
||||
!mInner.mName->Equals(aName))
|
||||
return PR_FALSE;
|
||||
if (mInner.mPrefix) {
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
}
|
||||
|
||||
return mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) :
|
||||
aPrefix.IsEmpty();
|
||||
return ((mInner.mNamespaceID == aNamespaceID) && aName.Equals(name) &&
|
||||
aPrefix.Equals(prefix));
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,19 +250,22 @@ nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const
|
|||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
||||
{
|
||||
|
||||
if (!mInner.mPrefix)
|
||||
return mInner.mName->Equals(aQualifiedName);
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!mInner.mPrefix) {
|
||||
return aQualifiedName.Equals(name);
|
||||
}
|
||||
|
||||
nsAString::const_iterator start;
|
||||
aQualifiedName.BeginReading(start);
|
||||
|
||||
nsAString::const_iterator colon(start);
|
||||
|
||||
const char* prefix;
|
||||
mInner.mPrefix->GetUTF8String(&prefix);
|
||||
const PRUnichar *prefix;
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
|
||||
PRUint32 len = strlen(prefix);
|
||||
PRUint32 len = nsCRT::strlen(prefix);
|
||||
|
||||
if (len >= aQualifiedName.Length()) {
|
||||
return PR_FALSE;
|
||||
|
@ -265,8 +280,9 @@ nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
|||
}
|
||||
|
||||
// Compare the prefix to the string from the start to the colon
|
||||
if (!mInner.mPrefix->Equals(Substring(start, colon)))
|
||||
if (!Substring(start, colon).Equals(prefix)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
++colon; // Skip the ':'
|
||||
|
||||
|
@ -275,7 +291,7 @@ nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
|||
|
||||
// Compare the local name to the string between the colon and the
|
||||
// end of aQualifiedName
|
||||
return mInner.mName->Equals(Substring(colon, end));
|
||||
return Substring(colon, end).Equals(name);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1807,8 +1807,8 @@ nsPlainTextSerializer::GetAttributeValue(const nsIParserNode* aNode,
|
|||
}
|
||||
}
|
||||
else if (aNode) {
|
||||
nsAutoString name;
|
||||
aName->ToString(name);
|
||||
const PRUnichar *name;
|
||||
aName->GetUnicode(&name);
|
||||
|
||||
PRInt32 count = aNode->GetAttributeCount();
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
|
|
|
@ -1862,8 +1862,10 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo,
|
|||
|
||||
PRBool nsGenericHTMLElement::IsEventName(nsIAtom* aName)
|
||||
{
|
||||
const char* name;
|
||||
aName->GetUTF8String(&name);
|
||||
const PRUnichar *name = nsnull;
|
||||
|
||||
aName->GetUnicode(&name);
|
||||
NS_ASSERTION(name, "Null string in atom!");
|
||||
|
||||
if (name[0] != 'o' || name[1] != 'n') {
|
||||
return PR_FALSE;
|
||||
|
|
|
@ -397,8 +397,6 @@ public:
|
|||
nsString mBaseTarget;
|
||||
|
||||
nsICSSLoader *mCSSLoader;
|
||||
|
||||
// depth of containment within <noembed>, <noframes> etc
|
||||
PRInt32 mInsideNoXXXTag;
|
||||
PRInt32 mInMonolithicContainer;
|
||||
PRUint32 mFlags;
|
||||
|
@ -1033,7 +1031,11 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
|
|||
parserService->HTMLIdToStringTag(id, &tag);
|
||||
NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");
|
||||
|
||||
if (!name->Equals(nsDependentString(tag))) {
|
||||
const PRUnichar *name_str = nsnull;
|
||||
name->GetUnicode(&name_str);
|
||||
NS_ASSERTION(name_str, "What? No string in atom?!?");
|
||||
|
||||
if (nsCRT::strcmp(tag, name_str) != 0) {
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(tag);
|
||||
|
||||
rv = aNodeInfo->NameChanged(atom, *getter_AddRefs(kungFuDeathGrip));
|
||||
|
@ -1708,13 +1710,14 @@ SinkContext::CloseContainer(const nsHTMLTag aTag)
|
|||
// Tracing code
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mStack[mStackPos].mContent->GetTag(*getter_AddRefs(tag));
|
||||
const char *tagStr;
|
||||
tag->GetUTF8String(&tagStr);
|
||||
const PRUnichar* tagChar;
|
||||
tag->GetUnicode(&tagChar);
|
||||
nsDependentString str(tagChar);
|
||||
|
||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||
("SinkContext::CloseContainer: reflow on notifyImmediate "
|
||||
"tag=%s newIndex=%d stackPos=%d",
|
||||
tagStr,
|
||||
NS_LossyConvertUCS2toASCII(str).get(),
|
||||
mStack[mStackPos].mNumFlushed, mStackPos));
|
||||
#endif
|
||||
mSink->NotifyAppend(content, mStack[mStackPos].mNumFlushed);
|
||||
|
@ -2114,12 +2117,13 @@ SinkContext::FlushTags(PRBool aNotify)
|
|||
// Tracing code
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mStack[stackPos].mContent->GetTag(*getter_AddRefs(tag));
|
||||
const char* tagStr;
|
||||
tag->GetUTF8String(&tagStr);
|
||||
const PRUnichar* tagChar;
|
||||
tag->GetUnicode(&tagChar);
|
||||
nsDependentString str(tagChar);
|
||||
|
||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||
("SinkContext::FlushTags: tag=%s from newindex=%d at "
|
||||
"stackPos=%d", tagStr,
|
||||
"stackPos=%d", NS_LossyConvertUCS2toASCII(str).get(),
|
||||
mStack[stackPos].mNumFlushed, stackPos));
|
||||
#endif
|
||||
if ((mStack[stackPos].mInsertionPoint != -1) &&
|
||||
|
@ -5255,11 +5259,12 @@ HTMLContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
|||
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
const char* header;
|
||||
(void)aHeader->GetUTF8String(&header);
|
||||
(void)httpChannel->SetResponseHeader(nsDependentCString(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
const PRUnichar *header = 0;
|
||||
(void)aHeader->GetUnicode(&header);
|
||||
(void)httpChannel->SetResponseHeader(
|
||||
NS_ConvertUCS2toUTF8(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1569,10 +1569,9 @@ static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
|||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
const char* str;
|
||||
aPseudo->GetUTF8String(&str);
|
||||
static const char moz_tree[] = ":moz-tree-";
|
||||
return nsCRT::strncmp(str, moz_tree, PRInt32(sizeof(moz_tree)-1)) == 0;
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return Substring(str, 0, 11).Equals(NS_LITERAL_STRING(":-moz-tree-"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -584,8 +584,8 @@ PRInt32 nsCSSSelector::CalcWeight(void) const
|
|||
static PRBool IsPseudoElement(nsIAtom* aAtom)
|
||||
{
|
||||
if (aAtom) {
|
||||
const char* str;
|
||||
aAtom->GetUTF8String(&str);
|
||||
const PRUnichar *str;
|
||||
aAtom->GetUnicode(&str);
|
||||
return str && (*str == ':');
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ void nsCSSSelector::AppendNegationToString(nsAString& aString)
|
|||
nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet, PRBool aIsPseudoElem,
|
||||
PRInt8 aNegatedIndex) const
|
||||
{
|
||||
nsAutoString temp;
|
||||
const PRUnichar* temp;
|
||||
PRBool aIsNegated = PRBool(0 < aNegatedIndex);
|
||||
|
||||
// selectors are linked from right-to-left, so the next selector in the linked list
|
||||
|
@ -631,8 +631,8 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
// will return null if namespace was the default
|
||||
sheetNS->FindNameSpacePrefix(mNameSpace, *getter_AddRefs(prefixAtom));
|
||||
if (prefixAtom) {
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
|
@ -648,16 +648,15 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
mTag->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
NS_IF_NEGATED_END(aIsNegated, aString)
|
||||
}
|
||||
// Append the id, if there is one
|
||||
if (mIDList) {
|
||||
nsAtomList* list = mIDList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('#'));
|
||||
aString.Append(temp);
|
||||
|
@ -669,7 +668,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
if (mClassList) {
|
||||
nsAtomList* list = mClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('.'));
|
||||
aString.Append(temp);
|
||||
|
@ -693,14 +692,14 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
// will return null if namespace was the default
|
||||
sheetNS->FindNameSpacePrefix(list->mNameSpace, *getter_AddRefs(prefixAtom));
|
||||
if (prefixAtom) {
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
}
|
||||
// Append the attribute name
|
||||
list->mAttr->ToString(temp);
|
||||
list->mAttr->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
// Append the function
|
||||
if (list->mFunction == NS_ATTR_FUNC_EQUALS) {
|
||||
|
@ -733,7 +732,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
if (mPseudoClassList) {
|
||||
nsAtomStringList* list = mPseudoClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(temp);
|
||||
if (nsnull != list->mString) {
|
||||
|
|
|
@ -168,11 +168,12 @@ RuleHash_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|||
if (match_atom == entry_atom)
|
||||
return PR_TRUE;
|
||||
|
||||
const char *match_str, *entry_str;
|
||||
match_atom->GetUTF8String(&match_str);
|
||||
entry_atom->GetUTF8String(&entry_str);
|
||||
const PRUnichar *match_str, *entry_str;
|
||||
match_atom->GetUnicode(&match_str);
|
||||
entry_atom->GetUnicode(&entry_str);
|
||||
|
||||
return (nsCRT::strcasecmp(entry_str, match_str) == 0);
|
||||
return nsDependentString(match_str).Equals(nsDependentString(entry_str),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
|
@ -1115,8 +1116,8 @@ DOMMediaListImpl::GetText(nsAString& aMediaText)
|
|||
QueryElementAt(index++, NS_GET_IID(nsIAtom), getter_AddRefs(medium));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
aMediaText.Append(buffer);
|
||||
if (index < count) {
|
||||
aMediaText.Append(NS_LITERAL_STRING(", "));
|
||||
|
@ -1233,8 +1234,8 @@ DOMMediaListImpl::Item(PRUint32 aIndex, nsAString& aReturn)
|
|||
nsCOMPtr<nsIAtom> medium(do_QueryInterface(tmp));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
aReturn.Assign(buffer);
|
||||
} else {
|
||||
aReturn.Truncate();
|
||||
|
@ -3741,15 +3742,15 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
IDList = IDList->mNext;
|
||||
} while (IDList);
|
||||
} else {
|
||||
const char* id1Str;
|
||||
data.mContentID->GetUTF8String(&id1Str);
|
||||
nsDependentCString id1(id1Str);
|
||||
const PRUnichar* id1Str;
|
||||
data.mContentID->GetUnicode(&id1Str);
|
||||
nsDependentString id1(id1Str);
|
||||
do {
|
||||
const char* id2Str;
|
||||
IDList->mAtom->GetUTF8String(&id2Str);
|
||||
nsDependentCString id2(id2Str);
|
||||
const PRUnichar* id2Str;
|
||||
IDList->mAtom->GetUnicode(&id2Str);
|
||||
nsDependentString id2(id2Str);
|
||||
if (localTrue !=
|
||||
id1.Equals(id2, nsCaseInsensitiveCStringComparator())) {
|
||||
id1.Equals(id2, nsCaseInsensitiveStringComparator())) {
|
||||
result = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1376,15 +1376,17 @@ nsHTMLAttributes::HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const
|
|||
classList = classList->mNext;
|
||||
} while (classList);
|
||||
} else {
|
||||
const char* class1;
|
||||
aClass->GetUTF8String(&class1);
|
||||
const PRUnichar* class1Buf;
|
||||
aClass->GetUnicode(&class1Buf);
|
||||
// This length calculation (and the |aCaseSensitive| check above) could
|
||||
// theoretically be pulled out of another loop by creating a separate
|
||||
// |HasClassCI| function.
|
||||
nsDependentString class1(class1Buf);
|
||||
do {
|
||||
const char* class2;
|
||||
classList->mAtom->GetUTF8String(&class2);
|
||||
if (nsCRT::strcasecmp(class1, class2) == 0)
|
||||
const PRUnichar* class2Buf;
|
||||
classList->mAtom->GetUnicode(&class2Buf);
|
||||
nsDependentString class2(class2Buf);
|
||||
if (class1.Equals(class2, nsCaseInsensitiveStringComparator()))
|
||||
return PR_TRUE;
|
||||
classList = classList->mNext;
|
||||
} while (classList);
|
||||
|
|
|
@ -93,22 +93,26 @@ NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIAtom* kSimpleAtom; // XXX these should get moved to nsXMLAtoms
|
||||
static nsIAtom* kHrefAtom;
|
||||
static nsIAtom* kShowAtom;
|
||||
static nsIAtom* kTypeAtom;
|
||||
static nsIAtom* kBaseAtom;
|
||||
static nsIAtom* kActuateAtom;
|
||||
static nsIAtom* kOnLoadAtom;
|
||||
static nsIAtom* kEmbedAtom;
|
||||
static PRUint32 kElementCount;
|
||||
|
||||
nsXMLElement::nsXMLElement() : mIsLink(PR_FALSE)
|
||||
{
|
||||
if (0 == kElementCount++) {
|
||||
kSimpleAtom = NS_NewAtom("simple");
|
||||
kHrefAtom = NS_NewAtom("href");
|
||||
kShowAtom = NS_NewAtom("show");
|
||||
kTypeAtom = NS_NewAtom("type");
|
||||
kBaseAtom = NS_NewAtom("base");
|
||||
kActuateAtom = NS_NewAtom("actuate");
|
||||
kOnLoadAtom = NS_NewAtom("onLoad");
|
||||
kEmbedAtom = NS_NewAtom("embed");
|
||||
}
|
||||
}
|
||||
|
@ -116,11 +120,13 @@ nsXMLElement::nsXMLElement() : mIsLink(PR_FALSE)
|
|||
nsXMLElement::~nsXMLElement()
|
||||
{
|
||||
if (0 == --kElementCount) {
|
||||
NS_RELEASE(kSimpleAtom);
|
||||
NS_RELEASE(kHrefAtom);
|
||||
NS_RELEASE(kShowAtom);
|
||||
NS_RELEASE(kTypeAtom);
|
||||
NS_RELEASE(kBaseAtom);
|
||||
NS_RELEASE(kActuateAtom);
|
||||
NS_RELEASE(kOnLoadAtom);
|
||||
NS_RELEASE(kEmbedAtom);
|
||||
}
|
||||
}
|
||||
|
@ -315,12 +321,17 @@ nsXMLElement::SetAttr(nsINodeInfo *aNodeInfo,
|
|||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
|
||||
if (aNodeInfo->Equals(kTypeAtom, kNameSpaceID_XLink)) {
|
||||
|
||||
// NOTE: This really is a link according to the XLink spec,
|
||||
// we do not need to check other attributes. If there
|
||||
// is no href attribute, then this link is simply
|
||||
// untraversible [XLink 3.2].
|
||||
mIsLink = aValue.Equals(NS_LITERAL_STRING("simple"));
|
||||
const PRUnichar* simpleStr;
|
||||
kSimpleAtom->GetUnicode(&simpleStr);
|
||||
if (aValue.Equals(simpleStr)) {
|
||||
// NOTE: This really is a link according to the XLink spec,
|
||||
// we do not need to check other attributes. If there
|
||||
// is no href attribute, then this link is simply
|
||||
// untraversible [XLink 3.2].
|
||||
mIsLink = PR_TRUE;
|
||||
} else {
|
||||
mIsLink = PR_FALSE;
|
||||
}
|
||||
|
||||
// We will check for actuate="onLoad" in MaybeTriggerAutoLink
|
||||
}
|
||||
|
@ -397,7 +408,10 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
if (mIsLink) {
|
||||
NS_NAMED_LITERAL_STRING(onloadString, "onLoad");
|
||||
// preload and precalculate length of atom outside of loop
|
||||
const PRUnichar *onloadUnicode;
|
||||
kOnLoadAtom->GetUnicode(&onloadUnicode);
|
||||
nsDependentString onloadString(onloadUnicode);
|
||||
do {
|
||||
// actuate="onLoad" ?
|
||||
nsAutoString value;
|
||||
|
|
|
@ -1177,6 +1177,7 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
|
|||
rv = originalCodebase->GetURI(getter_AddRefs(codebaseURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char *cookie = ToNewUTF8String(aValue);
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
|
@ -1195,8 +1196,8 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
|
|||
}
|
||||
}
|
||||
|
||||
rv = cookieServ->SetCookieString(codebaseURI, prompt, NS_ConvertUCS2toUTF8(aValue).get(), httpChannel);
|
||||
|
||||
rv = cookieServ->SetCookieString(codebaseURI, prompt, cookie, httpChannel);
|
||||
nsCRT::free(cookie);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} // END set-cookie
|
||||
else if (aHeader == nsHTMLAtoms::link) {
|
||||
|
@ -1222,11 +1223,12 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
|
|||
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
const char *header = 0;
|
||||
(void)aHeader->GetUTF8String(&header);
|
||||
(void)httpChannel->SetResponseHeader(nsDependentCString(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
const PRUnichar *header = 0;
|
||||
(void)aHeader->GetUnicode(&header);
|
||||
(void)httpChannel->SetResponseHeader(
|
||||
NS_ConvertUCS2toUTF8(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -946,8 +946,11 @@ MatchId(nsIContent *aContent, const nsAString& aName)
|
|||
nsCOMPtr<nsIXMLContent> xmlContent = do_QueryInterface(aContent);
|
||||
nsCOMPtr<nsIAtom> IDValue;
|
||||
if (xmlContent && NS_SUCCEEDED(xmlContent->GetID(*getter_AddRefs(IDValue))) && IDValue) {
|
||||
if (IDValue->Equals(aName))
|
||||
const PRUnichar* IDValStr = nsnull;
|
||||
IDValue->GetUnicode(&IDValStr);
|
||||
if (aName.Equals(IDValStr)) {
|
||||
return aContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -374,7 +374,9 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
|||
nsAutoString prefix;
|
||||
if (prefixAtom)
|
||||
{
|
||||
prefixAtom->ToString(prefix);
|
||||
const PRUnichar *unicodeString;
|
||||
prefixAtom->GetUnicode(&unicodeString);
|
||||
prefix = unicodeString;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2030,6 +2030,8 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
|
|||
// Now we execute the onchange handler in the context of the
|
||||
// observer. We need to find the observer in order to
|
||||
// execute the handler.
|
||||
nsAutoString attrName;
|
||||
aAttr->ToString(attrName);
|
||||
|
||||
nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
|
||||
PRInt32 count;
|
||||
|
@ -2063,7 +2065,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
|
|||
child->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute,
|
||||
listeningToAttribute);
|
||||
|
||||
if (!aAttr->Equals(listeningToAttribute) &&
|
||||
if (listeningToAttribute != attrName &&
|
||||
listeningToAttribute != NS_LITERAL_STRING("*")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -3070,13 +3072,13 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID,
|
|||
|
||||
// Ick. Construct a property from the attribute. Punt on
|
||||
// namespaces for now.
|
||||
const char* attrstr;
|
||||
rv = aAttribute->GetUTF8String(&attrstr);
|
||||
const PRUnichar* attrstr;
|
||||
rv = aAttribute->GetUnicode(&attrstr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> attr;
|
||||
rv = gRDFService->GetResource(nsDependentCString(attrstr),
|
||||
getter_AddRefs(attr));
|
||||
rv = gRDFService->GetUnicodeResource(nsDependentString(attrstr),
|
||||
getter_AddRefs(attr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Turn the value into a literal
|
||||
|
|
|
@ -184,14 +184,14 @@ nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations, void*
|
|||
if (tag != mTag) {
|
||||
consistent = PR_FALSE;
|
||||
|
||||
const char *expected, *actual;
|
||||
mTag->GetUTF8String(&expected);
|
||||
tag->GetUTF8String(&actual);
|
||||
const PRUnichar *expected, *actual;
|
||||
mTag->GetUnicode(&expected);
|
||||
tag->GetUnicode(&actual);
|
||||
|
||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
(" => tag mismatch; expected %s, actual %s",
|
||||
expected,
|
||||
actual));
|
||||
NS_LossyConvertUCS2toASCII(expected).get(),
|
||||
NS_LossyConvertUCS2toASCII(actual).get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -906,14 +906,14 @@ AtomToEventHandlerName(nsIAtom *aName, char *charName, PRUint32 charNameSize)
|
|||
// optimized to avoid ns*Str*.h explicit/implicit copying and malloc'ing
|
||||
// even nsCAutoString may call an Append that copy-constructs an nsStr from
|
||||
// a const PRUnichar*
|
||||
const char *name;
|
||||
aName->GetUTF8String(&name);
|
||||
const PRUnichar *name;
|
||||
aName->GetUnicode(&name);
|
||||
char c;
|
||||
PRUint32 i = 0;
|
||||
|
||||
do {
|
||||
NS_ASSERTION(name[i] < 128, "non-ASCII event handler name");
|
||||
c = name[i];
|
||||
c = char(name[i]);
|
||||
|
||||
// The HTML content sink must have folded to lowercase already.
|
||||
NS_ASSERTION(c == '\0' || isalpha(c), "non-alphabetic event handler name");
|
||||
|
|
|
@ -3587,9 +3587,9 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
|
|||
{
|
||||
nsAutoString tag;
|
||||
element->GetTagName(tag);
|
||||
const char *tagStr;
|
||||
aTag->GetUTF8String(&tagStr);
|
||||
if (tag.EqualsIgnoreCase(tagStr))
|
||||
const PRUnichar *unicodeString;
|
||||
aTag->GetUnicode(&unicodeString);
|
||||
if (tag.Equals(unicodeString, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ function onselect_loadURI(tree, columnName) {
|
|||
function getPropertyValue(properties, propName) {
|
||||
for (var i=0; i< properties.Count(); ++i) {
|
||||
var atom = properties.GetElementAt(i).QueryInterface(Components.interfaces.nsIAtom);
|
||||
var atomValue = atom.toString();
|
||||
var atomValue = atom.GetUnicode();
|
||||
if (atomValue.substr(0, propName.length) == propName)
|
||||
return atomValue.substr(propName.length);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ XBLBindings.prototype =
|
|||
|
||||
while (urls.hasMoreElements()) {
|
||||
var item = urls.getNext();
|
||||
var url = item.QueryInterface(Components.interfaces.nsIAtom).toString();
|
||||
var url = item.QueryInterface(Components.interfaces.nsIAtom).GetUnicode();
|
||||
var menu = document.createElement("menuitem");
|
||||
menu.setAttribute("value", url);
|
||||
menu.setAttribute("label", url);
|
||||
|
|
|
@ -73,7 +73,9 @@ void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest);
|
|||
*/
|
||||
static PRBool TX_StringEqualsAtom(const nsAString& aString, nsIAtom* aAtom)
|
||||
{
|
||||
return aAtom->Equals(aString);
|
||||
const PRUnichar* atom;
|
||||
aAtom->GetUnicode(&atom);
|
||||
return aString.Equals(atom);
|
||||
};
|
||||
|
||||
#endif // txStringUtils_h__
|
||||
|
|
|
@ -88,12 +88,12 @@ double txNameTest::getDefaultPriority()
|
|||
void txNameTest::toString(nsAString& aDest)
|
||||
{
|
||||
if (mPrefix) {
|
||||
nsAutoString prefix;
|
||||
mPrefix->ToString(prefix);
|
||||
aDest.Append(prefix);
|
||||
const PRUnichar* prefix;
|
||||
mPrefix->GetUnicode(&prefix);
|
||||
aDest.Append(nsDependentString(prefix));
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
nsAutoString localName;
|
||||
mLocalName->ToString(localName);
|
||||
aDest.Append(localName);
|
||||
const PRUnichar* localName;
|
||||
mLocalName->GetUnicode(&localName);
|
||||
aDest.Append(nsDependentString(localName));
|
||||
}
|
||||
|
|
|
@ -174,11 +174,13 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
// family is generic string like
|
||||
// "serif" "sans-serif" "cursive" "fantasy" "monospace" "-moz-fixed"
|
||||
// so look up preferences and get real family name
|
||||
const char *lang;
|
||||
aLangGroup->GetUTF8String( &lang );
|
||||
const PRUnichar *langGroup;
|
||||
aLangGroup->GetUnicode( &langGroup );
|
||||
char *lang = ToNewUTF8String(nsDependentString(langGroup));
|
||||
char prop[256];
|
||||
sprintf( prop, "font.name.%s.%s", family, lang );
|
||||
|
||||
nsMemory::Free(lang);
|
||||
nsMemory::Free(family);
|
||||
|
||||
// look up prefs
|
||||
|
|
|
@ -620,9 +620,9 @@ static nsFontPropertyName gWeightNames[] =
|
|||
static char*
|
||||
atomToName(nsIAtom* aAtom)
|
||||
{
|
||||
const char *namePRU;
|
||||
aAtom->GetUTF8String(&namePRU);
|
||||
return ToNewCString(nsDependentCString(namePRU));
|
||||
const PRUnichar *namePRU;
|
||||
aAtom->GetUnicode(&namePRU);
|
||||
return ToNewUTF8String(nsDependentString(namePRU));
|
||||
}
|
||||
|
||||
static PRUint16* gUserDefinedCCMap = nsnull;
|
||||
|
@ -1385,9 +1385,9 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
name.Append("variable");
|
||||
}
|
||||
name.Append(char('.'));
|
||||
const char* langGroup = nsnull;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
name.Append(langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
name.AppendWithConversion(langGroup);
|
||||
PRInt32 minimum = 0;
|
||||
res = gPref->GetIntPref(name.get(), &minimum);
|
||||
if (NS_FAILED(res)) {
|
||||
|
@ -6102,9 +6102,9 @@ nsFontMetricsGTK::FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUint32 aChar)
|
|||
// check user set pref
|
||||
nsCAutoString pref = prefix;
|
||||
pref.Append(char('.'));
|
||||
const char* langGroup = nsnull;
|
||||
aLangGroup->GetUTF8String(&langGroup);
|
||||
pref.Append(langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
aLangGroup->GetUnicode(&langGroup);
|
||||
pref.AppendWithConversion(langGroup);
|
||||
nsXPIDLCString value;
|
||||
gPref->CopyCharPref(pref.get(), getter_Copies(value));
|
||||
nsCAutoString str;
|
||||
|
|
|
@ -298,10 +298,10 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
|
||||
name.Append(char('.'));
|
||||
|
||||
nsCAutoString name;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
|
||||
name.Append(langGroup);
|
||||
name.AppendWithConversion(langGroup);
|
||||
|
||||
PRInt32 minimum = 0;
|
||||
nsresult res;
|
||||
|
@ -802,10 +802,10 @@ nsFontMetricsXft::SetupFCPattern(void)
|
|||
}
|
||||
|
||||
// language group
|
||||
const char *name;
|
||||
mLangGroup->Get(&name);
|
||||
const PRUnichar *name;
|
||||
mLangGroup->GetUnicode(&name);
|
||||
nsCAutoString cname;
|
||||
cname.Assign(name);
|
||||
cname.AssignWithConversion(nsDependentString(name));
|
||||
printf("\tlang group: %s\n", cname.get());
|
||||
|
||||
|
||||
|
@ -1671,8 +1671,10 @@ void
|
|||
AddLangGroup(FcPattern *aPattern, nsIAtom *aLangGroup)
|
||||
{
|
||||
// Find the FC lang group for this lang group
|
||||
const PRUnichar *name;
|
||||
aLangGroup->GetUnicode(&name);
|
||||
nsCAutoString cname;
|
||||
aLangGroup->ToUTF8String(cname);
|
||||
cname.AssignWithConversion(nsDependentString(name));
|
||||
|
||||
// see if the lang group needs to be translated from mozilla's
|
||||
// internal mapping into fontconfig's
|
||||
|
|
|
@ -599,8 +599,9 @@ nsFontMetricsOS2::SetFontHandle( HPS aPS, nsFontOS2* aFont )
|
|||
// Encoding:
|
||||
// There doesn't seem to be any encoding stuff yet, so guess.
|
||||
// (XXX unicode hack; use same codepage as converter!)
|
||||
const char* langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
nsCAutoString name(NS_LossyConvertUCS2toASCII(langGroup).get());
|
||||
for (int j=0; j < eCharset_COUNT; j++ )
|
||||
{
|
||||
if (langGroup[0] == gCharsetInfo[j].mLangGroup[0])
|
||||
|
|
|
@ -163,12 +163,18 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
str = strdup("serif");
|
||||
}
|
||||
|
||||
const char *cstring;
|
||||
aLangGroup->GetUTF8String( &uc );
|
||||
const PRUnichar *uc;
|
||||
aLangGroup->GetUnicode( &uc );
|
||||
nsString language( uc );
|
||||
char *cstring = ToNewCString(language);
|
||||
|
||||
char prop[256];
|
||||
sprintf( prop, "font.name.%s.%s", str, cstring );
|
||||
|
||||
/* Free cstring. */
|
||||
if (cstring)
|
||||
free (cstring);
|
||||
|
||||
char *font_default = NULL;
|
||||
nsIPref* prefs = nsnull;
|
||||
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**) &prefs);
|
||||
|
|
|
@ -866,13 +866,13 @@ nsFontPSFreeType::FindFont(PRUnichar aChar, const nsFont& aFont,
|
|||
aFontMetrics->GetLangGroup(getter_AddRefs(lang));
|
||||
if (!lang)
|
||||
lang = NS_NewAtom("x-western");
|
||||
const char *langStr;
|
||||
lang->GetUTF8String(&langStr);
|
||||
const PRUnichar *langStr;
|
||||
lang->GetUnicode(&langStr);
|
||||
if (langStr)
|
||||
fpi.lang.Append(langStr);
|
||||
gUsersLocale->GetUTF8String(&langStr);
|
||||
fpi.lang.AppendWithConversion(langStr);
|
||||
gUsersLocale->GetUnicode(&langStr);
|
||||
if (langStr)
|
||||
locale.Append(langStr);
|
||||
locale.AppendWithConversion(langStr);
|
||||
if (NS_IS_BOLD(fpi.nsfont->weight))
|
||||
fpi.weight = nsIFontCatalogService::kFCWeightBold;
|
||||
else
|
||||
|
|
|
@ -2203,7 +2203,7 @@ nsFontMetricsWin::CreateFontAdjustHandle(HDC aDC, LOGFONT* aLogFont)
|
|||
}
|
||||
|
||||
HFONT
|
||||
nsFontMetricsWin::CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLogFont)
|
||||
nsFontMetricsWin::CreateFontHandle(HDC aDC, nsString* aName, LOGFONT* aLogFont)
|
||||
{
|
||||
PRUint16 weightTable = LookForFontWeightTable(aDC, aName);
|
||||
PRInt32 weight = GetFontWeight(mFont.weight, weightTable);
|
||||
|
@ -2215,7 +2215,7 @@ nsFontMetricsWin::CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLog
|
|||
* but we don't really have a choice since CreateFontIndirectW is
|
||||
* not supported on Windows 9X (see below) -- erik
|
||||
*/
|
||||
WideCharToMultiByte(CP_ACP, 0, aName.get(), aName.Length() + 1,
|
||||
WideCharToMultiByte(CP_ACP, 0, aName->get(), aName->Length() + 1,
|
||||
aLogFont->lfFaceName, sizeof(aLogFont->lfFaceName), nsnull, nsnull);
|
||||
|
||||
if (mFont.sizeAdjust <= 0) {
|
||||
|
@ -2228,7 +2228,7 @@ nsFontMetricsWin::CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLog
|
|||
HFONT
|
||||
nsFontMetricsWin::CreateFontHandle(HDC aDC, nsGlobalFont* aGlobalFont, LOGFONT* aLogFont)
|
||||
{
|
||||
PRUint16 weightTable = LookForFontWeightTable(aDC, aGlobalFont->name);
|
||||
PRUint16 weightTable = LookForFontWeightTable(aDC, &aGlobalFont->name);
|
||||
PRInt32 weight = GetFontWeight(mFont.weight, weightTable);
|
||||
|
||||
FillLogFont(aLogFont, weight);
|
||||
|
@ -2244,7 +2244,7 @@ nsFontMetricsWin::CreateFontHandle(HDC aDC, nsGlobalFont* aGlobalFont, LOGFONT*
|
|||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWin::LoadFont(HDC aDC, const nsString& aName)
|
||||
nsFontMetricsWin::LoadFont(HDC aDC, nsString* aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = CreateFontHandle(aDC, aName, &logFont);
|
||||
|
@ -2559,7 +2559,7 @@ nsFontMetricsWin::FindSubstituteFont(HDC aDC, PRUint32 c)
|
|||
// that the substitute font also has glyphs for '&', '#', 'x', ';' and digits?
|
||||
// (Because this is a unicode font, those glyphs should in principle be there.)
|
||||
name.AssignWithConversion(font->mName);
|
||||
font = LoadSubstituteFont(aDC, name);
|
||||
font = LoadSubstituteFont(aDC, &name);
|
||||
if (font) {
|
||||
((nsFontWinSubstitute*)font)->SetRepresentable(c);
|
||||
mSubstituteFont = font;
|
||||
|
@ -2580,7 +2580,7 @@ nsFontMetricsWin::FindSubstituteFont(HDC aDC, PRUint32 c)
|
|||
continue;
|
||||
}
|
||||
if (CCMAP_HAS_CHAR(globalFont->ccmap, NS_REPLACEMENT_CHAR)) {
|
||||
nsFontWin* font = LoadSubstituteFont(aDC, globalFont->name);
|
||||
nsFontWin* font = LoadSubstituteFont(aDC, &globalFont->name);
|
||||
if (font) {
|
||||
((nsFontWinSubstitute*)font)->SetRepresentable(c);
|
||||
mSubstituteFont = font;
|
||||
|
@ -2591,7 +2591,7 @@ nsFontMetricsWin::FindSubstituteFont(HDC aDC, PRUint32 c)
|
|||
|
||||
// We are running out of resources if we reach here... Try a stock font
|
||||
NS_ASSERTION(::GetMapMode(aDC) == MM_TEXT, "mapping mode needs to be MM_TEXT");
|
||||
nsFontWin* font = LoadSubstituteFont(aDC, nsString());
|
||||
nsFontWin* font = LoadSubstituteFont(aDC, nsnull);
|
||||
if (font) {
|
||||
((nsFontWinSubstitute*)font)->SetRepresentable(c);
|
||||
mSubstituteFont = font;
|
||||
|
@ -2603,17 +2603,17 @@ nsFontMetricsWin::FindSubstituteFont(HDC aDC, PRUint32 c)
|
|||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWin::LoadSubstituteFont(HDC aDC, const nsString& aName)
|
||||
nsFontMetricsWin::LoadSubstituteFont(HDC aDC, nsString* aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = !aName.IsEmpty()
|
||||
HFONT hfont = aName
|
||||
? CreateFontHandle(aDC, aName, &logFont)
|
||||
: (HFONT)::GetStockObject(SYSTEM_FONT);
|
||||
if (hfont) {
|
||||
// XXX 'displayUnicode' has to be initialized based on the desired rendering mode
|
||||
PRBool displayUnicode = PR_FALSE;
|
||||
/* substitute font does not need ccmap */
|
||||
LOGFONT* lfont = !aName.IsEmpty() ? &logFont : nsnull;
|
||||
LOGFONT* lfont = aName ? &logFont : nsnull;
|
||||
nsFontWinSubstitute* font = new nsFontWinSubstitute(lfont, hfont, nsnull, displayUnicode);
|
||||
if (font) {
|
||||
HFONT oldFont = (HFONT)::SelectObject(aDC, (HGDIOBJ)hfont);
|
||||
|
@ -2782,12 +2782,12 @@ SearchSimulatedFontWeight(HDC aDC, nsFontWeightInfo* aWeightInfo)
|
|||
}
|
||||
|
||||
PRUint16
|
||||
nsFontMetricsWin::GetFontWeightTable(HDC aDC, const nsString& aFontName)
|
||||
nsFontMetricsWin::GetFontWeightTable(HDC aDC, nsString* aFontName)
|
||||
{
|
||||
// Look for all of the weights for a given font.
|
||||
LOGFONT logFont;
|
||||
logFont.lfCharSet = DEFAULT_CHARSET;
|
||||
WideCharToMultiByte(CP_ACP, 0, aFontName.get(), aFontName.Length() + 1,
|
||||
WideCharToMultiByte(CP_ACP, 0, aFontName->get(), aFontName->Length() + 1,
|
||||
logFont.lfFaceName, sizeof(logFont.lfFaceName), nsnull, nsnull);
|
||||
logFont.lfPitchAndFamily = 0;
|
||||
|
||||
|
@ -2936,7 +2936,7 @@ nsFontMetricsWin::GetFontWeight(PRInt32 aWeight, PRUint16 aWeightTable)
|
|||
}
|
||||
|
||||
PRUint16
|
||||
nsFontMetricsWin::LookForFontWeightTable(HDC aDC, const nsString& aName)
|
||||
nsFontMetricsWin::LookForFontWeightTable(HDC aDC, nsString* aName)
|
||||
{
|
||||
// Initialize the font weight table if need be.
|
||||
if (!gFontWeights) {
|
||||
|
@ -2950,7 +2950,7 @@ nsFontMetricsWin::LookForFontWeightTable(HDC aDC, const nsString& aName)
|
|||
// Use lower case name for hash table searches. This eliminates
|
||||
// keeping multiple font weights entries when the font name varies
|
||||
// only by case.
|
||||
nsAutoString low(aName);
|
||||
nsAutoString low(*aName);
|
||||
ToLowerCase(low);
|
||||
|
||||
// See if the font weight has already been computed.
|
||||
|
@ -2994,7 +2994,7 @@ nsFontMetricsWin::FindUserDefinedFont(HDC aDC, PRUint32 aChar)
|
|||
{
|
||||
if (mIsUserDefined) {
|
||||
// the user-defined font is always loaded as the first font
|
||||
nsFontWin* font = LoadFont(aDC, mUserDefined);
|
||||
nsFontWin* font = LoadFont(aDC, &mUserDefined);
|
||||
mIsUserDefined = PR_FALSE;
|
||||
if (font && font->HasGlyph(aChar))
|
||||
return font;
|
||||
|
@ -3110,7 +3110,7 @@ nsFontMetricsWin::FindLocalFont(HDC aDC, PRUint32 aChar)
|
|||
if (!winName) {
|
||||
winName = name;
|
||||
}
|
||||
nsFontWin* font = LoadFont(aDC, *winName);
|
||||
nsFontWin* font = LoadFont(aDC, winName);
|
||||
if (font && font->HasGlyph(aChar)) {
|
||||
return font;
|
||||
}
|
||||
|
@ -3119,14 +3119,14 @@ nsFontMetricsWin::FindLocalFont(HDC aDC, PRUint32 aChar)
|
|||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWin::LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName)
|
||||
nsFontMetricsWin::LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName)
|
||||
{
|
||||
for (int i = mLoadedFonts.Count()-1; i >= 0; --i) {
|
||||
// woah, this seems bad
|
||||
const nsACString& fontName =
|
||||
nsDependentCString(((nsFontWin*)mLoadedFonts[i])->mName);
|
||||
if (aName.Equals(NS_ConvertASCIItoUCS2(fontName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
if (aName->Equals(NS_ConvertASCIItoUCS2(((nsFontWin*)mLoadedFonts[i])->mName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
return nsnull;
|
||||
|
||||
}
|
||||
|
@ -3152,7 +3152,7 @@ GenericFontEnumCallback(const nsString& aFamily, PRBool aGeneric, void* aData)
|
|||
HDC dc = context->mDC;
|
||||
PRUint32 ch = context->mChar;
|
||||
nsFontMetricsWin* metrics = context->mMetrics;
|
||||
context->mFont = metrics->LoadGenericFont(dc, ch, aFamily);
|
||||
context->mFont = metrics->LoadGenericFont(dc, ch, (nsString*)&aFamily);
|
||||
if (context->mFont) {
|
||||
return PR_FALSE; // stop enumerating the list
|
||||
}
|
||||
|
@ -3211,9 +3211,10 @@ nsFontMetricsWin::FindGenericFont(HDC aDC, PRUint32 aChar)
|
|||
nsFont font("", 0, 0, 0, 0, 0);
|
||||
|
||||
if (mLangGroup) {
|
||||
const char* langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
AppendGenericFontFromPref(font.name, langGroup,
|
||||
nsAutoString langGroup;
|
||||
mLangGroup->ToString(langGroup);
|
||||
AppendGenericFontFromPref(font.name,
|
||||
NS_ConvertUCS2toUTF8(langGroup).get(),
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
|
@ -3225,12 +3226,13 @@ nsFontMetricsWin::FindGenericFont(HDC aDC, PRUint32 aChar)
|
|||
}
|
||||
|
||||
#if defined(DEBUG_rbs) || defined(DEBUG_shanjian)
|
||||
const char* lang;
|
||||
mLangGroup->GetUTF8String(&lang);
|
||||
NS_ConvertUCS2toUTF8 generic(mGeneric);
|
||||
NS_ConvertUCS2toUTF8 family(mFont.name);
|
||||
nsAutoString langGroupName;
|
||||
mLangGroup->ToString(langGroupName);
|
||||
nsCAutoString lang; lang.Assign(NS_ConvertUCS2toUTF8(langGroupName));
|
||||
nsCAutoString generic; generic.Assign(NS_ConvertUCS2toUTF8(mGeneric));
|
||||
nsCAutoString family; family.Assign(NS_ConvertUCS2toUTF8(mFont.name));
|
||||
printf("FindGenericFont missed:U+%04X langGroup:%s generic:%s mFont.name:%s\n",
|
||||
aChar, lang, generic.get(), family.get());
|
||||
aChar, lang.get(), generic.get(), family.get());
|
||||
#endif
|
||||
|
||||
mTriedAllGenerics = 1;
|
||||
|
@ -3277,17 +3279,17 @@ nsFontMetricsWin::FindPrefFont(HDC aDC, PRUint32 aChar)
|
|||
|
||||
// then try user locale first, if it is CJK
|
||||
if ((gUsersLocale != mLangGroup) && IsCJKLangGroupAtom(gUsersLocale)) {
|
||||
nsCAutoString usersLocaleLangGroup;
|
||||
gUsersLocale->ToUTF8String(usersLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, usersLocaleLangGroup.get(),
|
||||
const PRUnichar *usersLocaleLangGroup;
|
||||
gUsersLocale->GetUnicode(&usersLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, NS_ConvertUCS2toUTF8(usersLocaleLangGroup).get(),
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
// then system locale (os language)
|
||||
if ((gSystemLocale != mLangGroup) && (gSystemLocale != gUsersLocale) && IsCJKLangGroupAtom(gSystemLocale)) {
|
||||
nsCAutoString systemLocaleLangGroup;
|
||||
gSystemLocale->ToUTF8String(systemLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, systemLocaleLangGroup.get(),
|
||||
const PRUnichar *systemLocaleLangGroup;
|
||||
gSystemLocale->GetUnicode(&systemLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, NS_ConvertUCS2toUTF8(systemLocaleLangGroup).get(),
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
|
@ -4599,7 +4601,7 @@ nsFontWinA::DumpFontInfo()
|
|||
#endif
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadFont(HDC aDC, const nsString& aName)
|
||||
nsFontMetricsWinA::LoadFont(HDC aDC, nsString* aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = CreateFontHandle(aDC, aName, &logFont);
|
||||
|
@ -4732,7 +4734,7 @@ nsFontMetricsWinA::FindLocalFont(HDC aDC, PRUint32 aChar)
|
|||
if (!winName) {
|
||||
winName = name;
|
||||
}
|
||||
nsFontWinA* font = (nsFontWinA*)LoadFont(aDC, *winName);
|
||||
nsFontWinA* font = (nsFontWinA*)LoadFont(aDC, winName);
|
||||
if (font && font->HasGlyph(aChar)) {
|
||||
nsFontSubset* subset = font->FindSubset(aDC, (PRUnichar)aChar, this);
|
||||
if (subset)
|
||||
|
@ -4744,11 +4746,12 @@ nsFontMetricsWinA::FindLocalFont(HDC aDC, PRUint32 aChar)
|
|||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName)
|
||||
nsFontMetricsWinA::LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName)
|
||||
{
|
||||
for (int i = mLoadedFonts.Count()-1; i >= 0; --i) {
|
||||
|
||||
if (aName.EqualsIgnoreCase(((nsFontWin*)mLoadedFonts[i])->mName))
|
||||
if (aName->Equals(NS_ConvertASCIItoUCS2(((nsFontWin*)mLoadedFonts[i])->mName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
return nsnull;
|
||||
|
||||
}
|
||||
|
@ -4874,7 +4877,7 @@ nsFontMetricsWinA::FindSubstituteFont(HDC aDC, PRUint32 aChar)
|
|||
// make a substitute font from this one
|
||||
nsAutoString name;
|
||||
name.AssignWithConversion(font->mName);
|
||||
nsFontWinSubstituteA* substituteFont = (nsFontWinSubstituteA*)LoadSubstituteFont(aDC, name);
|
||||
nsFontWinSubstituteA* substituteFont = (nsFontWinSubstituteA*)LoadSubstituteFont(aDC, &name);
|
||||
if (substituteFont) {
|
||||
nsFontSubset* substituteSubset = substituteFont->mSubsets[0];
|
||||
substituteSubset->mCharset = subset->mCharset;
|
||||
|
@ -4916,7 +4919,7 @@ nsFontMetricsWinA::FindSubstituteFont(HDC aDC, PRUint32 aChar)
|
|||
delete font;
|
||||
if (charset != DEFAULT_CHARSET) {
|
||||
// make a substitute font now
|
||||
nsFontWinSubstituteA* substituteFont = (nsFontWinSubstituteA*)LoadSubstituteFont(aDC, globalFont->name);
|
||||
nsFontWinSubstituteA* substituteFont = (nsFontWinSubstituteA*)LoadSubstituteFont(aDC, &globalFont->name);
|
||||
if (substituteFont) {
|
||||
nsFontSubset* substituteSubset = substituteFont->mSubsets[0];
|
||||
substituteSubset->mCharset = charset;
|
||||
|
@ -4938,7 +4941,7 @@ nsFontMetricsWinA::FindSubstituteFont(HDC aDC, PRUint32 aChar)
|
|||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadSubstituteFont(HDC aDC, const nsString& aName)
|
||||
nsFontMetricsWinA::LoadSubstituteFont(HDC aDC, nsString* aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = CreateFontHandle(aDC, aName, &logFont);
|
||||
|
|
|
@ -227,10 +227,10 @@ public:
|
|||
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUint32 aChar);
|
||||
virtual nsFontWin* FindSubstituteFont(HDC aDC, PRUint32 aChar);
|
||||
|
||||
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
|
||||
virtual nsFontWin* LoadFont(HDC aDC, nsString* aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName);
|
||||
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, nsString* aName);
|
||||
|
||||
virtual nsFontWin* GetFontFor(HFONT aHFONT);
|
||||
|
||||
|
@ -266,7 +266,7 @@ public:
|
|||
static int SameAsPreviousMap(int aIndex);
|
||||
|
||||
// These functions create possibly adjusted fonts
|
||||
HFONT CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLogFont);
|
||||
HFONT CreateFontHandle(HDC aDC, nsString* aName, LOGFONT* aLogFont);
|
||||
HFONT CreateFontHandle(HDC aDC, nsGlobalFont* aGlobalFont, LOGFONT* aLogFont);
|
||||
HFONT CreateFontAdjustHandle(HDC aDC, LOGFONT* aLogFont);
|
||||
void InitMetricsFor(HDC aDC, nsFontWin* aFontWin);
|
||||
|
@ -287,12 +287,12 @@ protected:
|
|||
// what font weight to pass in the LOGFONT structure.
|
||||
|
||||
// Utility methods for managing font weights.
|
||||
PRUint16 LookForFontWeightTable(HDC aDc, const nsString& aName);
|
||||
PRUint16 LookForFontWeightTable(HDC aDc, nsString* aName);
|
||||
PRInt32 GetBolderWeight(PRInt32 aWeight, PRInt32 aDistance, PRUint16 aWeightTable);
|
||||
PRInt32 GetLighterWeight(PRInt32 aWeight, PRInt32 aDistance, PRUint16 aWeightTable);
|
||||
PRInt32 GetFontWeight(PRInt32 aWeight, PRUint16 aWeightTable);
|
||||
PRInt32 GetClosestWeight(PRInt32 aWeight, PRUint16 aWeightTable);
|
||||
PRUint16 GetFontWeightTable(HDC aDC, const nsString& aFontName);
|
||||
PRUint16 GetFontWeightTable(HDC aDC, nsString* aFontName);
|
||||
nsFontWin* LocateFont(HDC aDC, PRUint32 aChar, PRInt32 & aCount);
|
||||
|
||||
nsresult RealizeFont();
|
||||
|
@ -388,13 +388,13 @@ class nsFontMetricsWinA : public nsFontMetricsWin
|
|||
{
|
||||
public:
|
||||
virtual nsFontWin* FindLocalFont(HDC aDC, PRUint32 aChar);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName);
|
||||
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUint32 aChar);
|
||||
virtual nsFontWin* FindSubstituteFont(HDC aDC, PRUint32 aChar);
|
||||
|
||||
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadFont(HDC aDC, nsString* aName);
|
||||
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, nsString* aName);
|
||||
|
||||
virtual nsFontWin* GetFontFor(HFONT aHFONT);
|
||||
|
||||
|
|
|
@ -853,9 +853,9 @@ PRBool CopyFontCharSetMapXlib(nsFontMetricsXlibContext *aFmctx)
|
|||
static char*
|
||||
atomToName(nsIAtom* aAtom)
|
||||
{
|
||||
const char *namePRU;
|
||||
aAtom->GetUTF8String(&namePRU);
|
||||
return ToNewCString(nsDependentCString(namePRU));
|
||||
const PRUnichar *namePRU;
|
||||
aAtom->GetUnicode(&namePRU);
|
||||
return ToNewUTF8String(nsDependentString(namePRU));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1740,9 +1740,9 @@ NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
name.Append("variable");
|
||||
}
|
||||
name.Append(char('.'));
|
||||
const char* langGroup = nsnull;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
name.Append(langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
name.AppendWithConversion(langGroup);
|
||||
PRInt32 minimum = 0;
|
||||
res = mFontMetricsContext->mPref->GetIntPref(name.get(), &minimum);
|
||||
if (NS_FAILED(res)) {
|
||||
|
@ -5427,9 +5427,9 @@ nsFontMetricsXlib::FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUnichar aChar)
|
|||
// check user set pref
|
||||
nsCAutoString pref = prefix;
|
||||
pref.Append(char('.'));
|
||||
const char* langGroup = nsnull;
|
||||
aLangGroup->GetUTF8String(&langGroup);
|
||||
pref.Append(langGroup);
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
aLangGroup->GetUnicode(&langGroup);
|
||||
pref.AppendWithConversion(langGroup);
|
||||
nsXPIDLCString value;
|
||||
mFontMetricsContext->mPref->CopyCharPref(pref.get(), getter_Copies(value));
|
||||
nsCAutoString str;
|
||||
|
|
|
@ -44,10 +44,11 @@ NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
|||
NS_IMETHODIMP
|
||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
|
||||
*aId = nsHTMLTags::LookupTag(tagName);
|
||||
*aId = nsHTMLTags::LookupTag(nsDependentString(tagName));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -56,10 +57,11 @@ NS_IMETHODIMP
|
|||
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
||||
PRInt32* aId) const
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -382,10 +382,10 @@ nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
|||
//
|
||||
// return the preferred string
|
||||
//
|
||||
const char *prefName;
|
||||
res = charsetAtom->GetUTF8String(&prefName);
|
||||
const PRUnichar *prefName;
|
||||
res = charsetAtom->GetUnicode(&prefName);
|
||||
if (NS_SUCCEEDED(res))
|
||||
aCharset.AssignWithConversion(prefName);
|
||||
aCharset.Assign(prefName);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "failed to get preferred charset name, using non-preferred");
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ nsresult nsTestUConv::TestCharsetManager()
|
|||
char * trace = "TestCharsetManager";
|
||||
mLog.AddTrace(trace);
|
||||
nsresult res = NS_OK;
|
||||
nsAutoString name;
|
||||
const PRUnichar * name;
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager2> ccMan =
|
||||
|
@ -263,12 +263,12 @@ nsresult nsTestUConv::TestCharsetManager()
|
|||
mLog.PrintError("GetCharsetAtom()", res);
|
||||
return res;
|
||||
}
|
||||
res = csAtom->ToString(name);
|
||||
res = csAtom->GetUnicode(&name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
}
|
||||
if (!csName.Equals(name)) {
|
||||
if (!csName.Equals(nsDependentString(name))) {
|
||||
mLog.PrintError("Equals()", "unexpected charset name");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -280,12 +280,12 @@ nsresult nsTestUConv::TestCharsetManager()
|
|||
mLog.PrintError("GetCharsetAtom()", res);
|
||||
return res;
|
||||
}
|
||||
res = csAtom->ToString(name);
|
||||
res = csAtom->GetUnicode(&name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
}
|
||||
if (!csAlias2.Equals(name)) {
|
||||
if (!csAlias2.Equals(nsDependentString(name))) {
|
||||
mLog.PrintError("Equals()", "unexpected charset name");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -335,8 +335,8 @@ nsresult nsTestUConv::DisplayDetectors()
|
|||
return res;
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
res = cs->ToString(name);
|
||||
const PRUnichar * name;
|
||||
res = cs->GetUnicode(&name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
|
@ -410,8 +410,8 @@ nsresult nsTestUConv::DisplayCharsets()
|
|||
return res;
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
res = cs->ToString(name);
|
||||
const PRUnichar * name;
|
||||
res = cs->GetUnicode(&name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
|
|
|
@ -2250,16 +2250,6 @@ static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
|
|||
aKey.Append(NS_ConvertUCS2toUTF8(aString));
|
||||
}
|
||||
|
||||
static inline void KeyAppendString(const nsACString& aString, nsACString& aKey)
|
||||
{
|
||||
KeyAppendSep(aKey);
|
||||
|
||||
// Could escape separator here if collisions happen. > is not a legal char
|
||||
// for a name or type attribute, so we should be safe avoiding that extra work.
|
||||
|
||||
aKey.Append(aString);
|
||||
}
|
||||
|
||||
static inline void KeyAppendInt(PRInt32 aInt, nsACString& aKey)
|
||||
{
|
||||
KeyAppendSep(aKey);
|
||||
|
@ -2271,10 +2261,10 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
|
|||
{
|
||||
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
|
||||
|
||||
const char* atomString = nsnull;
|
||||
aAtom->GetUTF8String(&atomString);
|
||||
const PRUnichar* atomString = nsnull;
|
||||
aAtom->GetUnicode(&atomString);
|
||||
|
||||
KeyAppendString(nsDependentCString(atomString), aKey);
|
||||
KeyAppendString(nsDependentString(atomString), aKey);
|
||||
}
|
||||
|
||||
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
|
||||
|
|
|
@ -2250,16 +2250,6 @@ static inline void KeyAppendString(const nsAString& aString, nsACString& aKey)
|
|||
aKey.Append(NS_ConvertUCS2toUTF8(aString));
|
||||
}
|
||||
|
||||
static inline void KeyAppendString(const nsACString& aString, nsACString& aKey)
|
||||
{
|
||||
KeyAppendSep(aKey);
|
||||
|
||||
// Could escape separator here if collisions happen. > is not a legal char
|
||||
// for a name or type attribute, so we should be safe avoiding that extra work.
|
||||
|
||||
aKey.Append(aString);
|
||||
}
|
||||
|
||||
static inline void KeyAppendInt(PRInt32 aInt, nsACString& aKey)
|
||||
{
|
||||
KeyAppendSep(aKey);
|
||||
|
@ -2271,10 +2261,10 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
|
|||
{
|
||||
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
|
||||
|
||||
const char* atomString = nsnull;
|
||||
aAtom->GetUTF8String(&atomString);
|
||||
const PRUnichar* atomString = nsnull;
|
||||
aAtom->GetUnicode(&atomString);
|
||||
|
||||
KeyAppendString(nsDependentCString(atomString), aKey);
|
||||
KeyAppendString(nsDependentString(atomString), aKey);
|
||||
}
|
||||
|
||||
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
|
||||
|
|
|
@ -615,6 +615,9 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext,
|
|||
if (attrValue.IsEmpty())
|
||||
continue;
|
||||
|
||||
const PRUnichar* attrName;
|
||||
attrAtom->GetUnicode(&attrName);
|
||||
|
||||
// don't add rules that are already in mathml.css
|
||||
// (this will also clean up whitespace before units - see bug 125303)
|
||||
if (attrAtom == nsMathMLAtoms::fontsize_ || attrAtom == nsMathMLAtoms::mathsize_) {
|
||||
|
@ -629,12 +632,9 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext,
|
|||
else
|
||||
cssProperty.Append(attrValue);
|
||||
|
||||
nsAutoString attrName;
|
||||
attrAtom->ToString(attrName);
|
||||
|
||||
// make a style rule that maps to the equivalent CSS property
|
||||
nsAutoString cssRule;
|
||||
cssRule.Assign(NS_LITERAL_STRING("[") + attrName +
|
||||
cssRule.Assign(NS_LITERAL_STRING("[") + nsDependentString(attrName) +
|
||||
NS_LITERAL_STRING("='") + attrValue +
|
||||
NS_LITERAL_STRING("']{") + cssProperty + NS_LITERAL_STRING("}"));
|
||||
|
||||
|
@ -662,7 +662,7 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext,
|
|||
// XXX bug 142648 - GetSourceSelectorText is in the format *[color=blue] (i.e., no quotes...)
|
||||
// XXXrbs need to keep this in sync with the fix for bug 142648
|
||||
nsAutoString selector;
|
||||
selector.Assign(NS_LITERAL_STRING("*[") + attrName +
|
||||
selector.Assign(NS_LITERAL_STRING("*[") + nsDependentString(attrName) +
|
||||
NS_LITERAL_STRING("=") + attrValue +
|
||||
NS_LITERAL_STRING("]"));
|
||||
PRInt32 k, count;
|
||||
|
|
|
@ -1569,10 +1569,9 @@ static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
|||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
const char* str;
|
||||
aPseudo->GetUTF8String(&str);
|
||||
static const char moz_tree[] = ":moz-tree-";
|
||||
return nsCRT::strncmp(str, moz_tree, PRInt32(sizeof(moz_tree)-1)) == 0;
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return Substring(str, 0, 11).Equals(NS_LITERAL_STRING(":-moz-tree-"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -584,8 +584,8 @@ PRInt32 nsCSSSelector::CalcWeight(void) const
|
|||
static PRBool IsPseudoElement(nsIAtom* aAtom)
|
||||
{
|
||||
if (aAtom) {
|
||||
const char* str;
|
||||
aAtom->GetUTF8String(&str);
|
||||
const PRUnichar *str;
|
||||
aAtom->GetUnicode(&str);
|
||||
return str && (*str == ':');
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ void nsCSSSelector::AppendNegationToString(nsAString& aString)
|
|||
nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet, PRBool aIsPseudoElem,
|
||||
PRInt8 aNegatedIndex) const
|
||||
{
|
||||
nsAutoString temp;
|
||||
const PRUnichar* temp;
|
||||
PRBool aIsNegated = PRBool(0 < aNegatedIndex);
|
||||
|
||||
// selectors are linked from right-to-left, so the next selector in the linked list
|
||||
|
@ -631,8 +631,8 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
// will return null if namespace was the default
|
||||
sheetNS->FindNameSpacePrefix(mNameSpace, *getter_AddRefs(prefixAtom));
|
||||
if (prefixAtom) {
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
|
@ -648,16 +648,15 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
mTag->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
NS_IF_NEGATED_END(aIsNegated, aString)
|
||||
}
|
||||
// Append the id, if there is one
|
||||
if (mIDList) {
|
||||
nsAtomList* list = mIDList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('#'));
|
||||
aString.Append(temp);
|
||||
|
@ -669,7 +668,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
if (mClassList) {
|
||||
nsAtomList* list = mClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('.'));
|
||||
aString.Append(temp);
|
||||
|
@ -693,14 +692,14 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
// will return null if namespace was the default
|
||||
sheetNS->FindNameSpacePrefix(list->mNameSpace, *getter_AddRefs(prefixAtom));
|
||||
if (prefixAtom) {
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
}
|
||||
// Append the attribute name
|
||||
list->mAttr->ToString(temp);
|
||||
list->mAttr->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
// Append the function
|
||||
if (list->mFunction == NS_ATTR_FUNC_EQUALS) {
|
||||
|
@ -733,7 +732,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
|||
if (mPseudoClassList) {
|
||||
nsAtomStringList* list = mPseudoClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->ToString(temp);
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(temp);
|
||||
if (nsnull != list->mString) {
|
||||
|
|
|
@ -168,11 +168,12 @@ RuleHash_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|||
if (match_atom == entry_atom)
|
||||
return PR_TRUE;
|
||||
|
||||
const char *match_str, *entry_str;
|
||||
match_atom->GetUTF8String(&match_str);
|
||||
entry_atom->GetUTF8String(&entry_str);
|
||||
const PRUnichar *match_str, *entry_str;
|
||||
match_atom->GetUnicode(&match_str);
|
||||
entry_atom->GetUnicode(&entry_str);
|
||||
|
||||
return (nsCRT::strcasecmp(entry_str, match_str) == 0);
|
||||
return nsDependentString(match_str).Equals(nsDependentString(entry_str),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
|
@ -1115,8 +1116,8 @@ DOMMediaListImpl::GetText(nsAString& aMediaText)
|
|||
QueryElementAt(index++, NS_GET_IID(nsIAtom), getter_AddRefs(medium));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
aMediaText.Append(buffer);
|
||||
if (index < count) {
|
||||
aMediaText.Append(NS_LITERAL_STRING(", "));
|
||||
|
@ -1233,8 +1234,8 @@ DOMMediaListImpl::Item(PRUint32 aIndex, nsAString& aReturn)
|
|||
nsCOMPtr<nsIAtom> medium(do_QueryInterface(tmp));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
aReturn.Assign(buffer);
|
||||
} else {
|
||||
aReturn.Truncate();
|
||||
|
@ -3741,15 +3742,15 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
IDList = IDList->mNext;
|
||||
} while (IDList);
|
||||
} else {
|
||||
const char* id1Str;
|
||||
data.mContentID->GetUTF8String(&id1Str);
|
||||
nsDependentCString id1(id1Str);
|
||||
const PRUnichar* id1Str;
|
||||
data.mContentID->GetUnicode(&id1Str);
|
||||
nsDependentString id1(id1Str);
|
||||
do {
|
||||
const char* id2Str;
|
||||
IDList->mAtom->GetUTF8String(&id2Str);
|
||||
nsDependentCString id2(id2Str);
|
||||
const PRUnichar* id2Str;
|
||||
IDList->mAtom->GetUnicode(&id2Str);
|
||||
nsDependentString id2(id2Str);
|
||||
if (localTrue !=
|
||||
id1.Equals(id2, nsCaseInsensitiveCStringComparator())) {
|
||||
id1.Equals(id2, nsCaseInsensitiveStringComparator())) {
|
||||
result = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ var folderListener = {
|
|||
|
||||
//if we don't have a folder loaded, don't bother.
|
||||
if (currentURI) {
|
||||
if (property.toString() == "TotalMessages" || property.toString() == "TotalUnreadMessages") {
|
||||
if (property.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages") {
|
||||
var folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if (folder) {
|
||||
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -83,7 +83,7 @@ var folderListener = {
|
|||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.toString();
|
||||
var eventType = event.GetUnicode();
|
||||
|
||||
if (eventType == "DeleteOrMoveMsgCompleted")
|
||||
HandleDeleteOrMoveMsgCompleted(folder);
|
||||
|
|
|
@ -105,7 +105,7 @@ var folderListener = {
|
|||
|
||||
//if we don't have a folder loaded, don't bother.
|
||||
if(currentURI) {
|
||||
if(property.toString() == "TotalMessages" || property.toString() == "TotalUnreadMessages") {
|
||||
if(property.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages") {
|
||||
var folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(folder) {
|
||||
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -126,7 +126,7 @@ var folderListener = {
|
|||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) { },
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.toString();
|
||||
var eventType = event.GetUnicode();
|
||||
if (eventType == "FolderLoaded") {
|
||||
if (folder) {
|
||||
var uri = folder.URI;
|
||||
|
|
|
@ -201,7 +201,7 @@ var gFolderListener = {
|
|||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.toString();
|
||||
var eventType = event.GetUnicode();
|
||||
|
||||
if (eventType == "FolderCreateCompleted") {
|
||||
SetFolderPicker(folder.URI, gActionTargetElement.id);
|
||||
|
|
|
@ -193,8 +193,8 @@ var gFolderListener = {
|
|||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.toString();
|
||||
|
||||
var eventType = event.GetUnicode();
|
||||
|
||||
if (eventType == "DeleteOrMoveMsgCompleted") {
|
||||
HandleDeleteOrMoveMessageCompleted(folder);
|
||||
}
|
||||
|
|
|
@ -607,8 +607,8 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
res = ccm2->GetCharsetAtom(NS_ConvertASCIItoUCS2(charset).get(), getter_AddRefs(charsetAtom));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
const char *charsetName;
|
||||
res = charsetAtom->GetUTF8String(&charsetName);
|
||||
const PRUnichar *charsetName;
|
||||
res = charsetAtom->GetUnicode(&charsetName);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// charset converter plus entity, NCR generation
|
||||
|
@ -620,14 +620,14 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
// plain text - charset conv then fallback to '?'
|
||||
if (bTEXT_HTML)
|
||||
// For ISO-8859-1 only, convert to entity first (always generate entites like ).
|
||||
res = conv->Init(charsetName,
|
||||
!nsCRT::strcmp(charsetName, "ISO-8859-1") ?
|
||||
res = conv->Init(NS_ConvertUCS2toUTF8(charsetName).get(),
|
||||
!nsCRT::strcmp(charsetName, NS_LITERAL_STRING("ISO-8859-1").get()) ?
|
||||
nsISaveAsCharset::attr_htmlTextDefault :
|
||||
nsISaveAsCharset::attr_EntityAfterCharsetConv + nsISaveAsCharset::attr_FallbackDecimalNCR,
|
||||
nsIEntityConverter::html32);
|
||||
else
|
||||
// fallback for text/plain: first try transliterate then '?'
|
||||
res = conv->Init(charsetName,
|
||||
res = conv->Init(NS_ConvertUCS2toUTF8(charsetName).get(),
|
||||
nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_EntityAfterCharsetConv,
|
||||
nsIEntityConverter::transliterate);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -636,7 +636,7 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
|
||||
// Mapping characters in a certain range (required for Japanese only)
|
||||
nsAutoString mapped;
|
||||
if (!nsCRT::strcmp(charsetName, "ISO-2022-JP")) {
|
||||
if (!nsCRT::strcmp(charsetName, NS_LITERAL_STRING("ISO-2022-JP").get())) {
|
||||
static PRInt32 sSendHankakuKana = -1;
|
||||
if (sSendHankakuKana < 0) {
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
|
||||
|
@ -697,7 +697,7 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
// In case of HTML, non ASCII may be encoded as CER, NCR.
|
||||
// Exclude stateful charset which is 7 bit but not ASCII only.
|
||||
else if (isAsciiOnly && bTEXT_HTML && *outString &&
|
||||
!nsMsgI18Nstateful_charset(charsetName))
|
||||
!nsMsgI18Nstateful_charset(NS_LossyConvertUCS2toASCII(charsetName).get()))
|
||||
*isAsciiOnly = nsCRT::IsAscii(*outString);
|
||||
|
||||
return res;
|
||||
|
|
|
@ -1439,7 +1439,7 @@ function UpdateMailEditCharset()
|
|||
|
||||
if (gCharsetConvertManager) {
|
||||
var charsetAtom = gCharsetConvertManager.GetCharsetAtom(compFieldsCharset);
|
||||
if (charsetAtom && (charsetAtom.equals("us-ascii")))
|
||||
if (charsetAtom && (charsetAtom.GetUnicode() == "us-ascii"))
|
||||
compFieldsCharset = "ISO-8859-1"; // no menu item for "us-ascii"
|
||||
}
|
||||
|
||||
|
|
|
@ -308,9 +308,9 @@ PRInt32 generate_encodedwords(char *pUTF8, const char *charset, char method, cha
|
|||
nsMemory::Free(_pUCS2);
|
||||
return -1;
|
||||
}
|
||||
const char *charsetName;
|
||||
charsetAtom->GetUTF8String(&charsetName);
|
||||
strncpy(_charset, charsetName, sizeof(_charset)-1);
|
||||
const PRUnichar *charsetName;
|
||||
charsetAtom->GetUnicode(&charsetName);
|
||||
strncpy(_charset, NS_ConvertUCS2toUTF8(charsetName).get(), sizeof(_charset)-1);
|
||||
_charset[sizeof(_charset)-1] = '\0';
|
||||
if (_charset[0])
|
||||
charset = _charset;
|
||||
|
|
|
@ -2062,6 +2062,7 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixel
|
|||
nsCOMPtr<nsICharsetConverterManager2> charSetConverterManager2;
|
||||
nsCOMPtr <nsIAtom> charsetAtom;
|
||||
nsCOMPtr<nsIAtom> langGroupAtom;
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
nsCAutoString prefStr;
|
||||
|
||||
ToLowerCase(charset);
|
||||
|
@ -2077,13 +2078,15 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixel
|
|||
rv = charSetConverterManager2->GetCharsetLangGroup(charsetAtom,getter_AddRefs(langGroupAtom));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = langGroupAtom->ToUTF8String(fontLang);
|
||||
rv = langGroupAtom->GetUnicode(&langGroup);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
fontLang.AssignWithConversion(langGroup);
|
||||
|
||||
// get a font size from pref
|
||||
prefStr.Assign(!styleFixed ? "font.size.variable." : "font.size.fixed.");
|
||||
prefStr.Append(fontLang);
|
||||
prefStr.AppendWithConversion(langGroup);
|
||||
rv = prefs->GetIntPref(prefStr.get(), fontPixelSize);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
|
|
@ -44,10 +44,11 @@ NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
|||
NS_IMETHODIMP
|
||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
|
||||
*aId = nsHTMLTags::LookupTag(tagName);
|
||||
*aId = nsHTMLTags::LookupTag(nsDependentString(tagName));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -56,10 +57,11 @@ NS_IMETHODIMP
|
|||
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
||||
PRInt32* aId) const
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1105,17 +1105,17 @@ RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes,
|
|||
nsAutoString v(aAttributes[1]);
|
||||
nsRDFParserUtils::StripAndConvert(v);
|
||||
|
||||
const char* attrName;
|
||||
attr->GetUTF8String(&attrName);
|
||||
const PRUnichar* attrName;
|
||||
attr->GetUnicode(&attrName);
|
||||
|
||||
nsCAutoString propertyStr;
|
||||
|
||||
if (nameSpaceURI) {
|
||||
propertyStr.Assign(nsDependentCString(nameSpaceURI) +
|
||||
nsDependentCString(attrName));
|
||||
NS_ConvertUCS2toUTF8(attrName));
|
||||
}
|
||||
else {
|
||||
propertyStr.Assign(attrName);
|
||||
propertyStr.Assign(NS_ConvertUCS2toUTF8(attrName));
|
||||
}
|
||||
|
||||
// Add the assertion to RDF
|
||||
|
@ -1256,10 +1256,10 @@ RDFContentSinkImpl::OpenObject(const PRUnichar* aName,
|
|||
if (nameSpaceURI)
|
||||
typeStr = nameSpaceURI;
|
||||
|
||||
const char* attrName;
|
||||
tag->GetUTF8String(&attrName);
|
||||
const PRUnichar *attrName;
|
||||
tag->GetUnicode(&attrName);
|
||||
|
||||
typeStr += attrName;
|
||||
typeStr += NS_ConvertUCS2toUTF8(attrName);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> type;
|
||||
rv = gRDFService->GetResource(typeStr, getter_AddRefs(type));
|
||||
|
@ -1288,16 +1288,16 @@ RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttr
|
|||
ParseTagString(aName, &nameSpaceURI, getter_AddRefs(tag));
|
||||
|
||||
|
||||
const char* attrName;
|
||||
tag->GetUTF8String(&attrName);
|
||||
const PRUnichar *attrName;
|
||||
tag->GetUnicode(&attrName);
|
||||
|
||||
nsCAutoString propertyStr;
|
||||
if (nameSpaceURI) {
|
||||
propertyStr.Assign(nsDependentCString(nameSpaceURI) +
|
||||
nsDependentCString(attrName));
|
||||
NS_ConvertUCS2toUTF8(attrName));
|
||||
}
|
||||
else {
|
||||
propertyStr.Assign(attrName);
|
||||
propertyStr.Assign(NS_ConvertUCS2toUTF8(attrName));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
|
@ -1467,14 +1467,17 @@ RDFContentSinkImpl::GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI
|
|||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) {
|
||||
const char* prefixStr;
|
||||
nsAutoString prefixStr;
|
||||
if (aPrefix)
|
||||
aPrefix->GetUTF8String(&prefixStr);
|
||||
aPrefix->ToString(prefixStr);
|
||||
|
||||
char* prefixCStr = ToNewCString(prefixStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml: undeclared namespace prefix '%s'",
|
||||
prefixStr));
|
||||
prefixCStr));
|
||||
|
||||
nsCRT::free(prefixCStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -229,12 +229,12 @@ STDMETHODIMP SimpleDOMNode::get_attributes(
|
|||
for (index = 0; index < numAttribs; index++) {
|
||||
aNameSpaceIDs[index] = 0; aAttribValues[index] = aAttribNames[index] = nsnull;
|
||||
nsAutoString attributeValue;
|
||||
const char *pszAttributeName;
|
||||
const PRUnichar *pszAttributeName;
|
||||
|
||||
if (NS_SUCCEEDED(content->GetAttrNameAt(index, nameSpaceID, *getter_AddRefs(nameAtom), *getter_AddRefs(prefixAtom)))) {
|
||||
aNameSpaceIDs[index] = NS_STATIC_CAST(short, nameSpaceID);
|
||||
nameAtom->GetUTF8String(&pszAttributeName);
|
||||
aAttribNames[index] = ::SysAllocString(NS_ConvertUTF8toUCS2(pszAttributeName).get());
|
||||
nameAtom->GetUnicode(&pszAttributeName);
|
||||
aAttribNames[index] = ::SysAllocString(pszAttributeName);
|
||||
if (NS_SUCCEEDED(content->GetAttr(nameSpaceID, nameAtom, attributeValue)))
|
||||
aAttribValues[index] = ::SysAllocString(attributeValue.get());
|
||||
}
|
||||
|
|
|
@ -37,18 +37,10 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAtomTable.h"
|
||||
#include "nsStaticAtom.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "pldhash.h"
|
||||
#include "prenv.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#define PL_ARENA_CONST_ALIGN_MASK 3
|
||||
#include "plarena.h"
|
||||
|
||||
class nsStaticAtomWrapper;
|
||||
|
||||
/**
|
||||
* The shared hash table for atom lookups.
|
||||
|
@ -61,117 +53,29 @@ class nsStaticAtomWrapper;
|
|||
*/
|
||||
static PLDHashTable gAtomTable;
|
||||
|
||||
// this is where we keep the nsStaticAtomWrapper objects
|
||||
|
||||
static PLArenaPool* gStaticAtomArena = 0;
|
||||
|
||||
class nsStaticAtomWrapper : public nsIAtom
|
||||
{
|
||||
public:
|
||||
nsStaticAtomWrapper(const nsStaticAtom* aAtom) :
|
||||
mStaticAtom(aAtom)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStaticAtomWrapper);
|
||||
}
|
||||
virtual ~nsStaticAtomWrapper() {
|
||||
// this is arena allocated and won't be called except in debug
|
||||
// builds. If this function ever does anything non-debug, be sure
|
||||
// to get rid of the ifdefs in AtomTableClearEntry!
|
||||
MOZ_COUNT_DTOR(nsStaticAtomWrapper);
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
NS_DECL_NSIATOM
|
||||
|
||||
const nsStaticAtom* GetStaticAtom() {
|
||||
return mStaticAtom;
|
||||
}
|
||||
private:
|
||||
const nsStaticAtom* mStaticAtom;
|
||||
};
|
||||
|
||||
// the atomtableentry can contain either an AtomImpl or a
|
||||
// nsStaticAtomWrapper, indicated by the first bit of PtrBits
|
||||
typedef unsigned long PtrBits;
|
||||
|
||||
struct AtomTableEntry : public PLDHashEntryHdr {
|
||||
// mAtom & 0x1 means (mAtom & ~0x1) points to an nsStaticAtomWrapper
|
||||
// else it points to an nsAtomImpl
|
||||
PtrBits mAtom;
|
||||
|
||||
inline PRBool IsStaticAtom() const {
|
||||
return (mAtom & 0x1) != 0;
|
||||
}
|
||||
|
||||
inline void SetAtomImpl(AtomImpl* aAtom) {
|
||||
NS_ASSERTION(aAtom, "Setting null atom");
|
||||
mAtom = PtrBits(aAtom);
|
||||
}
|
||||
|
||||
inline void SetStaticAtomWrapper(nsStaticAtomWrapper* aAtom) {
|
||||
NS_ASSERTION(aAtom, "Setting null atom");
|
||||
NS_ASSERTION((PtrBits(aAtom) & ~0x1) == PtrBits(aAtom),
|
||||
"Pointers must align or this is broken");
|
||||
|
||||
mAtom = PtrBits(aAtom) | 0x1;
|
||||
}
|
||||
|
||||
inline void ClearAtom() {
|
||||
mAtom = nsnull;
|
||||
}
|
||||
|
||||
inline PRBool HasValue() const {
|
||||
return (mAtom & ~0x1) != 0;
|
||||
}
|
||||
|
||||
// these accessors assume that you already know the type
|
||||
inline AtomImpl *GetAtomImpl() const {
|
||||
NS_ASSERTION(!IsStaticAtom(), "This is a static atom, not an AtomImpl");
|
||||
return (AtomImpl*) (mAtom & ~0x1);
|
||||
}
|
||||
|
||||
inline nsStaticAtomWrapper *GetStaticAtomWrapper() const {
|
||||
NS_ASSERTION(IsStaticAtom(), "This is an AtomImpl, not a static atom");
|
||||
return (nsStaticAtomWrapper*) (mAtom & ~0x1);
|
||||
}
|
||||
|
||||
inline const nsStaticAtom* GetStaticAtom() const {
|
||||
return GetStaticAtomWrapper()->GetStaticAtom();
|
||||
}
|
||||
|
||||
// type-agnostic accessors
|
||||
|
||||
// get the string buffer
|
||||
inline const char* get() const {
|
||||
return IsStaticAtom() ? GetStaticAtom()->mString : GetAtomImpl()->mString;
|
||||
}
|
||||
|
||||
// get an addreffed nsIAtom - not using already_AddRef'ed atom
|
||||
// because the callers are not (and should not be) using nsCOMPtr
|
||||
inline nsIAtom* GetAtom() const {
|
||||
nsIAtom* result;
|
||||
|
||||
if (IsStaticAtom())
|
||||
result = GetStaticAtomWrapper();
|
||||
else {
|
||||
result = GetAtomImpl();
|
||||
NS_ADDREF(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
AtomImpl *mAtom;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(const void *)
|
||||
AtomTableGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
AtomTableEntry *he = NS_STATIC_CAST(AtomTableEntry*, entry);
|
||||
NS_ASSERTION(he->HasValue(), "Empty atom. how did that happen?");
|
||||
return he->get();
|
||||
return he->mAtom->mString;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashNumber)
|
||||
AtomTableHashKey(PLDHashTable *table, const void *key)
|
||||
{
|
||||
const PRUnichar *str = NS_STATIC_CAST(const PRUnichar*, key);
|
||||
|
||||
if (!str) {
|
||||
static const PRUnichar empty_buffer[] = {0};
|
||||
|
||||
str = empty_buffer;
|
||||
}
|
||||
|
||||
return nsCRT::HashCode(str);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
|
@ -180,43 +84,33 @@ AtomTableMatchKey(PLDHashTable *table,
|
|||
const void *key)
|
||||
{
|
||||
const AtomTableEntry *he = NS_STATIC_CAST(const AtomTableEntry*, entry);
|
||||
const char* keyStr = NS_STATIC_CAST(const char*, key);
|
||||
return nsCRT::strcmp(keyStr, he->get()) == 0;
|
||||
const PRUnichar* keyStr = NS_STATIC_CAST(const PRUnichar*, key);
|
||||
return nsCRT::strcmp(keyStr, he->mAtom->mString) == 0;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
AtomTableClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
AtomTableEntry *he = NS_STATIC_CAST(AtomTableEntry*, entry);
|
||||
|
||||
AtomImpl *atom = he->mAtom;
|
||||
he->mAtom = 0;
|
||||
he->keyHash = 0;
|
||||
|
||||
if (!he->IsStaticAtom()) {
|
||||
AtomImpl *atom = he->GetAtomImpl();
|
||||
// Normal |AtomImpl| atoms are deleted when their refcount hits 0, and
|
||||
// they then remove themselves from the table. In other words, they
|
||||
// are owned by the callers who own references to them.
|
||||
// |PermanentAtomImpl| permanent atoms ignore their refcount and are
|
||||
// deleted when they are removed from the table at table destruction.
|
||||
// In other words, they are owned by the atom table.
|
||||
if (atom->IsPermanent())
|
||||
delete atom;
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
// this is debug-only mostly for bloat logs
|
||||
else {
|
||||
he->GetStaticAtomWrapper()->~nsStaticAtomWrapper();
|
||||
}
|
||||
#endif
|
||||
|
||||
he->ClearAtom();
|
||||
// Normal |AtomImpl| atoms are deleted when their refcount hits 0, and
|
||||
// they then remove themselves from the table. In other words, they
|
||||
// are owned by the callers who own references to them.
|
||||
// |PermanentAtomImpl| permanent atoms ignore their refcount and are
|
||||
// deleted when they are removed from the table at table destruction.
|
||||
// In other words, they are owned by the atom table.
|
||||
if (atom->IsPermanent())
|
||||
delete atom;
|
||||
}
|
||||
|
||||
static PLDHashTableOps AtomTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
AtomTableGetKey,
|
||||
PL_DHashStringKey,
|
||||
AtomTableHashKey,
|
||||
AtomTableMatchKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
AtomTableClearEntry,
|
||||
|
@ -232,16 +126,12 @@ DumpAtomLeaks(PLDHashTable *table, PLDHashEntryHdr *he,
|
|||
PRUint32 index, void *arg)
|
||||
{
|
||||
AtomTableEntry *entry = NS_STATIC_CAST(AtomTableEntry*, he);
|
||||
|
||||
if (entry->IsStaticAtom())
|
||||
return PL_DHASH_NEXT;
|
||||
|
||||
AtomImpl* atom = entry->GetAtomImpl();
|
||||
AtomImpl* atom = entry->mAtom;
|
||||
if (!atom->IsPermanent()) {
|
||||
++*NS_STATIC_CAST(PRUint32*, arg);
|
||||
const char *str;
|
||||
atom->GetUTF8String(&str);
|
||||
fputs(str, stdout);
|
||||
const PRUnichar *str;
|
||||
atom->GetUnicode(&str);
|
||||
fputs(NS_LossyConvertUCS2toASCII(str).get(), stdout);
|
||||
fputs("\n", stdout);
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
|
@ -249,20 +139,6 @@ DumpAtomLeaks(PLDHashTable *table, PLDHashEntryHdr *he,
|
|||
|
||||
#endif
|
||||
|
||||
static inline
|
||||
void PromoteToPermanent(AtomImpl* aAtom)
|
||||
{
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
{
|
||||
nsrefcnt refcount = aAtom->GetRefCount();
|
||||
do {
|
||||
NS_LOG_RELEASE(aAtom, --refcount, "AtomImpl");
|
||||
} while (refcount);
|
||||
}
|
||||
#endif
|
||||
aAtom = new (aAtom) PermanentAtomImpl();
|
||||
}
|
||||
|
||||
void NS_PurgeAtomTable()
|
||||
{
|
||||
if (gAtomTable.entryCount) {
|
||||
|
@ -277,12 +153,6 @@ void NS_PurgeAtomTable()
|
|||
#endif
|
||||
PL_DHashTableFinish(&gAtomTable);
|
||||
gAtomTable.entryCount = 0;
|
||||
|
||||
if (gStaticAtomArena) {
|
||||
PL_FinishArenaPool(gStaticAtomArena);
|
||||
delete gStaticAtomArena;
|
||||
gStaticAtomArena = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +200,7 @@ PermanentAtomImpl::IsPermanent()
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void* AtomImpl::operator new ( size_t size, const nsACString& aString ) CPP_THROW_NEW
|
||||
void* AtomImpl::operator new ( size_t size, const nsAString& aString ) CPP_THROW_NEW
|
||||
{
|
||||
/*
|
||||
Note: since the |size| will initially also include the |PRUnichar| member
|
||||
|
@ -341,12 +211,12 @@ void* AtomImpl::operator new ( size_t size, const nsACString& aString ) CPP_THRO
|
|||
compiler. A more reliable scheme is used by |nsShared[C]String|s, see
|
||||
http://lxr.mozilla.org/seamonkey/source/xpcom/ds/nsSharedString.h#174
|
||||
*/
|
||||
size += aString.Length() * sizeof(char);
|
||||
size += aString.Length() * sizeof(PRUnichar);
|
||||
AtomImpl* ii = NS_STATIC_CAST(AtomImpl*, ::operator new(size));
|
||||
|
||||
char* toBegin = &ii->mString[0];
|
||||
nsACString::const_iterator fromBegin, fromEnd;
|
||||
*copy_string(aString.BeginReading(fromBegin), aString.EndReading(fromEnd), toBegin) = '\0';
|
||||
PRUnichar* toBegin = &ii->mString[0];
|
||||
nsReadingIterator<PRUnichar> fromBegin, fromEnd;
|
||||
*copy_string(aString.BeginReading(fromBegin), aString.EndReading(fromEnd), toBegin) = PRUnichar(0);
|
||||
return ii;
|
||||
}
|
||||
|
||||
|
@ -359,102 +229,25 @@ void* PermanentAtomImpl::operator new ( size_t size, AtomImpl* aAtom ) CPP_THROW
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::ToString(nsAString& aBuf)
|
||||
{
|
||||
aBuf.Assign(NS_ConvertUTF8toUCS2(mString));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::ToUTF8String(nsACString& aBuf)
|
||||
AtomImpl::ToString(nsAString& aBuf) /*FIX: const */
|
||||
{
|
||||
aBuf.Assign(mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::GetUTF8String(const char **aResult)
|
||||
AtomImpl::GetUnicode(const PRUnichar **aResult) /*FIX: const */
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null out param");
|
||||
*aResult = mString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::EqualsUTF8(const nsACString& aString, PRBool* aResult)
|
||||
{
|
||||
*aResult = aString.Equals(mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::Equals(const nsAString& aString, PRBool* aResult)
|
||||
{
|
||||
*aResult = NS_ConvertUCS2toUTF8(aString).Equals(mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// wrapper class for the nsStaticAtom struct
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsStaticAtomWrapper::AddRef()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsStaticAtomWrapper::Release()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsStaticAtomWrapper, nsIAtom)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStaticAtomWrapper::GetUTF8String(const char** aResult)
|
||||
{
|
||||
*aResult = mStaticAtom->mString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStaticAtomWrapper::ToString(nsAString& aBuf)
|
||||
{
|
||||
// static should always be always ASCII, to allow tools like gperf
|
||||
// to generate the tables, and to avoid unnecessary conversion
|
||||
NS_ASSERTION(nsCRT::IsAscii(mStaticAtom->mString),
|
||||
"Data loss - atom should be ASCII");
|
||||
CopyASCIItoUCS2(nsDependentCString(mStaticAtom->mString), aBuf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStaticAtomWrapper::ToUTF8String(nsACString& aBuf)
|
||||
{
|
||||
aBuf.Assign(mStaticAtom->mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStaticAtomWrapper::EqualsUTF8(const nsACString& aString, PRBool* aResult)
|
||||
{
|
||||
*aResult = aString.Equals(mStaticAtom->mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStaticAtomWrapper::Equals(const nsAString& aString, PRBool* aResult)
|
||||
{
|
||||
*aResult = NS_ConvertUCS2toUTF8(aString).Equals(mStaticAtom->mString);
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_COM nsIAtom* NS_NewAtom(const char* isolatin1)
|
||||
{
|
||||
return NS_NewAtom(nsDependentCString(isolatin1));
|
||||
return NS_NewAtom(NS_ConvertASCIItoUCS2(isolatin1));
|
||||
}
|
||||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1)
|
||||
|
@ -462,27 +255,7 @@ NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1)
|
|||
return NS_NewPermanentAtom(NS_ConvertASCIItoUCS2(isolatin1));
|
||||
}
|
||||
|
||||
static nsStaticAtomWrapper*
|
||||
WrapStaticAtom(const nsStaticAtom* aAtom)
|
||||
{
|
||||
if (!gStaticAtomArena) {
|
||||
gStaticAtomArena = new PLArenaPool;
|
||||
if (!gStaticAtomArena)
|
||||
return nsnull;
|
||||
|
||||
PL_INIT_ARENA_POOL(gStaticAtomArena, "nsStaticAtomArena", 4096);
|
||||
}
|
||||
|
||||
void* mem;
|
||||
PL_ARENA_ALLOCATE(mem, gStaticAtomArena, sizeof(nsStaticAtom));
|
||||
|
||||
nsStaticAtomWrapper* wrapper =
|
||||
new (mem) nsStaticAtomWrapper(aAtom);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
static AtomTableEntry* GetAtomHashEntry(const char* aString)
|
||||
static AtomTableEntry* GetAtomHashEntry(const nsAString& aString)
|
||||
{
|
||||
if ( !gAtomTable.entryCount )
|
||||
PL_DHashTableInit(&gAtomTable, &AtomTableOps, 0,
|
||||
|
@ -490,73 +263,22 @@ static AtomTableEntry* GetAtomHashEntry(const char* aString)
|
|||
|
||||
return NS_STATIC_CAST(AtomTableEntry*,
|
||||
PL_DHashTableOperate(&gAtomTable,
|
||||
aString,
|
||||
PromiseFlatString(aString).get(),
|
||||
PL_DHASH_ADD));
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
|
||||
{
|
||||
// this does two things:
|
||||
// 1) wraps each static atom in a wrapper, if necessary
|
||||
// 2) initializes the address pointed to by each mAtom slot
|
||||
|
||||
for (PRUint32 i=0; i<aAtomCount; i++) {
|
||||
NS_ASSERTION(nsCRT::IsAscii(aAtoms[i].mString),
|
||||
"Static atoms must be ASCII!");
|
||||
AtomTableEntry *he =
|
||||
GetAtomHashEntry(aAtoms[i].mString);
|
||||
|
||||
if (he->HasValue() && aAtoms[i].mAtom) {
|
||||
// there already is an atom with this name in the table.. but we
|
||||
// still have to update mAtom
|
||||
if (!he->IsStaticAtom() && !he->GetAtomImpl()->IsPermanent()) {
|
||||
// since we wanted to create a static atom but there is
|
||||
// already one there, we convert it to a non-refcounting
|
||||
// permanent atom
|
||||
PromoteToPermanent(he->GetAtomImpl());
|
||||
}
|
||||
|
||||
// and now, if the consumer wants to remember this value in a
|
||||
// slot, we do so
|
||||
if (aAtoms[i].mAtom)
|
||||
*aAtoms[i].mAtom = he->GetAtom();
|
||||
}
|
||||
|
||||
else {
|
||||
nsStaticAtomWrapper* atom = WrapStaticAtom(&aAtoms[i]);
|
||||
NS_ASSERTION(atom, "Failed to wrap static atom");
|
||||
|
||||
// but even if atom is null, no real difference in code..
|
||||
he->SetStaticAtomWrapper(atom);
|
||||
if (aAtoms[i].mAtom)
|
||||
*aAtoms[i].mAtom = atom;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_COM nsIAtom* NS_NewAtom( const nsAString& aString )
|
||||
{
|
||||
NS_ConvertUCS2toUTF8 utf8String(aString);
|
||||
AtomTableEntry *he = GetAtomHashEntry(aString);
|
||||
AtomImpl* atom = he->mAtom;
|
||||
|
||||
return NS_NewAtom(utf8String);
|
||||
}
|
||||
|
||||
NS_COM
|
||||
nsIAtom*
|
||||
NS_NewAtom( const nsACString& aString )
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(PromiseFlatCString(aString).get());
|
||||
|
||||
if (he->HasValue())
|
||||
return he->GetAtom();
|
||||
|
||||
AtomImpl* atom = new (aString) AtomImpl();
|
||||
he->SetAtomImpl(atom);
|
||||
if (!atom) {
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
atom = new (aString) AtomImpl();
|
||||
he->mAtom = atom;
|
||||
if (!atom) {
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(atom);
|
||||
|
@ -565,30 +287,26 @@ NS_NewAtom( const nsACString& aString )
|
|||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom( const nsAString& aString )
|
||||
{
|
||||
return NS_NewPermanentAtom(NS_ConvertUCS2toUTF8(aString));
|
||||
}
|
||||
AtomTableEntry *he = GetAtomHashEntry(aString);
|
||||
AtomImpl* atom = he->mAtom;
|
||||
|
||||
NS_COM
|
||||
nsIAtom* NS_NewPermanentAtom( const nsACString& aString )
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(PromiseFlatCString(aString).get());
|
||||
|
||||
if (he->HasValue() && he->IsStaticAtom())
|
||||
return he->GetStaticAtomWrapper();
|
||||
|
||||
// either there is no atom and we'll create an AtomImpl,
|
||||
// or there is an existing AtomImpl
|
||||
AtomImpl* atom = he->GetAtomImpl();
|
||||
|
||||
if (atom) {
|
||||
// ensure that it's permanent
|
||||
if (!atom->IsPermanent()) {
|
||||
PromoteToPermanent(atom);
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
{
|
||||
nsrefcnt refcount = atom->GetRefCount();
|
||||
do {
|
||||
NS_LOG_RELEASE(atom, --refcount, "AtomImpl");
|
||||
} while (refcount);
|
||||
}
|
||||
#endif
|
||||
atom = new (atom) PermanentAtomImpl();
|
||||
}
|
||||
} else {
|
||||
// otherwise, make a new atom
|
||||
atom = new (aString) PermanentAtomImpl();
|
||||
he->SetAtomImpl(atom);
|
||||
he->mAtom = atom;
|
||||
if ( !atom ) {
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
|
@ -601,7 +319,7 @@ nsIAtom* NS_NewPermanentAtom( const nsACString& aString )
|
|||
|
||||
NS_COM nsIAtom* NS_NewAtom( const PRUnichar* str )
|
||||
{
|
||||
return NS_NewAtom(NS_ConvertUCS2toUTF8(str));
|
||||
return NS_NewAtom(nsDependentString(str));
|
||||
}
|
||||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom( const PRUnichar* str )
|
||||
|
@ -613,4 +331,3 @@ NS_COM nsrefcnt NS_GetNumberOfAtoms(void)
|
|||
{
|
||||
return gAtomTable.entryCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
virtual PRBool IsPermanent();
|
||||
|
||||
void* operator new(size_t size, const nsACString& aString) CPP_THROW_NEW;
|
||||
void* operator new(size_t size, const nsAString& aString) CPP_THROW_NEW;
|
||||
|
||||
void operator delete(void* ptr) {
|
||||
::operator delete(ptr);
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
// Actually more; 0 terminated. This slot is reserved for the
|
||||
// terminating zero.
|
||||
char mString[1];
|
||||
PRUnichar mString[1];
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
virtual PRBool IsPermanent();
|
||||
|
||||
void* operator new(size_t size, const nsACString& aString) CPP_THROW_NEW {
|
||||
void* operator new(size_t size, const nsAString& aString) CPP_THROW_NEW {
|
||||
return AtomImpl::operator new(size, aString);
|
||||
}
|
||||
void* operator new(size_t size, AtomImpl* aAtom) CPP_THROW_NEW;
|
||||
|
|
|
@ -38,39 +38,14 @@
|
|||
interface nsIAtom : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the Unicode or UTF8 value for the string
|
||||
* Translate the unicode string into the stringbuf.
|
||||
*/
|
||||
AString toString();
|
||||
AUTF8String toUTF8String();
|
||||
|
||||
[noscript] AString toString();
|
||||
|
||||
/**
|
||||
* Return a pointer to a zero terminated UTF8 string.
|
||||
* Return a pointer to a zero terminated unicode string.
|
||||
*/
|
||||
[noscript] void getUTF8String([shared, retval] out string aResult);
|
||||
|
||||
/**
|
||||
* Compare the atom to a specific string value
|
||||
* Note that this will NEVER return/throw an error condition.
|
||||
*/
|
||||
boolean equals(in AString aString);
|
||||
|
||||
boolean equalsUTF8(in AUTF8String aString);
|
||||
|
||||
%{C++
|
||||
// note this is NOT virtual so this won't muck with the vtable!
|
||||
inline PRBool Equals(const nsAString& s) {
|
||||
PRBool result;
|
||||
Equals(s, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline PRBool EqualsUTF8(const nsACString& s) {
|
||||
PRBool result;
|
||||
EqualsUTF8(s, &result);
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
void GetUnicode([shared, retval] out wstring aResult);
|
||||
};
|
||||
|
||||
|
||||
|
@ -96,20 +71,13 @@ interface nsIAtom : nsISupports
|
|||
* Find an atom that matches the given ISO-Latin1 C string. The
|
||||
* C string is translated into its unicode equivalent.
|
||||
*/
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const char* utf8String);
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const nsACString& utf8String);
|
||||
extern NS_COM nsIAtom* NS_NewPermanentAtom(const char* utf8String);
|
||||
extern NS_COM nsIAtom* NS_NewPermanentAtom(const nsACString& utf8String);
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const char* isolatin1);
|
||||
extern NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1);
|
||||
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const char* utf8String)
|
||||
{ return NS_NewAtom(utf8String); }
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const nsACString& utf8String)
|
||||
{ return NS_NewAtom(utf8String); }
|
||||
|
||||
inline already_AddRefed<nsIAtom> do_GetPermanentAtom(const char* utf8String)
|
||||
{ return NS_NewPermanentAtom(utf8String); }
|
||||
inline already_AddRefed<nsIAtom> do_GetPermanentAtom(const nsACString& utf8String)
|
||||
{ return NS_NewPermanentAtom(utf8String); }
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const char* isolatin1)
|
||||
{ return NS_NewAtom(isolatin1); }
|
||||
inline already_AddRefed<nsIAtom> do_GetPermanentAtom(const char* isolatin1)
|
||||
{ return NS_NewPermanentAtom(isolatin1); }
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given unicode string. The string is assumed
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Static Atom classes.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsStaticAtom_h__
|
||||
#define nsStaticAtom_h__
|
||||
|
||||
#include "nsIAtom.h"
|
||||
|
||||
// see http://www.mozilla.org/projects/xpcom/atoms.html to use this stuff
|
||||
|
||||
// class for declaring a static list of atoms, for use with gperf
|
||||
// Keep this VERY simple
|
||||
// mString: the value of the atom - the policy is that this is only
|
||||
// ASCII, in order to avoid unnecessary conversions if
|
||||
// someone asks for this in unicode
|
||||
// mAtom: a convienience pointer - if you want to store the value of
|
||||
// the atom created by this structure somewhere, put its
|
||||
// address here
|
||||
struct nsStaticAtom {
|
||||
const char* mString;
|
||||
nsIAtom ** mAtom;
|
||||
};
|
||||
|
||||
|
||||
// register your lookup function with the atom table. Your function
|
||||
// will be called when at atom is not found in the main atom table.
|
||||
NS_COM nsresult
|
||||
NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
|
||||
|
||||
#endif
|
|
@ -81,9 +81,9 @@ int main(int argc, char** argv)
|
|||
|
||||
// Now make sure we can find all the idents we just made
|
||||
for (i = 0; i < count; i++) {
|
||||
const char *utf8String;
|
||||
ids[i]->GetUTF8String(&utf8String);
|
||||
nsIAtom* id = NS_NewAtom(utf8String);
|
||||
const PRUnichar *unicodeString;
|
||||
ids[i]->GetUnicode(&unicodeString);
|
||||
nsIAtom* id = NS_NewAtom(unicodeString);
|
||||
if (id != ids[i]) {
|
||||
id->ToString(s1);
|
||||
ids[i]->ToString(s2);
|
||||
|
|
|
@ -49,11 +49,11 @@ static void Assert(PRBool aCondition, const char* aStatement)
|
|||
printf("%s: %s\n", aCondition?"PASS":"FAIL", aStatement);
|
||||
}
|
||||
|
||||
static void AssertString(nsIAtom *aAtom, const nsACString& aString)
|
||||
static void AssertString(nsIAtom *aAtom, const nsAString& aString)
|
||||
{
|
||||
const char *str;
|
||||
NS_STATIC_CAST(AtomImpl*,aAtom)->GetUTF8String(&str);
|
||||
Assert(nsDependentCString(str) == aString, "string is correct");
|
||||
const PRUnichar *str;
|
||||
NS_STATIC_CAST(AtomImpl*,aAtom)->GetUnicode(&str);
|
||||
Assert(nsDependentString(str) == aString, "string is correct");
|
||||
}
|
||||
|
||||
static void AssertPermanence(nsIAtom *aAtom, PRBool aPermanence)
|
||||
|
@ -65,21 +65,21 @@ static void AssertPermanence(nsIAtom *aAtom, PRBool aPermanence)
|
|||
int main()
|
||||
{
|
||||
nsCOMPtr<nsIAtom> foo = do_GetAtom("foo");
|
||||
AssertString(foo, NS_LITERAL_CSTRING("foo"));
|
||||
AssertString(foo, NS_LITERAL_STRING("foo"));
|
||||
AssertPermanence(foo, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIAtom> foop = do_GetPermanentAtom("foo");
|
||||
AssertString(foop, NS_LITERAL_CSTRING("foo"));
|
||||
AssertString(foop, NS_LITERAL_STRING("foo"));
|
||||
AssertPermanence(foop, PR_TRUE);
|
||||
|
||||
Assert(foo == foop, "atoms are equal");
|
||||
|
||||
nsCOMPtr<nsIAtom> barp = do_GetPermanentAtom("bar");
|
||||
AssertString(barp, NS_LITERAL_CSTRING("bar"));
|
||||
AssertString(barp, NS_LITERAL_STRING("bar"));
|
||||
AssertPermanence(barp, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIAtom> bar = do_GetAtom("bar");
|
||||
AssertString(bar, NS_LITERAL_CSTRING("bar"));
|
||||
AssertString(bar, NS_LITERAL_STRING("bar"));
|
||||
AssertPermanence(bar, PR_TRUE);
|
||||
|
||||
Assert(bar == barp, "atoms are equal");
|
||||
|
|
Загрузка…
Ссылка в новой задаче