mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 859817 - Make NS_NewAtom return already_AddRefed; r=bz
This commit is contained in:
parent
eecc44edc5
commit
e0a4cd5848
@ -1229,9 +1229,9 @@ nsAttrValue::ParseAtom(const nsAString& aValue)
|
||||
{
|
||||
ResetIfSet();
|
||||
|
||||
nsIAtom* atom = NS_NewAtom(aValue);
|
||||
nsCOMPtr<nsIAtom> atom = NS_NewAtom(aValue);
|
||||
if (atom) {
|
||||
SetPtrValueAndType(atom, eAtomBase);
|
||||
SetPtrValueAndType(atom.forget().get(), eAtomBase);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1712,9 +1712,10 @@ nsAttrValue::SetMiscAtomOrString(const nsAString* aValue)
|
||||
"Empty string?");
|
||||
MiscContainer* cont = GetMiscContainer();
|
||||
if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
|
||||
nsIAtom* atom = NS_NewAtom(*aValue);
|
||||
nsCOMPtr<nsIAtom> atom = NS_NewAtom(*aValue);
|
||||
if (atom) {
|
||||
cont->mStringBits = reinterpret_cast<uintptr_t>(atom) | eAtomBase;
|
||||
cont->mStringBits =
|
||||
reinterpret_cast<uintptr_t>(atom.forget().get()) | eAtomBase;
|
||||
}
|
||||
} else {
|
||||
nsStringBuffer* buf = GetStringBuffer(*aValue);
|
||||
|
@ -2535,11 +2535,11 @@ nsContentUtils::SplitQName(const nsIContent* aNamespaceResolver,
|
||||
if (*aNamespace == kNameSpaceID_Unknown)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aLocalName = NS_NewAtom(Substring(colon + 1, end));
|
||||
*aLocalName = NS_NewAtom(Substring(colon + 1, end)).get();
|
||||
}
|
||||
else {
|
||||
*aNamespace = kNameSpaceID_None;
|
||||
*aLocalName = NS_NewAtom(aQName);
|
||||
*aLocalName = NS_NewAtom(aQName).get();
|
||||
}
|
||||
NS_ENSURE_TRUE(aLocalName, NS_ERROR_OUT_OF_MEMORY);
|
||||
return NS_OK;
|
||||
@ -2624,7 +2624,7 @@ nsContentUtils::SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
nameStart = (uriEnd + 1);
|
||||
if (nameEnd) {
|
||||
const PRUnichar *prefixStart = nameEnd + 1;
|
||||
*aPrefix = NS_NewAtom(Substring(prefixStart, pos));
|
||||
*aPrefix = NS_NewAtom(Substring(prefixStart, pos)).get();
|
||||
}
|
||||
else {
|
||||
nameEnd = pos;
|
||||
@ -2637,7 +2637,7 @@ nsContentUtils::SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
nameEnd = pos;
|
||||
*aPrefix = nullptr;
|
||||
}
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd));
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).get();
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -85,7 +85,7 @@ SVGTransformListParser::GetTransformToken(nsIAtom** aKeyAtom,
|
||||
|
||||
uint32_t len;
|
||||
if ((len = strlen(mTokenPos)) > 0) {
|
||||
*aKeyAtom = NS_NewAtom(Substring(mTokenPos, mTokenPos + len));
|
||||
*aKeyAtom = NS_NewAtom(Substring(mTokenPos, mTokenPos + len)).get();
|
||||
|
||||
if (aAdvancePos) {
|
||||
mInputPos = mTokenPos + len;
|
||||
|
@ -88,7 +88,7 @@ XMLUtils::splitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
nameStart = (uriEnd + 1);
|
||||
if (nameEnd) {
|
||||
const PRUnichar *prefixStart = nameEnd + 1;
|
||||
*aPrefix = NS_NewAtom(Substring(prefixStart, pos));
|
||||
*aPrefix = NS_NewAtom(Substring(prefixStart, pos)).get();
|
||||
if (!*aPrefix) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -105,7 +105,7 @@ XMLUtils::splitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
*aPrefix = nullptr;
|
||||
}
|
||||
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd));
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).get();
|
||||
|
||||
return *aLocalName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -125,12 +125,12 @@ XMLUtils::splitQName(const nsAString& aName, nsIAtom** aPrefix,
|
||||
const PRUnichar *end;
|
||||
qName.EndReading(end);
|
||||
|
||||
*aPrefix = NS_NewAtom(Substring(qName.get(), colon));
|
||||
*aLocalName = NS_NewAtom(Substring(colon + 1, end));
|
||||
*aPrefix = NS_NewAtom(Substring(qName.get(), colon)).get();
|
||||
*aLocalName = NS_NewAtom(Substring(colon + 1, end)).get();
|
||||
}
|
||||
else {
|
||||
*aPrefix = nullptr;
|
||||
*aLocalName = NS_NewAtom(aName);
|
||||
*aLocalName = NS_NewAtom(aName).get();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -893,12 +893,12 @@ txExprParser::resolveQName(const nsAString& aQName,
|
||||
aNamespace = kNameSpaceID_None;
|
||||
int32_t idx = aQName.FindChar(':');
|
||||
if (idx > 0) {
|
||||
*aPrefix = NS_NewAtom(StringHead(aQName, (uint32_t)idx));
|
||||
*aPrefix = NS_NewAtom(StringHead(aQName, (uint32_t)idx)).get();
|
||||
if (!*aPrefix) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aLocalName = NS_NewAtom(Substring(aQName, (uint32_t)idx + 1,
|
||||
aQName.Length() - (idx + 1)));
|
||||
aQName.Length() - (idx + 1))).get();
|
||||
if (!*aLocalName) {
|
||||
NS_RELEASE(*aPrefix);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -910,10 +910,10 @@ txExprParser::resolveQName(const nsAString& aQName,
|
||||
if (aIsNameTest && aContext->caseInsensitiveNameTests()) {
|
||||
nsAutoString lcname;
|
||||
nsContentUtils::ASCIIToLower(aQName, lcname);
|
||||
*aLocalName = NS_NewAtom(lcname);
|
||||
*aLocalName = NS_NewAtom(lcname).get();
|
||||
}
|
||||
else {
|
||||
*aLocalName = NS_NewAtom(aQName);
|
||||
*aLocalName = NS_NewAtom(aQName).get();
|
||||
}
|
||||
if (!*aLocalName) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -304,7 +304,7 @@ getAtomAttr(txStylesheetAttr* aAttributes,
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aAtom = NS_NewAtom(attr->mValue);
|
||||
*aAtom = NS_NewAtom(attr->mValue).get();
|
||||
NS_ENSURE_TRUE(*aAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2138,7 +2138,7 @@ nsXULTemplateBuilder::DetermineRDFQueryRef(nsIContent* aQueryElement, nsIAtom**
|
||||
content->GetAttr(kNameSpaceID_None, nsGkAtoms::tag, tag);
|
||||
|
||||
if (!tag.IsEmpty())
|
||||
*aTag = NS_NewAtom(tag);
|
||||
*aTag = NS_NewAtom(tag).get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -706,7 +706,7 @@ nsHTMLCSSUtils::ParseLength(const nsAString & aString, float * aValue, nsIAtom *
|
||||
i++;
|
||||
}
|
||||
*aValue = value * sign;
|
||||
*aUnit = NS_NewAtom(StringTail(aString, j-i));
|
||||
*aUnit = NS_NewAtom(StringTail(aString, j-i)).get();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -354,7 +354,7 @@ nsCharsetConverterManager::GetCharsetLangGroupRaw(const char * aCharset,
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ToLowerCase(langGroup); // use lowercase for all language atoms
|
||||
*aResult = NS_NewAtom(langGroup);
|
||||
*aResult = NS_NewAtom(langGroup).get();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -734,12 +734,10 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
|
||||
return false;
|
||||
}
|
||||
uint32_t length = JS_GetStringLength(str);
|
||||
nsIAtom* atom = NS_NewAtom(nsDependentSubstring(chars,
|
||||
chars + length));
|
||||
if (!atom && pErr)
|
||||
*pErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
*((nsISupports**)d) = atom;
|
||||
return atom != nullptr;
|
||||
nsCOMPtr<nsIAtom> atom =
|
||||
NS_NewAtom(nsDependentSubstring(chars, chars + length));
|
||||
atom.forget((nsISupports**)d);
|
||||
return true;
|
||||
}
|
||||
//else ...
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsHtml5Atom.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
|
||||
{
|
||||
|
@ -1347,7 +1347,7 @@ RDFContentSinkImpl::SplitExpatName(const PRUnichar *aExpatName,
|
||||
}
|
||||
|
||||
const nsDependentSubstring& nameSpaceURI = Substring(aExpatName, uriEnd);
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, pos));
|
||||
*aLocalName = NS_NewAtom(Substring(nameStart, pos)).get();
|
||||
return nameSpaceURI;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ nsAtomService::nsAtomService()
|
||||
nsresult
|
||||
nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult)
|
||||
{
|
||||
*aResult = NS_NewAtom(aString);
|
||||
*aResult = NS_NewAtom(aString).get();
|
||||
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -36,7 +36,7 @@ nsAtomService::GetPermanentAtom(const nsAString& aString, nsIAtom ** aResult)
|
||||
NS_IMETHODIMP
|
||||
nsAtomService::GetAtomUTF8(const char *aValue, nsIAtom* *aResult)
|
||||
{
|
||||
*aResult = NS_NewAtom(aValue);
|
||||
*aResult = NS_NewAtom(aValue).get();
|
||||
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -616,23 +616,22 @@ RegisterStaticAtoms(const nsStaticAtom* aAtoms, uint32_t aAtomCount)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
already_AddRefed<nsIAtom>
|
||||
NS_NewAtom(const char* aUTF8String)
|
||||
{
|
||||
return NS_NewAtom(nsDependentCString(aUTF8String));
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
already_AddRefed<nsIAtom>
|
||||
NS_NewAtom(const nsACString& aUTF8String)
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(aUTF8String.Data(),
|
||||
aUTF8String.Length());
|
||||
|
||||
if (he->mAtom) {
|
||||
nsIAtom* atom;
|
||||
NS_ADDREF(atom = he->mAtom);
|
||||
nsCOMPtr<nsIAtom> atom = he->mAtom;
|
||||
|
||||
return atom;
|
||||
return atom.forget();
|
||||
}
|
||||
|
||||
// This results in an extra addref/release of the nsStringBuffer.
|
||||
@ -640,38 +639,35 @@ NS_NewAtom(const nsACString& aUTF8String)
|
||||
// Actually, now there is, sort of: ForgetSharedBuffer.
|
||||
nsString str;
|
||||
CopyUTF8toUTF16(aUTF8String, str);
|
||||
AtomImpl* atom = new AtomImpl(str, he->keyHash);
|
||||
nsRefPtr<AtomImpl> atom = new AtomImpl(str, he->keyHash);
|
||||
|
||||
he->mAtom = atom;
|
||||
NS_ADDREF(atom);
|
||||
|
||||
return atom;
|
||||
return atom.forget();
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
already_AddRefed<nsIAtom>
|
||||
NS_NewAtom(const PRUnichar* aUTF16String)
|
||||
{
|
||||
return NS_NewAtom(nsDependentString(aUTF16String));
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
already_AddRefed<nsIAtom>
|
||||
NS_NewAtom(const nsAString& aUTF16String)
|
||||
{
|
||||
AtomTableEntry *he = GetAtomHashEntry(aUTF16String.Data(),
|
||||
aUTF16String.Length());
|
||||
|
||||
if (he->mAtom) {
|
||||
nsIAtom* atom;
|
||||
NS_ADDREF(atom = he->mAtom);
|
||||
nsCOMPtr<nsIAtom> atom = he->mAtom;
|
||||
|
||||
return atom;
|
||||
return atom.forget();
|
||||
}
|
||||
|
||||
AtomImpl* atom = new AtomImpl(aUTF16String, he->keyHash);
|
||||
nsRefPtr<AtomImpl> atom = new AtomImpl(aUTF16String, he->keyHash);
|
||||
he->mAtom = atom;
|
||||
NS_ADDREF(atom);
|
||||
|
||||
return atom;
|
||||
return atom.forget();
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
|
@ -99,7 +99,7 @@ protected:
|
||||
* Find an atom that matches the given UTF-8 string.
|
||||
* The string is assumed to be zero terminated. Never returns null.
|
||||
*/
|
||||
extern nsIAtom* NS_NewAtom(const char* aUTF8String);
|
||||
extern already_AddRefed<nsIAtom> NS_NewAtom(const char* aUTF8String);
|
||||
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const char* aUTF8String)
|
||||
{ return NS_NewAtom(aUTF8String); }
|
||||
@ -107,7 +107,7 @@ inline already_AddRefed<nsIAtom> do_GetAtom(const char* aUTF8String)
|
||||
/**
|
||||
* Find an atom that matches the given UTF-8 string. Never returns null.
|
||||
*/
|
||||
extern nsIAtom* NS_NewAtom(const nsACString& aUTF8String);
|
||||
extern already_AddRefed<nsIAtom> NS_NewAtom(const nsACString& aUTF8String);
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const nsACString& aUTF8String)
|
||||
{ return NS_NewAtom(aUTF8String); }
|
||||
|
||||
@ -115,14 +115,14 @@ inline already_AddRefed<nsIAtom> do_GetAtom(const nsACString& aUTF8String)
|
||||
* Find an atom that matches the given UTF-16 string.
|
||||
* The string is assumed to be zero terminated. Never returns null.
|
||||
*/
|
||||
extern nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String);
|
||||
extern already_AddRefed<nsIAtom> NS_NewAtom(const PRUnichar* aUTF16String);
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const PRUnichar* aUTF16String)
|
||||
{ return NS_NewAtom(aUTF16String); }
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given UTF-16 string. Never returns null.
|
||||
*/
|
||||
extern nsIAtom* NS_NewAtom(const nsAString& aUTF16String);
|
||||
extern already_AddRefed<nsIAtom> NS_NewAtom(const nsAString& aUTF16String);
|
||||
extern nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String);
|
||||
inline already_AddRefed<nsIAtom> do_GetAtom(const nsAString& aUTF16String)
|
||||
{ return NS_NewAtom(aUTF16String); }
|
||||
|
Loading…
Reference in New Issue
Block a user