mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
landing attempt #2 for 195262 - support for static atoms, and converting atoms over to UTF8 to reduce bloat - now without performance regressions!
sr=darin, r=dbaron
This commit is contained in:
parent
3a7fd80dab
commit
8c50d0242a
@ -269,7 +269,8 @@ public:
|
||||
const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const = 0;
|
||||
NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const = 0;
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsAString& aQualifiedName) const = 0;
|
||||
// switch to UTF8 - this allows faster access for consumers
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsACString& aQualifiedName) const = 0;
|
||||
|
||||
/*
|
||||
* This is a convinience method that creates a new nsINodeInfo that differs
|
||||
|
@ -2971,7 +2971,7 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
|
||||
nsLinkVerb aVerb,
|
||||
nsIURI* aBaseURL,
|
||||
const nsAString& aURLSpec,
|
||||
const nsAFlatString& aTargetSpec,
|
||||
const nsAString& aTargetSpec,
|
||||
PRBool aClick)
|
||||
{
|
||||
nsCOMPtr<nsILinkHandler> handler;
|
||||
@ -3006,10 +3006,10 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
|
||||
// says it's ok.
|
||||
if (NS_SUCCEEDED(proceed))
|
||||
handler->OnLinkClick(this, aVerb, targetURI,
|
||||
aTargetSpec.get());
|
||||
PromiseFlatString(aTargetSpec).get());
|
||||
} else {
|
||||
handler->OnOverLink(this, targetURI,
|
||||
aTargetSpec.get());
|
||||
PromiseFlatString(aTargetSpec).get());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -3086,11 +3086,13 @@ struct nsGenericAttribute
|
||||
: mNodeInfo(aNodeInfo),
|
||||
mValue(aValue)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsGenericAttribute);
|
||||
NS_IF_ADDREF(mNodeInfo);
|
||||
}
|
||||
|
||||
~nsGenericAttribute(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsGenericAttribute);
|
||||
NS_IF_RELEASE(mNodeInfo);
|
||||
}
|
||||
|
||||
@ -3125,11 +3127,12 @@ nsGenericContainerElement::~nsGenericContainerElement()
|
||||
nsresult
|
||||
nsGenericContainerElement::NormalizeAttrString(const nsAString& aStr, nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ConvertUCS2toUTF8 utf8String(aStr);
|
||||
if (mAttributes) {
|
||||
PRInt32 indx, count = mAttributes->Count();
|
||||
for (indx = 0; indx < count; indx++) {
|
||||
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(indx);
|
||||
if (attr->mNodeInfo->QualifiedNameEquals(aStr)) {
|
||||
if (attr->mNodeInfo->QualifiedNameEquals(utf8String)) {
|
||||
aNodeInfo = attr->mNodeInfo;
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
|
@ -63,8 +63,7 @@
|
||||
#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 char kMozStr[] = "moz";
|
||||
|
||||
static const PRInt32 kLongLineLen = 128;
|
||||
|
||||
@ -256,9 +255,7 @@ nsHTMLContentSerializer::EscapeURI(const nsAString& aURI, nsAString& aEscapedURI
|
||||
|
||||
|
||||
if (mCharSet && !uri.IsASCII()) {
|
||||
const PRUnichar *charset;
|
||||
mCharSet->GetUnicode(&charset);
|
||||
documentCharset.Adopt(ToNewUTF8String(nsDependentString(charset)));
|
||||
mCharSet->ToUTF8String(documentCharset);
|
||||
textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -316,6 +313,8 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
|
||||
aContent->GetAttrCount(count);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(mozStr1, "_moz");
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
aContent->GetAttrNameAt(index,
|
||||
namespaceID,
|
||||
@ -323,13 +322,12 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
*getter_AddRefs(attrPrefix));
|
||||
|
||||
// Filter out any attribute starting with [-|_]moz
|
||||
const PRUnichar* sharedName;
|
||||
attrName->GetUnicode(&sharedName);
|
||||
const char* sharedName;
|
||||
attrName->GetUTF8String(&sharedName);
|
||||
if ((('_' == *sharedName) || ('-' == *sharedName)) &&
|
||||
!nsCRT::strncmp(sharedName+1, kMozStr, kMozStrLength)) {
|
||||
!nsCRT::strncmp(sharedName+1, kMozStr, sizeof(kMozStr)-1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
aContent->GetAttr(namespaceID, attrName, valueStr);
|
||||
|
||||
//
|
||||
@ -338,8 +336,7 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
//
|
||||
if ((aTagName == nsHTMLAtoms::br) &&
|
||||
(attrName.get() == nsHTMLAtoms::type) &&
|
||||
!valueStr.IsEmpty() && ('_' == valueStr[0]) &&
|
||||
!nsCRT::strncmp(valueStr.get()+1, kMozStr, kMozStrLength)) {
|
||||
(mozStr1.Equals(Substring(valueStr, 0, mozStr1.Length())))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -457,9 +454,9 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
|
||||
AppendToString(kLessThan, aStr);
|
||||
|
||||
const PRUnichar* sharedName;
|
||||
name->GetUnicode(&sharedName);
|
||||
AppendToString(sharedName, -1, aStr);
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
|
||||
// Need to keep track of OL and LI elements in order to get ordinal number
|
||||
// for the LI.
|
||||
@ -554,13 +551,12 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||
}
|
||||
}
|
||||
|
||||
const PRUnichar* sharedName;
|
||||
name->GetUnicode(&sharedName);
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
|
||||
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
||||
|
||||
if (parserService && (name.get() != nsHTMLAtoms::style)) {
|
||||
nsAutoString nameStr(sharedName);
|
||||
PRBool isContainer;
|
||||
PRInt32 id;
|
||||
|
||||
@ -582,7 +578,7 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||
EndIndentation(name, hasDirtyAttr, aStr);
|
||||
|
||||
AppendToString(kEndTag, aStr);
|
||||
AppendToString(sharedName, -1, aStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
AppendToString(kGreaterThan, aStr);
|
||||
|
||||
if (LineBreakAfterClose(name, hasDirtyAttr)) {
|
||||
|
@ -107,8 +107,8 @@ nsNodeInfo::GetQualifiedName(nsAString& aQualifiedName) const
|
||||
aQualifiedName.Truncate();
|
||||
}
|
||||
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
nsAutoString name;
|
||||
mInner.mName->ToString(name);
|
||||
|
||||
aQualifiedName.Append(name);
|
||||
|
||||
@ -183,20 +183,14 @@ nsNodeInfo::GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name);
|
||||
return mInner.mName->Equals(aName);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!aName.Equals(name)) {
|
||||
if (!mInner.mName->Equals(aName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -204,19 +198,15 @@ nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
||||
return aPrefix.IsEmpty();
|
||||
}
|
||||
|
||||
mInner.mPrefix->GetUnicode(&name);
|
||||
|
||||
return aPrefix.Equals(name);
|
||||
return mInner.mPrefix->Equals(aPrefix);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name) && (mInner.mNamespaceID == aNamespaceID);
|
||||
return mInner.mNamespaceID == aNamespaceID &&
|
||||
mInner.mName->Equals(aName);
|
||||
}
|
||||
|
||||
|
||||
@ -225,15 +215,13 @@ 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.mPrefix) {
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
}
|
||||
if (!mInner.mNamespaceID == aNamespaceID ||
|
||||
!mInner.mName->Equals(aName))
|
||||
return PR_FALSE;
|
||||
|
||||
return ((mInner.mNamespaceID == aNamespaceID) && aName.Equals(name) &&
|
||||
aPrefix.Equals(prefix));
|
||||
return mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) :
|
||||
aPrefix.IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
@ -246,26 +234,22 @@ nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const
|
||||
return nsINodeInfo::NamespaceEquals(nsid);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
||||
nsNodeInfo::QualifiedNameEquals(const nsACString& aQualifiedName) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!mInner.mPrefix)
|
||||
return mInner.mName->EqualsUTF8(aQualifiedName);
|
||||
|
||||
if (!mInner.mPrefix) {
|
||||
return aQualifiedName.Equals(name);
|
||||
}
|
||||
|
||||
nsAString::const_iterator start;
|
||||
nsACString::const_iterator start;
|
||||
aQualifiedName.BeginReading(start);
|
||||
|
||||
nsAString::const_iterator colon(start);
|
||||
nsACString::const_iterator colon(start);
|
||||
|
||||
const PRUnichar *prefix;
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
const char* prefix;
|
||||
mInner.mPrefix->GetUTF8String(&prefix);
|
||||
|
||||
PRUint32 len = nsCRT::strlen(prefix);
|
||||
PRUint32 len = strlen(prefix);
|
||||
|
||||
if (len >= aQualifiedName.Length()) {
|
||||
return PR_FALSE;
|
||||
@ -280,18 +264,17 @@ nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
||||
}
|
||||
|
||||
// Compare the prefix to the string from the start to the colon
|
||||
if (!Substring(start, colon).Equals(prefix)) {
|
||||
if (!mInner.mPrefix->EqualsUTF8(Substring(start, colon)))
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
++colon; // Skip the ':'
|
||||
|
||||
nsAString::const_iterator end;
|
||||
nsACString::const_iterator end;
|
||||
aQualifiedName.EndReading(end);
|
||||
|
||||
// Compare the local name to the string between the colon and the
|
||||
// end of aQualifiedName
|
||||
return Substring(colon, end).Equals(name);
|
||||
return mInner.mName->EqualsUTF8(Substring(colon, end));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const;
|
||||
NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const;
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsAString& aQualifiedName) const;
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsACString& aQualifiedName) const;
|
||||
|
||||
NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo*& aResult);
|
||||
NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult);
|
||||
|
@ -1807,8 +1807,8 @@ nsPlainTextSerializer::GetAttributeValue(const nsIParserNode* aNode,
|
||||
}
|
||||
}
|
||||
else if (aNode) {
|
||||
const PRUnichar *name;
|
||||
aName->GetUnicode(&name);
|
||||
nsAutoString name;
|
||||
aName->ToString(name);
|
||||
|
||||
PRInt32 count = aNode->GetAttributeCount();
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
|
@ -1862,10 +1862,8 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo,
|
||||
|
||||
PRBool nsGenericHTMLElement::IsEventName(nsIAtom* aName)
|
||||
{
|
||||
const PRUnichar *name = nsnull;
|
||||
|
||||
aName->GetUnicode(&name);
|
||||
NS_ASSERTION(name, "Null string in atom!");
|
||||
const char* name;
|
||||
aName->GetUTF8String(&name);
|
||||
|
||||
if (name[0] != 'o' || name[1] != 'n') {
|
||||
return PR_FALSE;
|
||||
|
@ -397,6 +397,8 @@ public:
|
||||
nsString mBaseTarget;
|
||||
|
||||
nsICSSLoader *mCSSLoader;
|
||||
|
||||
// depth of containment within <noembed>, <noframes> etc
|
||||
PRInt32 mInsideNoXXXTag;
|
||||
PRInt32 mInMonolithicContainer;
|
||||
PRUint32 mFlags;
|
||||
@ -1031,11 +1033,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
|
||||
parserService->HTMLIdToStringTag(id, &tag);
|
||||
NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");
|
||||
|
||||
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) {
|
||||
if (!name->Equals(nsDependentString(tag))) {
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(tag);
|
||||
|
||||
rv = aNodeInfo->NameChanged(atom, *getter_AddRefs(kungFuDeathGrip));
|
||||
@ -1710,14 +1708,13 @@ SinkContext::CloseContainer(const nsHTMLTag aTag)
|
||||
// Tracing code
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mStack[mStackPos].mContent->GetTag(*getter_AddRefs(tag));
|
||||
const PRUnichar* tagChar;
|
||||
tag->GetUnicode(&tagChar);
|
||||
nsDependentString str(tagChar);
|
||||
const char *tagStr;
|
||||
tag->GetUTF8String(&tagStr);
|
||||
|
||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||
("SinkContext::CloseContainer: reflow on notifyImmediate "
|
||||
"tag=%s newIndex=%d stackPos=%d",
|
||||
NS_LossyConvertUCS2toASCII(str).get(),
|
||||
tagStr,
|
||||
mStack[mStackPos].mNumFlushed, mStackPos));
|
||||
#endif
|
||||
mSink->NotifyAppend(content, mStack[mStackPos].mNumFlushed);
|
||||
@ -2117,13 +2114,12 @@ SinkContext::FlushTags(PRBool aNotify)
|
||||
// Tracing code
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mStack[stackPos].mContent->GetTag(*getter_AddRefs(tag));
|
||||
const PRUnichar* tagChar;
|
||||
tag->GetUnicode(&tagChar);
|
||||
nsDependentString str(tagChar);
|
||||
const char* tagStr;
|
||||
tag->GetUTF8String(&tagStr);
|
||||
|
||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||
("SinkContext::FlushTags: tag=%s from newindex=%d at "
|
||||
"stackPos=%d", NS_LossyConvertUCS2toASCII(str).get(),
|
||||
"stackPos=%d", tagStr,
|
||||
mStack[stackPos].mNumFlushed, stackPos));
|
||||
#endif
|
||||
if ((mStack[stackPos].mInsertionPoint != -1) &&
|
||||
@ -5259,12 +5255,11 @@ HTMLContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
||||
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
const PRUnichar *header = 0;
|
||||
(void)aHeader->GetUnicode(&header);
|
||||
(void)httpChannel->SetResponseHeader(
|
||||
NS_ConvertUCS2toUTF8(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
const char* header;
|
||||
(void)aHeader->GetUTF8String(&header);
|
||||
(void)httpChannel->SetResponseHeader(nsDependentCString(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1569,9 +1569,10 @@ static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
||||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return Substring(str, 0, 11).Equals(NS_LITERAL_STRING(":-moz-tree-"));
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -584,8 +584,8 @@ PRInt32 nsCSSSelector::CalcWeight(void) const
|
||||
static PRBool IsPseudoElement(nsIAtom* aAtom)
|
||||
{
|
||||
if (aAtom) {
|
||||
const PRUnichar *str;
|
||||
aAtom->GetUnicode(&str);
|
||||
const char* str;
|
||||
aAtom->GetUTF8String(&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
|
||||
{
|
||||
const PRUnichar* temp;
|
||||
nsAutoString 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) {
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
@ -648,15 +648,16 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
mTag->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
NS_IF_NEGATED_END(aIsNegated, aString)
|
||||
}
|
||||
// Append the id, if there is one
|
||||
if (mIDList) {
|
||||
nsAtomList* list = mIDList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('#'));
|
||||
aString.Append(temp);
|
||||
@ -668,7 +669,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
if (mClassList) {
|
||||
nsAtomList* list = mClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('.'));
|
||||
aString.Append(temp);
|
||||
@ -692,14 +693,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) {
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
}
|
||||
// Append the attribute name
|
||||
list->mAttr->GetUnicode(&temp);
|
||||
list->mAttr->ToString(temp);
|
||||
aString.Append(temp);
|
||||
// Append the function
|
||||
if (list->mFunction == NS_ATTR_FUNC_EQUALS) {
|
||||
@ -732,7 +733,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
if (mPseudoClassList) {
|
||||
nsAtomStringList* list = mPseudoClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(temp);
|
||||
if (nsnull != list->mString) {
|
||||
|
@ -168,12 +168,11 @@ RuleHash_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||
if (match_atom == entry_atom)
|
||||
return PR_TRUE;
|
||||
|
||||
const PRUnichar *match_str, *entry_str;
|
||||
match_atom->GetUnicode(&match_str);
|
||||
entry_atom->GetUnicode(&entry_str);
|
||||
const char *match_str, *entry_str;
|
||||
match_atom->GetUTF8String(&match_str);
|
||||
entry_atom->GetUTF8String(&entry_str);
|
||||
|
||||
return nsDependentString(match_str).Equals(nsDependentString(entry_str),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
return (nsCRT::strcasecmp(entry_str, match_str) == 0);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
@ -1116,8 +1115,8 @@ DOMMediaListImpl::GetText(nsAString& aMediaText)
|
||||
QueryElementAt(index++, NS_GET_IID(nsIAtom), getter_AddRefs(medium));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
aMediaText.Append(buffer);
|
||||
if (index < count) {
|
||||
aMediaText.Append(NS_LITERAL_STRING(", "));
|
||||
@ -1234,8 +1233,8 @@ DOMMediaListImpl::Item(PRUint32 aIndex, nsAString& aReturn)
|
||||
nsCOMPtr<nsIAtom> medium(do_QueryInterface(tmp));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
aReturn.Assign(buffer);
|
||||
} else {
|
||||
aReturn.Truncate();
|
||||
@ -3742,15 +3741,15 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
IDList = IDList->mNext;
|
||||
} while (IDList);
|
||||
} else {
|
||||
const PRUnichar* id1Str;
|
||||
data.mContentID->GetUnicode(&id1Str);
|
||||
nsDependentString id1(id1Str);
|
||||
const char* id1Str;
|
||||
data.mContentID->GetUTF8String(&id1Str);
|
||||
nsDependentCString id1(id1Str);
|
||||
do {
|
||||
const PRUnichar* id2Str;
|
||||
IDList->mAtom->GetUnicode(&id2Str);
|
||||
nsDependentString id2(id2Str);
|
||||
const char* id2Str;
|
||||
IDList->mAtom->GetUTF8String(&id2Str);
|
||||
nsDependentCString id2(id2Str);
|
||||
if (localTrue !=
|
||||
id1.Equals(id2, nsCaseInsensitiveStringComparator())) {
|
||||
id1.Equals(id2, nsCaseInsensitiveCStringComparator())) {
|
||||
result = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -1376,17 +1376,15 @@ nsHTMLAttributes::HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const
|
||||
classList = classList->mNext;
|
||||
} while (classList);
|
||||
} else {
|
||||
const PRUnichar* class1Buf;
|
||||
aClass->GetUnicode(&class1Buf);
|
||||
const char* class1;
|
||||
aClass->GetUTF8String(&class1);
|
||||
// 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 PRUnichar* class2Buf;
|
||||
classList->mAtom->GetUnicode(&class2Buf);
|
||||
nsDependentString class2(class2Buf);
|
||||
if (class1.Equals(class2, nsCaseInsensitiveStringComparator()))
|
||||
const char* class2;
|
||||
classList->mAtom->GetUTF8String(&class2);
|
||||
if (nsCRT::strcasecmp(class1, class2) == 0)
|
||||
return PR_TRUE;
|
||||
classList = classList->mNext;
|
||||
} while (classList);
|
||||
|
@ -768,9 +768,10 @@ nsSVGAttributes::NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
PRInt32 indx, count = Count();
|
||||
NS_ConvertUCS2toUTF8 utf8String(aStr);
|
||||
for (indx = 0; indx < count; indx++) {
|
||||
nsSVGAttribute* attr = ElementAt(indx);
|
||||
if (attr->GetNodeInfo()->QualifiedNameEquals(aStr)) {
|
||||
if (attr->GetNodeInfo()->QualifiedNameEquals(utf8String)) {
|
||||
aNodeInfo = attr->GetNodeInfo();
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
|
@ -93,26 +93,22 @@ 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");
|
||||
}
|
||||
}
|
||||
@ -120,13 +116,11 @@ 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);
|
||||
}
|
||||
}
|
||||
@ -321,17 +315,12 @@ nsXMLElement::SetAttr(nsINodeInfo *aNodeInfo,
|
||||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
|
||||
if (aNodeInfo->Equals(kTypeAtom, kNameSpaceID_XLink)) {
|
||||
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;
|
||||
}
|
||||
|
||||
// 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"));
|
||||
|
||||
// We will check for actuate="onLoad" in MaybeTriggerAutoLink
|
||||
}
|
||||
@ -408,10 +397,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mIsLink) {
|
||||
// preload and precalculate length of atom outside of loop
|
||||
const PRUnichar *onloadUnicode;
|
||||
kOnLoadAtom->GetUnicode(&onloadUnicode);
|
||||
nsDependentString onloadString(onloadUnicode);
|
||||
NS_NAMED_LITERAL_STRING(onloadString, "onLoad");
|
||||
do {
|
||||
// actuate="onLoad" ?
|
||||
nsAutoString value;
|
||||
|
@ -1177,7 +1177,6 @@ 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));
|
||||
@ -1196,8 +1195,8 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
|
||||
}
|
||||
}
|
||||
|
||||
rv = cookieServ->SetCookieString(codebaseURI, prompt, cookie, httpChannel);
|
||||
nsCRT::free(cookie);
|
||||
rv = cookieServ->SetCookieString(codebaseURI, prompt, NS_ConvertUCS2toUTF8(aValue).get(), httpChannel);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} // END set-cookie
|
||||
else if (aHeader == nsHTMLAtoms::link) {
|
||||
@ -1223,12 +1222,11 @@ 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 PRUnichar *header = 0;
|
||||
(void)aHeader->GetUnicode(&header);
|
||||
(void)httpChannel->SetResponseHeader(
|
||||
NS_ConvertUCS2toUTF8(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
const char *header = 0;
|
||||
(void)aHeader->GetUTF8String(&header);
|
||||
(void)httpChannel->SetResponseHeader(nsDependentCString(header),
|
||||
NS_ConvertUCS2toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -946,11 +946,8 @@ 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) {
|
||||
const PRUnichar* IDValStr = nsnull;
|
||||
IDValue->GetUnicode(&IDValStr);
|
||||
if (aName.Equals(IDValStr)) {
|
||||
if (IDValue->Equals(aName))
|
||||
return aContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2388,11 +2388,13 @@ nsXULElement::NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
PRInt32 i, count = Attributes() ? Attributes()->Count() : 0;
|
||||
NS_ConvertUCS2toUTF8 utf8String(aStr);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsXULAttribute* attr = NS_REINTERPRET_CAST(nsXULAttribute*,
|
||||
Attributes()->ElementAt(i));
|
||||
nsINodeInfo *ni = attr->GetNodeInfo();
|
||||
if (ni->QualifiedNameEquals(aStr)) {
|
||||
if (ni->QualifiedNameEquals(utf8String)) {
|
||||
aNodeInfo = ni;
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
@ -2405,7 +2407,7 @@ nsXULElement::NormalizeAttrString(const nsAString& aStr,
|
||||
nsXULPrototypeAttribute* attr = &(mPrototype->mAttributes[i]);
|
||||
|
||||
nsINodeInfo *ni = attr->mNodeInfo;
|
||||
if (ni->QualifiedNameEquals(aStr)) {
|
||||
if (ni->QualifiedNameEquals(utf8String)) {
|
||||
aNodeInfo = ni;
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
|
@ -374,9 +374,7 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
||||
nsAutoString prefix;
|
||||
if (prefixAtom)
|
||||
{
|
||||
const PRUnichar *unicodeString;
|
||||
prefixAtom->GetUnicode(&unicodeString);
|
||||
prefix = unicodeString;
|
||||
prefixAtom->ToString(prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2030,8 +2030,6 @@ 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;
|
||||
@ -2065,7 +2063,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
|
||||
child->GetAttr(kNameSpaceID_None, nsXULAtoms::attribute,
|
||||
listeningToAttribute);
|
||||
|
||||
if (listeningToAttribute != attrName &&
|
||||
if (!aAttr->Equals(listeningToAttribute) &&
|
||||
listeningToAttribute != NS_LITERAL_STRING("*")) {
|
||||
continue;
|
||||
}
|
||||
@ -3072,13 +3070,13 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID,
|
||||
|
||||
// Ick. Construct a property from the attribute. Punt on
|
||||
// namespaces for now.
|
||||
const PRUnichar* attrstr;
|
||||
rv = aAttribute->GetUnicode(&attrstr);
|
||||
const char* attrstr;
|
||||
rv = aAttribute->GetUTF8String(&attrstr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> attr;
|
||||
rv = gRDFService->GetUnicodeResource(nsDependentString(attrstr),
|
||||
getter_AddRefs(attr));
|
||||
rv = gRDFService->GetResource(nsDependentCString(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 PRUnichar *expected, *actual;
|
||||
mTag->GetUnicode(&expected);
|
||||
tag->GetUnicode(&actual);
|
||||
const char *expected, *actual;
|
||||
mTag->GetUTF8String(&expected);
|
||||
tag->GetUTF8String(&actual);
|
||||
|
||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
(" => tag mismatch; expected %s, actual %s",
|
||||
NS_LossyConvertUCS2toASCII(expected).get(),
|
||||
NS_LossyConvertUCS2toASCII(actual).get()));
|
||||
expected,
|
||||
actual));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,14 +908,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 PRUnichar *name;
|
||||
aName->GetUnicode(&name);
|
||||
const char *name;
|
||||
aName->GetUTF8String(&name);
|
||||
char c;
|
||||
PRUint32 i = 0;
|
||||
|
||||
do {
|
||||
NS_ASSERTION(name[i] < 128, "non-ASCII event handler name");
|
||||
c = char(name[i]);
|
||||
c = 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 PRUnichar *unicodeString;
|
||||
aTag->GetUnicode(&unicodeString);
|
||||
if (tag.Equals(unicodeString, nsCaseInsensitiveStringComparator()))
|
||||
const char *tagStr;
|
||||
aTag->GetUTF8String(&tagStr);
|
||||
if (tag.EqualsIgnoreCase(tagStr))
|
||||
{
|
||||
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.GetUnicode();
|
||||
var atomValue = atom.toString();
|
||||
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).GetUnicode();
|
||||
var url = item.QueryInterface(Components.interfaces.nsIAtom).toString();
|
||||
var menu = document.createElement("menuitem");
|
||||
menu.setAttribute("value", url);
|
||||
menu.setAttribute("label", url);
|
||||
|
@ -73,9 +73,7 @@ void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest);
|
||||
*/
|
||||
static PRBool TX_StringEqualsAtom(const nsAString& aString, nsIAtom* aAtom)
|
||||
{
|
||||
const PRUnichar* atom;
|
||||
aAtom->GetUnicode(&atom);
|
||||
return aString.Equals(atom);
|
||||
return aAtom->Equals(aString);
|
||||
};
|
||||
|
||||
#endif // txStringUtils_h__
|
||||
|
@ -88,12 +88,12 @@ double txNameTest::getDefaultPriority()
|
||||
void txNameTest::toString(nsAString& aDest)
|
||||
{
|
||||
if (mPrefix) {
|
||||
const PRUnichar* prefix;
|
||||
mPrefix->GetUnicode(&prefix);
|
||||
aDest.Append(nsDependentString(prefix));
|
||||
nsAutoString prefix;
|
||||
mPrefix->ToString(prefix);
|
||||
aDest.Append(prefix);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
const PRUnichar* localName;
|
||||
mLocalName->GetUnicode(&localName);
|
||||
aDest.Append(nsDependentString(localName));
|
||||
nsAutoString localName;
|
||||
mLocalName->ToString(localName);
|
||||
aDest.Append(localName);
|
||||
}
|
||||
|
@ -174,13 +174,11 @@ 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 PRUnichar *langGroup;
|
||||
aLangGroup->GetUnicode( &langGroup );
|
||||
char *lang = ToNewUTF8String(nsDependentString(langGroup));
|
||||
const char *lang;
|
||||
aLangGroup->GetUTF8String( &lang );
|
||||
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 PRUnichar *namePRU;
|
||||
aAtom->GetUnicode(&namePRU);
|
||||
return ToNewUTF8String(nsDependentString(namePRU));
|
||||
const char *namePRU;
|
||||
aAtom->GetUTF8String(&namePRU);
|
||||
return ToNewCString(nsDependentCString(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 PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
name.AppendWithConversion(langGroup);
|
||||
const char* langGroup = nsnull;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
name.Append(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 PRUnichar* langGroup = nsnull;
|
||||
aLangGroup->GetUnicode(&langGroup);
|
||||
pref.AppendWithConversion(langGroup);
|
||||
const char* langGroup = nsnull;
|
||||
aLangGroup->GetUTF8String(&langGroup);
|
||||
pref.Append(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('.'));
|
||||
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
nsCAutoString name;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
|
||||
name.AppendWithConversion(langGroup);
|
||||
name.Append(langGroup);
|
||||
|
||||
PRInt32 minimum = 0;
|
||||
nsresult res;
|
||||
@ -802,10 +802,10 @@ nsFontMetricsXft::SetupFCPattern(void)
|
||||
}
|
||||
|
||||
// language group
|
||||
const PRUnichar *name;
|
||||
mLangGroup->GetUnicode(&name);
|
||||
const char *name;
|
||||
mLangGroup->Get(&name);
|
||||
nsCAutoString cname;
|
||||
cname.AssignWithConversion(nsDependentString(name));
|
||||
cname.Assign(name);
|
||||
printf("\tlang group: %s\n", cname.get());
|
||||
|
||||
|
||||
@ -1671,10 +1671,8 @@ void
|
||||
AddLangGroup(FcPattern *aPattern, nsIAtom *aLangGroup)
|
||||
{
|
||||
// Find the FC lang group for this lang group
|
||||
const PRUnichar *name;
|
||||
aLangGroup->GetUnicode(&name);
|
||||
nsCAutoString cname;
|
||||
cname.AssignWithConversion(nsDependentString(name));
|
||||
aLangGroup->ToUTF8String(cname);
|
||||
|
||||
// see if the lang group needs to be translated from mozilla's
|
||||
// internal mapping into fontconfig's
|
||||
|
@ -599,9 +599,8 @@ 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 PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
nsCAutoString name(NS_LossyConvertUCS2toASCII(langGroup).get());
|
||||
const char* langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
for (int j=0; j < eCharset_COUNT; j++ )
|
||||
{
|
||||
if (name.get()[0] == gCharsetInfo[j].mLangGroup[0])
|
||||
|
@ -163,18 +163,12 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
str = strdup("serif");
|
||||
}
|
||||
|
||||
const PRUnichar *uc;
|
||||
aLangGroup->GetUnicode( &uc );
|
||||
nsString language( uc );
|
||||
char *cstring = ToNewCString(language);
|
||||
const char *cstring;
|
||||
aLangGroup->GetUTF8String( &uc );
|
||||
|
||||
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 PRUnichar *langStr;
|
||||
lang->GetUnicode(&langStr);
|
||||
const char *langStr;
|
||||
lang->GetUTF8String(&langStr);
|
||||
if (langStr)
|
||||
fpi.lang.AppendWithConversion(langStr);
|
||||
gUsersLocale->GetUnicode(&langStr);
|
||||
fpi.lang.Append(langStr);
|
||||
gUsersLocale->GetUTF8String(&langStr);
|
||||
if (langStr)
|
||||
locale.AppendWithConversion(langStr);
|
||||
locale.Append(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, nsString* aName, LOGFONT* aLogFont)
|
||||
nsFontMetricsWin::CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLogFont)
|
||||
{
|
||||
PRUint16 weightTable = LookForFontWeightTable(aDC, aName);
|
||||
PRInt32 weight = GetFontWeight(mFont.weight, weightTable);
|
||||
@ -2215,7 +2215,7 @@ nsFontMetricsWin::CreateFontHandle(HDC aDC, nsString* aName, LOGFONT* aLogFont)
|
||||
* 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, nsString* aName, LOGFONT* aLogFont)
|
||||
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, nsString* aName)
|
||||
nsFontMetricsWin::LoadFont(HDC aDC, const 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, nsnull);
|
||||
nsFontWin* font = LoadSubstituteFont(aDC, nsString());
|
||||
if (font) {
|
||||
((nsFontWinSubstitute*)font)->SetRepresentable(c);
|
||||
mSubstituteFont = font;
|
||||
@ -2603,17 +2603,17 @@ nsFontMetricsWin::FindSubstituteFont(HDC aDC, PRUint32 c)
|
||||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWin::LoadSubstituteFont(HDC aDC, nsString* aName)
|
||||
nsFontMetricsWin::LoadSubstituteFont(HDC aDC, const nsString& aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = aName
|
||||
HFONT hfont = !aName.IsEmpty()
|
||||
? 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 ? &logFont : nsnull;
|
||||
LOGFONT* lfont = !aName.IsEmpty() ? &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, nsString* aFontName)
|
||||
nsFontMetricsWin::GetFontWeightTable(HDC aDC, const 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, nsString* aName)
|
||||
nsFontMetricsWin::LookForFontWeightTable(HDC aDC, const nsString& aName)
|
||||
{
|
||||
// Initialize the font weight table if need be.
|
||||
if (!gFontWeights) {
|
||||
@ -2950,7 +2950,7 @@ nsFontMetricsWin::LookForFontWeightTable(HDC aDC, 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, nsString* aName)
|
||||
nsFontMetricsWin::LoadGenericFont(HDC aDC, PRUint32 aChar, const 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(((nsFontWin*)mLoadedFonts[i])->mName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
if (aName.Equals(NS_ConvertASCIItoUCS2(fontName),
|
||||
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, (nsString*)&aFamily);
|
||||
context->mFont = metrics->LoadGenericFont(dc, ch, aFamily);
|
||||
if (context->mFont) {
|
||||
return PR_FALSE; // stop enumerating the list
|
||||
}
|
||||
@ -3211,10 +3211,9 @@ nsFontMetricsWin::FindGenericFont(HDC aDC, PRUint32 aChar)
|
||||
nsFont font("", 0, 0, 0, 0, 0);
|
||||
|
||||
if (mLangGroup) {
|
||||
nsAutoString langGroup;
|
||||
mLangGroup->ToString(langGroup);
|
||||
AppendGenericFontFromPref(font.name,
|
||||
NS_ConvertUCS2toUTF8(langGroup).get(),
|
||||
const char* langGroup;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
AppendGenericFontFromPref(font.name, langGroup,
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
@ -3226,13 +3225,12 @@ nsFontMetricsWin::FindGenericFont(HDC aDC, PRUint32 aChar)
|
||||
}
|
||||
|
||||
#if defined(DEBUG_rbs) || defined(DEBUG_shanjian)
|
||||
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));
|
||||
const char* lang;
|
||||
mLangGroup->GetUTF8String(&lang);
|
||||
NS_ConvertUCS2toUTF8 generic(mGeneric);
|
||||
NS_ConvertUCS2toUTF8 family(mFont.name);
|
||||
printf("FindGenericFont missed:U+%04X langGroup:%s generic:%s mFont.name:%s\n",
|
||||
aChar, lang.get(), generic.get(), family.get());
|
||||
aChar, lang, generic.get(), family.get());
|
||||
#endif
|
||||
|
||||
mTriedAllGenerics = 1;
|
||||
@ -3279,17 +3277,17 @@ nsFontMetricsWin::FindPrefFont(HDC aDC, PRUint32 aChar)
|
||||
|
||||
// then try user locale first, if it is CJK
|
||||
if ((gUsersLocale != mLangGroup) && IsCJKLangGroupAtom(gUsersLocale)) {
|
||||
const PRUnichar *usersLocaleLangGroup;
|
||||
gUsersLocale->GetUnicode(&usersLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, NS_ConvertUCS2toUTF8(usersLocaleLangGroup).get(),
|
||||
nsCAutoString usersLocaleLangGroup;
|
||||
gUsersLocale->ToUTF8String(usersLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, usersLocaleLangGroup.get(),
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
// then system locale (os language)
|
||||
if ((gSystemLocale != mLangGroup) && (gSystemLocale != gUsersLocale) && IsCJKLangGroupAtom(gSystemLocale)) {
|
||||
const PRUnichar *systemLocaleLangGroup;
|
||||
gSystemLocale->GetUnicode(&systemLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, NS_ConvertUCS2toUTF8(systemLocaleLangGroup).get(),
|
||||
nsCAutoString systemLocaleLangGroup;
|
||||
gSystemLocale->ToUTF8String(systemLocaleLangGroup);
|
||||
AppendGenericFontFromPref(font.name, systemLocaleLangGroup.get(),
|
||||
NS_ConvertUCS2toUTF8(mGeneric).get());
|
||||
}
|
||||
|
||||
@ -4601,7 +4599,7 @@ nsFontWinA::DumpFontInfo()
|
||||
#endif
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadFont(HDC aDC, nsString* aName)
|
||||
nsFontMetricsWinA::LoadFont(HDC aDC, const nsString& aName)
|
||||
{
|
||||
LOGFONT logFont;
|
||||
HFONT hfont = CreateFontHandle(aDC, aName, &logFont);
|
||||
@ -4734,7 +4732,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)
|
||||
@ -4746,12 +4744,11 @@ nsFontMetricsWinA::FindLocalFont(HDC aDC, PRUint32 aChar)
|
||||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName)
|
||||
nsFontMetricsWinA::LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName)
|
||||
{
|
||||
for (int i = mLoadedFonts.Count()-1; i >= 0; --i) {
|
||||
|
||||
if (aName->Equals(NS_ConvertASCIItoUCS2(((nsFontWin*)mLoadedFonts[i])->mName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
if (aName.EqualsIgnoreCase(((nsFontWin*)mLoadedFonts[i])->mName))
|
||||
return nsnull;
|
||||
|
||||
}
|
||||
@ -4877,7 +4874,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;
|
||||
@ -4919,7 +4916,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;
|
||||
@ -4941,7 +4938,7 @@ nsFontMetricsWinA::FindSubstituteFont(HDC aDC, PRUint32 aChar)
|
||||
}
|
||||
|
||||
nsFontWin*
|
||||
nsFontMetricsWinA::LoadSubstituteFont(HDC aDC, nsString* aName)
|
||||
nsFontMetricsWinA::LoadSubstituteFont(HDC aDC, const 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, nsString* aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, nsString* aName);
|
||||
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
|
||||
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, nsString* aName);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const 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, nsString* aName, LOGFONT* aLogFont);
|
||||
HFONT CreateFontHandle(HDC aDC, const 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, nsString* aName);
|
||||
PRUint16 LookForFontWeightTable(HDC aDc, const 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, nsString* aFontName);
|
||||
PRUint16 GetFontWeightTable(HDC aDC, const 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, nsString* aName);
|
||||
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
|
||||
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUint32 aChar);
|
||||
virtual nsFontWin* FindSubstituteFont(HDC aDC, PRUint32 aChar);
|
||||
|
||||
virtual nsFontWin* LoadFont(HDC aDC, nsString* aName);
|
||||
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName);
|
||||
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, nsString* aName);
|
||||
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const nsString& aName);
|
||||
|
||||
virtual nsFontWin* GetFontFor(HFONT aHFONT);
|
||||
|
||||
|
@ -853,9 +853,9 @@ PRBool CopyFontCharSetMapXlib(nsFontMetricsXlibContext *aFmctx)
|
||||
static char*
|
||||
atomToName(nsIAtom* aAtom)
|
||||
{
|
||||
const PRUnichar *namePRU;
|
||||
aAtom->GetUnicode(&namePRU);
|
||||
return ToNewUTF8String(nsDependentString(namePRU));
|
||||
const char *namePRU;
|
||||
aAtom->GetUTF8String(&namePRU);
|
||||
return ToNewCString(nsDependentCString(namePRU));
|
||||
}
|
||||
|
||||
//
|
||||
@ -1740,9 +1740,9 @@ NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
name.Append("variable");
|
||||
}
|
||||
name.Append(char('.'));
|
||||
const PRUnichar* langGroup = nsnull;
|
||||
mLangGroup->GetUnicode(&langGroup);
|
||||
name.AppendWithConversion(langGroup);
|
||||
const char* langGroup = nsnull;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
name.Append(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 PRUnichar* langGroup = nsnull;
|
||||
aLangGroup->GetUnicode(&langGroup);
|
||||
pref.AppendWithConversion(langGroup);
|
||||
const char* langGroup = nsnull;
|
||||
aLangGroup->GetUTF8String(&langGroup);
|
||||
pref.Append(langGroup);
|
||||
nsXPIDLCString value;
|
||||
mFontMetricsContext->mPref->CopyCharPref(pref.get(), getter_Copies(value));
|
||||
nsCAutoString str;
|
||||
|
@ -44,11 +44,10 @@ NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
|
||||
{
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
|
||||
*aId = nsHTMLTags::LookupTag(nsDependentString(tagName));
|
||||
*aId = nsHTMLTags::LookupTag(tagName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -57,11 +56,10 @@ NS_IMETHODIMP
|
||||
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
||||
PRInt32* aId) const
|
||||
{
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName);
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -382,10 +382,10 @@ nsPlatformCharset::VerifyCharset(nsString &aCharset)
|
||||
//
|
||||
// return the preferred string
|
||||
//
|
||||
const PRUnichar *prefName;
|
||||
res = charsetAtom->GetUnicode(&prefName);
|
||||
const char *prefName;
|
||||
res = charsetAtom->GetUTF8String(&prefName);
|
||||
if (NS_SUCCEEDED(res))
|
||||
aCharset.Assign(prefName);
|
||||
aCharset.AssignWithConversion(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;
|
||||
const PRUnichar * name;
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager2> ccMan =
|
||||
@ -263,12 +263,12 @@ nsresult nsTestUConv::TestCharsetManager()
|
||||
mLog.PrintError("GetCharsetAtom()", res);
|
||||
return res;
|
||||
}
|
||||
res = csAtom->GetUnicode(&name);
|
||||
res = csAtom->ToString(name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
}
|
||||
if (!csName.Equals(nsDependentString(name))) {
|
||||
if (!csName.Equals(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->GetUnicode(&name);
|
||||
res = csAtom->ToString(name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
}
|
||||
if (!csAlias2.Equals(nsDependentString(name))) {
|
||||
if (!csAlias2.Equals(name)) {
|
||||
mLog.PrintError("Equals()", "unexpected charset name");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
@ -335,8 +335,8 @@ nsresult nsTestUConv::DisplayDetectors()
|
||||
return res;
|
||||
}
|
||||
|
||||
const PRUnichar * name;
|
||||
res = cs->GetUnicode(&name);
|
||||
nsAutoString name;
|
||||
res = cs->ToString(name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
@ -410,8 +410,8 @@ nsresult nsTestUConv::DisplayCharsets()
|
||||
return res;
|
||||
}
|
||||
|
||||
const PRUnichar * name;
|
||||
res = cs->GetUnicode(&name);
|
||||
nsAutoString name;
|
||||
res = cs->ToString(name);
|
||||
if (NS_FAILED(res)) {
|
||||
mLog.PrintError("get()", res);
|
||||
return res;
|
||||
|
@ -2250,6 +2250,16 @@ 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);
|
||||
@ -2261,10 +2271,10 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
|
||||
{
|
||||
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
|
||||
|
||||
const PRUnichar* atomString = nsnull;
|
||||
aAtom->GetUnicode(&atomString);
|
||||
const char* atomString = nsnull;
|
||||
aAtom->GetUTF8String(&atomString);
|
||||
|
||||
KeyAppendString(nsDependentString(atomString), aKey);
|
||||
KeyAppendString(nsDependentCString(atomString), aKey);
|
||||
}
|
||||
|
||||
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
|
||||
|
@ -2250,6 +2250,16 @@ 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);
|
||||
@ -2261,10 +2271,10 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsACString& aKey)
|
||||
{
|
||||
NS_PRECONDITION(aAtom, "KeyAppendAtom: aAtom can not be null!\n");
|
||||
|
||||
const PRUnichar* atomString = nsnull;
|
||||
aAtom->GetUnicode(&atomString);
|
||||
const char* atomString = nsnull;
|
||||
aAtom->GetUTF8String(&atomString);
|
||||
|
||||
KeyAppendString(nsDependentString(atomString), aKey);
|
||||
KeyAppendString(nsDependentCString(atomString), aKey);
|
||||
}
|
||||
|
||||
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
|
||||
|
@ -615,9 +615,6 @@ 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_) {
|
||||
@ -632,9 +629,12 @@ 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("[") + nsDependentString(attrName) +
|
||||
cssRule.Assign(NS_LITERAL_STRING("[") + 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("*[") + nsDependentString(attrName) +
|
||||
selector.Assign(NS_LITERAL_STRING("*[") + attrName +
|
||||
NS_LITERAL_STRING("=") + attrValue +
|
||||
NS_LITERAL_STRING("]"));
|
||||
PRInt32 k, count;
|
||||
|
@ -1569,9 +1569,10 @@ static PRBool IsTreePseudoElement(const nsString& aPseudo)
|
||||
|
||||
static PRBool IsTreePseudoElement(nsIAtom* aPseudo)
|
||||
{
|
||||
nsAutoString str;
|
||||
aPseudo->ToString(str);
|
||||
return Substring(str, 0, 11).Equals(NS_LITERAL_STRING(":-moz-tree-"));
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -584,8 +584,8 @@ PRInt32 nsCSSSelector::CalcWeight(void) const
|
||||
static PRBool IsPseudoElement(nsIAtom* aAtom)
|
||||
{
|
||||
if (aAtom) {
|
||||
const PRUnichar *str;
|
||||
aAtom->GetUnicode(&str);
|
||||
const char* str;
|
||||
aAtom->GetUTF8String(&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
|
||||
{
|
||||
const PRUnichar* temp;
|
||||
nsAutoString 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) {
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
@ -648,15 +648,16 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
} else {
|
||||
// Append the tag name, if there is one
|
||||
if (mTag) {
|
||||
mTag->GetUnicode(&temp);
|
||||
aString.Append(temp);
|
||||
nsAutoString prefix;
|
||||
mTag->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
NS_IF_NEGATED_END(aIsNegated, aString)
|
||||
}
|
||||
// Append the id, if there is one
|
||||
if (mIDList) {
|
||||
nsAtomList* list = mIDList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('#'));
|
||||
aString.Append(temp);
|
||||
@ -668,7 +669,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
if (mClassList) {
|
||||
nsAtomList* list = mClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(PRUnichar('.'));
|
||||
aString.Append(temp);
|
||||
@ -692,14 +693,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) {
|
||||
const PRUnichar* prefix;
|
||||
prefixAtom->GetUnicode(&prefix);
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
aString.Append(prefix);
|
||||
aString.Append(PRUnichar('|'));
|
||||
}
|
||||
}
|
||||
// Append the attribute name
|
||||
list->mAttr->GetUnicode(&temp);
|
||||
list->mAttr->ToString(temp);
|
||||
aString.Append(temp);
|
||||
// Append the function
|
||||
if (list->mFunction == NS_ATTR_FUNC_EQUALS) {
|
||||
@ -732,7 +733,7 @@ nsresult nsCSSSelector::ToString( nsAString& aString, nsICSSStyleSheet* aSheet,
|
||||
if (mPseudoClassList) {
|
||||
nsAtomStringList* list = mPseudoClassList;
|
||||
while (list != nsnull) {
|
||||
list->mAtom->GetUnicode(&temp);
|
||||
list->mAtom->ToString(temp);
|
||||
NS_IF_NEGATED_START(aIsNegated, aString)
|
||||
aString.Append(temp);
|
||||
if (nsnull != list->mString) {
|
||||
|
@ -168,12 +168,11 @@ RuleHash_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||
if (match_atom == entry_atom)
|
||||
return PR_TRUE;
|
||||
|
||||
const PRUnichar *match_str, *entry_str;
|
||||
match_atom->GetUnicode(&match_str);
|
||||
entry_atom->GetUnicode(&entry_str);
|
||||
const char *match_str, *entry_str;
|
||||
match_atom->GetUTF8String(&match_str);
|
||||
entry_atom->GetUTF8String(&entry_str);
|
||||
|
||||
return nsDependentString(match_str).Equals(nsDependentString(entry_str),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
return (nsCRT::strcasecmp(entry_str, match_str) == 0);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
@ -1116,8 +1115,8 @@ DOMMediaListImpl::GetText(nsAString& aMediaText)
|
||||
QueryElementAt(index++, NS_GET_IID(nsIAtom), getter_AddRefs(medium));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
aMediaText.Append(buffer);
|
||||
if (index < count) {
|
||||
aMediaText.Append(NS_LITERAL_STRING(", "));
|
||||
@ -1234,8 +1233,8 @@ DOMMediaListImpl::Item(PRUint32 aIndex, nsAString& aReturn)
|
||||
nsCOMPtr<nsIAtom> medium(do_QueryInterface(tmp));
|
||||
NS_ENSURE_TRUE(medium, NS_ERROR_FAILURE);
|
||||
|
||||
const PRUnichar *buffer;
|
||||
medium->GetUnicode(&buffer);
|
||||
nsAutoString buffer;
|
||||
medium->ToString(buffer);
|
||||
aReturn.Assign(buffer);
|
||||
} else {
|
||||
aReturn.Truncate();
|
||||
@ -3742,15 +3741,15 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
IDList = IDList->mNext;
|
||||
} while (IDList);
|
||||
} else {
|
||||
const PRUnichar* id1Str;
|
||||
data.mContentID->GetUnicode(&id1Str);
|
||||
nsDependentString id1(id1Str);
|
||||
const char* id1Str;
|
||||
data.mContentID->GetUTF8String(&id1Str);
|
||||
nsDependentCString id1(id1Str);
|
||||
do {
|
||||
const PRUnichar* id2Str;
|
||||
IDList->mAtom->GetUnicode(&id2Str);
|
||||
nsDependentString id2(id2Str);
|
||||
const char* id2Str;
|
||||
IDList->mAtom->GetUTF8String(&id2Str);
|
||||
nsDependentCString id2(id2Str);
|
||||
if (localTrue !=
|
||||
id1.Equals(id2, nsCaseInsensitiveStringComparator())) {
|
||||
id1.Equals(id2, nsCaseInsensitiveCStringComparator())) {
|
||||
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.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages") {
|
||||
if (property.toString() == "TotalMessages" || property.toString() == "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.GetUnicode();
|
||||
var eventType = event.toString();
|
||||
|
||||
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.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages") {
|
||||
if(property.toString() == "TotalMessages" || property.toString() == "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.GetUnicode();
|
||||
var eventType = event.toString();
|
||||
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.GetUnicode();
|
||||
var eventType = event.toString();
|
||||
|
||||
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.GetUnicode();
|
||||
|
||||
var eventType = event.toString();
|
||||
|
||||
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 PRUnichar *charsetName;
|
||||
res = charsetAtom->GetUnicode(&charsetName);
|
||||
const char *charsetName;
|
||||
res = charsetAtom->GetUTF8String(&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(NS_ConvertUCS2toUTF8(charsetName).get(),
|
||||
!nsCRT::strcmp(charsetName, NS_LITERAL_STRING("ISO-8859-1").get()) ?
|
||||
res = conv->Init(charsetName,
|
||||
!nsCRT::strcmp(charsetName, "ISO-8859-1") ?
|
||||
nsISaveAsCharset::attr_htmlTextDefault :
|
||||
nsISaveAsCharset::attr_EntityAfterCharsetConv + nsISaveAsCharset::attr_FallbackDecimalNCR,
|
||||
nsIEntityConverter::html32);
|
||||
else
|
||||
// fallback for text/plain: first try transliterate then '?'
|
||||
res = conv->Init(NS_ConvertUCS2toUTF8(charsetName).get(),
|
||||
res = conv->Init(charsetName,
|
||||
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, NS_LITERAL_STRING("ISO-2022-JP").get())) {
|
||||
if (!nsCRT::strcmp(charsetName, "ISO-2022-JP")) {
|
||||
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(NS_LossyConvertUCS2toASCII(charsetName).get()))
|
||||
!nsMsgI18Nstateful_charset(charsetName))
|
||||
*isAsciiOnly = nsCRT::IsAscii(*outString);
|
||||
|
||||
return res;
|
||||
|
@ -1439,7 +1439,7 @@ function UpdateMailEditCharset()
|
||||
|
||||
if (gCharsetConvertManager) {
|
||||
var charsetAtom = gCharsetConvertManager.GetCharsetAtom(compFieldsCharset);
|
||||
if (charsetAtom && (charsetAtom.GetUnicode() == "us-ascii"))
|
||||
if (charsetAtom && (charsetAtom.equals("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 PRUnichar *charsetName;
|
||||
charsetAtom->GetUnicode(&charsetName);
|
||||
strncpy(_charset, NS_ConvertUCS2toUTF8(charsetName).get(), sizeof(_charset)-1);
|
||||
const char *charsetName;
|
||||
charsetAtom->GetUTF8String(&charsetName);
|
||||
strncpy(_charset, charsetName, sizeof(_charset)-1);
|
||||
_charset[sizeof(_charset)-1] = '\0';
|
||||
if (_charset[0])
|
||||
charset = _charset;
|
||||
|
@ -2062,7 +2062,6 @@ 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);
|
||||
@ -2078,15 +2077,13 @@ nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, PRInt32 *fontPixel
|
||||
rv = charSetConverterManager2->GetCharsetLangGroup(charsetAtom,getter_AddRefs(langGroupAtom));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = langGroupAtom->GetUnicode(&langGroup);
|
||||
rv = langGroupAtom->ToUTF8String(fontLang);
|
||||
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.AppendWithConversion(langGroup);
|
||||
prefStr.Append(fontLang);
|
||||
rv = prefs->GetIntPref(prefStr.get(), fontPixelSize);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -44,11 +44,10 @@ NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
|
||||
{
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
|
||||
*aId = nsHTMLTags::LookupTag(nsDependentString(tagName));
|
||||
*aId = nsHTMLTags::LookupTag(tagName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -57,11 +56,10 @@ NS_IMETHODIMP
|
||||
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
||||
PRInt32* aId) const
|
||||
{
|
||||
const PRUnichar *tagName = nsnull;
|
||||
aAtom->GetUnicode(&tagName);
|
||||
NS_ASSERTION(tagName, "Null string in atom!");
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName);
|
||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1105,17 +1105,17 @@ RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes,
|
||||
nsAutoString v(aAttributes[1]);
|
||||
nsRDFParserUtils::StripAndConvert(v);
|
||||
|
||||
const PRUnichar* attrName;
|
||||
attr->GetUnicode(&attrName);
|
||||
const char* attrName;
|
||||
attr->GetUTF8String(&attrName);
|
||||
|
||||
nsCAutoString propertyStr;
|
||||
|
||||
if (nameSpaceURI) {
|
||||
propertyStr.Assign(nsDependentCString(nameSpaceURI) +
|
||||
NS_ConvertUCS2toUTF8(attrName));
|
||||
nsDependentCString(attrName));
|
||||
}
|
||||
else {
|
||||
propertyStr.Assign(NS_ConvertUCS2toUTF8(attrName));
|
||||
propertyStr.Assign(attrName);
|
||||
}
|
||||
|
||||
// Add the assertion to RDF
|
||||
@ -1256,10 +1256,10 @@ RDFContentSinkImpl::OpenObject(const PRUnichar* aName,
|
||||
if (nameSpaceURI)
|
||||
typeStr = nameSpaceURI;
|
||||
|
||||
const PRUnichar *attrName;
|
||||
tag->GetUnicode(&attrName);
|
||||
const char* attrName;
|
||||
tag->GetUTF8String(&attrName);
|
||||
|
||||
typeStr += NS_ConvertUCS2toUTF8(attrName);
|
||||
typeStr += 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 PRUnichar *attrName;
|
||||
tag->GetUnicode(&attrName);
|
||||
const char* attrName;
|
||||
tag->GetUTF8String(&attrName);
|
||||
|
||||
nsCAutoString propertyStr;
|
||||
if (nameSpaceURI) {
|
||||
propertyStr.Assign(nsDependentCString(nameSpaceURI) +
|
||||
NS_ConvertUCS2toUTF8(attrName));
|
||||
nsDependentCString(attrName));
|
||||
}
|
||||
else {
|
||||
propertyStr.Assign(NS_ConvertUCS2toUTF8(attrName));
|
||||
propertyStr.Assign(attrName);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
@ -1467,17 +1467,14 @@ RDFContentSinkImpl::GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) {
|
||||
nsAutoString prefixStr;
|
||||
const char* prefixStr;
|
||||
if (aPrefix)
|
||||
aPrefix->ToString(prefixStr);
|
||||
|
||||
char* prefixCStr = ToNewCString(prefixStr);
|
||||
aPrefix->GetUTF8String(&prefixStr);
|
||||
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml: undeclared namespace prefix '%s'",
|
||||
prefixCStr));
|
||||
prefixStr));
|
||||
|
||||
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 PRUnichar *pszAttributeName;
|
||||
const char *pszAttributeName;
|
||||
|
||||
if (NS_SUCCEEDED(content->GetAttrNameAt(index, nameSpaceID, *getter_AddRefs(nameAtom), *getter_AddRefs(prefixAtom)))) {
|
||||
aNameSpaceIDs[index] = NS_STATIC_CAST(short, nameSpaceID);
|
||||
nameAtom->GetUnicode(&pszAttributeName);
|
||||
aAttribNames[index] = ::SysAllocString(pszAttributeName);
|
||||
nameAtom->GetUTF8String(&pszAttributeName);
|
||||
aAttribNames[index] = ::SysAllocString(NS_ConvertUTF8toUCS2(pszAttributeName).get());
|
||||
if (NS_SUCCEEDED(content->GetAttr(nameSpaceID, nameAtom, attributeValue)))
|
||||
aAttribValues[index] = ::SysAllocString(attributeValue.get());
|
||||
}
|
||||
|
@ -37,10 +37,18 @@
|
||||
* ***** 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.
|
||||
@ -53,29 +61,117 @@
|
||||
*/
|
||||
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 {
|
||||
AtomImpl *mAtom;
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(const void *)
|
||||
AtomTableGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
AtomTableEntry *he = NS_STATIC_CAST(AtomTableEntry*, entry);
|
||||
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);
|
||||
NS_ASSERTION(he->HasValue(), "Empty atom. how did that happen?");
|
||||
return he->get();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
@ -84,33 +180,43 @@ AtomTableMatchKey(PLDHashTable *table,
|
||||
const void *key)
|
||||
{
|
||||
const AtomTableEntry *he = NS_STATIC_CAST(const AtomTableEntry*, entry);
|
||||
const PRUnichar* keyStr = NS_STATIC_CAST(const PRUnichar*, key);
|
||||
return nsCRT::strcmp(keyStr, he->mAtom->mString) == 0;
|
||||
const char* keyStr = NS_STATIC_CAST(const char*, key);
|
||||
return nsCRT::strcmp(keyStr, he->get()) == 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;
|
||||
|
||||
// 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;
|
||||
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();
|
||||
}
|
||||
|
||||
static PLDHashTableOps AtomTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
AtomTableGetKey,
|
||||
AtomTableHashKey,
|
||||
PL_DHashStringKey,
|
||||
AtomTableMatchKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
AtomTableClearEntry,
|
||||
@ -126,12 +232,16 @@ DumpAtomLeaks(PLDHashTable *table, PLDHashEntryHdr *he,
|
||||
PRUint32 index, void *arg)
|
||||
{
|
||||
AtomTableEntry *entry = NS_STATIC_CAST(AtomTableEntry*, he);
|
||||
AtomImpl* atom = entry->mAtom;
|
||||
|
||||
if (entry->IsStaticAtom())
|
||||
return PL_DHASH_NEXT;
|
||||
|
||||
AtomImpl* atom = entry->GetAtomImpl();
|
||||
if (!atom->IsPermanent()) {
|
||||
++*NS_STATIC_CAST(PRUint32*, arg);
|
||||
const PRUnichar *str;
|
||||
atom->GetUnicode(&str);
|
||||
fputs(NS_LossyConvertUCS2toASCII(str).get(), stdout);
|
||||
const char *str;
|
||||
atom->GetUTF8String(&str);
|
||||
fputs(str, stdout);
|
||||
fputs("\n", stdout);
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
@ -139,6 +249,20 @@ 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) {
|
||||
@ -153,6 +277,12 @@ void NS_PurgeAtomTable()
|
||||
#endif
|
||||
PL_DHashTableFinish(&gAtomTable);
|
||||
gAtomTable.entryCount = 0;
|
||||
|
||||
if (gStaticAtomArena) {
|
||||
PL_FinishArenaPool(gStaticAtomArena);
|
||||
delete gStaticAtomArena;
|
||||
gStaticAtomArena = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +330,7 @@ PermanentAtomImpl::IsPermanent()
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void* AtomImpl::operator new ( size_t size, const nsAString& aString ) CPP_THROW_NEW
|
||||
void* AtomImpl::operator new ( size_t size, const nsACString& aString ) CPP_THROW_NEW
|
||||
{
|
||||
/*
|
||||
Note: since the |size| will initially also include the |PRUnichar| member
|
||||
@ -211,12 +341,12 @@ void* AtomImpl::operator new ( size_t size, const nsAString& aString ) CPP_THROW
|
||||
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(PRUnichar);
|
||||
size += aString.Length() * sizeof(char);
|
||||
AtomImpl* ii = NS_STATIC_CAST(AtomImpl*, ::operator new(size));
|
||||
|
||||
PRUnichar* toBegin = &ii->mString[0];
|
||||
nsReadingIterator<PRUnichar> fromBegin, fromEnd;
|
||||
*copy_string(aString.BeginReading(fromBegin), aString.EndReading(fromEnd), toBegin) = PRUnichar(0);
|
||||
char* toBegin = &ii->mString[0];
|
||||
nsACString::const_iterator fromBegin, fromEnd;
|
||||
*copy_string(aString.BeginReading(fromBegin), aString.EndReading(fromEnd), toBegin) = '\0';
|
||||
return ii;
|
||||
}
|
||||
|
||||
@ -229,25 +359,102 @@ void* PermanentAtomImpl::operator new ( size_t size, AtomImpl* aAtom ) CPP_THROW
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::ToString(nsAString& aBuf) /*FIX: const */
|
||||
AtomImpl::ToString(nsAString& aBuf)
|
||||
{
|
||||
aBuf.Assign(NS_ConvertUTF8toUCS2(mString));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::ToUTF8String(nsACString& aBuf)
|
||||
{
|
||||
aBuf.Assign(mString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::GetUnicode(const PRUnichar **aResult) /*FIX: const */
|
||||
AtomImpl::GetUTF8String(const char **aResult)
|
||||
{
|
||||
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(NS_ConvertASCIItoUCS2(isolatin1));
|
||||
return NS_NewAtom(nsDependentCString(isolatin1));
|
||||
}
|
||||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1)
|
||||
@ -255,7 +462,27 @@ NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1)
|
||||
return NS_NewPermanentAtom(NS_ConvertASCIItoUCS2(isolatin1));
|
||||
}
|
||||
|
||||
static AtomTableEntry* GetAtomHashEntry(const nsAString& aString)
|
||||
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)
|
||||
{
|
||||
if ( !gAtomTable.entryCount )
|
||||
PL_DHashTableInit(&gAtomTable, &AtomTableOps, 0,
|
||||
@ -263,22 +490,73 @@ static AtomTableEntry* GetAtomHashEntry(const nsAString& aString)
|
||||
|
||||
return NS_STATIC_CAST(AtomTableEntry*,
|
||||
PL_DHashTableOperate(&gAtomTable,
|
||||
PromiseFlatString(aString).get(),
|
||||
aString,
|
||||
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 )
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(aString);
|
||||
AtomImpl* atom = he->mAtom;
|
||||
NS_ConvertUCS2toUTF8 utf8String(aString);
|
||||
|
||||
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) {
|
||||
atom = new (aString) AtomImpl();
|
||||
he->mAtom = atom;
|
||||
if (!atom) {
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
}
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_ADDREF(atom);
|
||||
@ -287,26 +565,30 @@ NS_COM nsIAtom* NS_NewAtom( const nsAString& aString )
|
||||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom( const nsAString& aString )
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(aString);
|
||||
AtomImpl* atom = he->mAtom;
|
||||
return NS_NewPermanentAtom(NS_ConvertUCS2toUTF8(aString));
|
||||
}
|
||||
|
||||
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()) {
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
{
|
||||
nsrefcnt refcount = atom->GetRefCount();
|
||||
do {
|
||||
NS_LOG_RELEASE(atom, --refcount, "AtomImpl");
|
||||
} while (refcount);
|
||||
}
|
||||
#endif
|
||||
atom = new (atom) PermanentAtomImpl();
|
||||
PromoteToPermanent(atom);
|
||||
}
|
||||
} else {
|
||||
// otherwise, make a new atom
|
||||
atom = new (aString) PermanentAtomImpl();
|
||||
he->mAtom = atom;
|
||||
he->SetAtomImpl(atom);
|
||||
if ( !atom ) {
|
||||
PL_DHashTableRawRemove(&gAtomTable, he);
|
||||
return nsnull;
|
||||
@ -319,7 +601,7 @@ NS_COM nsIAtom* NS_NewPermanentAtom( const nsAString& aString )
|
||||
|
||||
NS_COM nsIAtom* NS_NewAtom( const PRUnichar* str )
|
||||
{
|
||||
return NS_NewAtom(nsDependentString(str));
|
||||
return NS_NewAtom(NS_ConvertUCS2toUTF8(str));
|
||||
}
|
||||
|
||||
NS_COM nsIAtom* NS_NewPermanentAtom( const PRUnichar* str )
|
||||
@ -331,3 +613,4 @@ NS_COM nsrefcnt NS_GetNumberOfAtoms(void)
|
||||
{
|
||||
return gAtomTable.entryCount;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
virtual PRBool IsPermanent();
|
||||
|
||||
void* operator new(size_t size, const nsAString& aString) CPP_THROW_NEW;
|
||||
void* operator new(size_t size, const nsACString& 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.
|
||||
PRUnichar mString[1];
|
||||
char mString[1];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -84,7 +84,7 @@ public:
|
||||
|
||||
virtual PRBool IsPermanent();
|
||||
|
||||
void* operator new(size_t size, const nsAString& aString) CPP_THROW_NEW {
|
||||
void* operator new(size_t size, const nsACString& aString) CPP_THROW_NEW {
|
||||
return AtomImpl::operator new(size, aString);
|
||||
}
|
||||
void* operator new(size_t size, AtomImpl* aAtom) CPP_THROW_NEW;
|
||||
|
@ -38,14 +38,39 @@
|
||||
interface nsIAtom : nsISupports
|
||||
{
|
||||
/**
|
||||
* Translate the unicode string into the stringbuf.
|
||||
* Get the Unicode or UTF8 value for the string
|
||||
*/
|
||||
[noscript] AString toString();
|
||||
|
||||
AString toString();
|
||||
AUTF8String toUTF8String();
|
||||
|
||||
/**
|
||||
* Return a pointer to a zero terminated unicode string.
|
||||
* Return a pointer to a zero terminated UTF8 string.
|
||||
*/
|
||||
void GetUnicode([shared, retval] out wstring aResult);
|
||||
[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;
|
||||
}
|
||||
%}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -71,13 +96,20 @@ 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* isolatin1);
|
||||
extern NS_COM nsIAtom* NS_NewPermanentAtom(const char* isolatin1);
|
||||
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);
|
||||
|
||||
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); }
|
||||
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); }
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given unicode string. The string is assumed
|
||||
|
@ -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 PRUnichar *unicodeString;
|
||||
ids[i]->GetUnicode(&unicodeString);
|
||||
nsIAtom* id = NS_NewAtom(unicodeString);
|
||||
const char *utf8String;
|
||||
ids[i]->GetUTF8String(&utf8String);
|
||||
nsIAtom* id = NS_NewAtom(utf8String);
|
||||
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 nsAString& aString)
|
||||
static void AssertString(nsIAtom *aAtom, const nsACString& aString)
|
||||
{
|
||||
const PRUnichar *str;
|
||||
NS_STATIC_CAST(AtomImpl*,aAtom)->GetUnicode(&str);
|
||||
Assert(nsDependentString(str) == aString, "string is correct");
|
||||
const char *str;
|
||||
NS_STATIC_CAST(AtomImpl*,aAtom)->GetUTF8String(&str);
|
||||
Assert(nsDependentCString(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_STRING("foo"));
|
||||
AssertString(foo, NS_LITERAL_CSTRING("foo"));
|
||||
AssertPermanence(foo, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIAtom> foop = do_GetPermanentAtom("foo");
|
||||
AssertString(foop, NS_LITERAL_STRING("foo"));
|
||||
AssertString(foop, NS_LITERAL_CSTRING("foo"));
|
||||
AssertPermanence(foop, PR_TRUE);
|
||||
|
||||
Assert(foo == foop, "atoms are equal");
|
||||
|
||||
nsCOMPtr<nsIAtom> barp = do_GetPermanentAtom("bar");
|
||||
AssertString(barp, NS_LITERAL_STRING("bar"));
|
||||
AssertString(barp, NS_LITERAL_CSTRING("bar"));
|
||||
AssertPermanence(barp, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIAtom> bar = do_GetAtom("bar");
|
||||
AssertString(bar, NS_LITERAL_STRING("bar"));
|
||||
AssertString(bar, NS_LITERAL_CSTRING("bar"));
|
||||
AssertPermanence(bar, PR_TRUE);
|
||||
|
||||
Assert(bar == barp, "atoms are equal");
|
||||
|
Loading…
Reference in New Issue
Block a user