if you want a pointer to the characters, your going to have to |.get()| it

This commit is contained in:
scc%mozilla.org 2000-09-13 04:47:36 +00:00
Родитель 3bc4518070
Коммит 983223fbc2
13 изменённых файлов: 14 добавлений и 451 удалений

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

@ -1083,7 +1083,7 @@ NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsAReadableString& aChar
for (PRInt32 i = 0; i < n; i++) {
nsIObserver* observer = (nsIObserver*) mCharSetObservers.ElementAt(i);
observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset").get(),
nsPromiseFlatString(aCharSetID));
nsPromiseFlatString(aCharSetID).get());
}
}
return NS_OK;

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

@ -347,7 +347,8 @@ nsNodeInfo::NamespaceEquals(const nsAReadableString& aNamespaceURI)
NS_IMETHODIMP_(PRBool)
nsNodeInfo::QualifiedNameEquals(const nsAReadableString& aQualifiedName)
{
const PRUnichar *qname = nsPromiseFlatString(aQualifiedName);
nsPromiseFlatString flatName(aQualifiedName);
const PRUnichar *qname = flatName.get();
PRUint32 i = 0;
if (mInner.mPrefix) {

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

@ -345,7 +345,7 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::suppress) {
if (nsCRT::strcasecmp(nsPromiseFlatString(aValue), NS_LITERAL_STRING("true").get())) {
if (nsCRT::strcasecmp(nsPromiseFlatString(aValue).get(), NS_LITERAL_STRING("true").get())) {
aResult.SetEmptyValue(); // XXX? shouldn't just leave "true"
return NS_CONTENT_ATTR_HAS_VALUE;
}

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

@ -419,7 +419,7 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, const nsAReadableS
return rv;
// Load the binding doc.
nsCString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL));
nsCString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL).get());
nsCOMPtr<nsIXBLDocumentInfo> info;
xblService->LoadBindingDocumentInfo(nsnull, aBoundDoc, url, nsCAutoString(), PR_TRUE, getter_AddRefs(info));
if (!info)

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

@ -618,7 +618,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsAReadableString& aURL,
// See if the URIs match.
nsCAutoString uri;
styleBinding->GetBindingURI(uri);
if (uri.EqualsWithConversion((const PRUnichar *) nsPromiseFlatString(aURL)))
if (uri.EqualsWithConversion((const PRUnichar *) nsPromiseFlatString(aURL).get()))
return NS_OK;
else {
FlushStyleBindings(aContent);

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

@ -91,7 +91,7 @@ nsPresState::SetStateProperty(const nsAReadableString& aName, const nsAReadableS
nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_WSTRING_PROGID, nsnull,
NS_GET_IID(nsISupportsWString), getter_AddRefs(supportsStr));
supportsStr->SetData(nsPromiseFlatString(aValue));
supportsStr->SetData(nsPromiseFlatString(aValue).get());
mPropertyTable->Put(&key, supportsStr);
return NS_OK;

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

@ -1083,7 +1083,7 @@ NS_IMETHODIMP nsDocument::SetDocumentCharacterSet(const nsAReadableString& aChar
for (PRInt32 i = 0; i < n; i++) {
nsIObserver* observer = (nsIObserver*) mCharSetObservers.ElementAt(i);
observer->Observe((nsIDocument*) this, NS_LITERAL_STRING("charset").get(),
nsPromiseFlatString(aCharSetID));
nsPromiseFlatString(aCharSetID).get());
}
}
return NS_OK;

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

@ -1,438 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsNodeInfo.h"
#include "nsNodeInfoManager.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIAtom.h"
#include "nsINameSpaceManager.h"
nsNodeInfo::nsNodeInfo()
: mInner(), mOwnerManager(nsnull)
{
NS_INIT_REFCNT();
}
nsNodeInfo::~nsNodeInfo()
{
if (mOwnerManager) {
mOwnerManager->RemoveNodeInfo(this);
NS_RELEASE(mOwnerManager);
}
NS_IF_RELEASE(mInner.mName);
NS_IF_RELEASE(mInner.mPrefix);
}
nsresult
nsNodeInfo::Init(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
nsNodeInfoManager *aOwnerManager)
{
NS_ENSURE_TRUE(!mInner.mName && !mInner.mPrefix && !mOwnerManager,
NS_ERROR_ALREADY_INITIALIZED);
NS_ENSURE_ARG_POINTER(aName);
NS_ENSURE_ARG_POINTER(aOwnerManager);
mInner.mName = aName;
NS_ADDREF(mInner.mName);
mInner.mPrefix = aPrefix;
NS_IF_ADDREF(mInner.mPrefix);
mInner.mNamespaceID = aNamespaceID;
mOwnerManager = aOwnerManager;
NS_ADDREF(mOwnerManager);
return NS_OK;
}
// nsISupports
NS_IMPL_THREADSAFE_ISUPPORTS(nsNodeInfo, NS_GET_IID(nsINodeInfo));
// nsINodeInfo
NS_IMETHODIMP
nsNodeInfo::GetName(nsAWritableString& aName)
{
NS_ENSURE_TRUE(mInner.mName, NS_ERROR_NOT_INITIALIZED);
return mInner.mName->ToString(aName);
}
NS_IMETHODIMP
nsNodeInfo::GetNameAtom(nsIAtom*& aAtom)
{
NS_ABORT_IF_FALSE(mInner.mName, "nsNodeInfo not initialized!");
aAtom = mInner.mName;
NS_IF_ADDREF(aAtom);
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetQualifiedName(nsAWritableString& aQualifiedName)
{
NS_ENSURE_TRUE(mInner.mName, NS_ERROR_NOT_INITIALIZED);
if (mInner.mPrefix) {
mInner.mPrefix->ToString(aQualifiedName);
aQualifiedName.Append(PRUnichar(':'));
}
const PRUnichar *name;
mInner.mName->GetUnicode(&name);
aQualifiedName.Append(name);
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetLocalName(nsAWritableString& aLocalName)
{
NS_ENSURE_TRUE(mInner.mName, NS_ERROR_NOT_INITIALIZED);
#ifdef STRICT_DOM_LEVEL2_LOCALNAME
if (mInner.mNamespaceID > 0) {
return mInner.mName->ToString(aLocalName);
}
aLocalName.Truncate();
return NS_OK;
#else
return mInner.mName->ToString(aLocalName);
#endif
}
NS_IMETHODIMP
nsNodeInfo::GetPrefix(nsAWritableString& aPrefix)
{
if (mInner.mPrefix) {
mInner.mPrefix->ToString(aPrefix);
} else {
aPrefix.Truncate();
}
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetPrefixAtom(nsIAtom*& aAtom)
{
aAtom = mInner.mPrefix;
NS_IF_ADDREF(aAtom);
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetNamespaceURI(nsAWritableString& aNameSpaceURI)
{
NS_ENSURE_TRUE(mOwnerManager, NS_ERROR_NOT_INITIALIZED);
nsresult rv = NS_OK;
if (mInner.mNamespaceID > 0) {
nsCOMPtr<nsINameSpaceManager> nsm;
mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsm));
NS_ENSURE_TRUE(nsm, NS_ERROR_NOT_INITIALIZED);
rv = nsm->GetNameSpaceURI(mInner.mNamespaceID, aNameSpaceURI);
} else {
aNameSpaceURI.Truncate();
}
return rv;
}
NS_IMETHODIMP
nsNodeInfo::GetNamespaceID(PRInt32& aResult)
{
aResult = mInner.mNamespaceID;
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetIDAttributeAtom(nsIAtom** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mInner.mIDAttributeAtom;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::SetIDAttributeAtom(nsIAtom* aID)
{
NS_ENSURE_ARG(aID);
mInner.mIDAttributeAtom = aID;
return NS_OK;
}
NS_IMETHODIMP
nsNodeInfo::GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager)
{
NS_ENSURE_TRUE(mOwnerManager, NS_ERROR_NOT_INITIALIZED);
aNodeInfoManager = mOwnerManager;
NS_ADDREF(aNodeInfoManager);
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(nsINodeInfo *aNodeInfo)
{
NS_ENSURE_ARG_POINTER(aNodeInfo);
return aNodeInfo->Equals(mInner.mName, mInner.mPrefix, mInner.mNamespaceID);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(nsIAtom *aNameAtom)
{
return mInner.mName == aNameAtom;
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(const nsAReadableString& aName)
{
if (!mInner.mName) return PR_FALSE;
const PRUnichar *name;
mInner.mName->GetUnicode(&name);
return aName.Equals(name);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom)
{
return (mInner.mName == aNameAtom) && (mInner.mPrefix == aPrefixAtom);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(const nsAReadableString& aName, const nsAReadableString& aPrefix)
{
if (!mInner.mName) return PR_FALSE;
const PRUnichar *name, *prefix = nsnull;
mInner.mName->GetUnicode(&name);
if (mInner.mPrefix)
mInner.mPrefix->GetUnicode(&prefix);
return aName.Equals(name) && aPrefix.Equals(prefix);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(nsIAtom *aNameAtom, PRInt32 aNamespaceID)
{
return (mInner.mName == aNameAtom) && (mInner.mNamespaceID == aNamespaceID);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(const nsAReadableString& aName, PRInt32 aNamespaceID)
{
if (!mInner.mName) return PR_FALSE;
const PRUnichar *name;
mInner.mName->GetUnicode(&name);
return aName.Equals(name) && (mInner.mNamespaceID == aNamespaceID);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom,
PRInt32 aNamespaceID)
{
return (mInner.mName == aNameAtom) &&
(mInner.mPrefix == aPrefixAtom) &&
(mInner.mNamespaceID == aNamespaceID);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::Equals(const nsAReadableString& aName, const nsAReadableString& aPrefix,
PRInt32 aNamespaceID)
{
if (!mInner.mName) return PR_FALSE;
const PRUnichar *name, *prefix = nsnull;
mInner.mName->GetUnicode(&name);
if (mInner.mPrefix)
mInner.mPrefix->GetUnicode(&prefix);
return aName.Equals(name) && aPrefix.Equals(prefix) &&
(mInner.mNamespaceID == aNamespaceID);
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::NamespaceEquals(PRInt32 aNamespaceID)
{
return mInner.mNamespaceID == aNamespaceID;
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::NamespaceEquals(const nsAReadableString& aNamespaceURI)
{
NS_ENSURE_TRUE(mOwnerManager, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsINameSpaceManager> nsmgr;
NS_ENSURE_SUCCESS(mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsmgr)),
NS_ERROR_NOT_INITIALIZED);
PRInt32 nsid;
nsmgr->GetNameSpaceID(aNamespaceURI, nsid);
return mInner.mNamespaceID == nsid;
}
NS_IMETHODIMP_(PRBool)
nsNodeInfo::QualifiedNameEquals(const nsAReadableString& aQualifiedName)
{
const PRUnichar *qname = nsPromiseFlatString(aQualifiedName);
PRUint32 i = 0;
if (mInner.mPrefix) {
const PRUnichar *prefix;
mInner.mPrefix->GetUnicode(&prefix);
i = nsCRT::strlen(prefix);
if (nsCRT::strncmp(qname, prefix, i))
return PR_FALSE;
if (*(qname + i) != PRUnichar(':'))
return PR_FALSE;
i++;
}
const PRUnichar *name;
mInner.mName->GetUnicode(&name);
if (nsCRT::strcmp(qname + i, name))
return PR_FALSE;
return PR_TRUE;
}
NS_IMETHODIMP
nsNodeInfo::NameChanged(nsIAtom *aName, nsINodeInfo*& aResult)
{
NS_ENSURE_TRUE(mOwnerManager, NS_ERROR_NOT_INITIALIZED);
return mOwnerManager->GetNodeInfo(aName, mInner.mPrefix, mInner.mNamespaceID,
aResult);
}
NS_IMETHODIMP
nsNodeInfo::PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult)
{
NS_ENSURE_TRUE(mOwnerManager, NS_ERROR_NOT_INITIALIZED);
return mOwnerManager->GetNodeInfo(mInner.mName, aPrefix, mInner.mNamespaceID,
aResult);
}
PLHashNumber
nsNodeInfoInner::GetHashValue(const void *key)
{
#ifdef NS_DEBUG // Just to shut down a compiler warning
NS_WARN_IF_FALSE(key, "Null key passed to nsNodeInfo::GetHashValue!");
#endif
if (key) {
const nsNodeInfoInner *node = (const nsNodeInfoInner *)key;
// Is this an acceptable has value?
return (((PLHashNumber)node->mName) & 0xffff) >> 8;
}
return 0;
}
PRIntn
nsNodeInfoInner::KeyCompare(const void *key1, const void *key2)
{
#ifdef NS_DEBUG // Just to shut down a compiler warning
NS_WARN_IF_FALSE(key1 && key2, "Null key passed to nsNodeInfo::KeyCompare!");
#endif
if (!key1 || !key2) {
return PR_FALSE;
}
const nsNodeInfoInner *node1 = (const nsNodeInfoInner *)key1;
const nsNodeInfoInner *node2 = (const nsNodeInfoInner *)key2;
if (node1->mName == node2->mName &&
node1->mPrefix == node2->mPrefix &&
node1->mNamespaceID == node2->mNamespaceID) {
return PR_TRUE;
}
return PR_FALSE;
}

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

@ -91,7 +91,7 @@ nsPresState::SetStateProperty(const nsAReadableString& aName, const nsAReadableS
nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_WSTRING_PROGID, nsnull,
NS_GET_IID(nsISupportsWString), getter_AddRefs(supportsStr));
supportsStr->SetData(nsPromiseFlatString(aValue));
supportsStr->SetData(nsPromiseFlatString(aValue).get());
mPropertyTable->Put(&key, supportsStr);
return NS_OK;

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

@ -539,7 +539,7 @@ nsXIFConverter::BeginLeaf(const nsAReadableString& aTag)
// XXX: Complete hack to prevent the style leaf
// From being created until the style sheet work
// is redone. -- gpk 1/27/99
if (nsCRT::strcasecmp(nsPromiseFlatString(aTag), NS_LITERAL_STRING("STYLE").get()) == 0)
if (nsCRT::strcasecmp(nsPromiseFlatString(aTag).get(), NS_LITERAL_STRING("STYLE").get()) == 0)
return NS_OK;
@ -556,7 +556,7 @@ nsXIFConverter::EndLeaf(const nsAReadableString& aTag)
// XXX: Complete hack to prevent the style leaf
// From being created until the style sheet work
// is redone. -- gpk 1/27/99
if (nsCRT::strcasecmp(nsPromiseFlatString(aTag), NS_LITERAL_STRING("STYLE").get()) == 0)
if (nsCRT::strcasecmp(nsPromiseFlatString(aTag).get(), NS_LITERAL_STRING("STYLE").get()) == 0)
return NS_OK;

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

@ -345,7 +345,7 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::suppress) {
if (nsCRT::strcasecmp(nsPromiseFlatString(aValue), NS_LITERAL_STRING("true").get())) {
if (nsCRT::strcasecmp(nsPromiseFlatString(aValue).get(), NS_LITERAL_STRING("true").get())) {
aResult.SetEmptyValue(); // XXX? shouldn't just leave "true"
return NS_CONTENT_ATTR_HAS_VALUE;
}

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

@ -419,7 +419,7 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, const nsAReadableS
return rv;
// Load the binding doc.
nsCString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL));
nsCString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL).get());
nsCOMPtr<nsIXBLDocumentInfo> info;
xblService->LoadBindingDocumentInfo(nsnull, aBoundDoc, url, nsCAutoString(), PR_TRUE, getter_AddRefs(info));
if (!info)

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

@ -618,7 +618,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsAReadableString& aURL,
// See if the URIs match.
nsCAutoString uri;
styleBinding->GetBindingURI(uri);
if (uri.EqualsWithConversion((const PRUnichar *) nsPromiseFlatString(aURL)))
if (uri.EqualsWithConversion((const PRUnichar *) nsPromiseFlatString(aURL).get()))
return NS_OK;
else {
FlushStyleBindings(aContent);