Fix use of nsString with nsAutoString where appropriate.

This commit is contained in:
waterson%netscape.com 1999-06-24 21:19:02 +00:00
parent 7b44d7dad9
commit b6f0320775
10 changed files with 70 additions and 70 deletions

View File

@ -108,9 +108,9 @@ public:
// Publicly exposed to make life easier. This is a private class
// anyway.
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsString mValue;
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsAutoString mValue;
private:
nsIContent* mContent;

View File

@ -133,7 +133,7 @@ static NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
struct XULBroadcastListener
{
nsString mAttribute;
nsAutoString mAttribute;
nsCOMPtr<nsIDOMElement> mListener;
XULBroadcastListener(const nsString& attr, nsIDOMElement* listen)
@ -1907,7 +1907,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
// Check for event handlers
nsString attributeName;
nsAutoString attributeName;
aName->ToString(attributeName);
if (attributeName.EqualsIgnoreCase("onclick") ||
@ -1946,15 +1946,15 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
count = mBroadcastListeners->Count();
for (i = 0; i < count; i++) {
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element) {
// First we set the attribute in the observer.
element->SetAttribute(aString, aValue);
ExecuteOnChangeHandler(element, aString);
element->SetAttribute(str, aValue);
ExecuteOnChangeHandler(element, str);
}
}
}
@ -2125,14 +2125,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
for (PRInt32 i = 0; i < count; i++)
{
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
// Unset the attribute in the broadcast listener.
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element)
element->RemoveAttribute(aString);
element->RemoveAttribute(str);
}
}
}
@ -2304,7 +2304,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
// In order for the event to have a proper target for menus (which have no corresponding
// frame target in the visual model), we have to explicitly set the target of the
// event to prevent it from trying to retrieve the target from a frame.
nsString tagName;
nsAutoString tagName;
GetTagName(tagName);
if (tagName == "menu" || tagName == "menuitem" ||
tagName == "menubar" || tagName == "key" || tagName == "keyset") {
@ -2430,7 +2430,7 @@ RDFElementImpl::AddBroadcastListener(const nsString& attr, nsIDOMElement* anElem
nsCOMPtr<nsIContent> listener( do_QueryInterface(anElement) );
// Find out if the attribute is even present at all.
nsString attrValue;
nsAutoString attrValue;
nsIAtom* kAtom = NS_NewAtom(attr);
nsresult result = GetAttribute(kNameSpaceID_None, kAtom, attrValue);
PRBool attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
@ -2820,7 +2820,7 @@ RDFElementImpl::GetElementsByAttribute(nsIDOMNode* aNode,
NS_IMETHODIMP
RDFElementImpl::GetID(nsIAtom*& aResult) const
{
nsString value;
nsAutoString value;
GetAttribute(kNameSpaceID_None, kIdAtom, value);
aResult = NS_NewAtom(value); // The NewAtom call does the AddRef.

View File

@ -192,11 +192,11 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
{
nsresult rv = NS_OK;
nsString type("popup");
nsAutoString type("popup");
if (eXULPopupType_context == popupType)
type = "context";
nsString identifier;
nsAutoString identifier;
element->GetAttribute(type, identifier);
if (identifier == "")
@ -241,10 +241,10 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(global);
if (domWindow != nsnull) {
// Find out if we're anchored.
nsString anchorAlignment("none");
nsAutoString anchorAlignment("none");
element->GetAttribute("popupanchor", anchorAlignment);
nsString popupAlignment("topleft");
nsAutoString popupAlignment("topleft");
element->GetAttribute("popupalign", popupAlignment);
// Set the popup in the document for the duration of this call.

View File

@ -1062,7 +1062,7 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
syntheticURL = dont_QueryInterface(aOptionalURL);
else
{
nsString seedString;
nsAutoString seedString;
generate_RDF_seed(&seedString, 0);
#ifndef NECKO
NS_NewURL(getter_AddRefs(syntheticURL), seedString);
@ -2031,7 +2031,7 @@ XULDocumentImpl::SelectAll()
nsIContent * end = nsnull;
nsIContent * body = nsnull;
nsString bodyStr("BODY");
nsAutoString bodyStr("BODY");
PRInt32 i, n;
mRootContent->ChildCount(n);
for (i=0;i<n;i++) {
@ -2556,8 +2556,8 @@ XULDocumentImpl::CreateContents(nsIContent* aElement)
{
// Find the node that we're supposed to be
// observing and perform the hookup.
nsString elementValue;
nsString attributeValue;
nsAutoString elementValue;
nsAutoString attributeValue;
nsCOMPtr<nsIDOMElement> domContent;
domContent = do_QueryInterface(childContent);
@ -2972,7 +2972,7 @@ XULDocumentImpl::SearchForNodeByID(const nsString& anID,
PRInt32 namespaceID;
anElement->GetNameSpaceID(namespaceID);
nsString idValue;
nsAutoString idValue;
anElement->GetAttribute(namespaceID, kIdAtom, idValue);

View File

@ -133,7 +133,7 @@ static NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
struct XULBroadcastListener
{
nsString mAttribute;
nsAutoString mAttribute;
nsCOMPtr<nsIDOMElement> mListener;
XULBroadcastListener(const nsString& attr, nsIDOMElement* listen)
@ -1907,7 +1907,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
// Check for event handlers
nsString attributeName;
nsAutoString attributeName;
aName->ToString(attributeName);
if (attributeName.EqualsIgnoreCase("onclick") ||
@ -1946,15 +1946,15 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
count = mBroadcastListeners->Count();
for (i = 0; i < count; i++) {
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element) {
// First we set the attribute in the observer.
element->SetAttribute(aString, aValue);
ExecuteOnChangeHandler(element, aString);
element->SetAttribute(str, aValue);
ExecuteOnChangeHandler(element, str);
}
}
}
@ -2125,14 +2125,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
for (PRInt32 i = 0; i < count; i++)
{
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
// Unset the attribute in the broadcast listener.
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element)
element->RemoveAttribute(aString);
element->RemoveAttribute(str);
}
}
}
@ -2304,7 +2304,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
// In order for the event to have a proper target for menus (which have no corresponding
// frame target in the visual model), we have to explicitly set the target of the
// event to prevent it from trying to retrieve the target from a frame.
nsString tagName;
nsAutoString tagName;
GetTagName(tagName);
if (tagName == "menu" || tagName == "menuitem" ||
tagName == "menubar" || tagName == "key" || tagName == "keyset") {
@ -2430,7 +2430,7 @@ RDFElementImpl::AddBroadcastListener(const nsString& attr, nsIDOMElement* anElem
nsCOMPtr<nsIContent> listener( do_QueryInterface(anElement) );
// Find out if the attribute is even present at all.
nsString attrValue;
nsAutoString attrValue;
nsIAtom* kAtom = NS_NewAtom(attr);
nsresult result = GetAttribute(kNameSpaceID_None, kAtom, attrValue);
PRBool attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
@ -2820,7 +2820,7 @@ RDFElementImpl::GetElementsByAttribute(nsIDOMNode* aNode,
NS_IMETHODIMP
RDFElementImpl::GetID(nsIAtom*& aResult) const
{
nsString value;
nsAutoString value;
GetAttribute(kNameSpaceID_None, kIdAtom, value);
aResult = NS_NewAtom(value); // The NewAtom call does the AddRef.

View File

@ -754,7 +754,7 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement)
// Now that we've built the children, check to see if the includesrc attribute
// exists on the node.
nsString includeSrc;
nsAutoString includeSrc;
if (NS_FAILED(rv = aElement->GetAttribute(kNameSpaceID_None,
kXULIncludeSrcAtom,
includeSrc))) {
@ -2245,15 +2245,15 @@ RDFXULBuilderImpl::CreateHTMLElement(nsINameSpace* aContainingNameSpace,
if (!tag)
break;
nsString tagName;
nsAutoString tagName;
tag->ToString(tagName);
if (tagName == "observes")
{
// Find the node that we're supposed to be
// observing and perform the hookup.
nsString elementValue;
nsString attributeValue;
nsAutoString elementValue;
nsAutoString attributeValue;
nsCOMPtr<nsIDOMElement> domContent;
domContent = do_QueryInterface(childContent);

View File

@ -108,9 +108,9 @@ public:
// Publicly exposed to make life easier. This is a private class
// anyway.
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsString mValue;
PRInt32 mNameSpaceID;
nsIAtom* mName;
nsAutoString mValue;
private:
nsIContent* mContent;

View File

@ -1062,7 +1062,7 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
syntheticURL = dont_QueryInterface(aOptionalURL);
else
{
nsString seedString;
nsAutoString seedString;
generate_RDF_seed(&seedString, 0);
#ifndef NECKO
NS_NewURL(getter_AddRefs(syntheticURL), seedString);
@ -2031,7 +2031,7 @@ XULDocumentImpl::SelectAll()
nsIContent * end = nsnull;
nsIContent * body = nsnull;
nsString bodyStr("BODY");
nsAutoString bodyStr("BODY");
PRInt32 i, n;
mRootContent->ChildCount(n);
for (i=0;i<n;i++) {
@ -2556,8 +2556,8 @@ XULDocumentImpl::CreateContents(nsIContent* aElement)
{
// Find the node that we're supposed to be
// observing and perform the hookup.
nsString elementValue;
nsString attributeValue;
nsAutoString elementValue;
nsAutoString attributeValue;
nsCOMPtr<nsIDOMElement> domContent;
domContent = do_QueryInterface(childContent);
@ -2972,7 +2972,7 @@ XULDocumentImpl::SearchForNodeByID(const nsString& anID,
PRInt32 namespaceID;
anElement->GetNameSpaceID(namespaceID);
nsString idValue;
nsAutoString idValue;
anElement->GetAttribute(namespaceID, kIdAtom, idValue);

View File

@ -133,7 +133,7 @@ static NS_DEFINE_IID(kIDOMPaintListenerIID, NS_IDOMPAINTLISTENER_IID);
struct XULBroadcastListener
{
nsString mAttribute;
nsAutoString mAttribute;
nsCOMPtr<nsIDOMElement> mListener;
XULBroadcastListener(const nsString& attr, nsIDOMElement* listen)
@ -1907,7 +1907,7 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
// Check for event handlers
nsString attributeName;
nsAutoString attributeName;
aName->ToString(attributeName);
if (attributeName.EqualsIgnoreCase("onclick") ||
@ -1946,15 +1946,15 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
count = mBroadcastListeners->Count();
for (i = 0; i < count; i++) {
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element) {
// First we set the attribute in the observer.
element->SetAttribute(aString, aValue);
ExecuteOnChangeHandler(element, aString);
element->SetAttribute(str, aValue);
ExecuteOnChangeHandler(element, str);
}
}
}
@ -2125,14 +2125,14 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot
for (PRInt32 i = 0; i < count; i++)
{
XULBroadcastListener* xulListener = (XULBroadcastListener*)mBroadcastListeners->ElementAt(i);
nsString aString;
aName->ToString(aString);
if (xulListener->mAttribute == aString) {
nsAutoString str;
aName->ToString(str);
if (xulListener->mAttribute == str) {
// Unset the attribute in the broadcast listener.
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface(xulListener->mListener);
if (element)
element->RemoveAttribute(aString);
element->RemoveAttribute(str);
}
}
}
@ -2304,7 +2304,7 @@ RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,
// In order for the event to have a proper target for menus (which have no corresponding
// frame target in the visual model), we have to explicitly set the target of the
// event to prevent it from trying to retrieve the target from a frame.
nsString tagName;
nsAutoString tagName;
GetTagName(tagName);
if (tagName == "menu" || tagName == "menuitem" ||
tagName == "menubar" || tagName == "key" || tagName == "keyset") {
@ -2430,7 +2430,7 @@ RDFElementImpl::AddBroadcastListener(const nsString& attr, nsIDOMElement* anElem
nsCOMPtr<nsIContent> listener( do_QueryInterface(anElement) );
// Find out if the attribute is even present at all.
nsString attrValue;
nsAutoString attrValue;
nsIAtom* kAtom = NS_NewAtom(attr);
nsresult result = GetAttribute(kNameSpaceID_None, kAtom, attrValue);
PRBool attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
@ -2820,7 +2820,7 @@ RDFElementImpl::GetElementsByAttribute(nsIDOMNode* aNode,
NS_IMETHODIMP
RDFElementImpl::GetID(nsIAtom*& aResult) const
{
nsString value;
nsAutoString value;
GetAttribute(kNameSpaceID_None, kIdAtom, value);
aResult = NS_NewAtom(value); // The NewAtom call does the AddRef.

View File

@ -192,11 +192,11 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
{
nsresult rv = NS_OK;
nsString type("popup");
nsAutoString type("popup");
if (eXULPopupType_context == popupType)
type = "context";
nsString identifier;
nsAutoString identifier;
element->GetAttribute(type, identifier);
if (identifier == "")
@ -241,10 +241,10 @@ XULPopupListenerImpl::LaunchPopup(nsIDOMEvent* anEvent)
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(global);
if (domWindow != nsnull) {
// Find out if we're anchored.
nsString anchorAlignment("none");
nsAutoString anchorAlignment("none");
element->GetAttribute("popupanchor", anchorAlignment);
nsString popupAlignment("topleft");
nsAutoString popupAlignment("topleft");
element->GetAttribute("popupalign", popupAlignment);
// Set the popup in the document for the duration of this call.