Cleaned up nsICollection and nsIEnumerator. Broke out nsIBidirectionalEnumerator. Added ISupportsArray enumerator. Cleaned nsISupportsArray.
git-svn-id: svn://10.0.0.236/trunk@21585 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a6c9db8b16
commit
cb10d9f3a0
@ -38,8 +38,8 @@ extern int CAPS_TARGET_HELP_URL;
|
||||
//
|
||||
char * JavaSecUI_targetRiskStr(int risk)
|
||||
{
|
||||
char * str;
|
||||
#ifdef XXX
|
||||
char * str;
|
||||
if (risk <= nsRiskType_LowRisk) {
|
||||
str = XP_GetString(CAPS_TARGET_RISK_STR_LOW);
|
||||
} else if (risk <= nsRiskType_MediumRisk) {
|
||||
|
||||
@ -977,7 +977,7 @@ StyleContextImpl::FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
(child->mRuleHash == hash) &&
|
||||
(child->mPseudoTag == aPseudoTag) &&
|
||||
(nsnull != child->mRules) &&
|
||||
(child->mRules->Count() == ruleCount)) {
|
||||
((PRInt32)child->mRules->Count() == ruleCount)) {
|
||||
if (child->mRules->Equals(aRules)) {
|
||||
aResult = child;
|
||||
break;
|
||||
|
||||
@ -273,8 +273,8 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
// lowest index last
|
||||
PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
|
||||
PRInt32 count = mDocSheets->Count();
|
||||
PRInt32 index;
|
||||
PRUint32 count = mDocSheets->Count();
|
||||
PRUint32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index);
|
||||
PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
|
||||
|
||||
@ -96,7 +96,7 @@ nsXMLDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
|
||||
*aReturn = nsnull;
|
||||
if (nsnull != mDocument) {
|
||||
PRUint32 prolog, epilog;
|
||||
PRUint32 prolog;
|
||||
|
||||
mDocument->PrologCount(&prolog);
|
||||
if (aIndex < prolog) {
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
#include "nsIDTD.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
@ -1875,7 +1874,7 @@ XULDocumentImpl::CreateContents(nsIContent* aElement)
|
||||
if (! mBuilders)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
// XXX we should QueryInterface() here
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
@ -2544,7 +2543,7 @@ XULDocumentImpl::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2564,7 +2563,7 @@ XULDocumentImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2584,7 +2583,7 @@ XULDocumentImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsID
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2604,7 +2603,7 @@ XULDocumentImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsID
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2624,7 +2623,7 @@ XULDocumentImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2647,7 +2646,7 @@ XULDocumentImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2665,7 +2664,7 @@ XULDocumentImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName,
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2683,7 +2682,7 @@ XULDocumentImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aNam
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2701,7 +2700,7 @@ XULDocumentImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAtt
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsICollection.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsICollection.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
@ -247,7 +247,7 @@ nsIWin32LocaleImpl::GetPlatformLocale(const nsString* locale,LCID* winLCID)
|
||||
NS_IMETHODIMP
|
||||
nsIWin32LocaleImpl::GetXPLocale(LCID winLCID, nsString* locale)
|
||||
{
|
||||
LCID lang_id, country_id;
|
||||
LCID lang_id;
|
||||
char language_code[3];
|
||||
char country_code[3];
|
||||
char rfc_locale_string[9];
|
||||
@ -278,4 +278,4 @@ nsIWin32LocaleImpl::GetXPLocale(LCID winLCID, nsString* locale)
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
||||
@ -23,7 +23,7 @@ static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
|
||||
class nsFrameIterator: public nsIEnumerator
|
||||
class nsFrameIterator: public nsIBidirectionalEnumerator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -86,7 +86,7 @@ private :
|
||||
/************IMPLEMENTATIONS**************/
|
||||
|
||||
nsresult
|
||||
NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart)
|
||||
NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart)
|
||||
{
|
||||
if (!aEnumerator || !aStart)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -96,7 +96,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsLeafIterator *trav = new nsLeafIterator(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
break;
|
||||
@ -105,7 +105,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsExtensiveTraversal *trav = new nsExtensiveTraversal(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_NOMEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
break;
|
||||
@ -113,7 +113,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsFastestTraversal *trav = new nsFastestTraversal(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_NOMEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
#endif
|
||||
@ -156,7 +156,7 @@ nsFrameIterator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIEnumeratorIID)) {
|
||||
*aInstancePtr = (void*)(nsIEnumerator*)this;
|
||||
*aInstancePtr = (void*)NS_STATIC_CAST(nsIEnumerator*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "nsIFrame.h"
|
||||
|
||||
enum nsTraversalType{LEAF, EXTENSIVE, FASTEST};
|
||||
nsresult NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart);
|
||||
nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart);
|
||||
|
||||
|
||||
#endif //NSFRAMETRAVERSAL_H
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "nsIFrame.h"
|
||||
|
||||
enum nsTraversalType{LEAF, EXTENSIVE, FASTEST};
|
||||
nsresult NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart);
|
||||
nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart);
|
||||
|
||||
|
||||
#endif //NSFRAMETRAVERSAL_H
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
||||
@ -23,7 +23,7 @@ static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
|
||||
class nsFrameIterator: public nsIEnumerator
|
||||
class nsFrameIterator: public nsIBidirectionalEnumerator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -86,7 +86,7 @@ private :
|
||||
/************IMPLEMENTATIONS**************/
|
||||
|
||||
nsresult
|
||||
NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart)
|
||||
NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator, nsTraversalType aType, nsIFrame *aStart)
|
||||
{
|
||||
if (!aEnumerator || !aStart)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -96,7 +96,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsLeafIterator *trav = new nsLeafIterator(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
break;
|
||||
@ -105,7 +105,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsExtensiveTraversal *trav = new nsExtensiveTraversal(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_NOMEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
break;
|
||||
@ -113,7 +113,7 @@ NS_NewFrameTraversal(nsIEnumerator **aEnumerator, nsTraversalType aType, nsIFram
|
||||
nsFastestTraversal *trav = new nsFastestTraversal(aStart);
|
||||
if (!trav)
|
||||
return NS_ERROR_NOMEMORY;
|
||||
*aEnumerator = (nsIEnumerator *)trav;
|
||||
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
||||
NS_ADDREF(trav);
|
||||
}
|
||||
#endif
|
||||
@ -156,7 +156,7 @@ nsFrameIterator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIEnumeratorIID)) {
|
||||
*aInstancePtr = (void*)(nsIEnumerator*)this;
|
||||
*aInstancePtr = (void*)NS_STATIC_CAST(nsIEnumerator*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ private:
|
||||
nsCOMPtr<nsISupportsArray> mSelectionListeners;
|
||||
};
|
||||
|
||||
class nsRangeListIterator : public nsIEnumerator
|
||||
class nsRangeListIterator : public nsIBidirectionalEnumerator
|
||||
{
|
||||
public:
|
||||
/*BEGIN nsIEnumerator interfaces
|
||||
@ -269,7 +269,7 @@ nsRangeListIterator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (mIndex >=0 && mIndex < mRangeList->mRangeArray->Count()){
|
||||
if (mIndex >=0 && mIndex < (PRInt32)mRangeList->mRangeArray->Count()){
|
||||
nsISupports *indexIsupports = mRangeList->mRangeArray->ElementAt(mIndex);
|
||||
return indexIsupports->QueryInterface(kISupportsIID, (void **)aItem);
|
||||
}
|
||||
@ -283,7 +283,7 @@ nsRangeListIterator::CurrentItem(nsIDOMRange **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (mIndex >=0 && mIndex < mRangeList->mRangeArray->Count()){
|
||||
if (mIndex >=0 && mIndex < (PRInt32)mRangeList->mRangeArray->Count()){
|
||||
nsISupports *indexIsupports = mRangeList->mRangeArray->ElementAt(mIndex);
|
||||
return indexIsupports->QueryInterface(kIDOMRangeIID, (void **)aItem);
|
||||
}
|
||||
@ -334,8 +334,9 @@ nsRangeListIterator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
NS_ADDREF(mRangeList);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIEnumeratorIID)) {
|
||||
nsIEnumerator* tmp = this;
|
||||
if (aIID.Equals(kIEnumeratorIID) ||
|
||||
aIID.Equals(nsIBidirectionalEnumerator::IID())) {
|
||||
nsIBidirectionalEnumerator* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
@ -365,7 +366,7 @@ nsRangeList::~nsRangeList()
|
||||
{
|
||||
if (mRangeArray)
|
||||
{
|
||||
for (PRInt32 i=0;i < mRangeArray->Count(); i++)
|
||||
for (PRUint32 i=0;i < mRangeArray->Count(); i++)
|
||||
{
|
||||
mRangeArray->RemoveElementAt(i);
|
||||
}
|
||||
@ -373,7 +374,7 @@ nsRangeList::~nsRangeList()
|
||||
|
||||
if (mSelectionListeners)
|
||||
{
|
||||
for (PRInt32 i=0;i < mSelectionListeners->Count(); i++)
|
||||
for (PRUint32 i=0;i < mSelectionListeners->Count(); i++)
|
||||
{
|
||||
mSelectionListeners->RemoveElementAt(i);
|
||||
}
|
||||
@ -479,7 +480,7 @@ nsRangeList::RemoveItem(nsISupports *aItem)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!aItem )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
for (PRInt32 i = 0; i < mRangeArray->Count();i++)
|
||||
for (PRUint32 i = 0; i < mRangeArray->Count();i++)
|
||||
{
|
||||
if (mRangeArray->ElementAt(i) == aItem)
|
||||
{
|
||||
@ -497,7 +498,7 @@ nsRangeList::Clear()
|
||||
{
|
||||
if (!mRangeArray)
|
||||
return NS_ERROR_FAILURE;
|
||||
for (PRInt32 i = 0; i < mRangeArray->Count();i++)
|
||||
for (PRUint32 i = 0; i < mRangeArray->Count();i++)
|
||||
{
|
||||
mRangeArray->RemoveElementAt(i);
|
||||
// Does RemoveElementAt also delete the elements?
|
||||
@ -549,7 +550,7 @@ nsRangeList::HandleKeyEvent(nsIFocusTracker *aTracker, nsGUIEvent *aGuiEvent)
|
||||
if (NS_KEY_DOWN == aGuiEvent->message) {
|
||||
|
||||
PRBool selected;
|
||||
PRInt32 beginoffset;
|
||||
PRInt32 beginoffset = 0;
|
||||
PRInt32 endoffset;
|
||||
PRInt32 contentoffset;
|
||||
nsresult result = NS_OK;
|
||||
@ -979,7 +980,7 @@ nsRangeList::ResetSelection(nsIFocusTracker *aTracker, nsIFrame *aStartFrame)
|
||||
frameContent = do_QueryInterface(GetFocusNode(),&res);
|
||||
}
|
||||
if (NS_SUCCEEDED(res)){
|
||||
for (PRInt32 i =0; i<mRangeArray->Count(); i++){
|
||||
for (PRUint32 i =0; i<mRangeArray->Count(); i++){
|
||||
//end content and start content do NOT necessarily mean anchor and focus frame respectively
|
||||
PRInt32 anchorOffset = -1; //the frames themselves can talk to the presentation manager. we will tell them
|
||||
PRInt32 frameOffset = -1; // where we would "like" to have the anchor pt. actually we count on it.
|
||||
@ -1120,7 +1121,7 @@ nsRangeList::NotifySelectionListeners()
|
||||
SetDirty();
|
||||
return NS_OK;
|
||||
}
|
||||
for (PRInt32 i = 0; i < mSelectionListeners->Count();i++)
|
||||
for (PRUint32 i = 0; i < mSelectionListeners->Count();i++)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSelectionListener> thisListener;
|
||||
nsCOMPtr<nsISupports> isupports(dont_AddRef(mSelectionListeners->ElementAt(i)));
|
||||
@ -1274,7 +1275,7 @@ nsRangeList::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
if (!mRangeArray)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mRangeArray->Count(); i++)
|
||||
{
|
||||
nsCOMPtr<nsIDOMRange> range (do_QueryInterface(mRangeArray->ElementAt(i)));
|
||||
|
||||
@ -977,7 +977,7 @@ StyleContextImpl::FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
(child->mRuleHash == hash) &&
|
||||
(child->mPseudoTag == aPseudoTag) &&
|
||||
(nsnull != child->mRules) &&
|
||||
(child->mRules->Count() == ruleCount)) {
|
||||
((PRInt32)child->mRules->Count() == ruleCount)) {
|
||||
if (child->mRules->Equals(aRules)) {
|
||||
aResult = child;
|
||||
break;
|
||||
|
||||
@ -273,8 +273,8 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
// lowest index last
|
||||
PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
|
||||
PRInt32 count = mDocSheets->Count();
|
||||
PRInt32 index;
|
||||
PRUint32 count = mDocSheets->Count();
|
||||
PRUint32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index);
|
||||
PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
|
||||
|
||||
@ -714,8 +714,6 @@ PRBool MySpaceManager::TestResizeRectRegion()
|
||||
// Test of getting the band data
|
||||
PRBool MySpaceManager::TestGetBandData()
|
||||
{
|
||||
BandsInfo bandsInfo;
|
||||
BandRect* bandRect;
|
||||
nsresult status;
|
||||
|
||||
// Clear any existing regions
|
||||
|
||||
@ -1605,7 +1605,7 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 a
|
||||
{
|
||||
//this will use the nsFrameTraversal as the default peek method.
|
||||
//this should change to use geometry and also look to ALL the child lists
|
||||
nsCOMPtr<nsIEnumerator> frameTraversal;
|
||||
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
||||
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
@ -1410,7 +1410,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext& aPresContext, nsGUIEvent* aEvent)
|
||||
size, acx);
|
||||
state.reason = eReflowReason_Incremental;
|
||||
nsReflowStatus status;
|
||||
nsDidReflowStatus didStatus;
|
||||
nsDidReflowStatus didStatus = 0;
|
||||
WillReflow(aPresContext);
|
||||
nsFramesetDrag drag(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
|
||||
Reflow(aPresContext, &drag, metrics, state, status);
|
||||
|
||||
@ -1605,7 +1605,7 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 a
|
||||
{
|
||||
//this will use the nsFrameTraversal as the default peek method.
|
||||
//this should change to use geometry and also look to ALL the child lists
|
||||
nsCOMPtr<nsIEnumerator> frameTraversal;
|
||||
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
||||
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
@ -1410,7 +1410,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext& aPresContext, nsGUIEvent* aEvent)
|
||||
size, acx);
|
||||
state.reason = eReflowReason_Incremental;
|
||||
nsReflowStatus status;
|
||||
nsDidReflowStatus didStatus;
|
||||
nsDidReflowStatus didStatus = 0;
|
||||
WillReflow(aPresContext);
|
||||
nsFramesetDrag drag(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
|
||||
Reflow(aPresContext, &drag, metrics, state, status);
|
||||
|
||||
@ -54,7 +54,7 @@ PRBool FixedTableLayoutStrategy::BalanceColumnWidths(nsIStyleContext *aTableStyl
|
||||
NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!");
|
||||
#endif
|
||||
|
||||
PRBool result;
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
NS_ASSERTION(nsnull!=aTableStyle, "bad arg");
|
||||
if (nsnull==aTableStyle)
|
||||
|
||||
@ -977,7 +977,7 @@ StyleContextImpl::FindChildWithRules(const nsIAtom* aPseudoTag,
|
||||
(child->mRuleHash == hash) &&
|
||||
(child->mPseudoTag == aPseudoTag) &&
|
||||
(nsnull != child->mRules) &&
|
||||
(child->mRules->Count() == ruleCount)) {
|
||||
((PRInt32)child->mRules->Count() == ruleCount)) {
|
||||
if (child->mRules->Equals(aRules)) {
|
||||
aResult = child;
|
||||
break;
|
||||
|
||||
@ -273,8 +273,8 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
// lowest index last
|
||||
PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
|
||||
PRInt32 count = mDocSheets->Count();
|
||||
PRInt32 index;
|
||||
PRUint32 count = mDocSheets->Count();
|
||||
PRUint32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index);
|
||||
PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
|
||||
|
||||
@ -54,7 +54,7 @@ PRBool FixedTableLayoutStrategy::BalanceColumnWidths(nsIStyleContext *aTableStyl
|
||||
NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!");
|
||||
#endif
|
||||
|
||||
PRBool result;
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
NS_ASSERTION(nsnull!=aTableStyle, "bad arg");
|
||||
if (nsnull==aTableStyle)
|
||||
|
||||
@ -96,7 +96,7 @@ nsXMLDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
|
||||
*aReturn = nsnull;
|
||||
if (nsnull != mDocument) {
|
||||
PRUint32 prolog, epilog;
|
||||
PRUint32 prolog;
|
||||
|
||||
mDocument->PrologCount(&prolog);
|
||||
if (aIndex < prolog) {
|
||||
|
||||
@ -189,7 +189,7 @@ nsToolboxFrame :: DrawGrippies ( nsIPresContext& aPresContext, nsIRenderingCont
|
||||
for ( PRUint32 i = 0; i < mNumToolbars; ++i ) {
|
||||
const TabInfo & grippy = mGrippies[i];
|
||||
|
||||
PRBool hilight = (mGrippyHilighted == i) ? PR_TRUE : PR_FALSE;
|
||||
PRBool hilight = (mGrippyHilighted == (PRInt32)i) ? PR_TRUE : PR_FALSE;
|
||||
DrawGrippy ( aPresContext, aRenderingContext, grippy.mBoundingRect, hilight );
|
||||
|
||||
} // for each child
|
||||
|
||||
@ -101,9 +101,7 @@ struct nsRegSubtreeEnumerator : public nsIEnumerator {
|
||||
|
||||
// This class implements the nsIEnumerator interface functions.
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
@ -851,15 +849,6 @@ nsRegSubtreeEnumerator::First() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Last -------------------------
|
||||
| This can't be implemented using the libreg functions. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Last() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Next -------------------------
|
||||
| First, we check if we've already advanced to the end by checking the mDone |
|
||||
| flag. |
|
||||
@ -902,15 +891,6 @@ NS_IMETHODIMP nsRegSubtreeEnumerator::advance() {
|
||||
return rv;
|
||||
};
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Prev -------------------------
|
||||
| This can't be implemented on top of libreg. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Prev() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*-------------------- nsRegSubtreeEnumerator::CurrentItem ---------------------
|
||||
| Allocates and returns a new instance of class nsRegistryNode. The node |
|
||||
| object will hold the curent mEnum value so it can obtain its name from |
|
||||
|
||||
@ -787,7 +787,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer :: OnDataAvailable(nsIURL* aURL, nsIInp
|
||||
|
||||
NS_IMETHODIMP nsPluginStreamListenerPeer :: OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
nsPluginReason reason = nsPluginReason_NoReason;
|
||||
|
||||
//XXX this is incomplete... MMP
|
||||
|
||||
@ -787,7 +787,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer :: OnDataAvailable(nsIURL* aURL, nsIInp
|
||||
|
||||
NS_IMETHODIMP nsPluginStreamListenerPeer :: OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
nsPluginReason reason = nsPluginReason_NoReason;
|
||||
|
||||
//XXX this is incomplete... MMP
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "prtypes.h"
|
||||
|
||||
#if !defined(DEBUG) && (defined(__cplusplus) || defined(__gcc))
|
||||
# ifndef INLINE
|
||||
@ -51,8 +52,6 @@ typedef int cmp_t(const void *, const void *, void *);
|
||||
static INLINE char *med3(char *, char *, char *, cmp_t *, void *);
|
||||
static INLINE void swapfunc(char *, char *, int, int);
|
||||
|
||||
#define min(a, b) (a) < (b) ? a : b
|
||||
|
||||
/*
|
||||
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
|
||||
*/
|
||||
@ -171,9 +170,9 @@ loop: SWAPINIT(a, es);
|
||||
}
|
||||
|
||||
pn = (char *)a + n * es;
|
||||
r = min(pa - (char *)a, pb - pa);
|
||||
r = PR_MIN(pa - (char *)a, pb - pa);
|
||||
vecswap(a, pb - r, r);
|
||||
r = min(pd - pc, pn - pd - es);
|
||||
r = PR_MIN(pd - pc, pn - pd - es);
|
||||
vecswap(pb, pn - r, r);
|
||||
if ((r = pb - pa) > es)
|
||||
rdf_qsort(a, r / es, es, cmp, data);
|
||||
|
||||
@ -1405,7 +1405,7 @@ RDFTreeBuilderImpl::GetColumnForProperty(nsIContent* aTreeElement,
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
if (0 == nsCRT::strcmp(uri, propertyURI)) {
|
||||
*aIndex == index;
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
#include "nsIDTD.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
@ -1875,7 +1874,7 @@ XULDocumentImpl::CreateContents(nsIContent* aElement)
|
||||
if (! mBuilders)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
// XXX we should QueryInterface() here
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
@ -2544,7 +2543,7 @@ XULDocumentImpl::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2564,7 +2563,7 @@ XULDocumentImpl::OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2584,7 +2583,7 @@ XULDocumentImpl::OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsID
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2604,7 +2603,7 @@ XULDocumentImpl::OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsID
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2624,7 +2623,7 @@ XULDocumentImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2647,7 +2646,7 @@ XULDocumentImpl::OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2665,7 +2664,7 @@ XULDocumentImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName,
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2683,7 +2682,7 @@ XULDocumentImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aNam
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
@ -2701,7 +2700,7 @@ XULDocumentImpl::OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAtt
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {
|
||||
nsIRDFContentModelBuilder* builder
|
||||
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "nsWidget.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(ChildWindow)
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include "nsDeleteObserver.h"
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#include "nsIMouseListener.h"
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#include "Xm/DialogS.h"
|
||||
#include "Xm/RowColumn.h"
|
||||
#include "Xm/Form.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
|
||||
@ -284,7 +284,24 @@ nsRadioGroup::Enumerator::~Enumerator()
|
||||
//
|
||||
// nsISupports methods
|
||||
//
|
||||
NS_IMPL_ISUPPORTS(nsRadioGroup::Enumerator, NS_IENUMERATOR_IID);
|
||||
NS_IMPL_ADDREF(nsRadioGroup::Enumerator);
|
||||
NS_IMPL_RELEASE(nsRadioGroup::Enumerator);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIBidirectionalEnumerator::IID()) ||
|
||||
aIID.Equals(nsIEnumerator::IID()) ||
|
||||
aIID.Equals(nsISupports::IID())) {
|
||||
*aInstancePtr = (void*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
@ -59,7 +59,7 @@ protected:
|
||||
|
||||
|
||||
// keep the list of children
|
||||
class Enumerator : public nsIEnumerator {
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
nsIRadioButton **mChildrens;
|
||||
int mCurrentPosition;
|
||||
int mArraySize;
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include "nsToolkit.h"
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIEnumerator.h"
|
||||
|
||||
#include "nsIMenuBar.h"
|
||||
|
||||
|
||||
@ -21,15 +21,32 @@
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMenuListener.h"
|
||||
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsBaseWidget, kIWidgetIID)
|
||||
NS_IMPL_ISUPPORTS(nsBaseWidget::Enumerator, kIEnumeratorIID)
|
||||
|
||||
NS_IMPL_ADDREF(nsBaseWidget::Enumerator);
|
||||
NS_IMPL_RELEASE(nsBaseWidget::Enumerator);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIBidirectionalEnumerator::IID()) ||
|
||||
aIID.Equals(nsIEnumerator::IID()) ||
|
||||
aIID.Equals(nsISupports::IID())) {
|
||||
*aInstancePtr = (void*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@ -125,7 +125,7 @@ protected:
|
||||
nsRect mBounds;
|
||||
|
||||
// keep the list of children
|
||||
class Enumerator : public nsIEnumerator {
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
@ -101,9 +101,7 @@ struct mozRegSubtreeEnumerator : public nsIEnumerator {
|
||||
|
||||
// This class implements the nsIEnumerator interface functions.
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
@ -851,15 +849,6 @@ mozRegSubtreeEnumerator::First() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Last -------------------------
|
||||
| This can't be implemented using the libreg functions. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
mozRegSubtreeEnumerator::Last() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Next -------------------------
|
||||
| First, we check if we've already advanced to the end by checking the mDone |
|
||||
| flag. |
|
||||
@ -902,15 +891,6 @@ NS_IMETHODIMP mozRegSubtreeEnumerator::advance() {
|
||||
return rv;
|
||||
};
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Prev -------------------------
|
||||
| This can't be implemented on top of libreg. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
mozRegSubtreeEnumerator::Prev() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*------------------- mozRegSubtreeEnumerator::CurrentItem ---------------------
|
||||
| Allocates and returns a new instance of class mozRegistryNode. The node |
|
||||
| object will hold the curent mEnum value so it can obtain its name from |
|
||||
|
||||
@ -101,9 +101,7 @@ struct nsRegSubtreeEnumerator : public nsIEnumerator {
|
||||
|
||||
// This class implements the nsIEnumerator interface functions.
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
@ -851,15 +849,6 @@ nsRegSubtreeEnumerator::First() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Last -------------------------
|
||||
| This can't be implemented using the libreg functions. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Last() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Next -------------------------
|
||||
| First, we check if we've already advanced to the end by checking the mDone |
|
||||
| flag. |
|
||||
@ -902,15 +891,6 @@ NS_IMETHODIMP nsRegSubtreeEnumerator::advance() {
|
||||
return rv;
|
||||
};
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Prev -------------------------
|
||||
| This can't be implemented on top of libreg. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Prev() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*-------------------- nsRegSubtreeEnumerator::CurrentItem ---------------------
|
||||
| Allocates and returns a new instance of class nsRegistryNode. The node |
|
||||
| object will hold the curent mEnum value so it can obtain its name from |
|
||||
|
||||
@ -20,13 +20,15 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEnumerator;
|
||||
|
||||
// IID for the nsICollection interface
|
||||
#define NS_ICOLLECTION_IID \
|
||||
{ 0xaeca730, 0x835b, 0x11d2, \
|
||||
{ 0x8f, 0x30, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
|
||||
|
||||
|
||||
// IID for the nsICollection Factort interface
|
||||
// IID for the nsICollection Factory interface
|
||||
#define NS_ICOLLECTIONFACTORY_IID \
|
||||
{ 0xf8052641, 0x8768, 0x11d2, \
|
||||
{ 0x8f, 0x39, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
|
||||
@ -39,21 +41,30 @@
|
||||
class nsICollection : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& IID() { static nsIID iid = NS_ICOLLECTION_IID; return iid; }
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_ICOLLECTION_IID; return iid; }
|
||||
|
||||
/** Return the count of elements in the collection.
|
||||
*/
|
||||
NS_IMETHOD_(PRUint32) Count(void) const = 0;
|
||||
|
||||
/** AddItem will take an ISupports and keep track of it
|
||||
* @param aItem is the Item to be added WILL BE ADDREFFED
|
||||
*/
|
||||
virtual nsresult AddItem(nsISupports *aItem)=0;
|
||||
NS_IMETHOD AppendElement(nsISupports *aItem) = 0;
|
||||
|
||||
/** RemoveItem will take an nsISupports and remove it from the collection
|
||||
* @param aItem is the item to be removed WILL BE RELEASED
|
||||
*/
|
||||
virtual nsresult RemoveItem(nsISupports *aItem)=0;
|
||||
NS_IMETHOD RemoveElement(nsISupports *aItem) = 0;
|
||||
|
||||
/** Return an enumeration for the collection.
|
||||
*/
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result) = 0;
|
||||
|
||||
/** Clear will clear all items from list
|
||||
*/
|
||||
virtual nsresult Clear()=0;
|
||||
NS_IMETHOD Clear(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -30,34 +30,49 @@
|
||||
class nsIEnumerator : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& IID() { static nsIID iid = NS_IENUMERATOR_IID; return iid; }
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_IENUMERATOR_IID; return iid; }
|
||||
|
||||
/** First will reset the list. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD First()=0;
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last()=0;
|
||||
NS_IMETHOD First(void) = 0;
|
||||
|
||||
/** Next will advance the list. will return failed if allready at end
|
||||
/** Next will advance the list. will return failed if already at end
|
||||
*/
|
||||
NS_IMETHOD Next()=0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if allready at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev()=0;
|
||||
NS_IMETHOD Next(void) = 0;
|
||||
|
||||
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem)=0;
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem) = 0;
|
||||
|
||||
/** return if the collection is at the end. that is the beginning following a call to Prev
|
||||
* and it is the end of the list following a call to next
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD IsDone()=0;
|
||||
NS_IMETHOD IsDone(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
#define NS_IBIDIRECTIONALENUMERATOR_IID \
|
||||
{ /* 75f158a0-cadd-11d2-8cca-0060b0fc14a3 */ \
|
||||
0x75f158a0, \
|
||||
0xcadd, \
|
||||
0x11d2, \
|
||||
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
class nsIBidirectionalEnumerator : public nsIEnumerator {
|
||||
public:
|
||||
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_IBIDIRECTIONALENUMERATOR_IID; return iid; }
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last(void) = 0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if already at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
#define nsISupportsArray_h___
|
||||
|
||||
#include "nsCom.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsICollection.h"
|
||||
|
||||
class nsIBidirectionalEnumerator;
|
||||
|
||||
// {791eafa0-b9e6-11d1-8031-006008159b5a}
|
||||
#define NS_ISUPPORTSARRAY_IID \
|
||||
@ -30,7 +32,7 @@
|
||||
// Enumerator callback function. Return PR_FALSE to stop
|
||||
typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);
|
||||
|
||||
class nsISupportsArray : public nsISupports {
|
||||
class nsISupportsArray : public nsICollection {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_ISUPPORTSARRAY_IID; return iid; }
|
||||
|
||||
@ -38,28 +40,21 @@ public:
|
||||
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& other) const = 0;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* other) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRInt32) Count(void) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRUint32 aIndex) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRUint32 aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const = 0;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRUint32 aStartIndex = 0) const = 0;
|
||||
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRUint32 aIndex) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRUint32 aIndex) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRUint32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElements(nsISupportsArray* aElements) = 0;
|
||||
|
||||
NS_IMETHOD_(void) Clear(void) = 0;
|
||||
|
||||
NS_IMETHOD_(void) Compact(void) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const = 0;
|
||||
@ -67,11 +62,16 @@ public:
|
||||
|
||||
private:
|
||||
// Copy constructors are not allowed
|
||||
// XXX test wether this has to be here nsISupportsArray(const nsISupportsArray& other);
|
||||
// XXX test whether this has to be here nsISupportsArray(const nsISupportsArray& other);
|
||||
};
|
||||
|
||||
// Construct and return a default implementation of nsISupportsArray:
|
||||
extern NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
|
||||
|
||||
// Construct and return a default implementation of an enumerator for nsISupportsArrays:
|
||||
extern NS_COM nsresult
|
||||
NS_NewISupportsArrayEnumerator(nsISupportsArray* array,
|
||||
nsIBidirectionalEnumerator* *aInstancePtrResult);
|
||||
|
||||
#endif // nsISupportsArray_h___
|
||||
|
||||
@ -16,68 +16,12 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsSupportsArrayEnumerator.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsArrayIID, NS_ISUPPORTSARRAY_IID);
|
||||
static const PRUint32 kGrowArrayBy = 8;
|
||||
|
||||
static const PRInt32 kGrowArrayBy = 8;
|
||||
static const PRInt32 kAutoArraySize = 4;
|
||||
|
||||
class SupportsArrayImpl : public nsISupportsArray {
|
||||
public:
|
||||
SupportsArrayImpl(void);
|
||||
~SupportsArrayImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& aOther);
|
||||
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& aOther) const { return Equals(&aOther); }
|
||||
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* aOther) const;
|
||||
|
||||
NS_IMETHOD_(PRInt32) Count(void) const { return mCount; }
|
||||
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const { return ElementAt(aIndex); }
|
||||
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const;
|
||||
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const;
|
||||
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex);
|
||||
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex);
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) {
|
||||
return InsertElementAt(aElement, mCount);
|
||||
}
|
||||
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex);
|
||||
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0);
|
||||
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement);
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElements(nsISupportsArray* aElements);
|
||||
|
||||
NS_IMETHOD_(void) Clear(void);
|
||||
|
||||
NS_IMETHOD_(void) Compact(void);
|
||||
|
||||
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const;
|
||||
NS_IMETHOD_(PRBool) EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const;
|
||||
|
||||
protected:
|
||||
void DeleteArray(void);
|
||||
|
||||
nsISupports** mArray;
|
||||
PRInt32 mArraySize;
|
||||
PRInt32 mCount;
|
||||
nsISupports* mAutoArray[kAutoArraySize];
|
||||
|
||||
private:
|
||||
// Copy constructors are not allowed
|
||||
SupportsArrayImpl(const nsISupportsArray& other);
|
||||
};
|
||||
|
||||
|
||||
SupportsArrayImpl::SupportsArrayImpl()
|
||||
nsSupportsArray::nsSupportsArray()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mArray = &(mAutoArray[0]);
|
||||
@ -85,14 +29,14 @@ SupportsArrayImpl::SupportsArrayImpl()
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
SupportsArrayImpl::~SupportsArrayImpl()
|
||||
nsSupportsArray::~nsSupportsArray()
|
||||
{
|
||||
DeleteArray();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(SupportsArrayImpl, kISupportsArrayIID);
|
||||
NS_IMPL_ISUPPORTS(nsSupportsArray, nsISupportsArray::IID());
|
||||
|
||||
void SupportsArrayImpl::DeleteArray(void)
|
||||
void nsSupportsArray::DeleteArray(void)
|
||||
{
|
||||
Clear();
|
||||
if (mArray != &(mAutoArray[0])) {
|
||||
@ -102,11 +46,19 @@ void SupportsArrayImpl::DeleteArray(void)
|
||||
}
|
||||
}
|
||||
|
||||
nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
|
||||
NS_IMETHODIMP_(nsISupportsArray&)
|
||||
nsISupportsArray::operator=(const nsISupportsArray& other)
|
||||
{
|
||||
PRInt32 otherCount = aOther.Count();
|
||||
NS_ASSERTION(0, "should be an abstract method");
|
||||
return *this; // bogus
|
||||
}
|
||||
|
||||
if (otherCount > mArraySize) {
|
||||
NS_IMETHODIMP_(nsISupportsArray&)
|
||||
nsSupportsArray::operator=(const nsISupportsArray& aOther)
|
||||
{
|
||||
PRUint32 otherCount = aOther.Count();
|
||||
|
||||
if (otherCount > (PRInt32)mArraySize) {
|
||||
DeleteArray();
|
||||
mArraySize = otherCount;
|
||||
mArray = new nsISupports*[mArraySize];
|
||||
@ -115,19 +67,20 @@ nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
|
||||
Clear();
|
||||
}
|
||||
mCount = otherCount;
|
||||
while (0 <= --otherCount) {
|
||||
while (0 < otherCount--) {
|
||||
mArray[otherCount] = aOther.ElementAt(otherCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::Equals(const nsISupportsArray* aOther) const
|
||||
{
|
||||
if (0 != aOther) {
|
||||
const SupportsArrayImpl* other = (const SupportsArrayImpl*)aOther;
|
||||
const nsSupportsArray* other = (const nsSupportsArray*)aOther;
|
||||
if (mCount == other->mCount) {
|
||||
PRInt32 index = mCount;
|
||||
while (0 <= --index) {
|
||||
PRUint32 index = mCount;
|
||||
while (0 < index--) {
|
||||
if (mArray[index] != other->mArray[index]) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
@ -138,7 +91,8 @@ PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
|
||||
NS_IMETHODIMP_(nsISupports*)
|
||||
nsSupportsArray::ElementAt(PRUint32 aIndex) const
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
nsISupports* element = mArray[aIndex];
|
||||
@ -148,7 +102,8 @@ nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsSupportsArray::IndexOf(const nsISupports* aPossibleElement, PRUint32 aStartIndex) const
|
||||
{
|
||||
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
|
||||
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
||||
@ -164,7 +119,8 @@ PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsSupportsArray::LastIndexOf(const nsISupports* aPossibleElement) const
|
||||
{
|
||||
if (0 < mCount) {
|
||||
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
||||
@ -178,7 +134,8 @@ PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) cons
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::InsertElementAt(nsISupports* aElement, PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex <= mCount)) {
|
||||
if (mArraySize < (mCount + 1)) { // need to grow the array
|
||||
@ -194,7 +151,7 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
if (0 < aIndex) {
|
||||
::memcpy(mArray, oldArray, aIndex * sizeof(nsISupports*));
|
||||
}
|
||||
PRInt32 slide = (mCount - aIndex);
|
||||
PRUint32 slide = (mCount - aIndex);
|
||||
if (0 < slide) {
|
||||
::memcpy(mArray + aIndex + 1, oldArray + aIndex, slide * sizeof(nsISupports*));
|
||||
}
|
||||
@ -204,7 +161,7 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
}
|
||||
}
|
||||
else {
|
||||
PRInt32 slide = (mCount - aIndex);
|
||||
PRUint32 slide = (mCount - aIndex);
|
||||
if (0 < slide) {
|
||||
::memmove(mArray + aIndex + 1, mArray + aIndex, slide * sizeof(nsISupports*));
|
||||
}
|
||||
@ -218,7 +175,8 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::ReplaceElementAt(nsISupports* aElement, PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
NS_ADDREF(aElement); // addref first in case it's the same object!
|
||||
@ -229,7 +187,8 @@ PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveElementAt(PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
NS_RELEASE(mArray[aIndex]);
|
||||
@ -244,14 +203,15 @@ PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveElement(const nsISupports* aElement, PRUint32 aStartIndex)
|
||||
{
|
||||
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
|
||||
nsISupports** ep = mArray;
|
||||
nsISupports** end = ep + mCount;
|
||||
while (ep < end) {
|
||||
if (*ep == aElement) {
|
||||
return RemoveElementAt(PRInt32(ep - mArray));
|
||||
return RemoveElementAt(PRUint32(ep - mArray));
|
||||
}
|
||||
ep++;
|
||||
}
|
||||
@ -259,27 +219,29 @@ PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aSt
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveLastElement(const nsISupports* aElement)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
|
||||
{
|
||||
if (0 < mCount) {
|
||||
nsISupports** ep = (mArray + mCount);
|
||||
while (mArray <= --ep) {
|
||||
if (*ep == aElement) {
|
||||
return RemoveElementAt(PRInt32(ep - mArray));
|
||||
return RemoveElementAt(PRUint32(ep - mArray));
|
||||
}
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::AppendElements(nsISupportsArray* aElements)
|
||||
{
|
||||
SupportsArrayImpl* elements = (SupportsArrayImpl*)aElements;
|
||||
nsSupportsArray* elements = (nsSupportsArray*)aElements;
|
||||
|
||||
if (elements && (0 < elements->mCount)) {
|
||||
if (mArraySize < (mCount + elements->mCount)) { // need to grow the array
|
||||
PRInt32 count = mCount + elements->mCount;
|
||||
PRInt32 oldSize = mArraySize;
|
||||
PRUint32 count = mCount + elements->mCount;
|
||||
PRUint32 oldSize = mArraySize;
|
||||
while (mArraySize < count) { // ick
|
||||
mArraySize += kGrowArrayBy;
|
||||
}
|
||||
@ -300,7 +262,7 @@ PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 index = 0;
|
||||
PRUint32 index = 0;
|
||||
while (index < elements->mCount) {
|
||||
NS_ADDREF(elements->mArray[index]);
|
||||
mArray[mCount++] = elements->mArray[index++];
|
||||
@ -310,19 +272,21 @@ PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void SupportsArrayImpl::Clear(void)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsArray::Clear(void)
|
||||
{
|
||||
while (0 <= --mCount) {
|
||||
NS_RELEASE(mArray[mCount]);
|
||||
while (mCount != 0) {
|
||||
NS_RELEASE(mArray[--mCount]);
|
||||
}
|
||||
mCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void SupportsArrayImpl::Compact(void)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsSupportsArray::Compact(void)
|
||||
{
|
||||
if ((mArraySize != mCount) && (kAutoArraySize < mArraySize)) {
|
||||
nsISupports** oldArray = mArray;
|
||||
PRInt32 oldArraySize = mArraySize;
|
||||
PRUint32 oldArraySize = mArraySize;
|
||||
if (mCount <= kAutoArraySize) {
|
||||
mArray = &(mAutoArray[0]);
|
||||
mArraySize = kAutoArraySize;
|
||||
@ -341,42 +305,52 @@ void SupportsArrayImpl::Compact(void)
|
||||
}
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (++index < mCount)) {
|
||||
while (running && (++index < (PRInt32)mCount)) {
|
||||
running = (*aFunc)(mArray[index], aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
PRUint32 index = mCount;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (0 <= --index)) {
|
||||
while (running && (0 < index--)) {
|
||||
running = (*aFunc)(mArray[index], aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsArray::Enumerate(nsIEnumerator* *result)
|
||||
{
|
||||
if (aInstancePtrResult == 0) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
SupportsArrayImpl *it = new SupportsArrayImpl();
|
||||
|
||||
if (0 == it) {
|
||||
nsSupportsArrayEnumerator* e = new nsSupportsArrayEnumerator(this);
|
||||
if (!e)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kISupportsArrayIID, (void **) aInstancePtrResult);
|
||||
*result = e;
|
||||
NS_ADDREF(e);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
|
||||
{
|
||||
if (aInstancePtrResult == 0)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsSupportsArray *it = new nsSupportsArray();
|
||||
if (0 == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
*aInstancePtrResult = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -20,13 +20,15 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEnumerator;
|
||||
|
||||
// IID for the nsICollection interface
|
||||
#define NS_ICOLLECTION_IID \
|
||||
{ 0xaeca730, 0x835b, 0x11d2, \
|
||||
{ 0x8f, 0x30, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
|
||||
|
||||
|
||||
// IID for the nsICollection Factort interface
|
||||
// IID for the nsICollection Factory interface
|
||||
#define NS_ICOLLECTIONFACTORY_IID \
|
||||
{ 0xf8052641, 0x8768, 0x11d2, \
|
||||
{ 0x8f, 0x39, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
|
||||
@ -39,21 +41,30 @@
|
||||
class nsICollection : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& IID() { static nsIID iid = NS_ICOLLECTION_IID; return iid; }
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_ICOLLECTION_IID; return iid; }
|
||||
|
||||
/** Return the count of elements in the collection.
|
||||
*/
|
||||
NS_IMETHOD_(PRUint32) Count(void) const = 0;
|
||||
|
||||
/** AddItem will take an ISupports and keep track of it
|
||||
* @param aItem is the Item to be added WILL BE ADDREFFED
|
||||
*/
|
||||
virtual nsresult AddItem(nsISupports *aItem)=0;
|
||||
NS_IMETHOD AppendElement(nsISupports *aItem) = 0;
|
||||
|
||||
/** RemoveItem will take an nsISupports and remove it from the collection
|
||||
* @param aItem is the item to be removed WILL BE RELEASED
|
||||
*/
|
||||
virtual nsresult RemoveItem(nsISupports *aItem)=0;
|
||||
NS_IMETHOD RemoveElement(nsISupports *aItem) = 0;
|
||||
|
||||
/** Return an enumeration for the collection.
|
||||
*/
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result) = 0;
|
||||
|
||||
/** Clear will clear all items from list
|
||||
*/
|
||||
virtual nsresult Clear()=0;
|
||||
NS_IMETHOD Clear(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -30,34 +30,49 @@
|
||||
class nsIEnumerator : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& IID() { static nsIID iid = NS_IENUMERATOR_IID; return iid; }
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_IENUMERATOR_IID; return iid; }
|
||||
|
||||
/** First will reset the list. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD First()=0;
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last()=0;
|
||||
NS_IMETHOD First(void) = 0;
|
||||
|
||||
/** Next will advance the list. will return failed if allready at end
|
||||
/** Next will advance the list. will return failed if already at end
|
||||
*/
|
||||
NS_IMETHOD Next()=0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if allready at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev()=0;
|
||||
NS_IMETHOD Next(void) = 0;
|
||||
|
||||
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem)=0;
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem) = 0;
|
||||
|
||||
/** return if the collection is at the end. that is the beginning following a call to Prev
|
||||
* and it is the end of the list following a call to next
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD IsDone()=0;
|
||||
NS_IMETHOD IsDone(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
#define NS_IBIDIRECTIONALENUMERATOR_IID \
|
||||
{ /* 75f158a0-cadd-11d2-8cca-0060b0fc14a3 */ \
|
||||
0x75f158a0, \
|
||||
0xcadd, \
|
||||
0x11d2, \
|
||||
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
class nsIBidirectionalEnumerator : public nsIEnumerator {
|
||||
public:
|
||||
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_IBIDIRECTIONALENUMERATOR_IID; return iid; }
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last(void) = 0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if already at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
#define nsISupportsArray_h___
|
||||
|
||||
#include "nsCom.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsICollection.h"
|
||||
|
||||
class nsIBidirectionalEnumerator;
|
||||
|
||||
// {791eafa0-b9e6-11d1-8031-006008159b5a}
|
||||
#define NS_ISUPPORTSARRAY_IID \
|
||||
@ -30,7 +32,7 @@
|
||||
// Enumerator callback function. Return PR_FALSE to stop
|
||||
typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);
|
||||
|
||||
class nsISupportsArray : public nsISupports {
|
||||
class nsISupportsArray : public nsICollection {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_ISUPPORTSARRAY_IID; return iid; }
|
||||
|
||||
@ -38,28 +40,21 @@ public:
|
||||
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& other) const = 0;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* other) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRInt32) Count(void) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRUint32 aIndex) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRUint32 aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const = 0;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const = 0;
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRUint32 aStartIndex = 0) const = 0;
|
||||
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRUint32 aIndex) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRUint32 aIndex) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRUint32 aIndex) = 0;
|
||||
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElements(nsISupportsArray* aElements) = 0;
|
||||
|
||||
NS_IMETHOD_(void) Clear(void) = 0;
|
||||
|
||||
NS_IMETHOD_(void) Compact(void) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const = 0;
|
||||
@ -67,11 +62,16 @@ public:
|
||||
|
||||
private:
|
||||
// Copy constructors are not allowed
|
||||
// XXX test wether this has to be here nsISupportsArray(const nsISupportsArray& other);
|
||||
// XXX test whether this has to be here nsISupportsArray(const nsISupportsArray& other);
|
||||
};
|
||||
|
||||
// Construct and return a default implementation of nsISupportsArray:
|
||||
extern NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
|
||||
|
||||
// Construct and return a default implementation of an enumerator for nsISupportsArrays:
|
||||
extern NS_COM nsresult
|
||||
NS_NewISupportsArrayEnumerator(nsISupportsArray* array,
|
||||
nsIBidirectionalEnumerator* *aInstancePtrResult);
|
||||
|
||||
#endif // nsISupportsArray_h___
|
||||
|
||||
@ -34,6 +34,7 @@ CPPSRCS = \
|
||||
nsID.cpp \
|
||||
nsServiceManager.cpp \
|
||||
nsSupportsArray.cpp \
|
||||
nsSupportsArrayEnumerator.cpp \
|
||||
nsRepository.cpp \
|
||||
nsTraceRefcnt.cpp \
|
||||
nsProxyEvent.cpp \
|
||||
|
||||
@ -54,10 +54,11 @@ CPPSRCS = \
|
||||
nsHashtable.cpp \
|
||||
nsID.cpp \
|
||||
nsCOMPtr.cpp \
|
||||
nsProxyEvent.cpp \
|
||||
nsProxyEvent.cpp \
|
||||
nsRepository.cpp \
|
||||
nsServiceManager.cpp \
|
||||
nsSupportsArray.cpp \
|
||||
nsSupportsArrayEnumerator.cpp \
|
||||
nsTraceRefcnt.cpp \
|
||||
nsXPComFactory.cpp \
|
||||
nsEventQueueService.cpp \
|
||||
@ -75,6 +76,7 @@ CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsRepository.obj \
|
||||
.\$(OBJDIR)\nsServiceManager.obj \
|
||||
.\$(OBJDIR)\nsSupportsArray.obj \
|
||||
.\$(OBJDIR)\nsSupportsArrayEnumerator.obj \
|
||||
.\$(OBJDIR)\nsTraceRefcnt.obj \
|
||||
.\$(OBJDIR)\nsXPComFactory.obj \
|
||||
.\$(OBJDIR)\nsEventQueueService.obj \
|
||||
|
||||
@ -101,9 +101,7 @@ struct mozRegSubtreeEnumerator : public nsIEnumerator {
|
||||
|
||||
// This class implements the nsIEnumerator interface functions.
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
@ -851,15 +849,6 @@ mozRegSubtreeEnumerator::First() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Last -------------------------
|
||||
| This can't be implemented using the libreg functions. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
mozRegSubtreeEnumerator::Last() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Next -------------------------
|
||||
| First, we check if we've already advanced to the end by checking the mDone |
|
||||
| flag. |
|
||||
@ -902,15 +891,6 @@ NS_IMETHODIMP mozRegSubtreeEnumerator::advance() {
|
||||
return rv;
|
||||
};
|
||||
|
||||
/*---------------------- mozRegSubtreeEnumerator::Prev -------------------------
|
||||
| This can't be implemented on top of libreg. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
mozRegSubtreeEnumerator::Prev() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*------------------- mozRegSubtreeEnumerator::CurrentItem ---------------------
|
||||
| Allocates and returns a new instance of class mozRegistryNode. The node |
|
||||
| object will hold the curent mEnum value so it can obtain its name from |
|
||||
|
||||
@ -101,9 +101,7 @@ struct nsRegSubtreeEnumerator : public nsIEnumerator {
|
||||
|
||||
// This class implements the nsIEnumerator interface functions.
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
@ -851,15 +849,6 @@ nsRegSubtreeEnumerator::First() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Last -------------------------
|
||||
| This can't be implemented using the libreg functions. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Last() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Next -------------------------
|
||||
| First, we check if we've already advanced to the end by checking the mDone |
|
||||
| flag. |
|
||||
@ -902,15 +891,6 @@ NS_IMETHODIMP nsRegSubtreeEnumerator::advance() {
|
||||
return rv;
|
||||
};
|
||||
|
||||
/*----------------------- nsRegSubtreeEnumerator::Prev -------------------------
|
||||
| This can't be implemented on top of libreg. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsRegSubtreeEnumerator::Prev() {
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*-------------------- nsRegSubtreeEnumerator::CurrentItem ---------------------
|
||||
| Allocates and returns a new instance of class nsRegistryNode. The node |
|
||||
| object will hold the curent mEnum value so it can obtain its name from |
|
||||
|
||||
@ -16,68 +16,12 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsSupportsArrayEnumerator.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsArrayIID, NS_ISUPPORTSARRAY_IID);
|
||||
static const PRUint32 kGrowArrayBy = 8;
|
||||
|
||||
static const PRInt32 kGrowArrayBy = 8;
|
||||
static const PRInt32 kAutoArraySize = 4;
|
||||
|
||||
class SupportsArrayImpl : public nsISupportsArray {
|
||||
public:
|
||||
SupportsArrayImpl(void);
|
||||
~SupportsArrayImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& aOther);
|
||||
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& aOther) const { return Equals(&aOther); }
|
||||
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* aOther) const;
|
||||
|
||||
NS_IMETHOD_(PRInt32) Count(void) const { return mCount; }
|
||||
|
||||
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const;
|
||||
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const { return ElementAt(aIndex); }
|
||||
|
||||
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const;
|
||||
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const;
|
||||
|
||||
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex);
|
||||
|
||||
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex);
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) {
|
||||
return InsertElementAt(aElement, mCount);
|
||||
}
|
||||
|
||||
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex);
|
||||
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0);
|
||||
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement);
|
||||
|
||||
NS_IMETHOD_(PRBool) AppendElements(nsISupportsArray* aElements);
|
||||
|
||||
NS_IMETHOD_(void) Clear(void);
|
||||
|
||||
NS_IMETHOD_(void) Compact(void);
|
||||
|
||||
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const;
|
||||
NS_IMETHOD_(PRBool) EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const;
|
||||
|
||||
protected:
|
||||
void DeleteArray(void);
|
||||
|
||||
nsISupports** mArray;
|
||||
PRInt32 mArraySize;
|
||||
PRInt32 mCount;
|
||||
nsISupports* mAutoArray[kAutoArraySize];
|
||||
|
||||
private:
|
||||
// Copy constructors are not allowed
|
||||
SupportsArrayImpl(const nsISupportsArray& other);
|
||||
};
|
||||
|
||||
|
||||
SupportsArrayImpl::SupportsArrayImpl()
|
||||
nsSupportsArray::nsSupportsArray()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mArray = &(mAutoArray[0]);
|
||||
@ -85,14 +29,14 @@ SupportsArrayImpl::SupportsArrayImpl()
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
SupportsArrayImpl::~SupportsArrayImpl()
|
||||
nsSupportsArray::~nsSupportsArray()
|
||||
{
|
||||
DeleteArray();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(SupportsArrayImpl, kISupportsArrayIID);
|
||||
NS_IMPL_ISUPPORTS(nsSupportsArray, nsISupportsArray::IID());
|
||||
|
||||
void SupportsArrayImpl::DeleteArray(void)
|
||||
void nsSupportsArray::DeleteArray(void)
|
||||
{
|
||||
Clear();
|
||||
if (mArray != &(mAutoArray[0])) {
|
||||
@ -102,11 +46,19 @@ void SupportsArrayImpl::DeleteArray(void)
|
||||
}
|
||||
}
|
||||
|
||||
nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
|
||||
NS_IMETHODIMP_(nsISupportsArray&)
|
||||
nsISupportsArray::operator=(const nsISupportsArray& other)
|
||||
{
|
||||
PRInt32 otherCount = aOther.Count();
|
||||
NS_ASSERTION(0, "should be an abstract method");
|
||||
return *this; // bogus
|
||||
}
|
||||
|
||||
if (otherCount > mArraySize) {
|
||||
NS_IMETHODIMP_(nsISupportsArray&)
|
||||
nsSupportsArray::operator=(const nsISupportsArray& aOther)
|
||||
{
|
||||
PRUint32 otherCount = aOther.Count();
|
||||
|
||||
if (otherCount > (PRInt32)mArraySize) {
|
||||
DeleteArray();
|
||||
mArraySize = otherCount;
|
||||
mArray = new nsISupports*[mArraySize];
|
||||
@ -115,19 +67,20 @@ nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
|
||||
Clear();
|
||||
}
|
||||
mCount = otherCount;
|
||||
while (0 <= --otherCount) {
|
||||
while (0 < otherCount--) {
|
||||
mArray[otherCount] = aOther.ElementAt(otherCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::Equals(const nsISupportsArray* aOther) const
|
||||
{
|
||||
if (0 != aOther) {
|
||||
const SupportsArrayImpl* other = (const SupportsArrayImpl*)aOther;
|
||||
const nsSupportsArray* other = (const nsSupportsArray*)aOther;
|
||||
if (mCount == other->mCount) {
|
||||
PRInt32 index = mCount;
|
||||
while (0 <= --index) {
|
||||
PRUint32 index = mCount;
|
||||
while (0 < index--) {
|
||||
if (mArray[index] != other->mArray[index]) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
@ -138,7 +91,8 @@ PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
|
||||
NS_IMETHODIMP_(nsISupports*)
|
||||
nsSupportsArray::ElementAt(PRUint32 aIndex) const
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
nsISupports* element = mArray[aIndex];
|
||||
@ -148,7 +102,8 @@ nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsSupportsArray::IndexOf(const nsISupports* aPossibleElement, PRUint32 aStartIndex) const
|
||||
{
|
||||
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
|
||||
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
||||
@ -164,7 +119,8 @@ PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) const
|
||||
NS_IMETHODIMP_(PRInt32)
|
||||
nsSupportsArray::LastIndexOf(const nsISupports* aPossibleElement) const
|
||||
{
|
||||
if (0 < mCount) {
|
||||
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
||||
@ -178,7 +134,8 @@ PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) cons
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::InsertElementAt(nsISupports* aElement, PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex <= mCount)) {
|
||||
if (mArraySize < (mCount + 1)) { // need to grow the array
|
||||
@ -194,7 +151,7 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
if (0 < aIndex) {
|
||||
::memcpy(mArray, oldArray, aIndex * sizeof(nsISupports*));
|
||||
}
|
||||
PRInt32 slide = (mCount - aIndex);
|
||||
PRUint32 slide = (mCount - aIndex);
|
||||
if (0 < slide) {
|
||||
::memcpy(mArray + aIndex + 1, oldArray + aIndex, slide * sizeof(nsISupports*));
|
||||
}
|
||||
@ -204,7 +161,7 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
}
|
||||
}
|
||||
else {
|
||||
PRInt32 slide = (mCount - aIndex);
|
||||
PRUint32 slide = (mCount - aIndex);
|
||||
if (0 < slide) {
|
||||
::memmove(mArray + aIndex + 1, mArray + aIndex, slide * sizeof(nsISupports*));
|
||||
}
|
||||
@ -218,7 +175,8 @@ PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::ReplaceElementAt(nsISupports* aElement, PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
NS_ADDREF(aElement); // addref first in case it's the same object!
|
||||
@ -229,7 +187,8 @@ PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveElementAt(PRUint32 aIndex)
|
||||
{
|
||||
if ((0 <= aIndex) && (aIndex < mCount)) {
|
||||
NS_RELEASE(mArray[aIndex]);
|
||||
@ -244,14 +203,15 @@ PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveElement(const nsISupports* aElement, PRUint32 aStartIndex)
|
||||
{
|
||||
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
|
||||
nsISupports** ep = mArray;
|
||||
nsISupports** end = ep + mCount;
|
||||
while (ep < end) {
|
||||
if (*ep == aElement) {
|
||||
return RemoveElementAt(PRInt32(ep - mArray));
|
||||
return RemoveElementAt(PRUint32(ep - mArray));
|
||||
}
|
||||
ep++;
|
||||
}
|
||||
@ -259,27 +219,29 @@ PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aSt
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::RemoveLastElement(const nsISupports* aElement)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
|
||||
{
|
||||
if (0 < mCount) {
|
||||
nsISupports** ep = (mArray + mCount);
|
||||
while (mArray <= --ep) {
|
||||
if (*ep == aElement) {
|
||||
return RemoveElementAt(PRInt32(ep - mArray));
|
||||
return RemoveElementAt(PRUint32(ep - mArray));
|
||||
}
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::AppendElements(nsISupportsArray* aElements)
|
||||
{
|
||||
SupportsArrayImpl* elements = (SupportsArrayImpl*)aElements;
|
||||
nsSupportsArray* elements = (nsSupportsArray*)aElements;
|
||||
|
||||
if (elements && (0 < elements->mCount)) {
|
||||
if (mArraySize < (mCount + elements->mCount)) { // need to grow the array
|
||||
PRInt32 count = mCount + elements->mCount;
|
||||
PRInt32 oldSize = mArraySize;
|
||||
PRUint32 count = mCount + elements->mCount;
|
||||
PRUint32 oldSize = mArraySize;
|
||||
while (mArraySize < count) { // ick
|
||||
mArraySize += kGrowArrayBy;
|
||||
}
|
||||
@ -300,7 +262,7 @@ PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 index = 0;
|
||||
PRUint32 index = 0;
|
||||
while (index < elements->mCount) {
|
||||
NS_ADDREF(elements->mArray[index]);
|
||||
mArray[mCount++] = elements->mArray[index++];
|
||||
@ -310,19 +272,21 @@ PRBool SupportsArrayImpl::AppendElements(nsISupportsArray* aElements)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void SupportsArrayImpl::Clear(void)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsArray::Clear(void)
|
||||
{
|
||||
while (0 <= --mCount) {
|
||||
NS_RELEASE(mArray[mCount]);
|
||||
while (mCount != 0) {
|
||||
NS_RELEASE(mArray[--mCount]);
|
||||
}
|
||||
mCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void SupportsArrayImpl::Compact(void)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsSupportsArray::Compact(void)
|
||||
{
|
||||
if ((mArraySize != mCount) && (kAutoArraySize < mArraySize)) {
|
||||
nsISupports** oldArray = mArray;
|
||||
PRInt32 oldArraySize = mArraySize;
|
||||
PRUint32 oldArraySize = mArraySize;
|
||||
if (mCount <= kAutoArraySize) {
|
||||
mArray = &(mAutoArray[0]);
|
||||
mArraySize = kAutoArraySize;
|
||||
@ -341,42 +305,52 @@ void SupportsArrayImpl::Compact(void)
|
||||
}
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (++index < mCount)) {
|
||||
while (running && (++index < (PRInt32)mCount)) {
|
||||
running = (*aFunc)(mArray[index], aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
PRBool SupportsArrayImpl::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsSupportsArray::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) const
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
PRUint32 index = mCount;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (0 <= --index)) {
|
||||
while (running && (0 < index--)) {
|
||||
running = (*aFunc)(mArray[index], aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsArray::Enumerate(nsIEnumerator* *result)
|
||||
{
|
||||
if (aInstancePtrResult == 0) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
SupportsArrayImpl *it = new SupportsArrayImpl();
|
||||
|
||||
if (0 == it) {
|
||||
nsSupportsArrayEnumerator* e = new nsSupportsArrayEnumerator(this);
|
||||
if (!e)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kISupportsArrayIID, (void **) aInstancePtrResult);
|
||||
*result = e;
|
||||
NS_ADDREF(e);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
|
||||
{
|
||||
if (aInstancePtrResult == 0)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsSupportsArray *it = new nsSupportsArray();
|
||||
if (0 == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(it);
|
||||
*aInstancePtrResult = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user