diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in
index 0c40b0248e1..24791df36b0 100644
--- a/mozilla/content/base/public/Makefile.in
+++ b/mozilla/content/base/public/Makefile.in
@@ -32,7 +32,6 @@ GRE_MODULE = 1
EXPORTS = \
nsIContent.h \
-nsIAnonymousContent.h \
nsIAttribute.h \
nsIContentIterator.h \
nsContentErrors.h \
diff --git a/mozilla/content/base/public/nsIAnonymousContent.h b/mozilla/content/base/public/nsIAnonymousContent.h
deleted file mode 100644
index af6474e5248..00000000000
--- a/mozilla/content/base/public/nsIAnonymousContent.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: NPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the NPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the NPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIAnonymousContent_h___
-#define nsIAnonymousContent_h___
-
-#include "nsISupports.h"
-#include "nsIContent.h"
-#include "nsCOMPtr.h"
-
-class nsISupportsArray;
-class nsIAtom;
-class nsINodeInfo;
-
-#define NS_IANONYMOUS_CONTENT_IID { 0x41a69e00, 0x2d6d, 0x12d3, { 0xb0, 0x33, 0xa1, 0x38, 0x71, 0x39, 0x78, 0x7c } }
-
-
-/**
- * If a node is anonymous. Then it should implement this interface.
- */
-class nsIAnonymousContent : public nsISupports {
-public:
- NS_DEFINE_STATIC_IID_ACCESSOR(NS_IANONYMOUS_CONTENT_IID)
-
- NS_IMETHOD Init(nsINodeInfo *aInfo) = 0;
-};
-
-nsresult NS_NewAnonymousContent2(nsIContent **aNewNode);
-#endif
-
diff --git a/mozilla/content/base/public/nsIAttribute.h b/mozilla/content/base/public/nsIAttribute.h
index c1c329eff5f..54b1dde2805 100644
--- a/mozilla/content/base/public/nsIAttribute.h
+++ b/mozilla/content/base/public/nsIAttribute.h
@@ -1,4 +1,4 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -41,9 +41,9 @@
#define nsIAttribute_h___
#include "nsISupports.h"
+#include "nsINodeInfo.h"
class nsIContent;
-class nsINodeInfo;
#define NS_IATTRIBUTE_IID \
{0xa6cf90dd, 0x15b3, 0x11d2, \
@@ -54,12 +54,38 @@ class nsIAttribute : public nsISupports
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IATTRIBUTE_IID)
- NS_IMETHOD DropReference() = 0;
+ void SetContent(nsIContent* aContent)
+ {
+ mContent = aContent;
+ }
- NS_IMETHOD SetContent(nsIContent* aContent) = 0;
- NS_IMETHOD GetContent(nsIContent** aContent) = 0;
+ nsIContent *GetContent()
+ {
+ return mContent;
+ }
- NS_IMETHOD GetNodeInfo(nsINodeInfo** aNodeInfo) = 0;
+ nsINodeInfo *NodeInfo()
+ {
+ return mNodeInfo;
+ }
+
+protected:
+ nsIAttribute(nsIContent *aContent, nsINodeInfo *aNodeInfo)
+ : mContent(aContent), mNodeInfo(aNodeInfo)
+ {
+ NS_ADDREF(mNodeInfo);
+ }
+
+ virtual ~nsIAttribute()
+ {
+ NS_RELEASE(mNodeInfo);
+ }
+
+ nsIContent *mContent; // WEAK
+ nsINodeInfo *mNodeInfo; // STRONG
+
+private:
+ nsIAttribute(); // Not to be implemented.
};
#endif /* nsIAttribute_h___ */
diff --git a/mozilla/content/base/public/nsIContentIterator.h b/mozilla/content/base/public/nsIContentIterator.h
index 0754ff2b67d..a5c9ca16fe3 100644
--- a/mozilla/content/base/public/nsIContentIterator.h
+++ b/mozilla/content/base/public/nsIContentIterator.h
@@ -56,49 +56,49 @@ class nsIDOMRange;
{ 0x99, 0x38, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c } }
-class nsIContentIterator : public nsISupports {
+class nsIContentIterator : public nsISupports
+{
public:
-
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTITERTOR_IID)
/* Initializes an iterator for the subtree rooted by the node aRoot
*/
- NS_IMETHOD Init(nsIContent* aRoot)=0;
+ virtual nsresult Init(nsIContent* aRoot) = 0;
/* Initializes an iterator for the subtree defined by the range aRange
*/
- NS_IMETHOD Init(nsIDOMRange* aRange)=0;
-
- /** First will reset the list. will return NS_FAILED if no items
- */
- NS_IMETHOD First()=0;
+ virtual nsresult Init(nsIDOMRange* aRange) = 0;
- /** Last will reset the list to the end. will return NS_FAILED if no items
+ /** First will reset the list.
*/
- NS_IMETHOD Last()=0;
-
- /** Next will advance the list. will return failed if allready at end
- */
- NS_IMETHOD Next()=0;
+ virtual void First() = 0;
- /** Prev will decrement the list. will return failed if allready at beginning
+ /** Last will reset the list to the end.
*/
- NS_IMETHOD Prev()=0;
+ virtual void Last() = 0;
- /** CurrentItem will return the CurrentItem item it will fail if the list is empty
- * @param aItem return value
+ /** Next will advance the list.
*/
- NS_IMETHOD CurrentNode(nsIContent **aNode)=0;
+ virtual void Next() = 0;
- /** return if the collection is at the end. that is the beginning following a call to Prev
+ /** Prev will decrement the list.
+ */
+ virtual void Prev() = 0;
+
+ /** CurrentItem will return the current item, or null if the list is empty
+ * @return the current node
+ */
+ virtual nsIContent *GetCurrentNode() = 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
+ * @return if the iterator is done.
*/
- NS_IMETHOD IsDone()=0;
+ virtual PRBool IsDone() = 0;
/** PositionAt will position the iterator to the supplied node
*/
- NS_IMETHOD PositionAt(nsIContent* aCurNode)=0;
+ virtual nsresult PositionAt(nsIContent* aCurNode) = 0;
};
class nsIPresShell;
@@ -110,9 +110,9 @@ public:
/* Initializes an iterator for the subtree rooted by the node aRoot
*/
- NS_IMETHOD Init(nsIPresShell *aShell, nsIDOMRange* aRange)=0;
+ virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange) = 0;
- NS_IMETHOD Init(nsIPresShell *aShell, nsIContent* aContent)=0;
+ virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent) = 0;
};
diff --git a/mozilla/content/base/public/nsIContentList.h b/mozilla/content/base/public/nsIContentList.h
index 5eeed2e2f47..8a5db65b283 100644
--- a/mozilla/content/base/public/nsIContentList.h
+++ b/mozilla/content/base/public/nsIContentList.h
@@ -51,29 +51,27 @@
/**
* Interface for content list.
*/
-class nsIContentList : public nsISupports {
+class nsIContentList : public nsISupports
+{
public:
-
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTLIST_IID)
/**
* Returns the object that the content list should be parented to.
*/
- NS_IMETHOD GetParentObject(nsISupports** aParentObject) = 0;
-
+ virtual nsISupports *GetParentObject() = 0;
+
// Callers will want to pass in PR_TRUE for aDoFlush unless they
// are explicitly avoiding an FlushPendingNotifications. The
// flush guarantees that the list will be up to date.
- NS_IMETHOD_(PRUint32) GetLength(PRBool aDoFlush) = 0;
+ virtual PRUint32 Length(PRBool aDoFlush) = 0;
- NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
- PRBool aDoFlush) = 0;
+ virtual nsIContent *Item(PRUint32 aIndex, PRBool aDoFlush) = 0;
- NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
- PRBool aDoFlush) = 0;
+ virtual nsIContent *NamedItem(const nsAString& aName, PRBool aDoFlush) = 0;
- NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush) = 0;
+ virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush) = 0;
};
#endif /* nsIContentList_h___ */
diff --git a/mozilla/content/base/public/nsIDocumentObserver.h b/mozilla/content/base/public/nsIDocumentObserver.h
index fc1cbf0f6b4..0d15599b2c2 100644
--- a/mozilla/content/base/public/nsIDocumentObserver.h
+++ b/mozilla/content/base/public/nsIDocumentObserver.h
@@ -60,7 +60,8 @@ typedef PRUint32 nsUpdateType;
#define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE | UPDATE_CONTENT_STATE)
// Document observer interface
-class nsIDocumentObserver : public nsISupports {
+class nsIDocumentObserver : public nsISupports
+{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
@@ -68,37 +69,38 @@ public:
* Notify that a content model update is beginning. This call can be
* nested.
*/
- NS_IMETHOD BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
+ virtual void BeginUpdate(nsIDocument *aDocument,
+ nsUpdateType aUpdateType) = 0;
/**
* Notify that a content model update is finished. This call can be
* nested.
*/
- NS_IMETHOD EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
+ virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
/**
* Notify the observer that a document load is beginning.
*/
- NS_IMETHOD BeginLoad(nsIDocument *aDocument) = 0;
+ virtual void BeginLoad(nsIDocument *aDocument) = 0;
/**
* Notify the observer that a document load has finished. Note that
* the associated reflow of the document will be done before
* EndLoad is invoked, not after.
*/
- NS_IMETHOD EndLoad(nsIDocument *aDocument) = 0;
+ virtual void EndLoad(nsIDocument *aDocument) = 0;
/**
* Notify the observer that the document is being reflowed in
* the given presentation shell.
*/
- NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
+ virtual void BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
/**
* Notify the observer that the document is done being reflowed in
* the given presentation shell.
*/
- NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
+ virtual void EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
/**
* Notification that the content model has changed. This method is
@@ -117,9 +119,9 @@ public:
* @param aSubContent subrange information about the piece of content
* that changed
*/
- NS_IMETHOD ContentChanged(nsIDocument *aDocument,
- nsIContent* aContent,
- nsISupports* aSubContent) = 0;
+ virtual void ContentChanged(nsIDocument *aDocument,
+ nsIContent* aContent,
+ nsISupports* aSubContent) = 0;
/**
* Notification that the state of a content node has changed.
@@ -144,10 +146,10 @@ public:
* @param aContent1 the piece of content that changed
* @param aContent2 optional second piece of content that changed
*/
- NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
- nsIContent* aContent1,
- nsIContent* aContent2,
- PRInt32 aStateMask) = 0;
+ virtual void ContentStatesChanged(nsIDocument* aDocument,
+ nsIContent* aContent1,
+ nsIContent* aContent2,
+ PRInt32 aStateMask) = 0;
/**
* Notification that the content model has changed. This method is called
@@ -161,11 +163,11 @@ public:
* @param aModType Whether or not the attribute was added, changed, or removed.
* The constants are defined in nsIDOMMutationEvent.h.
*/
- NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
- nsIContent* aContent,
- PRInt32 aNameSpaceID,
- nsIAtom* aAttribute,
- PRInt32 aModType) = 0;
+ virtual void AttributeChanged(nsIDocument *aDocument,
+ nsIContent* aContent,
+ PRInt32 aNameSpaceID,
+ nsIAtom* aAttribute,
+ PRInt32 aModType) = 0;
/**
* Notifcation that the content model has had data appended to the
@@ -180,9 +182,9 @@ public:
* @param aNewIndexInContainer the index in the container of the first
* new child
*/
- NS_IMETHOD ContentAppended(nsIDocument *aDocument,
- nsIContent* aContainer,
- PRInt32 aNewIndexInContainer) = 0;
+ virtual void ContentAppended(nsIDocument *aDocument,
+ nsIContent* aContainer,
+ PRInt32 aNewIndexInContainer) = 0;
/**
* Notification that content has been inserted. This method is called
@@ -196,10 +198,10 @@ public:
* @param aChild the child that was inserted
* @param aIndexInContainer the index of the child in the container
*/
- NS_IMETHOD ContentInserted(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer) = 0;
+ virtual void ContentInserted(nsIDocument *aDocument,
+ nsIContent* aContainer,
+ nsIContent* aChild,
+ PRInt32 aIndexInContainer) = 0;
/**
* Notification that content has been replaced. This method is called
@@ -215,11 +217,11 @@ public:
* @param aIndexInContainer the index of the old and new child in the
* container
*/
- NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aOldChild,
- nsIContent* aNewChild,
- PRInt32 aIndexInContainer) = 0;
+ virtual void ContentReplaced(nsIDocument *aDocument,
+ nsIContent* aContainer,
+ nsIContent* aOldChild,
+ nsIContent* aNewChild,
+ PRInt32 aIndexInContainer) = 0;
/**
* Content has just been removed. This method is called automatically
@@ -234,10 +236,10 @@ public:
* @param aIndexInContainer the index of the child in the container
* before it was removed
*/
- NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer) = 0;
+ virtual void ContentRemoved(nsIDocument *aDocument,
+ nsIContent* aContainer,
+ nsIContent* aChild,
+ PRInt32 aIndexInContainer) = 0;
/**
* A StyleSheet has just been added to the document. This method is
@@ -248,8 +250,8 @@ public:
* @param aDocument The document being observed
* @param aStyleSheet the StyleSheet that has been added
*/
- NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet) = 0;
+ virtual void StyleSheetAdded(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet) = 0;
/**
* A StyleSheet has just been removed from the document. This
@@ -260,8 +262,8 @@ public:
* @param aDocument The document being observed
* @param aStyleSheet the StyleSheet that has been removed
*/
- NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet) = 0;
+ virtual void StyleSheetRemoved(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet) = 0;
/**
* A StyleSheet has just changed its applicable state.
@@ -275,9 +277,9 @@ public:
* @param aApplicable PR_TRUE if the sheet is applicable, PR_FALSE if
* it is not applicable
*/
- NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- PRBool aApplicable) = 0;
+ virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet,
+ PRBool aApplicable) = 0;
/**
* A StyleRule has just been modified within a style sheet.
@@ -302,10 +304,10 @@ public:
* |QueryInterface|.
* @param aNewStyleRule The rule being added.
*/
- NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aOldStyleRule,
- nsIStyleRule* aNewStyleRule) = 0;
+ virtual void StyleRuleChanged(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aOldStyleRule,
+ nsIStyleRule* aNewStyleRule) = 0;
/**
* A StyleRule has just been added to a style sheet.
@@ -318,9 +320,9 @@ public:
* @param aStyleSheet the StyleSheet that has been modified
* @param aStyleRule the rule that was added
*/
- NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule) = 0;
+ virtual void StyleRuleAdded(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule) = 0;
/**
* A StyleRule has just been removed from a style sheet.
@@ -333,9 +335,9 @@ public:
* @param aStyleSheet the StyleSheet that has been modified
* @param aStyleRule the rule that was removed
*/
- NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule) = 0;
+ virtual void StyleRuleRemoved(nsIDocument *aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule) = 0;
/**
* The document is in the process of being destroyed.
@@ -344,210 +346,190 @@ public:
*
* @param aDocument The document being observed
*/
- NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
+ virtual void DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
};
#define NS_DECL_NSIDOCUMENTOBSERVER \
- NS_IMETHOD BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
- NS_IMETHOD EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType); \
- NS_IMETHOD BeginLoad(nsIDocument* aDocument); \
- NS_IMETHOD EndLoad(nsIDocument* aDocument); \
- NS_IMETHOD BeginReflow(nsIDocument* aDocument, \
+ virtual void BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
+ virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
+ virtual void BeginLoad(nsIDocument* aDocument); \
+ virtual void EndLoad(nsIDocument* aDocument); \
+ virtual void BeginReflow(nsIDocument* aDocument, \
+ nsIPresShell* aShell); \
+ virtual void EndReflow(nsIDocument* aDocument, \
nsIPresShell* aShell); \
- NS_IMETHOD EndReflow(nsIDocument* aDocument, \
- nsIPresShell* aShell); \
- NS_IMETHOD ContentChanged(nsIDocument* aDocument, \
- nsIContent* aContent, \
- nsISupports* aSubContent); \
- NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument, \
- nsIContent* aContent1, \
- nsIContent* aContent2, \
- PRInt32 aStateMask); \
- NS_IMETHOD AttributeChanged(nsIDocument* aDocument, \
+ virtual void ContentChanged(nsIDocument* aDocument, \
nsIContent* aContent, \
- PRInt32 aNameSpaceID, \
- nsIAtom* aAttribute, \
- PRInt32 aModType); \
- NS_IMETHOD ContentAppended(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- PRInt32 aNewIndexInContainer); \
- NS_IMETHOD ContentInserted(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aChild, \
- PRInt32 aIndexInContainer); \
- NS_IMETHOD ContentReplaced(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aOldChild, \
- nsIContent* aNewChild, \
- PRInt32 aIndexInContainer); \
- NS_IMETHOD ContentRemoved(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aChild, \
- PRInt32 aIndexInContainer); \
- NS_IMETHOD StyleSheetAdded(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet); \
- NS_IMETHOD StyleSheetRemoved(nsIDocument* aDocument, \
+ nsISupports* aSubContent); \
+ virtual void ContentStatesChanged(nsIDocument* aDocument, \
+ nsIContent* aContent1, \
+ nsIContent* aContent2, \
+ PRInt32 aStateMask); \
+ virtual void AttributeChanged(nsIDocument* aDocument, \
+ nsIContent* aContent, \
+ PRInt32 aNameSpaceID, \
+ nsIAtom* aAttribute, \
+ PRInt32 aModType); \
+ virtual void ContentAppended(nsIDocument* aDocument, \
+ nsIContent* aContainer, \
+ PRInt32 aNewIndexInContainer); \
+ virtual void ContentInserted(nsIDocument* aDocument, \
+ nsIContent* aContainer, \
+ nsIContent* aChild, \
+ PRInt32 aIndexInContainer); \
+ virtual void ContentReplaced(nsIDocument* aDocument, \
+ nsIContent* aContainer, \
+ nsIContent* aOldChild, \
+ nsIContent* aNewChild, \
+ PRInt32 aIndexInContainer); \
+ virtual void ContentRemoved(nsIDocument* aDocument, \
+ nsIContent* aContainer, \
+ nsIContent* aChild, \
+ PRInt32 aIndexInContainer); \
+ virtual void StyleSheetAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet); \
- NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet, \
- PRBool aApplicable); \
- NS_IMETHOD StyleRuleChanged(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet, \
- nsIStyleRule* aOldStyleRule, \
- nsIStyleRule* aNewStyleRule); \
- NS_IMETHOD StyleRuleAdded(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet, \
- nsIStyleRule* aStyleRule); \
- NS_IMETHOD StyleRuleRemoved(nsIDocument* aDocument, \
+ virtual void StyleSheetRemoved(nsIDocument* aDocument, \
+ nsIStyleSheet* aStyleSheet); \
+ virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
+ nsIStyleSheet* aStyleSheet,\
+ PRBool aApplicable); \
+ virtual void StyleRuleChanged(nsIDocument* aDocument, \
+ nsIStyleSheet* aStyleSheet, \
+ nsIStyleRule* aOldStyleRule, \
+ nsIStyleRule* aNewStyleRule); \
+ virtual void StyleRuleAdded(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
nsIStyleRule* aStyleRule); \
- NS_IMETHOD DocumentWillBeDestroyed(nsIDocument* aDocument); \
+ virtual void StyleRuleRemoved(nsIDocument* aDocument, \
+ nsIStyleSheet* aStyleSheet, \
+ nsIStyleRule* aStyleRule); \
+ virtual void DocumentWillBeDestroyed(nsIDocument* aDocument); \
#define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
-NS_IMETHODIMP \
+void \
_class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::DocumentWillBeDestroyed(nsIDocument* aDocument) \
{ \
- return NS_OK; \
}
#define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \
-NS_IMETHODIMP \
+void \
_class::BeginLoad(nsIDocument* aDocument) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::EndLoad(nsIDocument* aDocument) \
{ \
- return NS_OK; \
}
#define NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(_class) \
-NS_IMETHODIMP \
+void \
_class::BeginReflow(nsIDocument* aDocument, \
- nsIPresShell* aShell) \
+ nsIPresShell* aShell) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::EndReflow(nsIDocument* aDocument, \
- nsIPresShell* aShell) \
+ nsIPresShell* aShell) \
{ \
- return NS_OK; \
}
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
-NS_IMETHODIMP \
+void \
_class::ContentStatesChanged(nsIDocument* aDocument, \
- nsIContent* aContent1, \
- nsIContent* aContent2, \
- PRInt32 aStateMask) \
+ nsIContent* aContent1, \
+ nsIContent* aContent2, \
+ PRInt32 aStateMask) \
{ \
- return NS_OK; \
}
#define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
-NS_IMETHODIMP \
+void \
_class::ContentChanged(nsIDocument* aDocument, \
- nsIContent* aContent, \
- nsISupports* aSubContent) \
+ nsIContent* aContent, \
+ nsISupports* aSubContent) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::AttributeChanged(nsIDocument* aDocument, \
- nsIContent* aContent, \
- PRInt32 aNameSpaceID, \
- nsIAtom* aAttribute, \
- PRInt32 aModType) \
+ nsIContent* aContent, \
+ PRInt32 aNameSpaceID, \
+ nsIAtom* aAttribute, \
+ PRInt32 aModType) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::ContentAppended(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- PRInt32 aNewIndexInContainer) \
+ nsIContent* aContainer, \
+ PRInt32 aNewIndexInContainer) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::ContentInserted(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aChild, \
- PRInt32 aIndexInContainer) \
+ nsIContent* aContainer, \
+ nsIContent* aChild, \
+ PRInt32 aIndexInContainer) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::ContentReplaced(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aOldChild, \
- nsIContent* aNewChild, \
- PRInt32 aIndexInContainer) \
+ nsIContent* aContainer, \
+ nsIContent* aOldChild, \
+ nsIContent* aNewChild, \
+ PRInt32 aIndexInContainer) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::ContentRemoved(nsIDocument* aDocument, \
- nsIContent* aContainer, \
- nsIContent* aChild, \
- PRInt32 aIndexInContainer) \
+ nsIContent* aContainer, \
+ nsIContent* aChild, \
+ PRInt32 aIndexInContainer) \
{ \
- return NS_OK; \
}
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
-NS_IMETHODIMP \
+void \
_class::StyleSheetAdded(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet) \
+ nsIStyleSheet* aStyleSheet) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::StyleSheetRemoved(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet) \
+ nsIStyleSheet* aStyleSheet) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
PRBool aApplicable) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::StyleRuleChanged(nsIDocument* aDocument, \
nsIStyleSheet* aStyleSheet, \
nsIStyleRule* aOldStyleRule, \
nsIStyleRule* aNewStyleRule) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::StyleRuleAdded(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet, \
- nsIStyleRule* aStyleRule) \
+ nsIStyleSheet* aStyleSheet, \
+ nsIStyleRule* aStyleRule) \
{ \
- return NS_OK; \
} \
-NS_IMETHODIMP \
+void \
_class::StyleRuleRemoved(nsIDocument* aDocument, \
- nsIStyleSheet* aStyleSheet, \
- nsIStyleRule* aStyleRule) \
+ nsIStyleSheet* aStyleSheet, \
+ nsIStyleRule* aStyleRule) \
{ \
- return NS_OK; \
}
#endif /* nsIDocumentObserver_h___ */
diff --git a/mozilla/content/base/src/nsContentIterator.cpp b/mozilla/content/base/src/nsContentIterator.cpp
index 5d651cd56bb..798b0c5edc7 100644
--- a/mozilla/content/base/src/nsContentIterator.cpp
+++ b/mozilla/content/base/src/nsContentIterator.cpp
@@ -68,19 +68,25 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static PRUint32
GetNumChildren(nsIDOMNode *aNode)
{
- PRUint32 numChildren = 0;
if (!aNode)
return 0;
+ PRUint32 numChildren = 0;
PRBool hasChildNodes;
aNode->HasChildNodes(&hasChildNodes);
if (hasChildNodes)
{
+ nsCOMPtr content(do_QueryInterface(aNode));
+
+ if (content)
+ return content->GetChildCount();
+
nsCOMPtrnodeList;
- nsresult res = aNode->GetChildNodes(getter_AddRefs(nodeList));
- if (NS_SUCCEEDED(res) && nodeList)
+ aNode->GetChildNodes(getter_AddRefs(nodeList));
+ if (nodeList)
nodeList->GetLength(&numChildren);
}
+
return numChildren;
}
@@ -91,18 +97,24 @@ static nsCOMPtr
GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
{
nsCOMPtr resultNode;
-
+
if (!aParent)
return resultNode;
-
- PRBool hasChildNodes;
- aParent->HasChildNodes(&hasChildNodes);
- if (PR_TRUE==hasChildNodes)
- {
- nsCOMPtrnodeList;
- nsresult res = aParent->GetChildNodes(getter_AddRefs(nodeList));
- if (NS_SUCCEEDED(res) && nodeList)
- nodeList->Item(aOffset, getter_AddRefs(resultNode));
+
+ nsCOMPtr content(do_QueryInterface(aParent));
+
+ if (content) {
+ resultNode = do_QueryInterface(content->GetChildAt(aOffset));
+ } else if (aParent) {
+ PRBool hasChildNodes;
+ aParent->HasChildNodes(&hasChildNodes);
+ if (hasChildNodes)
+ {
+ nsCOMPtrnodeList;
+ aParent->GetChildNodes(getter_AddRefs(nodeList));
+ if (nodeList)
+ nodeList->Item(aOffset, getter_AddRefs(resultNode));
+ }
}
return resultNode;
@@ -120,18 +132,14 @@ ContentHasChildren(nsIContent *aContent)
///////////////////////////////////////////////////////////////////////////
// ContentToParentOffset: returns the content node's parent and offset.
//
-static void
-ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent, PRInt32 *aOffset)
-{
- if (!aParent || !aOffset)
- return;
+static void
+ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent,
+ PRInt32 *aOffset)
+{
*aParent = nsnull;
*aOffset = 0;
- if (!aContent)
- return;
-
nsIContent* parent = aContent->GetParent();
if (!parent)
@@ -198,23 +206,23 @@ public:
// nsIContentIterator interface methods ------------------------------
- NS_IMETHOD Init(nsIContent* aRoot);
+ virtual nsresult Init(nsIContent* aRoot);
- NS_IMETHOD Init(nsIDOMRange* aRange);
+ virtual nsresult Init(nsIDOMRange* aRange);
- NS_IMETHOD First();
+ virtual void First();
- NS_IMETHOD Last();
+ virtual void Last();
- NS_IMETHOD Next();
+ virtual void Next();
- NS_IMETHOD Prev();
+ virtual void Prev();
- NS_IMETHOD CurrentNode(nsIContent **aNode);
+ virtual nsIContent *GetCurrentNode();
- NS_IMETHOD IsDone();
+ virtual PRBool IsDone();
- NS_IMETHOD PositionAt(nsIContent* aCurNode);
+ virtual nsresult PositionAt(nsIContent* aCurNode);
// nsIEnumertor interface methods ------------------------------
@@ -224,12 +232,12 @@ protected:
nsIContent *GetDeepFirstChild(nsIContent *aRoot, nsVoidArray *aIndexes);
nsIContent *GetDeepLastChild(nsIContent *aRoot, nsVoidArray *aIndexes);
-
- nsresult GetNextSibling(nsCOMPtr aNode, nsCOMPtr *aSibling, nsVoidArray *aIndexes);
- nsresult GetPrevSibling(nsCOMPtr aNode, nsCOMPtr *aSibling, nsVoidArray *aIndexes);
-
- nsresult NextNode(nsCOMPtr *ioNextNode, nsVoidArray *aIndexes);
- nsresult PrevNode(nsCOMPtr *ioPrevNode, nsVoidArray *aIndexes);
+
+ nsIContent *GetNextSibling(nsIContent *aNode, nsVoidArray *aIndexes);
+ nsIContent *GetPrevSibling(nsIContent *aNode, nsVoidArray *aIndexes);
+
+ nsIContent *NextNode(nsIContent *aNode, nsVoidArray *aIndexes);
+ nsIContent *PrevNode(nsIContent *aNode, nsVoidArray *aIndexes);
// WARNING: This function is expensive
nsresult RebuildIndexStack();
@@ -296,7 +304,9 @@ nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
}
- return CallQueryInterface(iter, aInstancePtrResult);
+ NS_ADDREF(*aInstancePtrResult = iter);
+
+ return NS_OK;
}
@@ -307,7 +317,9 @@ nsresult NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
}
- return CallQueryInterface(iter, aInstancePtrResult);
+ NS_ADDREF(*aInstancePtrResult = iter);
+
+ return NS_OK;
}
@@ -315,37 +327,7 @@ nsresult NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult)
* XPCOM cruft
******************************************************/
-NS_IMPL_ADDREF(nsContentIterator)
-NS_IMPL_RELEASE(nsContentIterator)
-
-nsresult nsContentIterator::QueryInterface(const nsIID& aIID,
- void** aInstancePtrResult)
-{
- NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
- if (nsnull == aInstancePtrResult)
- {
- return NS_ERROR_NULL_POINTER;
- }
- if (aIID.Equals(kISupportsIID))
- {
- *aInstancePtrResult = (void*)(nsISupports*)(nsIContentIterator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
-/* if (aIID.Equals(NS_GET_IID(nsIEnumerator)))
- {
- *aInstancePtrResult = (void*)(nsIEnumerator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- } */
- if (aIID.Equals(NS_GET_IID(nsIContentIterator)))
- {
- *aInstancePtrResult = (void*)(nsIContentIterator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
- return NS_NOINTERFACE;
-}
+NS_IMPL_ISUPPORTS1(nsContentIterator, nsIContentIterator)
/******************************************************
@@ -369,39 +351,40 @@ nsContentIterator::~nsContentIterator()
******************************************************/
-nsresult nsContentIterator::Init(nsIContent* aRoot)
+nsresult
+nsContentIterator::Init(nsIContent* aRoot)
{
if (!aRoot)
return NS_ERROR_NULL_POINTER;
mIsDone = PR_FALSE;
- nsCOMPtr root(aRoot);
mIndexes.Clear();
if (mPre)
{
- mFirst = root;
- mLast = GetDeepLastChild(root, nsnull);
+ mFirst = aRoot;
+ mLast = GetDeepLastChild(aRoot, nsnull);
}
else
{
- mFirst = GetDeepFirstChild(root, nsnull);
- mLast = root;
+ mFirst = GetDeepFirstChild(aRoot, nsnull);
+ mLast = aRoot;
}
- mCommonParent = root;
+ mCommonParent = aRoot;
mCurNode = mFirst;
RebuildIndexStack();
return NS_OK;
}
-nsresult nsContentIterator::Init(nsIDOMRange* aRange)
+nsresult
+nsContentIterator::Init(nsIDOMRange* aRange)
{
if (!aRange)
return NS_ERROR_NULL_POINTER;
nsCOMPtr dN;
-
+
nsCOMPtr startCon;
nsCOMPtr startDOM;
nsCOMPtr endCon;
@@ -469,7 +452,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
// Find first node in range.
- nsCOMPtr cChild;
+ nsIContent *cChild = nsnull;
if (!cData && ContentHasChildren(startCon))
cChild = startCon->GetChildAt(startIndx);
@@ -484,7 +467,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
if (!cData)
{
- GetNextSibling(startCon, address_of(mFirst), nsnull);
+ mFirst = GetNextSibling(startCon, nsnull);
// Does mFirst node really intersect the range?
// The range could be 'degenerate', ie not collapsed
@@ -533,7 +516,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
if (!cData)
{
- GetPrevSibling(endCon, address_of(mLast), nsnull);
+ mLast = GetPrevSibling(endCon, nsnull);
if (!ContentIsInTraversalRange(mLast, mPre, startDOM, startIndx, endDOM, endIndx))
mLast = nsnull;
@@ -618,13 +601,13 @@ nsresult nsContentIterator::RebuildIndexStack()
return NS_OK;
}
-void nsContentIterator::MakeEmpty()
+void
+nsContentIterator::MakeEmpty()
{
- nsCOMPtr noNode;
- mCurNode = noNode;
- mFirst = noNode;
- mLast = noNode;
- mCommonParent = noNode;
+ mCurNode = nsnull;
+ mFirst = nsnull;
+ mLast = nsnull;
+ mCommonParent = nsnull;
mIsDone = PR_TRUE;
mIndexes.Clear();
}
@@ -684,22 +667,18 @@ nsContentIterator::GetDeepLastChild(nsIContent *aRoot, nsVoidArray *aIndexes)
}
// Get the next sibling, or parents next sibling, or grandpa's next sibling...
-nsresult nsContentIterator::GetNextSibling(nsCOMPtr aNode,
- nsCOMPtr *aSibling,
- nsVoidArray *aIndexes)
+nsIContent *
+nsContentIterator::GetNextSibling(nsIContent *aNode,
+ nsVoidArray *aIndexes)
{
if (!aNode)
- return NS_ERROR_NULL_POINTER;
- if (!aSibling)
- return NS_ERROR_NULL_POINTER;
-
- nsCOMPtr sib;
- nsCOMPtr parent;
- PRInt32 indx;
+ return nsnull;
- parent = aNode->GetParent();
+ nsIContent *parent = aNode->GetParent();
if (!parent)
- return NS_ERROR_FAILURE;
+ return nsnull;
+
+ PRInt32 indx;
if (aIndexes)
{
@@ -707,12 +686,13 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr aNode,
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
}
- else indx = mCachedIndex;
-
+ else
+ indx = mCachedIndex;
+
// reverify that the index of the current node hasn't changed.
// not super cheap, but a lot cheaper than IndexOf(), and still O(1).
// ignore result this time - the index may now be out of range.
- sib = parent->GetChildAt(indx);
+ nsIContent *sib = parent->GetChildAt(indx);
if (sib != aNode)
{
// someone changed our index - find the new index the painful way
@@ -722,7 +702,6 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr aNode,
// indx is now canonically correct
if ((sib = parent->GetChildAt(++indx)))
{
- *aSibling = sib;
// update index cache
if (aIndexes)
{
@@ -740,34 +719,25 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr aNode,
if (aIndexes->Count() > 1)
aIndexes->RemoveElementAt(aIndexes->Count()-1);
}
- return GetNextSibling(parent, aSibling, aIndexes);
- }
- else
- {
- *aSibling = nsnull;
- // ok to leave cache out of date here?
+ return GetNextSibling(parent, aIndexes);
}
- return NS_OK;
+ return sib;
}
// Get the prev sibling, or parents prev sibling, or grandpa's prev sibling...
-nsresult nsContentIterator::GetPrevSibling(nsCOMPtr aNode,
- nsCOMPtr *aSibling,
- nsVoidArray *aIndexes)
+nsIContent *
+nsContentIterator::GetPrevSibling(nsIContent *aNode,
+ nsVoidArray *aIndexes)
{
- if (!aNode)
- return NS_ERROR_NULL_POINTER;
- if (!aSibling)
- return NS_ERROR_NULL_POINTER;
-
- nsCOMPtr sib;
- nsCOMPtr parent;
- PRInt32 indx;
+ if (!aNode)
+ return nsnull;
- parent = aNode->GetParent();
+ nsIContent *parent = aNode->GetParent();
if (!parent)
- return NS_ERROR_FAILURE;
+ return nsnull;
+
+ PRInt32 indx;
if (aIndexes)
{
@@ -775,11 +745,12 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr aNode,
// use the last entry on the Indexes array for the current index
indx = NS_PTR_TO_INT32((*aIndexes)[aIndexes->Count()-1]);
}
- else indx = mCachedIndex;
-
+ else
+ indx = mCachedIndex;
+
// reverify that the index of the current node hasn't changed
// ignore result this time - the index may now be out of range.
- sib = parent->GetChildAt(indx);
+ nsIContent *sib = parent->GetChildAt(indx);
if (sib != aNode)
{
// someone changed our index - find the new index the painful way
@@ -789,7 +760,6 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr aNode,
// indx is now canonically correct
if (indx > 0 && (sib = parent->GetChildAt(--indx)))
{
- *aSibling = sib;
// update index cache
if (aIndexes)
{
@@ -804,25 +774,17 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr aNode,
// pop node off the stack, go up one level and try again.
aIndexes->RemoveElementAt(aIndexes->Count()-1);
}
- return GetPrevSibling(parent, aSibling, aIndexes);
- }
- else
- {
- *aSibling = nsnull;
- // ok to leave cache out of date here?
+ return GetPrevSibling(parent, aIndexes);
}
- return NS_OK;
+ return sib;
}
-nsresult
-nsContentIterator::NextNode(nsCOMPtr *ioNextNode,
- nsVoidArray *aIndexes)
+nsIContent *
+nsContentIterator::NextNode(nsIContent *aNode, nsVoidArray *aIndexes)
{
- if (!ioNextNode)
- return NS_ERROR_NULL_POINTER;
-
- nsCOMPtr cN = *ioNextNode;
+ nsIContent *cN = aNode;
+ nsIContent *nextNode = nsnull;
if (mPre) // if we are a Pre-order iterator, use pre-order
{
@@ -839,21 +801,18 @@ nsContentIterator::NextNode(nsCOMPtr *ioNextNode,
}
else mCachedIndex = 0;
- *ioNextNode = cFirstChild;
- return NS_OK;
+ return cFirstChild;
}
-
+
// else next sibling is next
- return GetNextSibling(cN, ioNextNode, aIndexes);
+ nextNode = GetNextSibling(cN, aIndexes);
}
else // post-order
{
- nsCOMPtr cSibling;
- nsCOMPtr parent;
- PRInt32 indx;
+ nsIContent *parent = cN->GetParent();
+ nsIContent *cSibling = nsnull;
+ PRInt32 indx;
- parent = cN->GetParent();
-
// get the cached index
if (aIndexes)
{
@@ -887,8 +846,7 @@ nsContentIterator::NextNode(nsCOMPtr *ioNextNode,
else mCachedIndex = indx;
// next node is siblings "deep left" child
- *ioNextNode = GetDeepFirstChild(cSibling, aIndexes);
- return NS_OK;
+ return GetDeepFirstChild(cSibling, aIndexes);
}
// else it's the parent
@@ -902,25 +860,23 @@ nsContentIterator::NextNode(nsCOMPtr *ioNextNode,
aIndexes->RemoveElementAt(aIndexes->Count()-1);
}
else mCachedIndex = 0; // this might be wrong, but we are better off guessing
- *ioNextNode = parent;
+ nextNode = parent;
}
- return NS_OK;
+
+ return nextNode;
}
-nsresult nsContentIterator::PrevNode(nsCOMPtr *ioNextNode, nsVoidArray *aIndexes)
+nsIContent *
+nsContentIterator::PrevNode(nsIContent *aNode, nsVoidArray *aIndexes)
{
- if (!ioNextNode)
- return NS_ERROR_NULL_POINTER;
-
- nsCOMPtr cN = *ioNextNode;
+ nsIContent *prevNode = nsnull;
+ nsIContent *cN = aNode;
if (mPre) // if we are a Pre-order iterator, use pre-order
{
- nsCOMPtr cSibling;
- nsCOMPtr parent;
- PRInt32 indx;
-
- parent = cN->GetParent();
+ nsIContent *parent = cN->GetParent();
+ nsIContent *cSibling = nsnull;
+ PRInt32 indx;
// get the cached index
if (aIndexes)
@@ -955,8 +911,7 @@ nsresult nsContentIterator::PrevNode(nsCOMPtr *ioNextNode, nsVoidArr
else mCachedIndex = indx;
// prev node is siblings "deep right" child
- *ioNextNode = GetDeepLastChild(cSibling, aIndexes);
- return NS_OK;
+ return GetDeepLastChild(cSibling, aIndexes);
}
// else it's the parent
@@ -967,20 +922,16 @@ nsresult nsContentIterator::PrevNode(nsCOMPtr *ioNextNode, nsVoidArr
aIndexes->RemoveElementAt(aIndexes->Count()-1);
}
else mCachedIndex = 0; // this might be wrong, but we are better off guessing
- *ioNextNode = parent;
+ prevNode = parent;
}
else // post-order
{
- nsCOMPtr cLastChild;
PRInt32 numChildren = cN->GetChildCount();
// if it has children then prev node is last child
if (numChildren)
{
- cLastChild = cN->GetChildAt(--numChildren);
-
- if (!cLastChild)
- return NS_ERROR_FAILURE;
+ nsIContent *cLastChild = cN->GetChildAt(--numChildren);
// update cache
if (aIndexes)
@@ -990,89 +941,107 @@ nsresult nsContentIterator::PrevNode(nsCOMPtr *ioNextNode, nsVoidArr
}
else mCachedIndex = numChildren;
- *ioNextNode = cLastChild;
- return NS_OK;
+ return cLastChild;
}
-
+
// else prev sibling is previous
- return GetPrevSibling(cN, ioNextNode, aIndexes);
+ prevNode = GetPrevSibling(cN, aIndexes);
}
- return NS_OK;
+
+ return prevNode;
}
/******************************************************
* ContentIterator routines
******************************************************/
-nsresult nsContentIterator::First()
+void
+nsContentIterator::First()
{
- if (!mFirst)
- return NS_ERROR_FAILURE;
+ NS_ASSERTION(mFirst, "No first node!");
- return PositionAt(mFirst);
+ if (mFirst) {
+#ifdef DEBUG
+ nsresult rv =
+#endif
+ PositionAt(mFirst);
+
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to position iterator!");
+ }
+
+ mIsDone = mFirst == nsnull;
}
-nsresult nsContentIterator::Last()
+void
+nsContentIterator::Last()
{
- if (!mLast)
- return NS_ERROR_FAILURE;
+ NS_ASSERTION(mLast, "No last node!");
- return PositionAt(mLast);
+ if (mLast) {
+#ifdef DEBUG
+ nsresult rv =
+#endif
+ PositionAt(mLast);
+
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to position iterator!");
+ }
+
+ mIsDone = mLast == nsnull;
}
-nsresult nsContentIterator::Next()
+void
+nsContentIterator::Next()
{
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
+ if (mIsDone || !mCurNode)
+ return;
+
if (mCurNode == mLast)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
-
- return NextNode(address_of(mCurNode), &mIndexes);
+
+ mCurNode = NextNode(mCurNode, &mIndexes);
}
-nsresult nsContentIterator::Prev()
+void
+nsContentIterator::Prev()
{
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
+ if (mIsDone || !mCurNode)
+ return;
+
if (mCurNode == mFirst)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
-
- return PrevNode(address_of(mCurNode), &mIndexes);
+
+ mCurNode = PrevNode(mCurNode, &mIndexes);
}
-nsresult nsContentIterator::IsDone()
+PRBool
+nsContentIterator::IsDone()
{
- if (mIsDone)
- return NS_OK;
- else
- return NS_ENUMERATOR_FALSE;
+ return mIsDone;
}
// Keeping arrays of indexes for the stack of nodes makes PositionAt
// interesting...
-nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
+nsresult
+nsContentIterator::PositionAt(nsIContent* aCurNode)
{
- nsCOMPtr newCurNode;
- nsCOMPtr tempNode(mCurNode);
-
if (!aCurNode)
return NS_ERROR_NULL_POINTER;
- mCurNode = newCurNode = do_QueryInterface(aCurNode);
+
+ nsIContent *newCurNode = aCurNode;
+ nsIContent *tempNode = mCurNode;
+
+ mCurNode = aCurNode;
// take an early out if this doesn't actually change the position
if (mCurNode == tempNode)
{
@@ -1112,7 +1081,7 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
firstOffset = numChildren;
else
ContentToParentOffset(mFirst, getter_AddRefs(firstNode), &firstOffset);
-
+
ContentToParentOffset(mLast, getter_AddRefs(lastNode), &lastOffset);
++lastOffset;
}
@@ -1128,7 +1097,6 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
// We can be at ANY node in the sequence.
// Need to regenerate the array of indexes back to the root or common parent!
- nsCOMPtr parent;
nsAutoVoidArray oldParentStack;
nsAutoVoidArray newIndexes;
@@ -1150,7 +1118,7 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
// Insert at head since we're walking up
oldParentStack.InsertElementAt(tempNode,0);
- parent = tempNode->GetParent();
+ nsIContent *parent = tempNode->GetParent();
if (!parent) // this node has no parent, and thus no index
break;
@@ -1170,8 +1138,8 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
// Ok. We have the array of old parents. Look for a match.
while (newCurNode)
{
- parent = newCurNode->GetParent();
-
+ nsIContent *parent = newCurNode->GetParent();
+
if (!parent) // this node has no parent, and thus no index
break;
@@ -1205,13 +1173,16 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
}
-nsresult nsContentIterator::CurrentNode(nsIContent **aNode)
+nsIContent *
+nsContentIterator::GetCurrentNode()
{
- if (!mCurNode || mIsDone) {
- return NS_ERROR_FAILURE;
+ if (mIsDone) {
+ return nsnull;
}
- return CallQueryInterface(mCurNode, aNode);
+ NS_ASSERTION(mCurNode, "Null current node in an iterator that's not done!");
+
+ return mCurNode;
}
@@ -1242,27 +1213,27 @@ public:
// nsContentIterator overrides ------------------------------
- NS_IMETHOD Init(nsIContent* aRoot);
+ virtual nsresult Init(nsIContent* aRoot);
- NS_IMETHOD Init(nsIDOMRange* aRange);
+ virtual nsresult Init(nsIDOMRange* aRange);
- NS_IMETHOD Next();
+ virtual void Next();
- NS_IMETHOD Prev();
+ virtual void Prev();
- NS_IMETHOD PositionAt(nsIContent* aCurNode);
+ virtual nsresult PositionAt(nsIContent* aCurNode);
// Must override these because we don't do PositionAt
- NS_IMETHOD First();
+ virtual void First();
// Must override these because we don't do PositionAt
- NS_IMETHOD Last();
+ virtual void Last();
protected:
- nsresult GetTopAncestorInRange( nsCOMPtr aNode,
- nsCOMPtr *outAnestor);
-
+ nsresult GetTopAncestorInRange(nsIContent *aNode,
+ nsCOMPtr *outAnestor);
+
// no copy's or assigns FIX ME
nsContentSubtreeIterator(const nsContentSubtreeIterator&);
nsContentSubtreeIterator& operator=(const nsContentSubtreeIterator&);
@@ -1291,7 +1262,9 @@ nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
}
- return CallQueryInterface(iter, aInstancePtrResult);
+ NS_ADDREF(*aInstancePtrResult = iter);
+
+ return NS_OK;
}
@@ -1314,7 +1287,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
mIsDone = PR_FALSE;
- mRange = do_QueryInterface(aRange);
+ mRange = aRange;
// get the start node and offset, convert to nsIContent
nsCOMPtr commonParent;
@@ -1323,8 +1296,8 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
nsCOMPtr cStartP;
nsCOMPtr cEndP;
nsCOMPtr cN;
- nsCOMPtr firstCandidate;
- nsCOMPtr lastCandidate;
+ nsIContent *firstCandidate = nsnull;
+ nsIContent *lastCandidate = nsnull;
nsCOMPtr dChild;
nsCOMPtr cChild;
PRInt32 indx, startIndx, endIndx;
@@ -1399,7 +1372,9 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
if (!firstCandidate)
{
// then firstCandidate is next node after cN
- if (NS_FAILED(GetNextSibling(cN, address_of(firstCandidate), nsnull)) || !firstCandidate)
+ firstCandidate = GetNextSibling(cN, nsnull);
+
+ if (!firstCandidate)
{
MakeEmpty();
return NS_OK;
@@ -1428,9 +1403,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
// in the range. That's the real first node.
if (NS_FAILED(GetTopAncestorInRange(firstCandidate, address_of(mFirst))))
return NS_ERROR_FAILURE;
-
-
-
+
// now to find the last node
aRange->GetEndOffset(&indx);
numChildren = GetNumChildren(endParent);
@@ -1465,11 +1438,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
if (!lastCandidate)
{
// then lastCandidate is prev node before cN
- if (NS_FAILED(GetPrevSibling(cN, address_of(lastCandidate), nsnull)))
- {
- MakeEmpty();
- return NS_OK;
- }
+ lastCandidate = GetPrevSibling(cN, nsnull);
}
lastCandidate = GetDeepLastChild(lastCandidate, nsnull);
@@ -1505,45 +1474,38 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
****************************************************************/
// we can't call PositionAt in a subtree iterator...
-nsresult nsContentSubtreeIterator::First()
+void
+nsContentSubtreeIterator::First()
{
- if (!mFirst)
- return NS_ERROR_FAILURE;
- mIsDone = PR_FALSE;
- if (mFirst == mCurNode)
- return NS_OK;
+ mIsDone = mFirst == nsnull;
+
mCurNode = mFirst;
- return NS_OK;
}
// we can't call PositionAt in a subtree iterator...
-nsresult nsContentSubtreeIterator::Last()
+void
+nsContentSubtreeIterator::Last()
{
- if (!mLast)
- return NS_ERROR_FAILURE;
- mIsDone = PR_FALSE;
- if (mLast == mCurNode)
- return NS_OK;
+ mIsDone = mLast == nsnull;
+
mCurNode = mLast;
- return NS_OK;
}
-nsresult nsContentSubtreeIterator::Next()
+void
+nsContentSubtreeIterator::Next()
{
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
+ if (mIsDone || !mCurNode)
+ return;
+
if (mCurNode == mLast)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
- nsCOMPtr nextNode;
- if (NS_FAILED(GetNextSibling(mCurNode, address_of(nextNode), nsnull)))
- return NS_OK;
+ nsCOMPtr nextNode = GetNextSibling(mCurNode, nsnull);
+
/*
nextNode = GetDeepFirstChild(nextNode);
return GetTopAncestorInRange(nextNode, address_of(mCurNode));
@@ -1554,8 +1516,13 @@ nsresult nsContentSubtreeIterator::Next()
// as long as we are finding ancestors of the endpoint of the range,
// dive down into their children
nsIContent *cChild = nextNode->GetChildAt(0);
- if (!cChild)
- return NS_ERROR_NULL_POINTER;
+ if (!cChild) {
+ // XXX: Is this check necessary?
+
+ NS_ERROR("Iterator error, expected a child node!");
+
+ return;
+ }
// should be impossible to get a null pointer. If we went all the
// down the child chain to the bottom without finding an interior node,
@@ -1565,34 +1532,39 @@ nsresult nsContentSubtreeIterator::Next()
i = mEndNodes.IndexOf(nextNode.get());
}
- mCurNode = do_QueryInterface(nextNode);
- return NS_OK;
+ mCurNode = nextNode;
+
+ return;
}
-nsresult nsContentSubtreeIterator::Prev()
+void
+nsContentSubtreeIterator::Prev()
{
- // Prev should be optimized to use the mStartNodes, just as Next uses mEndNodes.
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
+ // Prev should be optimized to use the mStartNodes, just as Next
+ // uses mEndNodes.
+ if (mIsDone || !mCurNode)
+ return;
+
if (mCurNode == mFirst)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
-
- nsCOMPtr prevNode;
- prevNode = GetDeepFirstChild(mCurNode, nsnull);
- if (NS_FAILED(PrevNode(address_of(prevNode), nsnull)))
- return NS_OK;
+
+ nsIContent *prevNode = PrevNode(GetDeepFirstChild(mCurNode, nsnull), nsnull);
+
prevNode = GetDeepLastChild(prevNode, nsnull);
- return GetTopAncestorInRange(prevNode, address_of(mCurNode));
+
+ GetTopAncestorInRange(prevNode, address_of(mCurNode));
}
-nsresult nsContentSubtreeIterator::PositionAt(nsIContent* aCurNode)
+
+nsresult
+nsContentSubtreeIterator::PositionAt(nsIContent* aCurNode)
{
+ NS_ERROR("Not implemented!");
+
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -1600,9 +1572,9 @@ nsresult nsContentSubtreeIterator::PositionAt(nsIContent* aCurNode)
* nsContentSubtreeIterator helper routines
****************************************************************/
-nsresult nsContentSubtreeIterator::GetTopAncestorInRange(
- nsCOMPtr aNode,
- nsCOMPtr *outAnestor)
+nsresult
+nsContentSubtreeIterator::GetTopAncestorInRange(nsIContent *aNode,
+ nsCOMPtr *outAnestor)
{
if (!aNode)
return NS_ERROR_NULL_POINTER;
diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp
index 9e1bf08af81..e41f3fe6251 100644
--- a/mozilla/content/base/src/nsContentList.cpp
+++ b/mozilla/content/base/src/nsContentList.cpp
@@ -103,36 +103,30 @@ nsBaseContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
return CallQueryInterface(tmp, aReturn);
}
-NS_IMETHODIMP
+void
nsBaseContentList::AppendElement(nsIContent *aContent)
{
// Shouldn't hold a reference since we'll be told when the content
// leaves the document or the document will be destroyed.
mElements.AppendElement(aContent);
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBaseContentList::RemoveElement(nsIContent *aContent)
{
mElements.RemoveElement(aContent);
-
- return NS_OK;
}
-NS_IMETHODIMP_(PRInt32)
+PRInt32
nsBaseContentList::IndexOf(nsIContent *aContent, PRBool aDoFlush)
{
return mElements.IndexOf(aContent);
}
-NS_IMETHODIMP
+void
nsBaseContentList::Reset()
{
mElements.Clear();
-
- return NS_OK;
}
// static
@@ -173,15 +167,15 @@ nsFormContentList::~nsFormContentList()
Reset();
}
-NS_IMETHODIMP
+void
nsFormContentList::AppendElement(nsIContent *aContent)
{
NS_ADDREF(aContent);
- return nsBaseContentList::AppendElement(aContent);
+ nsBaseContentList::AppendElement(aContent);
}
-NS_IMETHODIMP
+void
nsFormContentList::RemoveElement(nsIContent *aContent)
{
PRInt32 i = mElements.IndexOf(aContent);
@@ -193,11 +187,9 @@ nsFormContentList::RemoveElement(nsIContent *aContent)
mElements.RemoveElementAt(i);
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsFormContentList::Reset()
{
PRInt32 i, length = mElements.Count();
@@ -208,7 +200,7 @@ nsFormContentList::Reset()
NS_RELEASE(content);
}
- return nsBaseContentList::Reset();
+ nsBaseContentList::Reset();
}
// Hashtable for storing nsContentLists
@@ -405,21 +397,18 @@ NS_IMPL_ADDREF_INHERITED(nsContentList, nsBaseContentList)
NS_IMPL_RELEASE_INHERITED(nsContentList, nsBaseContentList)
-NS_IMETHODIMP
-nsContentList::GetParentObject(nsISupports** aParentObject)
+nsISupports *
+nsContentList::GetParentObject()
{
if (mRootContent) {
- *aParentObject = mRootContent;
- } else {
- *aParentObject = mDocument;
+ return mRootContent;
}
- NS_IF_ADDREF(*aParentObject);
- return NS_OK;
+ return mDocument;
}
-NS_IMETHODIMP_(PRUint32)
-nsContentList::GetLength(PRBool aDoFlush)
+PRUint32
+nsContentList::Length(PRBool aDoFlush)
{
CheckDocumentExistence();
BringSelfUpToDate(aDoFlush);
@@ -427,8 +416,8 @@ nsContentList::GetLength(PRBool aDoFlush)
return mElements.Count();
}
-NS_IMETHODIMP
-nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn, PRBool aDoFlush)
+nsIContent *
+nsContentList::Item(PRUint32 aIndex, PRBool aDoFlush)
{
CheckDocumentExistence();
@@ -443,19 +432,11 @@ nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn, PRBool aDoFlush)
NS_ASSERTION(!mDocument || mState != LIST_DIRTY,
"PopulateSelf left the list in a dirty (useless) state!");
- nsIContent *element = NS_STATIC_CAST(nsIContent *,
- mElements.SafeElementAt(aIndex));
-
- if (element) {
- return CallQueryInterface(element, aReturn);
- }
-
- *aReturn = nsnull;
- return NS_OK;
+ return NS_STATIC_CAST(nsIContent *, mElements.SafeElementAt(aIndex));
}
-NS_IMETHODIMP
-nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn, PRBool aDoFlush)
+nsIContent *
+nsContentList::NamedItem(const nsAString& aName, PRBool aDoFlush)
{
CheckDocumentExistence();
@@ -475,16 +456,15 @@ nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn, PRBool aD
((content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id,
name) == NS_CONTENT_ATTR_HAS_VALUE) &&
aName.Equals(name))) {
- return CallQueryInterface(content, aReturn);
+ return content;
}
}
}
- *aReturn = nsnull;
- return NS_OK;
+ return nsnull;
}
-NS_IMETHODIMP_(PRInt32)
+PRInt32
nsContentList::IndexOf(nsIContent *aContent, PRBool aDoFlush)
{
CheckDocumentExistence();
@@ -496,7 +476,7 @@ nsContentList::IndexOf(nsIContent *aContent, PRBool aDoFlush)
NS_IMETHODIMP
nsContentList::GetLength(PRUint32* aLength)
{
- *aLength = GetLength(PR_TRUE);
+ *aLength = Length(PR_TRUE);
return NS_OK;
}
@@ -504,13 +484,29 @@ nsContentList::GetLength(PRUint32* aLength)
NS_IMETHODIMP
nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
- return Item(aIndex, aReturn, PR_TRUE);
+ nsIContent *content = Item(aIndex, PR_TRUE);
+
+ if (content) {
+ return CallQueryInterface(content, aReturn);
+ }
+
+ *aReturn = nsnull;
+
+ return NS_OK;
}
NS_IMETHODIMP
nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn)
{
- return NamedItem(aName, aReturn, PR_TRUE);
+ nsIContent *content = NamedItem(aName, PR_TRUE);
+
+ if (content) {
+ return CallQueryInterface(content, aReturn);
+ }
+
+ *aReturn = nsnull;
+
+ return NS_OK;
}
NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(nsContentList)
@@ -518,34 +514,30 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsContentList)
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsContentList)
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsContentList)
-NS_IMETHODIMP
+void
nsContentList::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::ContentChanged(nsIDocument* aDocument, nsIContent* aContent,
nsISupports* aSubContent)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent,
PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRInt32 aModType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
@@ -556,7 +548,7 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
* our list and we want to put off doing work as much as possible.
*/
if (mState == LIST_DIRTY)
- return NS_OK;
+ return;
PRInt32 count = aContainer->GetChildCount();
@@ -611,7 +603,7 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
}
}
- return NS_OK;
+ return;
}
/*
@@ -621,7 +613,7 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
* may never get asked for this content... so don't grab it yet.
*/
if (mState == LIST_LAZY) // be lazy
- return NS_OK;
+ return;
/*
* We're up to date. That means someone's actively using us; we
@@ -632,11 +624,9 @@ nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
PopulateWith(aContainer->GetChildAt(i), PR_TRUE, limit);
}
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
@@ -646,15 +636,13 @@ nsContentList::ContentInserted(nsIDocument *aDocument,
// the document itself; any attempted optimizations to this method
// should deal with that.
if (mState == LIST_DIRTY)
- return NS_OK;
+ return;
if (IsDescendantOfRoot(aContainer) && MatchSelf(aChild))
mState = LIST_DIRTY;
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
@@ -662,7 +650,7 @@ nsContentList::ContentReplaced(nsIDocument *aDocument,
PRInt32 aIndexInContainer)
{
if (mState == LIST_DIRTY)
- return NS_OK;
+ return;
if (IsDescendantOfRoot(aContainer)) {
if (MatchSelf(aOldChild) || MatchSelf(aNewChild)) {
@@ -672,11 +660,9 @@ nsContentList::ContentReplaced(nsIDocument *aDocument,
else if (ContainsRoot(aOldChild)) {
DisconnectFromDocument();
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
@@ -693,17 +679,13 @@ nsContentList::ContentRemoved(nsIDocument *aDocument,
else if (ContainsRoot(aChild)) {
DisconnectFromDocument();
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsContentList::DocumentWillBeDestroyed(nsIDocument *aDocument)
{
DisconnectFromDocument();
Reset();
-
- return NS_OK;
}
PRBool
diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h
index eebdcd0576b..0353cdba0c4 100644
--- a/mozilla/content/base/src/nsContentList.h
+++ b/mozilla/content/base/src/nsContentList.h
@@ -65,10 +65,10 @@ public:
// nsIDOMNodeList
NS_DECL_NSIDOMNODELIST
- NS_IMETHOD AppendElement(nsIContent *aContent);
- NS_IMETHOD RemoveElement(nsIContent *aContent);
- NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush);
- NS_IMETHOD Reset();
+ virtual void AppendElement(nsIContent *aContent);
+ virtual void RemoveElement(nsIContent *aContent);
+ virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
+ virtual void Reset();
static void Shutdown();
@@ -87,10 +87,10 @@ public:
nsBaseContentList& aContentList);
virtual ~nsFormContentList();
- NS_IMETHOD AppendElement(nsIContent *aContent);
- NS_IMETHOD RemoveElement(nsIContent *aContent);
+ virtual void AppendElement(nsIContent *aContent);
+ virtual void RemoveElement(nsIContent *aContent);
- NS_IMETHOD Reset();
+ virtual void Reset();
};
/**
@@ -169,18 +169,14 @@ public:
virtual ~nsContentList();
// nsIDOMHTMLCollection
- NS_IMETHOD GetLength(PRUint32* aLength);
- NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
- NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn);
+ NS_DECL_NSIDOMHTMLCOLLECTION
/// nsIContentList
- NS_IMETHOD GetParentObject(nsISupports** aParentObject);
- NS_IMETHOD_(PRUint32) GetLength(PRBool aDoFlush);
- NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
- PRBool aDoFlush);
- NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
- PRBool aDoFlush);
- NS_IMETHOD_(PRInt32) IndexOf(nsIContent *aContent, PRBool aDoFlush);
+ virtual nsISupports *GetParentObject();
+ virtual PRUint32 Length(PRBool aDoFlush);
+ virtual nsIContent *Item(PRUint32 aIndex, PRBool aDoFlush);
+ virtual nsIContent *NamedItem(const nsAString& aName, PRBool aDoFlush);
+ virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER
diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp
index 26f28637b61..d96b8c16c0d 100644
--- a/mozilla/content/base/src/nsContentUtils.cpp
+++ b/mozilla/content/base/src/nsContentUtils.cpp
@@ -465,12 +465,12 @@ nsContentUtils::GetDocumentAndPrincipal(nsIDOMNode* aNode,
if (!domDoc) {
// if we can't get a doc then lets try to get principal through nodeinfo
// manager
- nsCOMPtr ni;
+ nsINodeInfo *ni;
if (content) {
ni = content->GetNodeInfo();
}
else {
- attr->GetNodeInfo(getter_AddRefs(ni));
+ ni = attr->NodeInfo();
}
if (!ni) {
diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp
index ced11f265f0..fbef9f7f8c1 100644
--- a/mozilla/content/base/src/nsDOMAttribute.cpp
+++ b/mozilla/content/base/src/nsDOMAttribute.cpp
@@ -50,7 +50,7 @@
nsDOMAttribute::nsDOMAttribute(nsIContent* aContent, nsINodeInfo *aNodeInfo,
const nsAString& aValue)
- : mContent(aContent), mNodeInfo(aNodeInfo), mValue(aValue), mChild(nsnull),
+ : nsIAttribute(aContent, aNodeInfo), mValue(aValue), mChild(nsnull),
mChildList(nsnull)
{
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
@@ -82,44 +82,9 @@ NS_IMPL_ADDREF(nsDOMAttribute)
NS_IMPL_RELEASE(nsDOMAttribute)
-NS_IMETHODIMP
-nsDOMAttribute::DropReference()
-{
- mContent = nsnull;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMAttribute::SetContent(nsIContent* aContent)
-{
- mContent = aContent;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMAttribute::GetContent(nsIContent** aContent)
-{
- *aContent = mContent;
- NS_IF_ADDREF(*aContent);
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMAttribute::GetNodeInfo(nsINodeInfo** aNodeInfo)
-{
- NS_IF_ADDREF(*aNodeInfo = mNodeInfo);
-
- return NS_OK;
-}
-
nsresult
nsDOMAttribute::GetName(nsAString& aName)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
mNodeInfo->GetQualifiedName(aName);
return NS_OK;
}
@@ -127,8 +92,6 @@ nsDOMAttribute::GetName(nsAString& aName)
nsresult
nsDOMAttribute::GetValue(nsAString& aValue)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
if (mContent) {
nsAutoString tmpValue;
nsresult attrResult = mContent->GetAttr(mNodeInfo->NamespaceID(),
@@ -147,8 +110,6 @@ nsDOMAttribute::GetValue(nsAString& aValue)
nsresult
nsDOMAttribute::SetValue(const nsAString& aValue)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
nsresult result = NS_OK;
if (mContent) {
result = mContent->SetAttr(mNodeInfo->NamespaceID(), mNodeInfo->NameAtom(),
@@ -162,7 +123,6 @@ nsDOMAttribute::SetValue(const nsAString& aValue)
nsresult
nsDOMAttribute::GetSpecified(PRBool* aSpecified)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
NS_ENSURE_ARG_POINTER(aSpecified);
if (!mContent) {
@@ -279,7 +239,7 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
return result;
}
if (!value.IsEmpty()) {
- if (!mChild) {
+ if (!mChild) {
nsCOMPtr content;
result = NS_NewTextNode(getter_AddRefs(content));
@@ -363,10 +323,10 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
nsAutoString value;
mContent->GetAttr(mNodeInfo->NamespaceID(),
mNodeInfo->NameAtom(), value);
- newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value);
+ newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value);
}
else {
- newAttr = new nsDOMAttribute(nsnull, mNodeInfo, mValue);
+ newAttr = new nsDOMAttribute(nsnull, mNodeInfo, mValue);
}
if (!newAttr) {
@@ -376,7 +336,7 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
return CallQueryInterface(newAttr, aReturn);
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
{
nsresult result = NS_OK;
@@ -393,27 +353,22 @@ nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
return result;
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::GetNamespaceURI(nsAString& aNamespaceURI)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::GetPrefix(nsAString& aPrefix)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
mNodeInfo->GetPrefix(aPrefix);
return NS_OK;
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::SetPrefix(const nsAString& aPrefix)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
nsCOMPtr newNodeInfo;
nsCOMPtr prefix;
@@ -443,16 +398,14 @@ nsDOMAttribute::SetPrefix(const nsAString& aPrefix)
return NS_OK;
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::GetLocalName(nsAString& aLocalName)
{
- NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
-
mNodeInfo->GetLocalName(aLocalName);
return NS_OK;
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsDOMAttribute::Normalize()
{
// Nothing to do here
@@ -707,7 +660,7 @@ nsDOMAttribute::GetUserData(const nsAString& aKey,
NS_IMETHODIMP
nsDOMAttribute::LookupPrefix(const nsAString& aNamespaceURI,
- nsAString& aPrefix)
+ nsAString& aPrefix)
{
aPrefix.Truncate();
@@ -744,7 +697,7 @@ nsAttributeChildList::~nsAttributeChildList()
{
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsAttributeChildList::GetLength(PRUint32* aLength)
{
*aLength = 0;
@@ -759,7 +712,7 @@ nsAttributeChildList::GetLength(PRUint32* aLength)
return NS_OK;
}
-NS_IMETHODIMP
+NS_IMETHODIMP
nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
*aReturn = nsnull;
@@ -770,7 +723,7 @@ nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
return NS_OK;
}
-void
+void
nsAttributeChildList::DropReference()
{
mAttribute = nsnull;
diff --git a/mozilla/content/base/src/nsDOMAttribute.h b/mozilla/content/base/src/nsDOMAttribute.h
index 43ce3a67aa7..f7e6076ddb9 100644
--- a/mozilla/content/base/src/nsDOMAttribute.h
+++ b/mozilla/content/base/src/nsDOMAttribute.h
@@ -89,16 +89,11 @@ public:
// nsIDOMAttr interface
NS_DECL_NSIDOMATTR
-
+
// nsIAttribute interface
- NS_IMETHOD DropReference();
- NS_IMETHOD SetContent(nsIContent* aContent);
- NS_IMETHOD GetContent(nsIContent** aContent);
- NS_IMETHOD GetNodeInfo(nsINodeInfo** aNodeInfo);
+ // No methods, all inline.
private:
- nsIContent* mContent;
- nsCOMPtr mNodeInfo;
nsString mValue;
// XXX For now, there's only a single child - a text
// element representing the value
diff --git a/mozilla/content/base/src/nsDOMAttributeMap.cpp b/mozilla/content/base/src/nsDOMAttributeMap.cpp
index 17f5a91d7f5..9076ac7bac4 100644
--- a/mozilla/content/base/src/nsDOMAttributeMap.cpp
+++ b/mozilla/content/base/src/nsDOMAttributeMap.cpp
@@ -411,11 +411,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
"didn't implement nsIAttribute");
NS_ENSURE_TRUE(attr, NS_ERROR_UNEXPECTED);
-
- nsCOMPtr ni;
- attr->GetNodeInfo(getter_AddRefs(ni));
- NS_ENSURE_TRUE(ni, NS_ERROR_UNEXPECTED);
-
+ nsINodeInfo *ni = attr->NodeInfo();
mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE);
return NS_OK;
diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp
index 9a76a396d75..c725496b5d9 100644
--- a/mozilla/content/base/src/nsDocument.cpp
+++ b/mozilla/content/base/src/nsDocument.cpp
@@ -235,7 +235,33 @@ nsDOMStyleSheetList::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn)
return NS_OK;
}
-NS_IMETHODIMP
+NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(nsDOMStyleSheetList)
+NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsDOMStyleSheetList)
+NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsDOMStyleSheetList)
+NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(nsDOMStyleSheetList)
+
+void
+nsDOMStyleSheetList::BeginUpdate(nsIDocument* aDocument,
+ nsUpdateType aUpdateType)
+{
+}
+
+void
+nsDOMStyleSheetList::EndUpdate(nsIDocument* aDocument,
+ nsUpdateType aUpdateType)
+{
+}
+
+void
+nsDOMStyleSheetList::DocumentWillBeDestroyed(nsIDocument *aDocument)
+{
+ if (nsnull != mDocument) {
+ aDocument->RemoveObserver(this);
+ mDocument = nsnull;
+ }
+}
+
+void
nsDOMStyleSheetList::StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet)
{
@@ -245,11 +271,9 @@ nsDOMStyleSheetList::StyleSheetAdded(nsIDocument *aDocument,
mLength++;
}
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsDOMStyleSheetList::StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet)
{
@@ -259,20 +283,38 @@ nsDOMStyleSheetList::StyleSheetRemoved(nsIDocument *aDocument,
mLength--;
}
}
- return NS_OK;
}
-NS_IMETHODIMP
-nsDOMStyleSheetList::DocumentWillBeDestroyed(nsIDocument *aDocument)
+void
+nsDOMStyleSheetList::StyleSheetApplicableStateChanged(nsIDocument* aDocument,
+ nsIStyleSheet* aStyleSheet,
+ PRBool aApplicable)
{
- if (nsnull != mDocument) {
- aDocument->RemoveObserver(this);
- mDocument = nsnull;
- }
-
- return NS_OK;
}
+void
+nsDOMStyleSheetList::StyleRuleChanged(nsIDocument* aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aOldStyleRule,
+ nsIStyleRule* aNewStyleRule)
+{
+}
+
+void
+nsDOMStyleSheetList::StyleRuleAdded(nsIDocument* aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule)
+{
+}
+
+void
+nsDOMStyleSheetList::StyleRuleRemoved(nsIDocument* aDocument,
+ nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule)
+{
+}
+
+
class nsDOMImplementation : public nsIDOMDOMImplementation,
public nsIPrivateDOMImplementation
{
diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h
index 1bbd71aa7d6..1559fd27e96 100644
--- a/mozilla/content/base/src/nsDocument.h
+++ b/mozilla/content/base/src/nsDocument.h
@@ -154,65 +154,7 @@ public:
NS_DECL_NSIDOMSTYLESHEETLIST
- NS_IMETHOD BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) {
- return NS_OK;
- }
- NS_IMETHOD EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) {
- return NS_OK;
- }
- NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
- NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
- NS_IMETHOD BeginReflow(nsIDocument *aDocument,
- nsIPresShell* aShell) { return NS_OK; }
- NS_IMETHOD EndReflow(nsIDocument *aDocument,
- nsIPresShell* aShell) { return NS_OK; }
- NS_IMETHOD ContentChanged(nsIDocument *aDocument,
- nsIContent* aContent,
- nsISupports* aSubContent) { return NS_OK; }
- NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
- nsIContent* aContent1,
- nsIContent* aContent2,
- PRInt32 aStateMask) { return NS_OK; }
- NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
- nsIContent* aContent,
- PRInt32 aNameSpaceID,
- nsIAtom* aAttribute,
- PRInt32 aModType) { return NS_OK; }
- NS_IMETHOD ContentAppended(nsIDocument *aDocument,
- nsIContent* aContainer,
- PRInt32 aNewIndexInContainer)
- { return NS_OK; }
- NS_IMETHOD ContentInserted(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer) { return NS_OK; }
- NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aOldChild,
- nsIContent* aNewChild,
- PRInt32 aIndexInContainer) { return NS_OK; }
- NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer) { return NS_OK; }
- NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet);
- NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet);
- NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- PRBool aApplicable) { return NS_OK; }
- NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aOldStyleRule,
- nsIStyleRule* aNewStyleRule) { return NS_OK; }
- NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule) { return NS_OK; }
- NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
- nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule) { return NS_OK; }
- NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
+ NS_DECL_NSIDOCUMENTOBSERVER
protected:
PRInt32 mLength;
diff --git a/mozilla/content/base/src/nsGeneratedIterator.cpp b/mozilla/content/base/src/nsGeneratedIterator.cpp
index c621caa0fb5..c58bd4b7c6b 100644
--- a/mozilla/content/base/src/nsGeneratedIterator.cpp
+++ b/mozilla/content/base/src/nsGeneratedIterator.cpp
@@ -59,10 +59,10 @@
#define DO_BEFORE 1
///////////////////////////////////////////////////////////////////////////
-// GetNumChildren: returns the number of things inside aNode.
+// GetNumChildren: returns the number of things inside aNode.
//
static PRUint32
-GetNumChildren(nsIDOMNode *aNode)
+GetNumChildren(nsIDOMNode *aNode)
{
PRUint32 numChildren = 0;
if (!aNode)
@@ -74,7 +74,7 @@ GetNumChildren(nsIDOMNode *aNode)
{
nsCOMPtrnodeList;
nsresult res = aNode->GetChildNodes(getter_AddRefs(nodeList));
- if (NS_SUCCEEDED(res) && nodeList)
+ if (NS_SUCCEEDED(res) && nodeList)
nodeList->GetLength(&numChildren);
}
return numChildren;
@@ -83,32 +83,33 @@ GetNumChildren(nsIDOMNode *aNode)
///////////////////////////////////////////////////////////////////////////
// GetChildAt: returns the node at this position index in the parent
//
-static nsCOMPtr
+static nsCOMPtr
GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
{
nsCOMPtr resultNode;
-
- if (!aParent)
+
+ if (!aParent)
return resultNode;
-
+
PRBool hasChildNodes;
aParent->HasChildNodes(&hasChildNodes);
if (PR_TRUE==hasChildNodes)
{
nsCOMPtrnodeList;
nsresult res = aParent->GetChildNodes(getter_AddRefs(nodeList));
- if (NS_SUCCEEDED(res) && nodeList)
+ if (NS_SUCCEEDED(res) && nodeList)
nodeList->Item(aOffset, getter_AddRefs(resultNode));
}
-
+
return resultNode;
}
-
+
/*
* A simple iterator class for traversing the generated content in "close tag" order
*/
-class nsGeneratedContentIterator : public nsIContentIterator ,public nsIGeneratedContentIterator//, public nsIEnumerator
+class nsGeneratedContentIterator : public nsIContentIterator,
+ public nsIGeneratedContentIterator
{
public:
NS_DECL_ISUPPORTS
@@ -118,46 +119,46 @@ public:
// nsIContentIterator interface methods ------------------------------
- NS_IMETHOD Init(nsIContent* aRoot);
+ virtual nsresult Init(nsIContent* aRoot);
- NS_IMETHOD Init(nsIDOMRange* aRange);
+ virtual nsresult Init(nsIDOMRange* aRange);
- NS_IMETHOD First();
+ virtual void First();
- NS_IMETHOD Last();
-
- NS_IMETHOD Next();
+ virtual void Last();
- NS_IMETHOD Prev();
+ virtual void Next();
- NS_IMETHOD CurrentNode(nsIContent **aNode);
+ virtual void Prev();
- NS_IMETHOD IsDone();
+ virtual nsIContent *GetCurrentNode();
- NS_IMETHOD PositionAt(nsIContent* aCurNode);
+ virtual PRBool IsDone();
+
+ virtual nsresult PositionAt(nsIContent* aCurNode);
// nsIEnumertor interface methods ------------------------------
-
+
//NS_IMETHOD CurrentItem(nsISupports **aItem);
//nsIGeneratedContentIterator
- NS_IMETHOD Init(nsIPresShell *aShell, nsIDOMRange* aRange);
- NS_IMETHOD Init(nsIPresShell *aShell, nsIContent* aContent);
+ virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange);
+ virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent);
protected:
// Do these cause too much refcounting???
nsCOMPtr GetDeepFirstChild(nsCOMPtr aRoot);
nsCOMPtr GetDeepLastChild(nsCOMPtr aRoot);
-
- nsresult GetNextSibling(nsCOMPtr aNode, nsCOMPtr *aSibling);
- nsresult GetPrevSibling(nsCOMPtr aNode, nsCOMPtr *aSibling);
-
- nsresult NextNode(nsCOMPtr *ioNextNode);
- nsresult PrevNode(nsCOMPtr *ioPrevNode);
+
+ nsIContent *GetNextSibling(nsIContent *aNode);
+ nsIContent *GetPrevSibling(nsIContent *aNode);
+
+ nsIContent *NextNode(nsIContent *aNode);
+ nsIContent *PrevNode(nsIContent *aNode);
void MakeEmpty();
-
+
nsCOMPtr mCurNode;
nsCOMPtr mFirst;
nsCOMPtr mLast;
@@ -171,7 +172,7 @@ protected:
nsIPresShell::GeneratedContentType mLastIterType;
nsCOMPtr mPresShell;
PRBool mIsDone;
-
+
private:
// no copy's or assigns FIX ME
@@ -185,67 +186,34 @@ private:
* repository cruft
******************************************************/
-nsresult NS_NewGenRegularIterator(nsIContentIterator ** aInstancePtrResult)
+nsresult
+NS_NewGenRegularIterator(nsIContentIterator ** aInstancePtrResult)
{
nsGeneratedContentIterator * iter = new nsGeneratedContentIterator();
if (!iter) {
return NS_ERROR_OUT_OF_MEMORY;
}
- return CallQueryInterface(iter, aInstancePtrResult);
+ NS_ADDREF(*aInstancePtrResult = iter);
+
+ return NS_OK;
}
/******************************************************
* XPCOM cruft
******************************************************/
-
-NS_IMPL_ADDREF(nsGeneratedContentIterator)
-NS_IMPL_RELEASE(nsGeneratedContentIterator)
-nsresult nsGeneratedContentIterator::QueryInterface(const nsIID& aIID,
- void** aInstancePtrResult)
-{
- NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
- if (nsnull == aInstancePtrResult)
- {
- return NS_ERROR_NULL_POINTER;
- }
- if (aIID.Equals(NS_GET_IID(nsISupports)))
- {
- *aInstancePtrResult = (void*)(nsISupports*)(nsIContentIterator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
-/* if (aIID.Equals(NS_GET_IID(nsIEnumerator)))
- {
- *aInstancePtrResult = (void*)(nsIEnumerator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- } */
- if (aIID.Equals(NS_GET_IID(nsIContentIterator)))
- {
- *aInstancePtrResult = (void*)(nsIContentIterator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
- if (aIID.Equals(NS_GET_IID(nsIGeneratedContentIterator)))
- {
- *aInstancePtrResult = (void*)(nsIGeneratedContentIterator*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
- return NS_NOINTERFACE;
-}
+NS_IMPL_ISUPPORTS2(nsGeneratedContentIterator, nsIGeneratedContentIterator,
+ nsIContentIterator)
/******************************************************
* constructor/destructor
******************************************************/
-nsGeneratedContentIterator::nsGeneratedContentIterator() :
- // don't need to explicitly initialize |nsCOMPtr|s, they will automatically be NULL
- mIsDone(PR_FALSE)
+nsGeneratedContentIterator::nsGeneratedContentIterator()
+ : mIsDone(PR_FALSE)
{
}
@@ -260,12 +228,13 @@ nsGeneratedContentIterator::~nsGeneratedContentIterator()
******************************************************/
-nsresult nsGeneratedContentIterator::Init(nsIContent* aRoot)
+nsresult
+nsGeneratedContentIterator::Init(nsIContent* aRoot)
{
- if (!aRoot)
- return NS_ERROR_NULL_POINTER;
+ if (!aRoot)
+ return NS_ERROR_NULL_POINTER;
mIsDone = PR_FALSE;
- nsCOMPtr root( do_QueryInterface(aRoot) );
+ nsCOMPtr root(aRoot);
mFirst = GetDeepFirstChild(root);
if (mGenIter)//we have generated
{
@@ -278,14 +247,14 @@ nsresult nsGeneratedContentIterator::Init(nsIContent* aRoot)
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
nsGeneratedContentIterator::Init(nsIPresShell *aShell, nsIDOMRange* aRange)
{
mPresShell = aShell;
return Init(aRange);
}
-NS_IMETHODIMP
+nsresult
nsGeneratedContentIterator::Init(nsIPresShell *aShell, nsIContent* aContent)
{
mPresShell = aShell;
@@ -293,20 +262,21 @@ nsGeneratedContentIterator::Init(nsIPresShell *aShell, nsIContent* aContent)
}
-nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
+nsresult
+nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
{
- if (!aRange)
- return NS_ERROR_NULL_POINTER;
+ if (!aRange)
+ return NS_ERROR_NULL_POINTER;
nsCOMPtr dN;
-
+
nsCOMPtr startCon;
nsCOMPtr startDOM;
nsCOMPtr endCon;
nsCOMPtr endDOM;
PRInt32 startIndx;
PRInt32 endIndx;
-
+
mIsDone = PR_FALSE;
// get common content parent
@@ -316,20 +286,20 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
// get the start node and offset, convert to nsIContent
aRange->GetStartContainer(getter_AddRefs(startDOM));
- if (!startDOM)
+ if (!startDOM)
return NS_ERROR_ILLEGAL_VALUE;
startCon = do_QueryInterface(startDOM);
- if (!startCon)
+ if (!startCon)
return NS_ERROR_FAILURE;
-
+
aRange->GetStartOffset(&startIndx);
-
+
// get the end node and offset, convert to nsIContent
aRange->GetEndContainer(getter_AddRefs(endDOM));
- if (!endDOM)
+ if (!endDOM)
return NS_ERROR_ILLEGAL_VALUE;
endCon = do_QueryInterface(endDOM);
- if (!endCon)
+ if (!endCon)
return NS_ERROR_FAILURE;
aRange->GetEndOffset(&endIndx);
@@ -356,10 +326,10 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
}
}
}
-
+
if (!cChild) // no children, must be a text node
{
- mFirst = startCon;
+ mFirst = startCon;
}
else
{
@@ -382,24 +352,24 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
// 'degenerate', ie not collapsed but still containing
// no content. In this case, we want the iterator to
// be empty
-
+
if (!IsNodeIntersectsRange(mFirst, aRange))
{
MakeEmpty();
return NS_OK;
}
}
-
+
// find last node in range
cChild = endCon->GetChildAt(0);
if (!cChild) // no children, must be a text node
{
- mLast = endCon;
+ mLast = endCon;
}
else if (endIndx == 0) // before first child, parent is last node
{
- mLast = endCon;
+ mLast = endCon;
}
else
{
@@ -411,12 +381,12 @@ nsresult nsGeneratedContentIterator::Init(nsIDOMRange* aRange)
if (!cChild)
{
NS_NOTREACHED("nsGeneratedContentIterator::nsGeneratedContentIterator");
- return NS_ERROR_FAILURE;
+ return NS_ERROR_FAILURE;
}
}
- mLast = cChild;
+ mLast = cChild;
}
-
+
mCurNode = mFirst;
return NS_OK;
}
@@ -442,9 +412,9 @@ void nsGeneratedContentIterator::MakeEmpty()
nsCOMPtr nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr aRoot)
{
nsCOMPtr deepFirstChild;
-
- if (aRoot)
- {
+
+ if (aRoot)
+ {
nsCOMPtr cN = aRoot;
#if DO_BEFORE
@@ -480,19 +450,19 @@ nsCOMPtr nsGeneratedContentIterator::GetDeepFirstChild(nsCOMPtr nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr aRoot)
{
nsCOMPtr deepFirstChild;
-
- if (aRoot)
- {
+
+ if (aRoot)
+ {
nsCOMPtr cN = aRoot;
nsCOMPtr cChild;
-
+
#if DO_AFTER
//CHECK FOR AFTER STUFF
nsresult result = NS_ERROR_FAILURE;
@@ -534,302 +504,287 @@ nsCOMPtr nsGeneratedContentIterator::GetDeepLastChild(nsCOMPtr aNode, nsCOMPtr *aSibling)
+nsIContent *
+nsGeneratedContentIterator::GetNextSibling(nsIContent *aNode)
{
- if (!aNode)
- return NS_ERROR_NULL_POINTER;
- if (!aSibling)
- return NS_ERROR_NULL_POINTER;
-
+ if (!aNode)
+ return nsnull;
nsIContent *parent = aNode->GetParent();
if (!parent)
- return NS_ERROR_FAILURE;
+ return nsnull;
PRInt32 indx = parent->IndexOf(aNode);
nsIContent *sib = parent->GetChildAt(++indx);
- if (sib)
- {
- *aSibling = sib;
- }
- else //CHECK AFTER CONTEXT ON PARENT
+ if (!sib)
{
#if DO_AFTER
//CHECK FOR AFTERESTUFF
- nsresult result = NS_ERROR_FAILURE;
if (mPresShell)
- result = mPresShell->GetGeneratedContentIterator(parent,nsIPresShell::After,getter_AddRefs(mGenIter));
- if (NS_SUCCEEDED(result) && mGenIter)
+ mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::After,
+ getter_AddRefs(mGenIter));
+ if (mGenIter)
{ //ok we have a generated iter all bets are off
mGenIter->First();
mIterType = nsIPresShell::After;
- *aSibling = parent;
- return result;
+
+ return parent;
}
-#endif
+#endif
if (parent != mCommonParent)
{
- return GetNextSibling(parent, aSibling);
+ return GetNextSibling(parent);
}
else
{
- *aSibling = nsCOMPtr();
+ sib = nsnull;
}
}
-
- return NS_OK;
+
+ return sib;
}
// Get the prev sibling, or parents prev sibling, or grandpa's prev sibling...
-nsresult nsGeneratedContentIterator::GetPrevSibling(nsCOMPtr aNode, nsCOMPtr *aSibling)
+nsIContent *
+nsGeneratedContentIterator::GetPrevSibling(nsIContent *aNode)
{
- if (!aNode)
- return NS_ERROR_NULL_POINTER;
- if (!aSibling)
- return NS_ERROR_NULL_POINTER;
-
- nsCOMPtr sib;
- nsCOMPtr parent;
+ if (!aNode)
+ return nsnull;
- parent = aNode->GetParent();
+ nsIContent *parent = aNode->GetParent();
if (!parent)
- return NS_ERROR_FAILURE;
+ return nsnull;
PRInt32 indx = parent->IndexOf(aNode);
+ nsIContent *sib = nsnull;
- if (indx && (sib = parent->GetChildAt(--indx)))
- {
- *aSibling = sib;
- }
- else
+ if (indx < 1 || !(sib = parent->GetChildAt(--indx)))
{
#if DO_BEFORE
//CHECK FOR BEFORESTUFF
- nsresult result = NS_ERROR_FAILURE;
if (mPresShell)
- result = mPresShell->GetGeneratedContentIterator(parent,nsIPresShell::Before,getter_AddRefs(mGenIter));
- if (NS_SUCCEEDED(result) && mGenIter)
+ mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::Before,
+ getter_AddRefs(mGenIter));
+ if (mGenIter)
{ //ok we have a generated iter all bets are off
mGenIter->Last();
- *aSibling = parent;
mIterType = nsIPresShell::Before;
- return result;
+ return parent;
}
else
#endif
if (parent != mCommonParent)
{
- return GetPrevSibling(parent, aSibling);
+ return GetPrevSibling(parent);
}
else
{
- *aSibling = nsCOMPtr();
+ sib = nsnull;
}
- }
- return NS_OK;
+ }
+
+ return sib;
}
-nsresult nsGeneratedContentIterator::NextNode(nsCOMPtr *ioNextNode)
+nsIContent *
+nsGeneratedContentIterator::NextNode(nsIContent *aNode)
{
- if (!ioNextNode)
- return NS_ERROR_NULL_POINTER;
-
+ if (!aNode)
+ return nsnull;
+
if (mGenIter)
{
if (mGenIter->IsDone())
mGenIter = 0;
- else
- return mGenIter->Next();
+ else {
+ mGenIter->Next();
+
+ return nsnull;
+ }
+
if (nsIPresShell::After == mIterType)//answer is parent
{
//*ioNextNode = parent; leave it the same
- return NS_OK;
+ return nsnull;
}
- nsIContent *cN = (*ioNextNode)->GetChildAt(0);
+ nsIContent *cN = aNode->GetChildAt(0);
if (cN)
{
- *ioNextNode = GetDeepFirstChild(cN);
-
- return NS_OK;
+ return GetDeepFirstChild(cN);
}
}
- {
- nsCOMPtr cN = *ioNextNode;
- nsCOMPtr parent;
-
+ nsIContent *cN = aNode;
+
// get next sibling if there is one
- parent = cN->GetParent();
- if (!parent)
- {
- // a little noise to catch some iterator usage bugs.
- NS_NOTREACHED("nsGeneratedContentIterator::NextNode() : no parent found");
- return NS_ERROR_FAILURE;
- }
-
- PRInt32 indx = parent->IndexOf(cN);
-
- nsIContent *cSibling = parent->GetChildAt(++indx);
- if (cSibling)
- {
- // next node is siblings "deep left" child
- *ioNextNode = GetDeepFirstChild(cSibling);
- return NS_OK;
- }
- //CHECK FOR AFTERSTUFF
- if (mGenIter)//we allready had an afteriter. it must be done!
- {
- mGenIter = 0;
- }
- else//check for after node.
- {
- nsresult result = NS_ERROR_FAILURE;
- if (mPresShell)
- result = mPresShell->GetGeneratedContentIterator(parent,nsIPresShell::After,getter_AddRefs(mGenIter));
- if (NS_SUCCEEDED(result) && mGenIter)
- { //ok we have a generated iter all bets are off
- mGenIter->First();
- mIterType = nsIPresShell::After;
- }
- else
- mGenIter = 0;
- }
-
- // else it's the parent
- *ioNextNode = parent;
+ nsIContent *parent = cN->GetParent();
+ if (!parent)
+ {
+ // a little noise to catch some iterator usage bugs.
+ NS_NOTREACHED("nsGeneratedContentIterator::NextNode() : no parent found");
+ return nsnull;
}
- return NS_OK;
+
+ PRInt32 indx = parent->IndexOf(cN);
+
+ nsIContent *cSibling = parent->GetChildAt(++indx);
+ if (cSibling)
+ {
+ // next node is siblings "deep left" child
+ return GetDeepFirstChild(cSibling);
+ }
+
+ //CHECK FOR AFTERSTUFF
+ if (mGenIter)//we allready had an afteriter. it must be done!
+ {
+ mGenIter = 0;
+ }
+ else//check for after node.
+ {
+ if (mPresShell)
+ mPresShell->GetGeneratedContentIterator(parent, nsIPresShell::After,
+ getter_AddRefs(mGenIter));
+ if (mGenIter)
+ { //ok we have a generated iter all bets are off
+ mGenIter->First();
+ mIterType = nsIPresShell::After;
+ }
+ else
+ mGenIter = 0;
+ }
+
+ // else it's the parent
+ return parent;
}
//THIS NEEDS TO USE A GENERATED SUBTREEITER HERE
-nsresult
-nsGeneratedContentIterator::PrevNode(nsCOMPtr *ioNextNode)
+nsIContent *
+nsGeneratedContentIterator::PrevNode(nsIContent *aNode)
{
- if (!ioNextNode)
- return NS_ERROR_NULL_POINTER;
-
- nsIContent *cN = *ioNextNode;
-
- PRUint32 numChildren = cN->GetChildCount();
+ PRUint32 numChildren = aNode->GetChildCount();
// if it has children then prev node is last child
if (numChildren > 0)
{
- nsIContent *cLastChild = cN->GetChildAt(--numChildren);
-
- if (!cLastChild)
- return NS_ERROR_FAILURE;
-
- *ioNextNode = cLastChild;
-
- return NS_OK;
+ return aNode->GetChildAt(--numChildren);
}
-
+
// else prev sibling is previous
- return GetPrevSibling(cN, ioNextNode);
+ return GetPrevSibling(aNode);
}
/******************************************************
* ContentIterator routines
******************************************************/
-nsresult nsGeneratedContentIterator::First()
+void
+nsGeneratedContentIterator::First()
{
- if (!mFirst)
- return NS_ERROR_FAILURE;
+ if (!mFirst) {
+ mIsDone = PR_TRUE;
+
+ return;
+ }
+
mIsDone = PR_FALSE;
+
mCurNode = mFirst;
mGenIter = mFirstIter;
if (mGenIter)//set directionback to before...
mGenIter->First();
- return NS_OK;
}
-nsresult nsGeneratedContentIterator::Last()
+void
+nsGeneratedContentIterator::Last()
{
- if (!mLast)
- return NS_ERROR_FAILURE;
+ if (!mLast) {
+ mIsDone = PR_TRUE;
+
+ return;
+ }
+
mIsDone = PR_FALSE;
+
mGenIter = mLastIter;
mCurNode = mLast;
- return NS_OK;
}
-nsresult nsGeneratedContentIterator::Next()
+void
+nsGeneratedContentIterator::Next()
{
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
- nsCOMPtr curnode;
- CurrentNode(getter_AddRefs(curnode));
- if (curnode == mLast)
+ if (mIsDone || !mCurNode)
+ return;
+
+ if (GetCurrentNode() == mLast)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
-
- return NextNode(address_of(mCurNode));
+
+ mCurNode = NextNode(mCurNode);
}
-nsresult nsGeneratedContentIterator::Prev()
+void
+nsGeneratedContentIterator::Prev()
{
- if (mIsDone)
- return NS_OK;
- if (!mCurNode)
- return NS_OK;
- if (mCurNode == mFirst)
+ if (mIsDone)
+ return;
+ if (!mCurNode)
+ return;
+ if (mCurNode == mFirst)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
}
-
- return PrevNode(address_of(mCurNode));
+
+ mCurNode = PrevNode(mCurNode);
}
-nsresult nsGeneratedContentIterator::IsDone()
+PRBool
+nsGeneratedContentIterator::IsDone()
{
- if (mIsDone)
- return NS_OK;
- else
- return NS_ENUMERATOR_FALSE;
+ return mIsDone;
}
-nsresult nsGeneratedContentIterator::PositionAt(nsIContent* aCurNode)
+nsresult
+nsGeneratedContentIterator::PositionAt(nsIContent* aCurNode)
{
// XXX need to confirm that aCurNode is within range
if (!aCurNode)
return NS_ERROR_NULL_POINTER;
- mCurNode = do_QueryInterface(aCurNode);
+ mCurNode = aCurNode;
mIsDone = PR_FALSE;
return NS_OK;
}
-nsresult nsGeneratedContentIterator::CurrentNode(nsIContent **aNode)
+nsIContent *
+nsGeneratedContentIterator::GetCurrentNode()
{
if (!mCurNode || mIsDone) {
- return NS_ERROR_FAILURE;
+ return nsnull;
}
if (mGenIter) {
- return mGenIter->CurrentNode(aNode);
+ return mGenIter->GetCurrentNode();
}
- return CallQueryInterface(mCurNode, aNode);
+ NS_ASSERTION(mCurNode, "Null current node in an iterator that's not done!");
+
+ return mCurNode;
}
@@ -847,7 +802,7 @@ nsresult nsGeneratedContentIterator::CurrentNode(nsIContent **aNode)
/*
* A simple iterator class for traversing the content in "top subtree" order
*/
-class nsGeneratedSubtreeIterator : public nsGeneratedContentIterator
+class nsGeneratedSubtreeIterator : public nsGeneratedContentIterator
{
public:
nsGeneratedSubtreeIterator() {};
@@ -855,24 +810,24 @@ public:
// nsContentIterator overrides ------------------------------
- NS_IMETHOD Init(nsIContent* aRoot);
+ virtual nsresult Init(nsIContent* aRoot);
- NS_IMETHOD Init(nsIDOMRange* aRange);
+ virtual nsresult Init(nsIDOMRange* aRange);
- NS_IMETHOD Next();
+ virtual void Next();
- NS_IMETHOD Prev();
+ virtual void Prev();
- NS_IMETHOD PositionAt(nsIContent* aCurNode);
+ virtual nsresult PositionAt(nsIContent* aCurNode);
//nsIGeneratedContentIterator
- NS_IMETHOD Init(nsIPresShell *aShell, nsIDOMRange* aRange);
- NS_IMETHOD Init(nsIPresShell *aShell, nsIContent* aContent);
+ virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange);
+ virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent);
protected:
nsresult GetTopAncestorInRange( nsCOMPtr aNode,
nsCOMPtr *outAnestor);
-
+
// no copy's or assigns FIX ME
nsGeneratedSubtreeIterator(const nsGeneratedSubtreeIterator&);
nsGeneratedSubtreeIterator& operator=(const nsGeneratedSubtreeIterator&);
@@ -895,7 +850,9 @@ nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
}
- return CallQueryInterface(iter, aInstancePtrResult);
+ NS_ADDREF(*aInstancePtrResult = iter);
+
+ return NS_OK;
}
@@ -905,34 +862,36 @@ nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult)
******************************************************/
-nsresult nsGeneratedSubtreeIterator::Init(nsIContent* aRoot)
+nsresult
+nsGeneratedSubtreeIterator::Init(nsIContent* aRoot)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
-NS_IMETHODIMP
+nsresult
nsGeneratedSubtreeIterator::Init(nsIPresShell *aShell, nsIDOMRange* aRange)
{
mPresShell = aShell;
return Init(aRange);
}
-NS_IMETHODIMP
+nsresult
nsGeneratedSubtreeIterator::Init(nsIPresShell *aShell, nsIContent* aContent)
{
mPresShell = aShell;
return Init(aContent);
}
-nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
+nsresult
+nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
{
- if (!aRange)
- return NS_ERROR_NULL_POINTER;
+ if (!aRange)
+ return NS_ERROR_NULL_POINTER;
mIsDone = PR_FALSE;
- mRange = do_QueryInterface(aRange);
-
+ mRange = aRange;
+
// get the start node and offset, convert to nsIContent
nsCOMPtr commonParent;
nsCOMPtr startParent;
@@ -963,12 +922,12 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
return NS_ERROR_FAILURE;
cEndP = do_QueryInterface(endParent);
aRange->GetEndOffset(&endIndx);
-
+
// short circuit when start node == end node
if (startParent == endParent)
{
cChild = cStartP->GetChildAt(0);
-
+
if (!cChild) // no children, must be a text node or empty container
{
// all inside one text node - empty subtree iterator
@@ -984,14 +943,14 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
}
}
}
-
+
// find first node in range
aRange->GetStartOffset(&indx);
numChildren = GetNumChildren(startParent);
-
+
if (!numChildren) // no children, must be a text node
{
- cN = cStartP;
+ cN = cStartP;
}
else
{
@@ -1006,11 +965,13 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
firstCandidate = cChild;
}
}
-
+
if (!firstCandidate)
{
// then firstCandidate is next node after cN
- if (NS_FAILED(GetNextSibling(cN, address_of(firstCandidate))))
+ firstCandidate = GetNextSibling(cN);
+
+ if (!firstCandidate)
{
MakeEmpty();
return NS_OK;
@@ -1033,7 +994,7 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
// confirm that this first possible contained node
// is indeed contained. Else we have a range that
// does not fully contain any node.
-
+
PRBool nodeBefore(PR_FALSE), nodeAfter(PR_FALSE);
if (!mFirstIter &&
NS_FAILED(nsRange::CompareNodeToRange(firstCandidate, aRange,
@@ -1051,16 +1012,16 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
// in the range. That's the real first node.
if (NS_SUCCEEDED(GetTopAncestorInRange(firstCandidate, address_of(mFirst))))
{
- mFirstIter = 0;//ancestor has one no
+ mFirstIter = 0;//ancestor has one no
mGenIter = 0;
}
else if (!mFirstIter) //something bad happened and its not generated content iterators fault
return NS_ERROR_FAILURE;
else
mFirst = firstCandidate;//setting last candidate to parent of generated content this is ok
-
-
-
+
+
+
// now to find the last node
aRange->GetEndOffset(&indx);
numChildren = GetNumChildren(endParent);
@@ -1074,7 +1035,7 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
{
if (!numChildren) // no children, must be a text node
{
- cN = cEndP;
+ cN = cEndP;
}
else
{
@@ -1091,11 +1052,13 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
}
}
}
-
+
if (!lastCandidate)
{
// then lastCandidate is prev node before cN
- if (NS_FAILED(GetPrevSibling(cN, address_of(lastCandidate))))
+ lastCandidate = GetPrevSibling(cN);
+
+ if (!lastCandidate)
{
MakeEmpty();
return NS_OK;
@@ -1115,16 +1078,16 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
mLastIterType = mIterType;
}
}
-
+
// confirm that this first possible contained node
// is indeed contained. Else we have a range that
// does not fully contain any node.
-
+
if (!mLastIter &&
NS_FAILED(nsRange::CompareNodeToRange(lastCandidate, aRange, &nodeBefore,
&nodeAfter)))
return NS_ERROR_FAILURE;
-
+
if (nodeBefore || nodeAfter)
{
MakeEmpty();
@@ -1136,14 +1099,14 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
// in the range. That's the real first node.
if (NS_SUCCEEDED(GetTopAncestorInRange(lastCandidate, address_of(mLast))))
{
- mLastIter = 0;//ancestor has one no
+ mLastIter = 0;//ancestor has one no
mGenIter = 0;
}
else if (!mLastIter) //something bad happened and its not generated content iterators fault
return NS_ERROR_FAILURE;
else
mLast = lastCandidate;//setting last candidate to parent of generated content this is ok
-
+
mCurNode = mFirst;
mGenIter = mFirstIter;
mIterType = mFirstIterType ;
@@ -1155,10 +1118,11 @@ nsresult nsGeneratedSubtreeIterator::Init(nsIDOMRange* aRange)
* nsGeneratedSubtreeIterator overrides of ContentIterator routines
****************************************************************/
-nsresult nsGeneratedSubtreeIterator::Next()
+void
+nsGeneratedSubtreeIterator::Next()
{
- if (mIsDone)
- return NS_OK;
+ if (mIsDone)
+ return;
nsCOMPtr curnode;
nsCOMPtr nextNode;
if (mGenIter)
@@ -1169,29 +1133,42 @@ nsresult nsGeneratedSubtreeIterator::Next()
if (mIterType == nsIPresShell::After)
{
- if (NS_FAILED(GetNextSibling(mCurNode, address_of(nextNode))))
- return NS_OK;
+ nextNode = GetNextSibling(mCurNode);
+
+ if (!nextNode)
+ {
+ mIsDone = PR_TRUE;
+
+ return;
+ }
}
else
{
nextNode = mCurNode->GetChildAt(0);
}
}
- else
- return mGenIter->Next();
- }
+ else {
+ mGenIter->Next();
+
+ return;
+ }
+ }
else
{
- if (mCurNode == mLast)
+ if (mCurNode == mLast)
{
mIsDone = PR_TRUE;
- return NS_OK;
+ return;
+ }
+ nextNode = GetNextSibling(mCurNode);
+
+ if (!nextNode)
+ {
+ mIsDone = PR_TRUE;
+
+ return;
}
- if (NS_FAILED(GetNextSibling(mCurNode, address_of(nextNode))))
- return NS_OK;
}
-
-
if (!mGenIter)
nextNode = GetDeepFirstChild(nextNode);
@@ -1200,21 +1177,24 @@ nsresult nsGeneratedSubtreeIterator::Next()
mGenIter = 0;
}
else if (!mGenIter) //something bad happened and its not generated content iterators fault
- return NS_ERROR_FAILURE;
+ return;
else
mCurNode = nextNode;//setting last candidate to parent of generated content this is ok
- return NS_OK;
}
-nsresult nsGeneratedSubtreeIterator::Prev()
+void
+nsGeneratedSubtreeIterator::Prev()
{
//notimplemented
- return NS_ERROR_NOT_IMPLEMENTED;
+ NS_ERROR("Not implemented!");
}
-nsresult nsGeneratedSubtreeIterator::PositionAt(nsIContent* aCurNode)
+nsresult
+nsGeneratedSubtreeIterator::PositionAt(nsIContent* aCurNode)
{
+ NS_ERROR("Not implemented!");
+
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -1226,12 +1206,12 @@ nsresult nsGeneratedSubtreeIterator::GetTopAncestorInRange(
nsCOMPtr aNode,
nsCOMPtr *outAnestor)
{
- if (!aNode)
+ if (!aNode)
return NS_ERROR_NULL_POINTER;
- if (!outAnestor)
+ if (!outAnestor)
return NS_ERROR_NULL_POINTER;
-
-
+
+
// sanity check: aNode is itself in the range
PRBool nodeBefore, nodeAfter;
if (NS_FAILED(nsRange::CompareNodeToRange(aNode, mRange, &nodeBefore,
@@ -1240,7 +1220,7 @@ nsresult nsGeneratedSubtreeIterator::GetTopAncestorInRange(
if (nodeBefore || nodeAfter)
return NS_ERROR_FAILURE;
-
+
nsCOMPtr parent;
while (aNode)
{
diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp
index 8407a9851c2..56891d05a8a 100644
--- a/mozilla/content/base/src/nsRange.cpp
+++ b/mozilla/content/base/src/nsRange.cpp
@@ -839,12 +839,12 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent*
nsresult res = NS_NewContentIterator(getter_AddRefs(iter));
iter->Init(aSourceNode);
- nsCOMPtr cN;
const nsVoidArray* theRangeList;
-
- iter->CurrentNode(getter_AddRefs(cN));
- while (cN && (NS_ENUMERATOR_FALSE == iter->IsDone()))
+
+ while (!iter->IsDone())
{
+ nsIContent *cN = iter->GetCurrentNode();
+
theRangeList = cN->GetRangeList();
if (theRangeList)
{
@@ -884,13 +884,8 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent*
theCount = 0;
}
}
- res = iter->Next();
- if (NS_FAILED(res)) // a little noise here to catch bugs
- {
- NS_NOTREACHED("nsRange::PopRanges() : iterator failed to advance");
- return res;
- }
- iter->CurrentNode(getter_AddRefs(cN));
+
+ iter->Next();
}
return NS_OK;
@@ -1192,230 +1187,25 @@ private:
nsCOMPtr mIter;
RangeSubtreeIterState mIterState;
- nsCOMPtr mStartCData;
- nsCOMPtr mEndCData;
+ nsCOMPtr mStartCData;
+ nsCOMPtr mEndCData;
public:
- RangeSubtreeIterator() : mIterState(eDone) {}
- ~RangeSubtreeIterator() {}
-
- nsresult Init(nsIDOMRange *aRange)
+ RangeSubtreeIterator()
+ : mIterState(eDone)
+ {
+ }
+ ~RangeSubtreeIterator()
{
- NS_ENSURE_ARG_POINTER(aRange);
-
- mIterState = eDone;
-
- nsCOMPtr node;
-
- // Grab the start point of the range and QI it to
- // a CharacterData pointer. If it is CharacterData store
- // a pointer to the node.
-
- nsresult res = aRange->GetStartContainer(getter_AddRefs(node));
- if (NS_FAILED(res)) return res;
- if (!node) return NS_ERROR_FAILURE;
-
- nsCOMPtr cData = do_QueryInterface(node);
- if (cData)
- mStartCData = node;
-
- // Grab the end point of the range and QI it to
- // a CharacterData pointer. If it is CharacterData store
- // a pointer to the node.
-
- res = aRange->GetEndContainer(getter_AddRefs(node));
- if (NS_FAILED(res)) return res;
- if (!node) return NS_ERROR_FAILURE;
-
- cData = do_QueryInterface(node);
- if (cData)
- mEndCData = node;
-
- if (mStartCData && mStartCData == mEndCData)
- {
- // The range starts and stops in the same CharacterData
- // node. Null out the end pointer so we only visit the
- // node once!
-
- mEndCData = nsnull;
- }
- else
- {
- // Now create a Content Subtree Iterator to be used
- // for the subtrees between the end points!
-
- res = NS_NewContentSubtreeIterator(getter_AddRefs(mIter));
-
- if (NS_FAILED(res)) return res;
- if (!mIter) return NS_ERROR_FAILURE;
-
- res = mIter->Init(aRange);
- if (NS_FAILED(res)) return res;
-
- if (mIter->IsDone() != NS_ENUMERATOR_FALSE)
- {
- // The subtree iterator thinks there's nothing
- // to iterate over, so just free it up so we
- // don't accidentally call into it.
-
- mIter = nsnull;
- }
- }
-
- // Initialize the iterator by calling First().
- // Note that we are ignoring the return value on purpose!
-
- (void)First();
-
- return NS_OK;
}
- nsresult CurrentNode(nsIDOMNode **aNode)
- {
- NS_ENSURE_ARG_POINTER(aNode);
-
- *aNode = nsnull;
-
- nsresult res = NS_OK;
-
- if (mIterState == eUseStartCData && mStartCData)
- *aNode = mStartCData;
- else if (mIterState == eUseEndCData && mEndCData)
- *aNode = mEndCData;
- else if (mIterState == eUseIterator && mIter)
- {
- nsCOMPtr content;
- res = mIter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- if (!content) return NS_ERROR_FAILURE;
- nsCOMPtr node(do_QueryInterface(content));
- if (!node) return NS_ERROR_FAILURE;
- *aNode = node;
- }
- else
- res = NS_ERROR_FAILURE;
-
- NS_IF_ADDREF(*aNode);
-
- return res;
- }
-
- nsresult First()
- {
- nsresult res = NS_OK;
-
- if (mStartCData)
- mIterState = eUseStartCData;
- else if (mIter)
- {
- res = mIter->First();
- if (NS_FAILED(res)) return res;
- mIterState = eUseIterator;
- }
- else if (mEndCData)
- mIterState = eUseEndCData;
- else
- res = NS_ERROR_FAILURE;
-
- return res;
- }
-
- nsresult Last()
- {
- nsresult res = NS_OK;
-
- if (mEndCData)
- mIterState = eUseEndCData;
- else if (mIter)
- {
- res = mIter->Last();
- if (NS_FAILED(res)) return res;
- mIterState = eUseIterator;
- }
- else if (mStartCData)
- mIterState = eUseStartCData;
- else
- res = NS_ERROR_FAILURE;
-
- return res;
- }
-
- nsresult Next()
- {
- nsresult res = NS_OK;
-
- if (mIterState == eUseStartCData)
- {
- if (mIter)
- {
- res = mIter->First();
- if (NS_FAILED(res)) return res;
- mIterState = eUseIterator;
- }
- else if (mEndCData)
- mIterState = eUseEndCData;
- else
- mIterState = eDone;
- }
- else if (mIterState == eUseIterator)
- {
- res = mIter->Next();
- if (NS_FAILED(res)) return res;
-
- if (mIter->IsDone() != NS_ENUMERATOR_FALSE)
- {
- if (mEndCData)
- mIterState = eUseEndCData;
- else
- mIterState = eDone;
- }
- }
- else if (mIterState == eUseEndCData)
- mIterState = eDone;
- else
- res = NS_ERROR_FAILURE;
-
- return res;
- }
-
- nsresult Prev()
- {
- nsresult res = NS_OK;
-
- if (mIterState == eUseEndCData)
- {
- if (mIter)
- {
- res = mIter->Last();
- if (NS_FAILED(res)) return res;
- mIterState = eUseIterator;
- }
- else if (mStartCData)
- mIterState = eUseStartCData;
- else
- mIterState = eDone;
- }
- else if (mIterState == eUseIterator)
- {
- res = mIter->Prev();
- if (NS_FAILED(res)) return res;
-
- if (mIter->IsDone() != NS_ENUMERATOR_FALSE)
- {
- if (mStartCData)
- mIterState = eUseStartCData;
- else
- mIterState = eDone;
- }
- }
- else if (mIterState == eUseStartCData)
- mIterState = eDone;
- else
- res = NS_ERROR_FAILURE;
-
- return res;
- }
+ nsresult Init(nsIDOMRange *aRange);
+ already_AddRefed GetCurrentNode();
+ void First();
+ void Last();
+ void Next();
+ void Prev();
PRBool IsDone()
{
@@ -1423,6 +1213,188 @@ public:
}
};
+nsresult
+RangeSubtreeIterator::Init(nsIDOMRange *aRange)
+{
+ mIterState = eDone;
+
+ nsCOMPtr node;
+
+ // Grab the start point of the range and QI it to
+ // a CharacterData pointer. If it is CharacterData store
+ // a pointer to the node.
+
+ nsresult res = aRange->GetStartContainer(getter_AddRefs(node));
+ if (!node) return NS_ERROR_FAILURE;
+
+ mStartCData = do_QueryInterface(node);
+
+ // Grab the end point of the range and QI it to
+ // a CharacterData pointer. If it is CharacterData store
+ // a pointer to the node.
+
+ res = aRange->GetEndContainer(getter_AddRefs(node));
+ if (!node) return NS_ERROR_FAILURE;
+
+ mEndCData = do_QueryInterface(node);
+
+ if (mStartCData && mStartCData == mEndCData)
+ {
+ // The range starts and stops in the same CharacterData
+ // node. Null out the end pointer so we only visit the
+ // node once!
+
+ mEndCData = nsnull;
+ }
+ else
+ {
+ // Now create a Content Subtree Iterator to be used
+ // for the subtrees between the end points!
+
+ res = NS_NewContentSubtreeIterator(getter_AddRefs(mIter));
+ if (NS_FAILED(res)) return res;
+
+ res = mIter->Init(aRange);
+ if (NS_FAILED(res)) return res;
+
+ if (mIter->IsDone())
+ {
+ // The subtree iterator thinks there's nothing
+ // to iterate over, so just free it up so we
+ // don't accidentally call into it.
+
+ mIter = nsnull;
+ }
+ }
+
+ // Initialize the iterator by calling First().
+ // Note that we are ignoring the return value on purpose!
+
+ First();
+
+ return NS_OK;
+}
+
+already_AddRefed
+RangeSubtreeIterator::GetCurrentNode()
+{
+ nsIDOMNode *node = nsnull;
+
+ if (mIterState == eUseStartCData && mStartCData) {
+ NS_ADDREF(node = mStartCData);
+ } else if (mIterState == eUseEndCData && mEndCData)
+ NS_ADDREF(node = mEndCData);
+ else if (mIterState == eUseIterator && mIter)
+ {
+ nsIContent *content = mIter->GetCurrentNode();
+
+ if (content) {
+ CallQueryInterface(content, &node);
+ }
+ }
+
+ return node;
+}
+
+void
+RangeSubtreeIterator::First()
+{
+ if (mStartCData)
+ mIterState = eUseStartCData;
+ else if (mIter)
+ {
+ mIter->First();
+
+ mIterState = eUseIterator;
+ }
+ else if (mEndCData)
+ mIterState = eUseEndCData;
+ else
+ mIterState = eDone;
+}
+
+void
+RangeSubtreeIterator::Last()
+{
+ if (mEndCData)
+ mIterState = eUseEndCData;
+ else if (mIter)
+ {
+ mIter->Last();
+
+ mIterState = eUseIterator;
+ }
+ else if (mStartCData)
+ mIterState = eUseStartCData;
+ else
+ mIterState = eDone;
+}
+
+void
+RangeSubtreeIterator::Next()
+{
+ if (mIterState == eUseStartCData)
+ {
+ if (mIter)
+ {
+ mIter->First();
+
+ mIterState = eUseIterator;
+ }
+ else if (mEndCData)
+ mIterState = eUseEndCData;
+ else
+ mIterState = eDone;
+ }
+ else if (mIterState == eUseIterator)
+ {
+ mIter->Next();
+
+ if (mIter->IsDone())
+ {
+ if (mEndCData)
+ mIterState = eUseEndCData;
+ else
+ mIterState = eDone;
+ }
+ }
+ else
+ mIterState = eDone;
+}
+
+void
+RangeSubtreeIterator::Prev()
+{
+ if (mIterState == eUseEndCData)
+ {
+ if (mIter)
+ {
+ mIter->Last();
+
+ mIterState = eUseIterator;
+ }
+ else if (mStartCData)
+ mIterState = eUseStartCData;
+ else
+ mIterState = eDone;
+ }
+ else if (mIterState == eUseIterator)
+ {
+ mIter->Prev();
+
+ if (mIter->IsDone())
+ {
+ if (mStartCData)
+ mIterState = eUseStartCData;
+ else
+ mIterState = eDone;
+ }
+ }
+ else
+ mIterState = eDone;
+}
+
+
// CollapseRangeAfterDelete() is a utiltiy method that is used by
// DeleteContents() and ExtractContents() to collapse the range
// in the correct place, under the range's root container (the
@@ -1540,13 +1512,7 @@ nsresult nsRange::DeleteContents()
// We delete backwards to avoid iterator problems!
- res = iter.Last();
- if (NS_FAILED(res)) return res;
-
- nsCOMPtr node;
- res = iter.CurrentNode(getter_AddRefs(node));
- if (NS_FAILED(res)) return res;
- if (!node) return NS_ERROR_FAILURE;
+ iter.Last();
PRBool handled = PR_FALSE;
@@ -1554,13 +1520,14 @@ nsresult nsRange::DeleteContents()
// end points, the subtree iterator should only give us back subtrees
// that are completely contained between the range's end points.
- while (node)
+ while (!iter.IsDone())
{
+ nsCOMPtr node(iter.GetCurrentNode());
+
// Before we delete anything, advance the iterator to the
// next subtree.
- res = iter.Prev();
- if (NS_FAILED(res)) return res;
+ iter.Prev();
handled = PR_FALSE;
@@ -1628,19 +1595,11 @@ nsresult nsRange::DeleteContents()
nsCOMPtr parent, tmpNode;
- res = node->GetParentNode(getter_AddRefs(parent));
- if (NS_FAILED(res)) return res;
+ node->GetParentNode(getter_AddRefs(parent));
res = parent->RemoveChild(node, getter_AddRefs(tmpNode));
if (NS_FAILED(res)) return res;
}
-
- if (iter.IsDone())
- break; // We must be done!
-
- res = iter.CurrentNode(getter_AddRefs(node));
- if (NS_FAILED(res)) return res;
- if (!node) return NS_ERROR_FAILURE;
}
// XXX_kin: At this point we should be checking for the case
@@ -1834,14 +1793,7 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
return NS_OK;
}
- res = iter.First();
- if (NS_FAILED(res)) return res;
-
- nsCOMPtr node;
- res = iter.CurrentNode(getter_AddRefs(node));
- if (NS_FAILED(res)) return res;
- if (!node) return NS_ERROR_FAILURE;
-
+ iter.First();
// With the exception of text nodes that contain one of the range
// end points, the subtree iterator should only give us back subtrees
@@ -1852,15 +1804,14 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
// parent hierarchy, adds a cloned version of the subtree, to it, then
// correctly places this new subtree into the doc fragment.
- while (node)
+ while (!iter.IsDone())
{
+ nsCOMPtr node(iter.GetCurrentNode());
// Clone the current subtree!
nsCOMPtr clone;
res = node->CloneNode(PR_TRUE, getter_AddRefs(clone));
-
if (NS_FAILED(res)) return res;
- if (!clone) return NS_ERROR_FAILURE;
// If it's CharacterData, make sure we only clone what
// is in the range.
@@ -1931,8 +1882,6 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
// immediate parent of the subtree.
res = closestAncestor->AppendChild(clone, getter_AddRefs(tmpNode));
-
- if (NS_FAILED(res)) return res;
}
else
{
@@ -1940,21 +1889,18 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
// commonAncestor and node, so just append clone to commonCloneAncestor.
res = commonCloneAncestor->AppendChild(clone, getter_AddRefs(tmpNode));
-
- if (NS_FAILED(res)) return res;
}
+ if (NS_FAILED(res)) return res;
// Get the next subtree to be processed. The idea here is to setup
// the parameters for the next iteration of the loop.
- res = iter.Next();
+ iter.Next();
if (iter.IsDone())
break; // We must be done!
- nsCOMPtr nextNode;
- res = iter.CurrentNode(getter_AddRefs(nextNode));
- if (NS_FAILED(res)) return res;
+ nsCOMPtr nextNode(iter.GetCurrentNode());
if (!nextNode) return NS_ERROR_FAILURE;
// Get node and nextNode's common parent.
@@ -1979,7 +1925,6 @@ nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
}
commonCloneAncestor = clone;
- node = nextNode;
}
*aReturn = clonedFrag;
@@ -2221,13 +2166,13 @@ nsresult nsRange::ToString(nsAString& aReturn)
iter->Init(this);
nsString tempString;
- nsCOMPtr cN;
// loop through the content iterator, which returns nodes in the range in
// close tag order, and grab the text from any text node
- iter->CurrentNode(getter_AddRefs(cN));
- while (cN && (NS_ENUMERATOR_FALSE == iter->IsDone()))
+ while (!iter->IsDone())
{
+ nsIContent *cN = iter->GetCurrentNode();
+
#ifdef DEBUG_range
// If debug, dump it:
cN->List(stdout);
@@ -2253,13 +2198,8 @@ nsresult nsRange::ToString(nsAString& aReturn)
aReturn += tempString;
}
}
- nsresult res = iter->Next();
- if (NS_FAILED(res)) // a little noise here to catch bugs
- {
- NS_NOTREACHED("nsRange::ToString() : iterator failed to advance");
- return res;
- }
- iter->CurrentNode(getter_AddRefs(cN));
+
+ iter->Next();
}
#ifdef DEBUG_range
diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp
index 82a1617c257..e671cbf13d6 100644
--- a/mozilla/content/base/src/nsSelection.cpp
+++ b/mozilla/content/base/src/nsSelection.cpp
@@ -4933,45 +4933,49 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
#endif //OLD_TABLE_SELECTION
}
// Now iterated through the child frames and set them
- nsCOMPtr innercontent;
- while (NS_ENUMERATOR_FALSE == aInnerIter->IsDone())
+ while (!aInnerIter->IsDone())
{
- result = aInnerIter->CurrentNode(getter_AddRefs(innercontent));
- if (NS_SUCCEEDED(result) && innercontent)
+ nsIContent *innercontent = aInnerIter->GetCurrentNode();
+
+ result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame);
+ if (NS_SUCCEEDED(result) && frame)
{
- result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame);
- if (NS_SUCCEEDED(result) && frame)
+ //NOTE: eSpreadDown is now IGNORED. Selected state is set only
+ //for given frame
+
+ //spread from here to hit all frames in flow
+ frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
+ nsRect frameRect = frame->GetRect();
+
+ //if a rect is 0 height/width then try to notify next
+ //available in flow of selection status.
+ while (!frameRect.width || !frameRect.height)
{
- //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame
- frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);//spread from here to hit all frames in flow
- nsRect frameRect = frame->GetRect();
-
- //if a rect is 0 height/width then try to notify next available in flow of selection status.
- while (!frameRect.width || !frameRect.height)
+ //try to notify next in flow that its content is selected.
+ if (NS_SUCCEEDED(frame->GetNextInFlow(&frame)) && frame)
{
- //try to notify next in flow that its content is selected.
- if (NS_SUCCEEDED(frame->GetNextInFlow(&frame)) && frame)
- {
- frameRect = frame->GetRect();
- frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
- }
- else
- break;
+ frameRect = frame->GetRect();
+ frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);
}
- //if the frame is splittable and this frame is 0,0 then set the next in flow frame to be selected also
+ else
+ break;
}
+ //if the frame is splittable and this frame is 0,0 then set
+ //the next in flow frame to be selected also
}
- result = aInnerIter->Next();
- if (NS_FAILED(result))
- return result;
+
+ aInnerIter->Next();
}
+
#if 0
result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && frame)
frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
#endif
+
return NS_OK;
}
+
return NS_ERROR_FAILURE;
}
@@ -5034,14 +5038,15 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange
frame->SetSelected(aPresContext, aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
}
//end start content
- result = iter->First();
- while (NS_SUCCEEDED(result) && NS_ENUMERATOR_FALSE == iter->IsDone())
+ iter->First();
+
+ while (!iter->IsDone())
{
- result = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(result) || !content)
- return result;
+ content = iter->GetCurrentNode();
+
selectFrames(aPresContext, inneriter, content, aRange, presShell,aFlags);
- result = iter->Next();
+
+ iter->Next();
}
//we must now do the last one if it is not the same as the first
if (FetchEndParent(aRange) != FetchStartParent(aRange))
diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
index 37fd084fa61..76cc77681eb 100644
--- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -587,29 +587,21 @@ nsHTMLAnchorElement::GetText(nsAString& aText)
// Initialize the content iterator with the children of the anchor
iter->Init(this);
- nsCOMPtr curNode;
-
// Position the iterator. Last() is the anchor itself, this is not what we
// want. Prev() positions the iterator to the last child of the anchor,
// starting at the deepest level of children, just like NS4 does.
- rv = iter->Last();
- NS_ENSURE_SUCCESS(rv, rv);
- rv = iter->Prev();
- NS_ENSURE_SUCCESS(rv, rv);
+ iter->Last();
+ iter->Prev();
- iter->CurrentNode(getter_AddRefs(curNode));
-
- while(curNode && (NS_ENUMERATOR_FALSE == iter->IsDone())) {
- nsCOMPtr textNode(do_QueryInterface(curNode));
+ while(!iter->IsDone()) {
+ nsCOMPtr textNode(do_QueryInterface(iter->GetCurrentNode()));
if(textNode) {
// The current node is a text node. Get its value and break the loop.
textNode->GetData(aText);
break;
}
- rv = iter->Prev();
- NS_ENSURE_SUCCESS(rv, rv);
- iter->CurrentNode(getter_AddRefs(curNode));
+ iter->Prev();
}
return NS_OK;
diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index b40ae68dcc8..f65ae63f146 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -4319,10 +4319,9 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(HTMLContentSink)
NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(HTMLContentSink)
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(HTMLContentSink)
-NS_IMETHODIMP
+void
HTMLContentSink::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
{
- nsresult result = NS_OK;
// If we're in a script and we didn't do the notification,
// something else in the script processing caused the
// notification to occur. Since this could result in frame
@@ -4332,13 +4331,11 @@ HTMLContentSink::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
// until the end of this update, even if nested updates or
// FlushPendingNotifications calls happen during it.
if (!mInNotification++ && mCurrentContext) {
- result = mCurrentContext->FlushTags(PR_TRUE);
+ mCurrentContext->FlushTags(PR_TRUE);
}
-
- return result;
}
-NS_IMETHODIMP
+void
HTMLContentSink::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
{
@@ -4350,14 +4347,11 @@ HTMLContentSink::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
if (!--mInNotification) {
UpdateAllContexts();
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
HTMLContentSink::DocumentWillBeDestroyed(nsIDocument *aDocument)
{
- return NS_OK;
}
nsresult
diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp
index 7eab4fcc550..cac1fddbd13 100644
--- a/mozilla/content/xbl/src/nsBindingManager.cpp
+++ b/mozilla/content/xbl/src/nsBindingManager.cpp
@@ -1324,25 +1324,23 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsBindingManager)
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsBindingManager)
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsBindingManager)
-NS_IMETHODIMP
+void
nsBindingManager::ContentChanged(nsIDocument* aDoc,
nsIContent* aContent,
nsISupports* aSubContent)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBindingManager::AttributeChanged(nsIDocument* aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBindingManager::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
@@ -1350,7 +1348,7 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
// XXX This is hacked and not quite correct. See below.
if (aNewIndexInContainer == -1 || !mContentListTable.ops)
// It's anonymous.
- return NS_OK;
+ return;
PRInt32 childCount = aContainer->GetChildCount();
@@ -1387,11 +1385,9 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
}
}
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBindingManager::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
@@ -1400,8 +1396,8 @@ nsBindingManager::ContentInserted(nsIDocument* aDocument,
// XXX This is hacked just to make menus work again.
if (aIndexInContainer == -1 || !mContentListTable.ops)
// It's anonymous.
- return NS_OK;
-
+ return;
+
nsCOMPtr ins;
GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(ins));
@@ -1429,21 +1425,18 @@ nsBindingManager::ContentInserted(nsIDocument* aDocument,
}
}
}
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBindingManager::ContentReplaced(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsBindingManager::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
@@ -1452,8 +1445,8 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument,
{
if (aIndexInContainer == -1 || !mContentListTable.ops)
// It's anonymous.
- return NS_OK;
-
+ return;
+
nsCOMPtr point;
GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(point));
@@ -1475,8 +1468,6 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument,
}
}
}
-
- return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp
index 0971300f0f9..796d4c1bc37 100644
--- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp
+++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp
@@ -214,14 +214,14 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsXMLPrettyPrinter)
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsXMLPrettyPrinter)
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsXMLPrettyPrinter)
-NS_IMETHODIMP
-nsXMLPrettyPrinter::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)
+void
+nsXMLPrettyPrinter::BeginUpdate(nsIDocument* aDocument,
+ nsUpdateType aUpdateType)
{
mUpdateDepth++;
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)
{
mUpdateDepth--;
@@ -245,20 +245,18 @@ nsXMLPrettyPrinter::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)
NS_RELEASE_THIS();
}
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::ContentChanged(nsIDocument* aDocument,
nsIContent *aContent,
nsISupports *aSubContent)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
@@ -266,29 +264,26 @@ nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument,
PRInt32 aModType)
{
MaybeUnhook(aContent);
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
MaybeUnhook(aContainer);
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
MaybeUnhook(aContainer);
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::ContentReplaced(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
@@ -296,26 +291,22 @@ nsXMLPrettyPrinter::ContentReplaced(nsIDocument* aDocument,
PRInt32 aIndexInContainer)
{
MaybeUnhook(aContainer);
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
MaybeUnhook(aContainer);
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXMLPrettyPrinter::DocumentWillBeDestroyed(nsIDocument* aDocument)
{
mDocument = nsnull;
NS_RELEASE_THIS();
-
- return NS_OK;
}
diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp
index 42317d04941..de7f4a5eb8f 100644
--- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -128,13 +128,13 @@ public:
NS_IMETHOD CreateContents(nsIContent* aElement);
// nsIDocumentObserver interface
- NS_IMETHOD AttributeChanged(nsIDocument* aDocument,
- nsIContent* aContent,
- PRInt32 aNameSpaceID,
- nsIAtom* aAttribute,
- PRInt32 aModType);
+ virtual void AttributeChanged(nsIDocument* aDocument,
+ nsIContent* aContent,
+ PRInt32 aNameSpaceID,
+ nsIAtom* aAttribute,
+ PRInt32 aModType);
- NS_IMETHOD DocumentWillBeDestroyed(nsIDocument* aDocument);
+ void DocumentWillBeDestroyed(nsIDocument* aDocument);
protected:
friend NS_IMETHODIMP
@@ -1599,7 +1599,7 @@ nsXULContentBuilder::CreateContents(nsIContent* aElement)
// nsIDocumentObserver methods
//
-NS_IMETHODIMP
+void
nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
@@ -1624,16 +1624,17 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument,
}
// Pass along to the generic template builder.
- return nsXULTemplateBuilder::AttributeChanged(aDocument, aContent, aNameSpaceID, aAttribute, aModType);
+ nsXULTemplateBuilder::AttributeChanged(aDocument, aContent, aNameSpaceID,
+ aAttribute, aModType);
}
-NS_IMETHODIMP
+void
nsXULContentBuilder::DocumentWillBeDestroyed(nsIDocument *aDocument)
{
// Break circular references
mContentSupportMap.Clear();
- return nsXULTemplateBuilder::DocumentWillBeDestroyed(aDocument);
+ nsXULTemplateBuilder::DocumentWillBeDestroyed(aDocument);
}
diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
index f1bff6a0087..9c349df46ff 100644
--- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -287,29 +287,26 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsXULTemplateBuilder)
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsXULTemplateBuilder)
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsXULTemplateBuilder)
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::BeginUpdate(nsIDocument *aDocument,
nsUpdateType aUpdateType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::EndUpdate(nsIDocument *aDocument,
nsUpdateType aUpdateType)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::ContentChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsISupports* aSubContent)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
PRInt32 aNameSpaceID,
@@ -321,47 +318,41 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument *aDocument,
// beneath the element.
if ((aAttribute == nsXULAtoms::ref) && (aContent == mRoot))
Rebuild();
-
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
- return NS_OK;
}
-NS_IMETHODIMP
+void
nsXULTemplateBuilder::DocumentWillBeDestroyed(nsIDocument *aDocument)
{
// Break circular references
@@ -371,7 +362,6 @@ nsXULTemplateBuilder::DocumentWillBeDestroyed(nsIDocument *aDocument)
}
mRoot = nsnull;
- return NS_OK;
}
diff --git a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp
index 34288d9fc7e..a223cd3e043 100644
--- a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp
+++ b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp
@@ -94,7 +94,7 @@ public:
// nsITreeView
NS_DECL_NSITREEVIEW
- NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
+ virtual void DocumentWillBeDestroyed(nsIDocument *aDocument);
protected:
friend NS_IMETHODIMP
@@ -1069,13 +1069,13 @@ nsXULTreeBuilder::PerformActionOnCell(const PRUnichar* action, PRInt32 row, cons
}
-NS_IMETHODIMP
+void
nsXULTreeBuilder::DocumentWillBeDestroyed(nsIDocument* aDocument)
{
if (mObservers)
mObservers->Clear();
- return nsXULTemplateBuilder::DocumentWillBeDestroyed(aDocument);
+ nsXULTemplateBuilder::DocumentWillBeDestroyed(aDocument);
}
diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp
index ee29aaad7b7..d78485da44b 100644
--- a/mozilla/dom/src/base/nsDOMClassInfo.cpp
+++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp
@@ -4475,7 +4475,6 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
}
jsval v;
-
nsresult rv = WrapNative(cx, ::JS_GetGlobalObject(cx), native_parent,
NS_GET_IID(nsISupports), &v);
@@ -4972,8 +4971,7 @@ nsContentListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
nsCOMPtr contentList(do_QueryInterface(nativeObj));
NS_ASSERTION(contentList, "Why does something not implementing nsIContentList use nsContentListSH??");
- nsCOMPtr native_parent;
- contentList->GetParentObject(getter_AddRefs(native_parent));
+ nsISupports *native_parent = contentList->GetParentObject();
if (!native_parent) {
*parentObj = globalObj;
diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp
index ba325bbea3e..46c7d24ef0f 100644
--- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp
+++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp
@@ -328,14 +328,12 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
nsresult result = iter->Init(mRange);
if (NS_FAILED(result)) return result;
-
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+
+ while (!iter->IsDone())
{
- nsCOMPtr content;
- result = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(result)) return result;
- nsCOMPtr node = do_QueryInterface(content);
- if (!node) return NS_ERROR_NULL_POINTER;
+ nsCOMPtr node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_NULL_POINTER;
DeleteElementTxn *txn;
result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn);
diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.cpp b/mozilla/editor/libeditor/base/nsEditorUtils.cpp
index e30d55edad2..23d46289471 100644
--- a/mozilla/editor/libeditor/base/nsEditorUtils.cpp
+++ b/mozilla/editor/libeditor/base/nsEditorUtils.cpp
@@ -122,20 +122,17 @@ nsDOMIterator::Init(nsIDOMNode* aNode)
void
nsDOMIterator::ForEach(nsDomIterFunctor& functor) const
{
- nsCOMPtr content;
nsCOMPtr node;
- nsresult res;
// iterate through dom
- while (NS_ENUMERATOR_FALSE == mIter->IsDone())
+ while (!mIter->IsDone())
{
- res = mIter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return;
- node = do_QueryInterface(content);
- if (!node) return;
+ node = do_QueryInterface(mIter->GetCurrentNode());
+ if (!node)
+ return;
+
functor(node);
- res = mIter->Next();
- if (NS_FAILED(res)) return;
+ mIter->Next();
}
}
@@ -143,23 +140,20 @@ nsresult
nsDOMIterator::AppendList(nsBoolDomIterFunctor& functor,
nsCOMArray& arrayOfNodes) const
{
- nsCOMPtr content;
nsCOMPtr node;
- nsresult res;
// iterate through dom and build list
- while (NS_ENUMERATOR_FALSE == mIter->IsDone())
+ while (!mIter->IsDone())
{
- res = mIter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_NULL_POINTER;
+ node = do_QueryInterface(mIter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_NULL_POINTER;
+
if (functor(node))
{
arrayOfNodes.AppendObject(node);
}
- res = mIter->Next();
- if (NS_FAILED(res)) return res;
+ mIter->Next();
}
return NS_OK;
}
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
index 5714b47437c..f1f339ae2b0 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -7624,14 +7624,14 @@ nsHTMLEditRules::RemoveEmptyNodes()
nsVoidArray skipList;
// check for empty nodes
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
nsCOMPtr node, parent;
- nsCOMPtr content;
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
+
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
node->GetParentNode(getter_AddRefs(parent));
PRInt32 idx = skipList.IndexOf((void*)node);
@@ -7703,8 +7703,8 @@ nsHTMLEditRules::RemoveEmptyNodes()
skipList.AppendElement((void*)parent);
}
}
- res = iter->Next();
- if (NS_FAILED(res)) return res;
+
+ iter->Next();
}
// now delete the empty nodes
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
index 11622b92cbe..bf29d2f0a64 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
@@ -876,10 +876,10 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
{
nsCOMPtr lastRange;
iter->Init(aRange);
- nsCOMPtr currentContent;
- iter->CurrentNode(getter_AddRefs(currentContent));
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (iter->IsDone())
{
+ nsCOMPtr currentContent = iter->GetCurrentNode();
+
nsCOMPtrcurrentNode = do_QueryInterface(currentContent);
if (currentNode)
{
@@ -949,7 +949,6 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
* we rely on iter->IsDone to tell us when the iteration is complete
*/
iter->Next();
- iter->CurrentNode(getter_AddRefs(currentContent));
}
}
return result;
@@ -994,14 +993,15 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
if (NS_FAILED(iter->Init(blockContent))) return nullNode;
if (NS_FAILED(iter->PositionAt(content))) return nullNode;
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- if (NS_FAILED(iter->CurrentNode(getter_AddRefs(content)))) return nullNode;
- // ignore nodes that aren't elements or text, or that are the block parent
- node = do_QueryInterface(content);
- if (node && IsTextOrElementNode(node) && (node != blockParent) && (node.get() != aNode))
+ // ignore nodes that aren't elements or text, or that are the
+ // block parent
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (node && IsTextOrElementNode(node) && node != blockParent &&
+ node != aNode)
return node;
-
+
if (aDir == kIterForward)
iter->Next();
else
@@ -1419,24 +1419,26 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled)
// position iter at block
res = iter->PositionAt(cBlock);
if (NS_FAILED(res)) return res;
+
nsCOMPtr node;
- nsCOMPtr cNode;
do
{
- if (inIsShift) res = iter->Prev();
- else res = iter->Next();
- if (NS_FAILED(res)) break;
- res = iter->CurrentNode(getter_AddRefs(cNode));
- if (NS_FAILED(res)) break;
- node = do_QueryInterface(cNode);
- if (nsHTMLEditUtils::IsTableCell(node) && (GetEnclosingTable(node) == tbl))
+ if (inIsShift)
+ iter->Prev();
+ else
+ iter->Next();
+
+ node = do_QueryInterface(iter->GetCurrentNode());
+
+ if (node && nsHTMLEditUtils::IsTableCell(node) &&
+ GetEnclosingTable(node) == tbl)
{
res = CollapseSelectionToDeepestNonTableFirstChild(nsnull, node);
if (NS_FAILED(res)) return res;
*outHandled = PR_TRUE;
return NS_OK;
}
- } while (iter->IsDone() == NS_ENUMERATOR_FALSE);
+ } while (!iter->IsDone());
if (!(*outHandled) && !inIsShift)
{
@@ -3200,61 +3202,53 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
nsCOMPtr iter =
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
if (NS_FAILED(res)) return res;
- if (iter)
+
+ iter->Init(currange);
+ // loop through the content iterator for each content node
+ while (!iter->IsDone())
{
- iter->Init(currange);
- // loop through the content iterator for each content node
- nsCOMPtr content;
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ // Query interface to cast nsIContent to nsIDOMNode
+ // then get tagType to compare to aTagName
+ // Clone node of each desired type and append it to the aDomFrag
+ selectedElement = do_QueryInterface(iter->GetCurrentNode());
+ if (selectedElement)
{
- res = iter->CurrentNode(getter_AddRefs(content));
- // Note likely!
- if (NS_FAILED(res))
- return NS_ERROR_FAILURE;
-
- // Query interface to cast nsIContent to nsIDOMNode
- // then get tagType to compare to aTagName
- // Clone node of each desired type and append it to the aDomFrag
- selectedElement = do_QueryInterface(content);
- if (selectedElement)
+ // If we already found a node, then we have another element,
+ // thus there's not just one element selected
+ if (bNodeFound)
{
- // If we already found a node, then we have another element,
- // thus there's not just one element selected
- if (bNodeFound)
- {
- bNodeFound = PR_FALSE;
- break;
- }
-
- selectedElement->GetNodeName(domTagName);
- ToLowerCase(domTagName);
-
- if (anyTag)
- {
- // Get name of first selected element
- selectedElement->GetTagName(TagName);
- ToLowerCase(TagName);
- anyTag = PR_FALSE;
- }
-
- // The "A" tag is a pain,
- // used for both link(href is set) and "Named Anchor"
- nsCOMPtr selectedNode = do_QueryInterface(selectedElement);
- if ( (isLinkTag && nsHTMLEditUtils::IsLink(selectedNode)) ||
- (isNamedAnchorTag && nsHTMLEditUtils::IsNamedAnchor(selectedNode)) )
- {
- bNodeFound = PR_TRUE;
- } else if (TagName == domTagName) { // All other tag names are handled here
- bNodeFound = PR_TRUE;
- }
- if (!bNodeFound)
- {
- // Check if node we have is really part of the selection???
- break;
- }
+ bNodeFound = PR_FALSE;
+ break;
+ }
+
+ selectedElement->GetNodeName(domTagName);
+ ToLowerCase(domTagName);
+
+ if (anyTag)
+ {
+ // Get name of first selected element
+ selectedElement->GetTagName(TagName);
+ ToLowerCase(TagName);
+ anyTag = PR_FALSE;
+ }
+
+ // The "A" tag is a pain,
+ // used for both link(href is set) and "Named Anchor"
+ nsCOMPtr selectedNode = do_QueryInterface(selectedElement);
+ if ( (isLinkTag && nsHTMLEditUtils::IsLink(selectedNode)) ||
+ (isNamedAnchorTag && nsHTMLEditUtils::IsNamedAnchor(selectedNode)) )
+ {
+ bNodeFound = PR_TRUE;
+ } else if (TagName == domTagName) { // All other tag names are handled here
+ bNodeFound = PR_TRUE;
+ }
+ if (!bNodeFound)
+ {
+ // Check if node we have is really part of the selection???
+ break;
}
- iter->Next();
}
+ iter->Next();
}
} else {
// Should never get here?
@@ -3537,13 +3531,9 @@ nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
iter->Init(doc->GetRootContent());
// loop through the content iterator for each content node
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- nsCOMPtr content;
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res))
- break;
- nsCOMPtr node (do_QueryInterface(content));
+ nsCOMPtr node (do_QueryInterface(iter->GetCurrentNode()));
if (node)
{
// Let nsURIRefObject make the hard decisions:
@@ -3552,8 +3542,8 @@ nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
if (NS_SUCCEEDED(res))
{
nsCOMPtr isupp (do_QueryInterface(refObject));
- if (isupp)
- (*aNodeList)->AppendElement(isupp);
+
+ (*aNodeList)->AppendElement(isupp);
}
}
iter->Next();
@@ -3903,12 +3893,9 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
iter->Init(doc->GetRootContent());
// loop through the content iterator for each content node
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- nsCOMPtr content;
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res))
- break;
+ nsIContent *content = iter->GetCurrentNode();
nsCOMPtr node (do_QueryInterface(content));
if (node)
{
@@ -4735,23 +4722,21 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
nsCOMPtr iter =
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &result);
if (NS_FAILED(result)) return result;
- if (!iter) return NS_ERROR_NULL_POINTER;
iter->Init(aInRange);
- nsCOMPtr content;
- result = iter->CurrentNode(getter_AddRefs(content));
- if (!content) return NS_OK;
-
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+
+ while (!iter->IsDone())
{
+ nsIContent *content = iter->GetCurrentNode();
+
nsCOMPtr text = do_QueryInterface(content);
nsCOMPtr node = do_QueryInterface(content);
if (text && node && IsEditable(node))
{
textNodes.AppendElement(node.get());
}
+
iter->Next();
- iter->CurrentNode(getter_AddRefs(content));
}
// now that I have a list of text nodes, collapse adjacent text nodes
@@ -4767,7 +4752,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
nsCOMPtr prevSibOfRightNode;
result = GetPriorHTMLSibling(rightTextNode, address_of(prevSibOfRightNode));
if (NS_FAILED(result)) return result;
- if (prevSibOfRightNode && (prevSibOfRightNode.get() == leftTextNode))
+ if (prevSibOfRightNode && (prevSibOfRightNode == leftTextNode))
{
nsCOMPtr parent;
result = rightTextNode->GetParentNode(getter_AddRefs(parent));
@@ -5451,7 +5436,7 @@ nsHTMLEditor::IsEmptyNodeImpl( nsIDOMNode *aNode,
else // an editable, non-text node. we need to check it's content.
{
// is it the node we are iterating over?
- if (node.get() == aNode) break;
+ if (node == aNode) break;
else if (aSingleBRDoesntCount && !*aSeenBR && nsTextEditUtils::IsBreak(node))
{
// the first br in a block doesn't count if the caller so indicated
@@ -5722,7 +5707,6 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
if (!iter) return NS_ERROR_FAILURE;
nsCOMArray arrayOfNodes;
- nsCOMPtr content;
nsCOMPtr node;
// iterate range and build up array
@@ -5733,18 +5717,18 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
// any *whole* nodes.
if (NS_SUCCEEDED(res))
{
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
if (IsEditable(node))
{
arrayOfNodes.AppendObject(node);
}
- res = iter->Next();
- if (NS_FAILED(res)) return res;
+
+ iter->Next();
}
}
// first check the start parent of the range to see if it needs to
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
index 4cd7591156a..630a6532103 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -215,7 +215,6 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
if (!iter) return NS_ERROR_FAILURE;
nsCOMArray arrayOfNodes;
- nsCOMPtr content;
nsCOMPtr node;
// iterate range and build up array
@@ -226,18 +225,18 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
// any *whole* nodes.
if (NS_SUCCEEDED(res))
{
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
if (IsEditable(node))
{
arrayOfNodes.AppendObject(node);
}
- res = iter->Next();
- if (NS_FAILED(res)) return res;
+
+ iter->Next();
}
}
// first check the start parent of the range to see if it needs to
@@ -1086,17 +1085,18 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
if (!iter) return NS_ERROR_NULL_POINTER;
iter->Init(range);
- nsCOMPtr content;
nsAutoString firstValue, theValue;
- iter->CurrentNode(getter_AddRefs(content));
+
nsCOMPtr endNode;
PRInt32 endOffset;
result = range->GetEndContainer(getter_AddRefs(endNode));
if (NS_FAILED(result)) return result;
result = range->GetEndOffset(&endOffset);
if (NS_FAILED(result)) return result;
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
+ nsIContent *content = iter->GetCurrentNode();
+
nsCOMPtr node = do_QueryInterface(content);
if (node && nsTextEditUtils::IsBody(node))
@@ -1190,10 +1190,8 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
}
}
}
- result = iter->Next();
- if (NS_FAILED(result))
- break;
- iter->CurrentNode(getter_AddRefs(content));
+
+ iter->Next();
}
}
if (!*aAny)
@@ -1378,23 +1376,22 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
if (!iter) return NS_ERROR_FAILURE;
nsCOMArray arrayOfNodes;
- nsCOMPtr content;
nsCOMPtr node;
// iterate range and build up array
iter->Init(range);
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
if (IsEditable(node))
{
arrayOfNodes.AppendObject(node);
}
- res = iter->Next();
- if (NS_FAILED(res)) return res;
+
+ iter->Next();
}
// loop through the list, remove the property on each node
@@ -1557,23 +1554,23 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
if (!iter) return NS_ERROR_FAILURE;
nsCOMArray arrayOfNodes;
- nsCOMPtr content;
nsCOMPtr node;
// iterate range and build up array
res = iter->Init(range);
if (NS_SUCCEEDED(res))
{
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
+ node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
if (IsEditable(node))
{
arrayOfNodes.AppendObject(node);
}
+
iter->Next();
}
diff --git a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
index aede89c0eb3..191df9e042c 100644
--- a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -699,11 +699,9 @@ nsPlaintextEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
nsCOMPtrblockParentContent = do_QueryInterface(aInCommonParentNode);
iter->Init(blockParentContent);
// loop through the content iterator for each content node
- nsCOMPtr content;
- result = iter->CurrentNode(getter_AddRefs(content));
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- textNode = do_QueryInterface(content);
+ textNode = do_QueryInterface(iter->GetCurrentNode());
if (textNode)
{
nsCOMPtrcurrentNode = do_QueryInterface(textNode);
@@ -725,7 +723,6 @@ nsPlaintextEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
}
}
iter->Next();
- iter->CurrentNode(getter_AddRefs(content));
}
if (-1==aOutEndOffset) {
aOutEndOffset = totalLength;
diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.cpp b/mozilla/editor/libeditor/text/nsTextEditRules.cpp
index e48ec37a278..ff8c11f012b 100644
--- a/mozilla/editor/libeditor/text/nsTextEditRules.cpp
+++ b/mozilla/editor/libeditor/text/nsTextEditRules.cpp
@@ -1120,14 +1120,12 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
nsCOMArray arrayOfNodes;
// gather up a list of editable preformatted text nodes
- while (NS_ENUMERATOR_FALSE == iter->IsDone())
+ while (!iter->IsDone())
{
- nsCOMPtr content;
- res = iter->CurrentNode(getter_AddRefs(content));
- if (NS_FAILED(res)) return res;
- nsCOMPtr node = do_QueryInterface(content);
- if (!node) return NS_ERROR_FAILURE;
-
+ nsCOMPtr node = do_QueryInterface(iter->GetCurrentNode());
+ if (!node)
+ return NS_ERROR_FAILURE;
+
if (mEditor->IsTextNode(node) && mEditor->IsEditable(node))
{
PRBool isPRE;
@@ -1139,8 +1137,7 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
arrayOfNodes.AppendObject(data);
}
}
- res = iter->Next();
- if (NS_FAILED(res)) return res;
+ iter->Next();
}
// replace newlines with breaks. have to do this left to right,
diff --git a/mozilla/editor/txtsvc/src/nsFilteredContentIterator.cpp b/mozilla/editor/txtsvc/src/nsFilteredContentIterator.cpp
index 029c3f22ea9..91dcdf0476a 100644
--- a/mozilla/editor/txtsvc/src/nsFilteredContentIterator.cpp
+++ b/mozilla/editor/txtsvc/src/nsFilteredContentIterator.cpp
@@ -68,7 +68,7 @@ nsFilteredContentIterator::~nsFilteredContentIterator()
NS_IMPL_ISUPPORTS1(nsFilteredContentIterator, nsIContentIterator)
//------------------------------------------------------------
-NS_IMETHODIMP
+nsresult
nsFilteredContentIterator::Init(nsIContent* aRoot)
{
NS_ENSURE_TRUE(mPreIterator, NS_ERROR_FAILURE);
@@ -92,7 +92,7 @@ nsFilteredContentIterator::Init(nsIContent* aRoot)
}
//------------------------------------------------------------
-NS_IMETHODIMP
+nsresult
nsFilteredContentIterator::Init(nsIDOMRange* aRange)
{
NS_ENSURE_TRUE(mPreIterator, NS_ERROR_FAILURE);
@@ -116,8 +116,7 @@ nsFilteredContentIterator::Init(nsIDOMRange* aRange)
nsresult
nsFilteredContentIterator::SwitchDirections(PRPackedBool aChangeToForward)
{
- nsCOMPtr node;
- mCurrentIterator->CurrentNode(getter_AddRefs(node));
+ nsIContent *node = mCurrentIterator->GetCurrentNode();
if (aChangeToForward) {
mCurrentIterator = mPreIterator;
@@ -138,10 +137,14 @@ nsFilteredContentIterator::SwitchDirections(PRPackedBool aChangeToForward)
}
//------------------------------------------------------------
-NS_IMETHODIMP
+void
nsFilteredContentIterator::First()
{
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
+ if (!mCurrentIterator) {
+ NS_ERROR("Missing iterator!");
+
+ return;
+ }
// If we are switching directions then
// we need to switch how we process the nodes
@@ -151,28 +154,28 @@ nsFilteredContentIterator::First()
mIsOutOfRange = PR_FALSE;
}
- nsresult rv = mCurrentIterator->First();
- NS_ENSURE_SUCCESS(rv, rv);
+ mCurrentIterator->First();
- if (NS_ENUMERATOR_FALSE != mCurrentIterator->IsDone()) {
- return NS_OK;
+ if (mCurrentIterator->IsDone()) {
+ return;
}
- nsCOMPtr currentContent;
- rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
+ nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
nsCOMPtr node(do_QueryInterface(currentContent));
PRPackedBool didCross;
CheckAdvNode(node, didCross, eForward);
-
- return NS_OK;
}
//------------------------------------------------------------
-NS_IMETHODIMP
+void
nsFilteredContentIterator::Last()
{
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
+ if (!mCurrentIterator) {
+ NS_ERROR("Missing iterator!");
+
+ return;
+ }
// If we are switching directions then
// we need to switch how we process the nodes
@@ -182,21 +185,17 @@ nsFilteredContentIterator::Last()
mIsOutOfRange = PR_FALSE;
}
- nsresult rv = mCurrentIterator->Last();
- NS_ENSURE_SUCCESS(rv, rv);
+ mCurrentIterator->Last();
- if (NS_ENUMERATOR_FALSE != mCurrentIterator->IsDone()) {
- return NS_OK;
+ if (mCurrentIterator->IsDone()) {
+ return;
}
- nsCOMPtr currentContent;
- rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
+ nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
nsCOMPtr node(do_QueryInterface(currentContent));
PRPackedBool didCross;
CheckAdvNode(node, didCross, eBackward);
-
- return NS_OK;
}
///////////////////////////////////////////////////////////////////////////
@@ -360,99 +359,91 @@ nsFilteredContentIterator::CheckAdvNode(nsIDOMNode* aNode, PRPackedBool& aDidSki
}
}
-NS_IMETHODIMP
+void
nsFilteredContentIterator::Next()
{
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
+ if (mIsOutOfRange || !mCurrentIterator) {
+ NS_ASSERTION(mCurrentIterator, "Missing iterator!");
- if (mIsOutOfRange) {
- return NS_OK;
+ return;
}
+
// If we are switching directions then
// we need to switch how we process the nodes
if (mDirection != eForward) {
nsresult rv = SwitchDirections(PR_TRUE);
if (NS_FAILED(rv)) {
- return NS_OK;
+ return;
}
}
- nsresult rv = mCurrentIterator->Next();
- NS_ENSURE_SUCCESS(rv, rv);
+ mCurrentIterator->Next();
- if (NS_ENUMERATOR_FALSE != mCurrentIterator->IsDone()) {
- return NS_OK;
+ if (mCurrentIterator->IsDone()) {
+ return;
}
// If we can't get the current node then
// don't check to see if we can skip it
- nsCOMPtr currentContent;
- rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr node(do_QueryInterface(currentContent));
- CheckAdvNode(node, mDidSkip, eForward);
- }
+ nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
- return NS_OK;
+ nsCOMPtr node(do_QueryInterface(currentContent));
+ CheckAdvNode(node, mDidSkip, eForward);
}
-NS_IMETHODIMP
+void
nsFilteredContentIterator::Prev()
{
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
+ if (mIsOutOfRange || !mCurrentIterator) {
+ NS_ASSERTION(mCurrentIterator, "Missing iterator!");
- if (mIsOutOfRange) {
- return NS_OK;
+ return;
}
+
// If we are switching directions then
// we need to switch how we process the nodes
if (mDirection != eBackward) {
nsresult rv = SwitchDirections(PR_FALSE);
if (NS_FAILED(rv)) {
- return NS_OK;
+ return;
}
}
- nsresult rv = mCurrentIterator->Prev();
- NS_ENSURE_SUCCESS(rv, rv);
+ mCurrentIterator->Prev();
- if (NS_ENUMERATOR_FALSE != mCurrentIterator->IsDone()) {
- return NS_OK;
+ if (mCurrentIterator->IsDone()) {
+ return;
}
// If we can't get the current node then
// don't check to see if we can skip it
- nsCOMPtr currentContent;
- rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr node(do_QueryInterface(currentContent));
- CheckAdvNode(node, mDidSkip, eBackward);
- }
+ nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
- return NS_OK;
+ nsCOMPtr node(do_QueryInterface(currentContent));
+ CheckAdvNode(node, mDidSkip, eBackward);
}
-NS_IMETHODIMP
-nsFilteredContentIterator::CurrentNode(nsIContent **aNode)
+nsIContent *
+nsFilteredContentIterator::GetCurrentNode()
{
- if (mIsOutOfRange) {
- return NS_ERROR_FAILURE;
+ if (mIsOutOfRange || !mCurrentIterator) {
+ return nsnull;
}
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
- return mCurrentIterator->CurrentNode(aNode);
+
+ return mCurrentIterator->GetCurrentNode();
}
-NS_IMETHODIMP
+PRBool
nsFilteredContentIterator::IsDone()
{
- if (mIsOutOfRange) {
- return NS_OK;
+ if (mIsOutOfRange || !mCurrentIterator) {
+ return PR_TRUE;
}
- NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
+
return mCurrentIterator->IsDone();
}
-NS_IMETHODIMP
+nsresult
nsFilteredContentIterator::PositionAt(nsIContent* aCurNode)
{
NS_ENSURE_TRUE(mCurrentIterator, NS_ERROR_FAILURE);
diff --git a/mozilla/editor/txtsvc/src/nsFilteredContentIterator.h b/mozilla/editor/txtsvc/src/nsFilteredContentIterator.h
index a839bfcb89f..d1145bdf11e 100644
--- a/mozilla/editor/txtsvc/src/nsFilteredContentIterator.h
+++ b/mozilla/editor/txtsvc/src/nsFilteredContentIterator.h
@@ -61,15 +61,15 @@ public:
virtual ~nsFilteredContentIterator();
/* nsIContentIterator */
- NS_IMETHOD Init(nsIContent* aRoot);
- NS_IMETHOD Init(nsIDOMRange* aRange);
- NS_IMETHOD First();
- NS_IMETHOD Last();
- NS_IMETHOD Next();
- NS_IMETHOD Prev();
- NS_IMETHOD CurrentNode(nsIContent **aNode);
- NS_IMETHOD IsDone();
- NS_IMETHOD PositionAt(nsIContent* aCurNode);
+ virtual nsresult Init(nsIContent* aRoot);
+ virtual nsresult Init(nsIDOMRange* aRange);
+ virtual void First();
+ virtual void Last();
+ virtual void Next();
+ virtual void Prev();
+ virtual nsIContent *GetCurrentNode();
+ virtual PRBool IsDone();
+ virtual nsresult PositionAt(nsIContent* aCurNode);
/* Helpers */
PRPackedBool DidSkip() { return mDidSkip; }
diff --git a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
index be6c084f6f4..8a477f56749 100644
--- a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -412,10 +412,7 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
return NS_OK;
}
- nsCOMPtr firstTextContent;
-
- result = iter->CurrentNode(getter_AddRefs(firstTextContent));
- NS_ENSURE_SUCCESS(result, result);
+ nsIContent *firstTextContent = iter->GetCurrentNode();
NS_ENSURE_TRUE(firstTextContent, NS_ERROR_FAILURE);
// Find the last text node in the range.
@@ -431,10 +428,7 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
return NS_ERROR_FAILURE;
}
- nsCOMPtr lastTextContent;
-
- result = iter->CurrentNode(getter_AddRefs(lastTextContent));
- NS_ENSURE_SUCCESS(result, result);
+ nsIContent *lastTextContent = iter->GetCurrentNode();
NS_ENSURE_TRUE(lastTextContent, NS_ERROR_FAILURE);
// Now make sure our end points are in terms of text nodes in the range!
@@ -725,7 +719,6 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
nsCOMPtr iter;
nsCOMPtr range;
nsCOMPtr parent;
- nsCOMPtr content;
PRInt32 i, rangeCount, offset;
if (isCollapsed)
@@ -777,7 +770,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
// of the text block containing this text node and
// return.
- content = do_QueryInterface(parent);
+ nsCOMPtr content = do_QueryInterface(parent);
if (!content)
{
@@ -864,39 +857,19 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
- result = iter->Last();
+ iter->Last();
- if (NS_FAILED(result))
+ nsIContent *content = nsnull;
+ while (!iter->IsDone())
{
- UNLOCK_DOC(this);
- return result;
- }
-
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
- {
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
-
- if (!content)
- {
- UNLOCK_DOC(this);
- return NS_ERROR_FAILURE;
- }
+ content = iter->GetCurrentNode();
if (IsTextNode(content))
break;
content = nsnull;
- result = iter->Prev();
-
- if (NS_FAILED(result))
- return result;
+ iter->Prev();
}
if (!content)
@@ -993,25 +966,13 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
- result = iter->First();
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ iter->First();
// Now walk through the range till we find a text node.
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
+ while (!iter->IsDone())
{
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ nsIContent *content = iter->GetCurrentNode();
if (IsTextNode(content))
{
@@ -1054,10 +1015,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
}
- result = iter->Next();
-
- if (NS_FAILED(result))
- return result;
+ iter->Next();
}
}
@@ -1135,23 +1093,11 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
- result = iter->Last();
+ iter->Last();
- if (NS_FAILED(result))
+ while (!iter->IsDone())
{
- UNLOCK_DOC(this);
- return result;
- }
-
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
- {
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ nsIContent *content = iter->GetCurrentNode();
if (IsTextNode(content))
{
@@ -1174,7 +1120,6 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
-
mIteratorStatus = nsTextServicesDocument::eValid;
result = CreateOffsetTable(&mOffsetTable, mIterator, &mIteratorStatus,
@@ -1193,10 +1138,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
- result = iter->Prev();
-
- if (NS_FAILED(result))
- return result;
+ iter->Prev();
}
// If we get here, we didn't find any block before or inside
@@ -1212,7 +1154,9 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
// and combine them into one method.
NS_IMETHODIMP
-nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, PRInt32 *aSelOffset, PRInt32 *aSelLength)
+nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
+ PRInt32 *aSelOffset,
+ PRInt32 *aSelLength)
{
nsresult result = NS_OK;
@@ -1254,7 +1198,6 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
nsCOMPtr iter;
nsCOMPtr range;
nsCOMPtr parent;
- nsCOMPtr content;
PRInt32 i, rangeCount, offset;
if (isCollapsed)
@@ -1306,7 +1249,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
// of the text block containing this text node and
// return.
- content = do_QueryInterface(parent);
+ nsCOMPtr content(do_QueryInterface(parent));
if (!content)
{
@@ -1392,39 +1335,19 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
- result = iter->First();
+ iter->First();
- if (NS_FAILED(result))
+ nsIContent *content = nsnull;
+ while (!iter->IsDone())
{
- UNLOCK_DOC(this);
- return result;
- }
-
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
- {
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
-
- if (!content)
- {
- UNLOCK_DOC(this);
- return NS_ERROR_FAILURE;
- }
+ content = iter->GetCurrentNode();
if (IsTextNode(content))
break;
content = nsnull;
- result = iter->Next();
-
- if (NS_FAILED(result))
- return result;
+ iter->Next();
}
if (!content)
@@ -1521,25 +1444,13 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
- result = iter->Last();
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ iter->Last();
// Now walk through the range till we find a text node.
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
+ while (!iter->IsDone())
{
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ nsIContent *content = iter->GetCurrentNode();
if (IsTextNode(content))
{
@@ -1582,10 +1493,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
}
- result = iter->Prev();
-
- if (NS_FAILED(result))
- return result;
+ iter->Prev();
}
}
@@ -1663,23 +1571,11 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
- result = iter->First();
+ iter->First();
- if (NS_FAILED(result))
+ while (!iter->IsDone())
{
- UNLOCK_DOC(this);
- return result;
- }
-
- while (iter->IsDone() == NS_ENUMERATOR_FALSE)
- {
- result = iter->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ nsIContent *content = iter->GetCurrentNode();
if (IsTextNode(content))
{
@@ -1721,10 +1617,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
- result = iter->Next();
-
- if (NS_FAILED(result))
- return result;
+ iter->Next();
}
// If we get here, we didn't find any block before or inside
@@ -1762,7 +1655,7 @@ nsTextServicesDocument::PrevBlock()
return result;
}
- if (mIterator->IsDone() != NS_ENUMERATOR_FALSE)
+ if (mIterator->IsDone())
{
mIteratorStatus = nsTextServicesDocument::eIsDone;
UNLOCK_DOC(this);
@@ -1835,7 +1728,7 @@ nsTextServicesDocument::NextBlock()
return result;
}
- if (mIterator->IsDone() != NS_ENUMERATOR_FALSE)
+ if (mIterator->IsDone())
{
mIteratorStatus = nsTextServicesDocument::eIsDone;
UNLOCK_DOC(this);
@@ -2150,7 +2043,7 @@ nsTextServicesDocument::DeleteSelection()
// The range has changed, so we need to create a new content
// iterator based on the new range.
- nsCOMPtr curContent;
+ nsIContent *curContent;
if (mIteratorStatus != nsTextServicesDocument::eIsDone)
{
@@ -2158,13 +2051,7 @@ nsTextServicesDocument::DeleteSelection()
// so get it's current node so we can restore it after we
// create the new iterator!
- result = mIterator->CurrentNode(getter_AddRefs(curContent));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
+ curContent = mIterator->GetCurrentNode();
}
// Create the new iterator.
@@ -2578,29 +2465,20 @@ nsTextServicesDocument::DeleteNode(nsIDOMNode *aChild)
return NS_OK;
}
- nsCOMPtr content;
- nsCOMPtr node;
-
- result = mIterator->CurrentNode(getter_AddRefs(content));
+ nsCOMPtr node = do_QueryInterface(mIterator->GetCurrentNode());
- if (content)
+ if (node && node == aChild &&
+ mIteratorStatus != nsTextServicesDocument::eIsDone)
{
- node = do_QueryInterface(content);
+ // XXX: This should never really happen because
+ // AdjustContentIterator() should have been called prior
+ // to the delete to try and position the iterator on the
+ // next valid text node in the offset table, and if there
+ // wasn't a next, it would've set mIteratorStatus to eIsDone.
- if (node && node == aChild &&
- mIteratorStatus != nsTextServicesDocument::eIsDone)
- {
- // XXX: This should never really happen because
- // AdjustContentIterator() should have been called prior
- // to the delete to try and position the iterator on the
- // next valid text node in the offset table, and if there
- // wasn't a next, it would've set mIteratorStatus to eIsDone.
-
- NS_ASSERTION(0, "DeleteNode called for current iterator node.");
- }
+ NS_ASSERTION(0, "DeleteNode called for current iterator node.");
}
-
tcount = mOffsetTable.Count();
while (nodeIndex < tcount)
@@ -2762,7 +2640,6 @@ nsTextServicesDocument::JoinNodes(nsIDOMNode *aLeftNode,
// Now check to see if the iterator is pointing to the
// left node. If it is, make it point to the right node!
- nsCOMPtr currentContent;
nsCOMPtr leftContent = do_QueryInterface(aLeftNode);
nsCOMPtr rightContent = do_QueryInterface(aRightNode);
@@ -2772,15 +2649,7 @@ nsTextServicesDocument::JoinNodes(nsIDOMNode *aLeftNode,
return NS_ERROR_FAILURE;
}
- result = mIterator->CurrentNode(getter_AddRefs(currentContent));
-
- if (NS_FAILED(result))
- {
- UNLOCK_DOC(this);
- return result;
- }
-
- if (currentContent == leftContent)
+ if (mIterator->GetCurrentNode() == leftContent)
result = mIterator->PositionAt(rightContent);
UNLOCK_DOC(this);
@@ -3035,23 +2904,12 @@ nsTextServicesDocument::CreateDocumentContentIterator(nsIContentIterator **aIter
nsresult
nsTextServicesDocument::AdjustContentIterator()
{
- nsCOMPtr content;
- nsCOMPtr node;
- nsresult result;
- PRInt32 i;
+ nsresult result = NS_OK;
if (!mIterator)
return NS_ERROR_FAILURE;
- result = mIterator->CurrentNode(getter_AddRefs(content));
-
- if (NS_FAILED(result))
- return result;
-
- if (!content)
- return NS_ERROR_FAILURE;
-
- node = do_QueryInterface(content);
+ nsCOMPtr node(do_QueryInterface(mIterator->GetCurrentNode()));
if (!node)
return NS_ERROR_FAILURE;
@@ -3064,7 +2922,7 @@ nsTextServicesDocument::AdjustContentIterator()
PRBool foundEntry = PR_FALSE;
OffsetEntry *entry;
- for (i = 0; i < tcount && !nextValidNode; i++)
+ for (PRInt32 i = 0; i < tcount && !nextValidNode; i++)
{
entry = (OffsetEntry *)mOffsetTable[i];
@@ -3099,7 +2957,7 @@ nsTextServicesDocument::AdjustContentIterator()
}
}
- content = nsnull;
+ nsCOMPtr content;
if (prevValidNode)
content = do_QueryInterface(prevValidNode);
@@ -3492,7 +3350,6 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
// check already. Just assume it's collapsed!
nsCOMPtr range;
- nsCOMPtr content;
OffsetEntry *entry;
nsCOMPtr