Bug 711841, Null(C)String(), r=bsmedberg,glandium

This commit is contained in:
Olli Pettay 2011-12-20 21:46:00 +02:00
parent 6e8b839d73
commit c35f7bb3a9
8 changed files with 26 additions and 20 deletions

View File

@ -1402,11 +1402,9 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(true);
return NS_NewDOMDocumentType(aReturn, mOwner->NodeInfoManager(),
name, aPublicId,
aSystemId, voidString);
aSystemId, NullString());
}
NS_IMETHODIMP
@ -1461,14 +1459,12 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
nsCOMPtr<nsIDOMDocumentType> doctype;
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(true);
nsresult rv = NS_NewDOMDocumentType(getter_AddRefs(doctype),
mOwner->NodeInfoManager(),
nsGkAtoms::html, // aName
EmptyString(), // aPublicId
EmptyString(), // aSystemId
voidString); // aInternalSubset
NullString()); // aInternalSubset
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -24,6 +24,7 @@ function checkDoc(title, expectedtitle, normalizedtitle) {
is(doc.doctype.name, "html");
is(doc.doctype.publicId, "");
is(doc.doctype.systemId, "");
is(doc.doctype.internalSubset, null, "internalSubset should be null!");
isElement(doc.documentElement, "html");
isElement(doc.documentElement.firstChild, "head");
is(doc.documentElement.firstChild.childNodes.length, 1);

View File

@ -77,10 +77,7 @@ Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
return JS_FALSE;
}
nsString voidStr;
voidStr.SetIsVoid(true);
rv = (self->*setfunc)(voidStr, arg0);
rv = (self->*setfunc)(NullString(), arg0);
}
if (NS_FAILED(rv))

View File

@ -2453,11 +2453,9 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
}
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(true);
rv = NS_NewDOMDocumentType(getter_AddRefs(docType),
mDocument->NodeInfoManager(), nameAtom,
publicId, systemId, voidString);
publicId, systemId, NullString());
NS_ENSURE_SUCCESS(rv, rv);
if (oldDocType) {

View File

@ -936,14 +936,12 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID
}
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(true);
rv = NS_NewDOMDocumentType(getter_AddRefs(documentType),
mNodeInfoManager,
doctypeName,
mOutputFormat.mPublicId,
mOutputFormat.mSystemId,
voidString);
NullString());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> docType = do_QueryInterface(documentType);

View File

@ -734,12 +734,9 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin,
rv = fileManagerDirectory->Append(dbBaseFilename);
NS_ENSURE_SUCCESS(rv, rv);
nsString voidString;
voidString.SetIsVoid(true);
nsCOMPtr<mozIStorageConnection> connection;
rv = OpenDatabaseHelper::CreateDatabaseConnection(
voidString, file, fileManagerDirectory, getter_AddRefs(connection));
NullString(), file, fileManagerDirectory, getter_AddRefs(connection));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<mozIStorageStatement> stmt;

View File

@ -368,6 +368,9 @@ StringEndsWith( const nsACString& aSource, const nsACString& aSubstring,
const nsAFlatString& EmptyString();
const nsAFlatCString& EmptyCString();
const nsAFlatString& NullString();
const nsAFlatCString& NullCString();
/**
* Compare a UTF-8 string to an UTF-16 string.
*

View File

@ -1046,6 +1046,22 @@ EmptyCString()
return sEmpty;
}
const nsAFlatString&
NullString()
{
static const nsXPIDLString sNull;
return sNull;
}
const nsAFlatCString&
NullCString()
{
static const nsXPIDLCString sNull;
return sNull;
}
PRInt32
CompareUTF8toUTF16(const nsASingleFragmentCString& aUTF8String,
const nsASingleFragmentString& aUTF16String)