mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-10 22:09:32 +00:00
Bug 184362: kill nsISupportsArray in transformiix
r=bz sr=peterv
This commit is contained in:
parent
59b89d83a2
commit
fc9ebdd688
@ -45,8 +45,8 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsXPathException.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsXPathResult)
|
||||
NS_IMPL_RELEASE(nsXPathResult)
|
||||
@ -151,9 +151,9 @@ nsXPathResult::GetSnapshotLength(PRUint32 *aSnapshotLength)
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
|
||||
NS_ENSURE_ARG(aSnapshotLength);
|
||||
if (mElements)
|
||||
return mElements->Count(aSnapshotLength);
|
||||
*aSnapshotLength = 0;
|
||||
if (mElements)
|
||||
*aSnapshotLength = mElements->Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -171,14 +171,10 @@ nsXPathResult::IterateNext(nsIDOMNode **aResult)
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
|
||||
NS_ENSURE_ARG(aResult);
|
||||
if (mElements) {
|
||||
PRUint32 count;
|
||||
mElements->Count(&count);
|
||||
if (mCurrentPos < count) {
|
||||
return mElements->QueryElementAt(mCurrentPos++,
|
||||
NS_GET_IID(nsIDOMNode),
|
||||
(void**)aResult);
|
||||
}
|
||||
if (mElements && mCurrentPos < mElements->Count()) {
|
||||
*aResult = mElements->ObjectAt(mCurrentPos++);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
@ -192,14 +188,10 @@ nsXPathResult::SnapshotItem(PRUint32 aIndex, nsIDOMNode **aResult)
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
|
||||
NS_ENSURE_ARG(aResult);
|
||||
if (mElements) {
|
||||
PRUint32 count;
|
||||
mElements->Count(&count);
|
||||
if (aIndex < count) {
|
||||
return mElements->QueryElementAt(aIndex,
|
||||
NS_GET_IID(nsIDOMNode),
|
||||
(void**)aResult);
|
||||
}
|
||||
if (mElements && aIndex < mElements->Count()) {
|
||||
*aResult = mElements->ObjectAt(aIndex);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
@ -316,23 +308,28 @@ nsXPathResult::SetExprResult(ExprResult* aExprResult, PRUint16 aResultType)
|
||||
if (count == 0)
|
||||
return NS_OK;
|
||||
|
||||
NS_NewISupportsArray(&mElements);
|
||||
mElements = new nsCOMArray<nsIDOMNode>;
|
||||
NS_ENSURE_TRUE(mElements, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsISupports* mozNode = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
int i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
mozNode = nodeSet->get(i)->getNSObj();
|
||||
mElements->AppendElement(mozNode);
|
||||
NS_ADDREF(mozNode);
|
||||
node = do_QueryInterface(nodeSet->get(i)->getNSObj());
|
||||
NS_ASSERTION(node, "node isn't an nsIDOMNode");
|
||||
mElements->AppendObject(node);
|
||||
}
|
||||
|
||||
// If we support the document() function in DOM-XPath we need to
|
||||
// observe all documents that we have resultnodes in.
|
||||
if (mResultType == UNORDERED_NODE_ITERATOR_TYPE ||
|
||||
mResultType == ORDERED_NODE_ITERATOR_TYPE) {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mozNode);
|
||||
if (content)
|
||||
content->GetDocument(*getter_AddRefs(mDocument));
|
||||
nsCOMPtr<nsIDOMDocument> document;
|
||||
node->GetOwnerDocument(getter_AddRefs(document));
|
||||
if (document)
|
||||
mDocument = do_QueryInterface(document);
|
||||
else
|
||||
mDocument = do_QueryInterface(mozNode);
|
||||
mDocument = do_QueryInterface(node);
|
||||
|
||||
NS_ASSERTION(mDocument, "We need a document!");
|
||||
if (mDocument)
|
||||
mDocument->AddObserver(this);
|
||||
@ -367,7 +364,7 @@ nsXPathResult::Reset()
|
||||
mResultType == ORDERED_NODE_ITERATOR_TYPE ||
|
||||
mResultType == UNORDERED_NODE_SNAPSHOT_TYPE ||
|
||||
mResultType == ORDERED_NODE_SNAPSHOT_TYPE) {
|
||||
NS_IF_RELEASE(mElements);
|
||||
delete mElements;
|
||||
mCurrentPos = 0;
|
||||
}
|
||||
else if (mResultType == FIRST_ORDERED_NODE_TYPE ||
|
||||
|
@ -44,10 +44,10 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
class ExprResult;
|
||||
class String;
|
||||
class nsISupportsArray;
|
||||
|
||||
// {15b9b301-2012-11d6-a7f2-e6d0a678995c}
|
||||
#define NS_IXPATHRESULT_IID \
|
||||
@ -93,7 +93,7 @@ private:
|
||||
String* mStringValue;
|
||||
PRBool mBooleanValue;
|
||||
nsIDOMNode* mNode;
|
||||
nsISupportsArray* mElements;
|
||||
nsCOMArray<nsIDOMNode>* mElements;
|
||||
};
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
PRUint32 mCurrentPos;
|
||||
|
@ -318,11 +318,7 @@ void txMozillaXMLOutput::processingInstruction(const String& aTarget, const Stri
|
||||
|
||||
void txMozillaXMLOutput::removeScriptElement(nsIDOMHTMLScriptElement *aElement)
|
||||
{
|
||||
if (mScriptElements) {
|
||||
PRInt32 index = mScriptElements->IndexOf(aElement);
|
||||
if (index > -1)
|
||||
mScriptElements->RemoveElementAt(index);
|
||||
}
|
||||
mScriptElements.RemoveObject(aElement);
|
||||
}
|
||||
|
||||
void txMozillaXMLOutput::startDocument()
|
||||
@ -547,11 +543,7 @@ void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement,
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement =
|
||||
do_QueryInterface(mCurrentNode);
|
||||
NS_ASSERTION(scriptElement, "Need script element");
|
||||
if (!mScriptElements)
|
||||
NS_NewISupportsArray(getter_AddRefs(mScriptElements));
|
||||
NS_ASSERTION(mScriptElements, "Can't create array");
|
||||
if (mScriptElements)
|
||||
mScriptElements->AppendElement(scriptElement);
|
||||
mScriptElements.AppendObject(scriptElement);
|
||||
}
|
||||
// Set document title
|
||||
else if (mCreatingNewDocument &&
|
||||
@ -776,12 +768,8 @@ txMozillaXMLOutput::SignalTransformEnd()
|
||||
return;
|
||||
}
|
||||
|
||||
if (mScriptElements) {
|
||||
PRUint32 scriptCount = 0;
|
||||
mScriptElements->Count(&scriptCount);
|
||||
if (scriptCount != 0) {
|
||||
return;
|
||||
}
|
||||
if (mScriptElements.Count() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure that we don't get deleted while this function is executed and
|
||||
|
@ -47,9 +47,9 @@
|
||||
#include "nsIScriptLoaderObserver.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsString.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "txOutputFormat.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
class txMozillaXMLOutput : public txIOutputXMLEventHandler,
|
||||
public nsIScriptLoaderObserver
|
||||
@ -191,7 +191,7 @@ private:
|
||||
PRUint32 mBadChildLevel;
|
||||
nsCString mRefreshString;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> mScriptElements;
|
||||
nsCOMArray<nsIDOMHTMLScriptElement> mScriptElements;
|
||||
|
||||
nsAutoString mText;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user