зеркало из https://github.com/mozilla/pjs.git
Fixing bug 230840. DeCOMtaminating nsIDocumentObserver, nsIAttribute, nsIContentList, and nsIContentIterator, and doing some other cleanup. r=jonas@sicking.cc, sr=bryner@brianryner.com
This commit is contained in:
Родитель
9450e46f80
Коммит
d62aed44c4
|
@ -32,7 +32,6 @@ GRE_MODULE = 1
|
|||
|
||||
EXPORTS = \
|
||||
nsIContent.h \
|
||||
nsIAnonymousContent.h \
|
||||
nsIAttribute.h \
|
||||
nsIContentIterator.h \
|
||||
nsContentErrors.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___ */
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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___ */
|
||||
|
|
|
@ -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 <b>before</b>
|
||||
* 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___ */
|
||||
|
|
|
@ -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<nsIContent> content(do_QueryInterface(aNode));
|
||||
|
||||
if (content)
|
||||
return content->GetChildCount();
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList>nodeList;
|
||||
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<nsIDOMNode>
|
|||
GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> resultNode;
|
||||
|
||||
|
||||
if (!aParent)
|
||||
return resultNode;
|
||||
|
||||
PRBool hasChildNodes;
|
||||
aParent->HasChildNodes(&hasChildNodes);
|
||||
if (PR_TRUE==hasChildNodes)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList>nodeList;
|
||||
nsresult res = aParent->GetChildNodes(getter_AddRefs(nodeList));
|
||||
if (NS_SUCCEEDED(res) && nodeList)
|
||||
nodeList->Item(aOffset, getter_AddRefs(resultNode));
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aParent));
|
||||
|
||||
if (content) {
|
||||
resultNode = do_QueryInterface(content->GetChildAt(aOffset));
|
||||
} else if (aParent) {
|
||||
PRBool hasChildNodes;
|
||||
aParent->HasChildNodes(&hasChildNodes);
|
||||
if (hasChildNodes)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList>nodeList;
|
||||
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<nsIContent> aNode, nsCOMPtr<nsIContent> *aSibling, nsVoidArray *aIndexes);
|
||||
nsresult GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<nsIContent> *aSibling, nsVoidArray *aIndexes);
|
||||
|
||||
nsresult NextNode(nsCOMPtr<nsIContent> *ioNextNode, nsVoidArray *aIndexes);
|
||||
nsresult PrevNode(nsCOMPtr<nsIContent> *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<nsIContent> 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<nsIDOMNode> dN;
|
||||
|
||||
|
||||
nsCOMPtr<nsIContent> startCon;
|
||||
nsCOMPtr<nsIDOMNode> startDOM;
|
||||
nsCOMPtr<nsIContent> endCon;
|
||||
|
@ -469,7 +452,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
|
|||
|
||||
// Find first node in range.
|
||||
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> aNode,
|
||||
nsCOMPtr<nsIContent> *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<nsIContent> sib;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIContent> aNode,
|
||||
nsCOMPtr<nsIContent> *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<nsIContent> sib;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIContent> *ioNextNode,
|
||||
nsVoidArray *aIndexes)
|
||||
nsIContent *
|
||||
nsContentIterator::NextNode(nsIContent *aNode, nsVoidArray *aIndexes)
|
||||
{
|
||||
if (!ioNextNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> *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<nsIContent> cSibling;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> *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<nsIContent> *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<nsIContent> *ioNextNode, nsVoidArray *aIndexes)
|
||||
nsIContent *
|
||||
nsContentIterator::PrevNode(nsIContent *aNode, nsVoidArray *aIndexes)
|
||||
{
|
||||
if (!ioNextNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> cN = *ioNextNode;
|
||||
nsIContent *prevNode = nsnull;
|
||||
nsIContent *cN = aNode;
|
||||
|
||||
if (mPre) // if we are a Pre-order iterator, use pre-order
|
||||
{
|
||||
nsCOMPtr<nsIContent> cSibling;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> *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<nsIContent> *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<nsIContent> 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<nsIContent> *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<nsIContent> newCurNode;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> aNode,
|
||||
nsCOMPtr<nsIContent> *outAnestor);
|
||||
|
||||
nsresult GetTopAncestorInRange(nsIContent *aNode,
|
||||
nsCOMPtr<nsIContent> *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<nsIDOMNode> commonParent;
|
||||
|
@ -1323,8 +1296,8 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
|||
nsCOMPtr<nsIContent> cStartP;
|
||||
nsCOMPtr<nsIContent> cEndP;
|
||||
nsCOMPtr<nsIContent> cN;
|
||||
nsCOMPtr<nsIContent> firstCandidate;
|
||||
nsCOMPtr<nsIContent> lastCandidate;
|
||||
nsIContent *firstCandidate = nsnull;
|
||||
nsIContent *lastCandidate = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> dChild;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> nextNode;
|
||||
if (NS_FAILED(GetNextSibling(mCurNode, address_of(nextNode), nsnull)))
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> aNode,
|
||||
nsCOMPtr<nsIContent> *outAnestor)
|
||||
nsresult
|
||||
nsContentSubtreeIterator::GetTopAncestorInRange(nsIContent *aNode,
|
||||
nsCOMPtr<nsIContent> *outAnestor)
|
||||
{
|
||||
if (!aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<nsINodeInfo> ni;
|
||||
nsINodeInfo *ni;
|
||||
if (content) {
|
||||
ni = content->GetNodeInfo();
|
||||
}
|
||||
else {
|
||||
attr->GetNodeInfo(getter_AddRefs(ni));
|
||||
ni = attr->NodeInfo();
|
||||
}
|
||||
|
||||
if (!ni) {
|
||||
|
|
|
@ -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<nsITextContent> 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<nsINodeInfo> newNodeInfo;
|
||||
nsCOMPtr<nsIAtom> 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;
|
||||
|
|
|
@ -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<nsINodeInfo> mNodeInfo;
|
||||
nsString mValue;
|
||||
// XXX For now, there's only a single child - a text
|
||||
// element representing the value
|
||||
|
|
|
@ -411,11 +411,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
|||
"didn't implement nsIAttribute");
|
||||
NS_ENSURE_TRUE(attr, NS_ERROR_UNEXPECTED);
|
||||
|
||||
|
||||
nsCOMPtr<nsINodeInfo> 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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -839,12 +839,12 @@ nsresult nsRange::PopRanges(nsIDOMNode* aDestNode, PRInt32 aOffset, nsIContent*
|
|||
nsresult res = NS_NewContentIterator(getter_AddRefs(iter));
|
||||
iter->Init(aSourceNode);
|
||||
|
||||
nsCOMPtr<nsIContent> 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<nsIContentIterator> mIter;
|
||||
RangeSubtreeIterState mIterState;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mStartCData;
|
||||
nsCOMPtr<nsIDOMNode> mEndCData;
|
||||
nsCOMPtr<nsIDOMCharacterData> mStartCData;
|
||||
nsCOMPtr<nsIDOMCharacterData> mEndCData;
|
||||
|
||||
public:
|
||||
|
||||
RangeSubtreeIterator() : mIterState(eDone) {}
|
||||
~RangeSubtreeIterator() {}
|
||||
|
||||
nsresult Init(nsIDOMRange *aRange)
|
||||
RangeSubtreeIterator()
|
||||
: mIterState(eDone)
|
||||
{
|
||||
}
|
||||
~RangeSubtreeIterator()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRange);
|
||||
|
||||
mIterState = eDone;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMCharacterData> 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<nsIContent> content;
|
||||
res = mIter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!content) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> GetCurrentNode();
|
||||
void First();
|
||||
void Last();
|
||||
void Next();
|
||||
void Prev();
|
||||
|
||||
PRBool IsDone()
|
||||
{
|
||||
|
@ -1423,6 +1213,188 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
nsresult
|
||||
RangeSubtreeIterator::Init(nsIDOMRange *aRange)
|
||||
{
|
||||
mIterState = eDone;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode>
|
||||
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<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> node(iter.GetCurrentNode());
|
||||
// Clone the current subtree!
|
||||
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> nextNode;
|
||||
res = iter.CurrentNode(getter_AddRefs(nextNode));
|
||||
if (NS_FAILED(res)) return res;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> 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
|
||||
|
|
|
@ -4933,45 +4933,49 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
|
|||
#endif //OLD_TABLE_SELECTION
|
||||
}
|
||||
// Now iterated through the child frames and set them
|
||||
nsCOMPtr<nsIContent> 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))
|
||||
|
|
|
@ -587,29 +587,21 @@ nsHTMLAnchorElement::GetText(nsAString& aText)
|
|||
// Initialize the content iterator with the children of the anchor
|
||||
iter->Init(this);
|
||||
|
||||
nsCOMPtr<nsIContent> 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<nsIDOMText> textNode(do_QueryInterface(curNode));
|
||||
while(!iter->IsDone()) {
|
||||
nsCOMPtr<nsIDOMText> 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<nsIContent> 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<nsIContent> point;
|
||||
GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(point));
|
||||
|
||||
|
@ -1475,8 +1468,6 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<nsIContentList> contentList(do_QueryInterface(nativeObj));
|
||||
NS_ASSERTION(contentList, "Why does something not implementing nsIContentList use nsContentListSH??");
|
||||
|
||||
nsCOMPtr<nsISupports> native_parent;
|
||||
contentList->GetParentObject(getter_AddRefs(native_parent));
|
||||
nsISupports *native_parent = contentList->GetParentObject();
|
||||
|
||||
if (!native_parent) {
|
||||
*parentObj = globalObj;
|
||||
|
|
|
@ -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<nsIContent> content;
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(result)) return result;
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
|
||||
if (!node) return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(iter->GetCurrentNode());
|
||||
if (!node)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
DeleteElementTxn *txn;
|
||||
result = TransactionFactory::GetNewTransaction(DeleteElementTxn::GetCID(), (EditTxn **)&txn);
|
||||
|
|
|
@ -122,20 +122,17 @@ nsDOMIterator::Init(nsIDOMNode* aNode)
|
|||
void
|
||||
nsDOMIterator::ForEach(nsDomIterFunctor& functor) const
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode>& arrayOfNodes) const
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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;
|
||||
}
|
||||
|
|
|
@ -7624,14 +7624,14 @@ nsHTMLEditRules::RemoveEmptyNodes()
|
|||
nsVoidArray skipList;
|
||||
|
||||
// check for empty nodes
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node, parent;
|
||||
nsCOMPtr<nsIContent> 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
|
||||
|
|
|
@ -876,10 +876,10 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
|
|||
{
|
||||
nsCOMPtr<nsIDOMRange> lastRange;
|
||||
iter->Init(aRange);
|
||||
nsCOMPtr<nsIContent> currentContent;
|
||||
iter->CurrentNode(getter_AddRefs(currentContent));
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
while (iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> currentContent = iter->GetCurrentNode();
|
||||
|
||||
nsCOMPtr<nsIDOMNode>currentNode = 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<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIContent> 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<nsIContentIterator> 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<nsIContent> 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<nsIDOMNode> 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<nsIDOMNode> 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<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
nsCOMPtr<nsIDOMNode> 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<nsISupports> 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<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res))
|
||||
break;
|
||||
nsIContent *content = iter->GetCurrentNode();
|
||||
nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
|
||||
if (node)
|
||||
{
|
||||
|
@ -4735,23 +4722,21 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
|
|||
nsCOMPtr<nsIContentIterator> 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<nsIContent> 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<nsIDOMCharacterData> text = do_QueryInterface(content);
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> prevSibOfRightNode;
|
||||
result = GetPriorHTMLSibling(rightTextNode, address_of(prevSibOfRightNode));
|
||||
if (NS_FAILED(result)) return result;
|
||||
if (prevSibOfRightNode && (prevSibOfRightNode.get() == leftTextNode))
|
||||
if (prevSibOfRightNode && (prevSibOfRightNode == leftTextNode))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> arrayOfNodes;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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
|
||||
|
|
|
@ -215,7 +215,6 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
|||
if (!iter) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> content;
|
||||
nsAutoString firstValue, theValue;
|
||||
iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> 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<nsIDOMNode> arrayOfNodes;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> arrayOfNodes;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -699,11 +699,9 @@ nsPlaintextEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
|
|||
nsCOMPtr<nsIContent>blockParentContent = do_QueryInterface(aInCommonParentNode);
|
||||
iter->Init(blockParentContent);
|
||||
// loop through the content iterator for each content node
|
||||
nsCOMPtr<nsIContent> 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)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>currentNode = do_QueryInterface(textNode);
|
||||
|
@ -725,7 +723,6 @@ nsPlaintextEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
|
|||
}
|
||||
}
|
||||
iter->Next();
|
||||
iter->CurrentNode(getter_AddRefs(content));
|
||||
}
|
||||
if (-1==aOutEndOffset) {
|
||||
aOutEndOffset = totalLength;
|
||||
|
|
|
@ -1120,14 +1120,12 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
|
|||
nsCOMArray<nsIDOMCharacterData> arrayOfNodes;
|
||||
|
||||
// gather up a list of editable preformatted text nodes
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
res = iter->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(res)) return res;
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(content);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> 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,
|
||||
|
|
|
@ -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<nsIContent> 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<nsIContent> currentContent;
|
||||
rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
|
||||
nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> currentContent;
|
||||
rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
|
||||
nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> currentContent;
|
||||
rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(currentContent));
|
||||
CheckAdvNode(node, mDidSkip, eForward);
|
||||
}
|
||||
nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
|
||||
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> currentContent;
|
||||
rv = mCurrentIterator->CurrentNode(getter_AddRefs(currentContent));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(currentContent));
|
||||
CheckAdvNode(node, mDidSkip, eBackward);
|
||||
}
|
||||
nsIContent *currentContent = mCurrentIterator->GetCurrentNode();
|
||||
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> 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);
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -412,10 +412,7 @@ nsTextServicesDocument::ExpandRangeToWordBoundaries(nsIDOMRange *aRange)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContentIterator> iter;
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContentIterator> iter;
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
|
||||
result = mIterator->CurrentNode(getter_AddRefs(content));
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIContent> currentContent;
|
||||
nsCOMPtr<nsIContent> leftContent = do_QueryInterface(aLeftNode);
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMNode> 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<nsIDOMNode> 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<nsIContent> content;
|
||||
|
||||
if (prevValidNode)
|
||||
content = do_QueryInterface(prevValidNode);
|
||||
|
@ -3492,7 +3350,6 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
// check already. Just assume it's collapsed!
|
||||
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
OffsetEntry *entry;
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
PRInt32 offset, tableCount, i;
|
||||
|
@ -3653,7 +3510,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
content = do_QueryInterface(saveNode);
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(saveNode));
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3668,7 +3525,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
// The parent has no children, so position the iterator
|
||||
// on the parent.
|
||||
|
||||
content = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(parent));
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3685,12 +3542,9 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
// the text block, to find the first text node you
|
||||
// come across.
|
||||
|
||||
while (iter->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
nsIContent *content = iter->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -3704,10 +3558,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
|
||||
node = nsnull;
|
||||
|
||||
result = iter->Prev();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Prev();
|
||||
}
|
||||
|
||||
if (node)
|
||||
|
@ -3715,8 +3566,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
// We found a node, now set the offset to the end
|
||||
// of the text node.
|
||||
|
||||
nsString str;
|
||||
|
||||
nsAutoString str;
|
||||
result = node->GetNodeValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
|
@ -3732,19 +3582,18 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
// the right, towards the end of the text block, looking
|
||||
// for a text node.
|
||||
|
||||
content = do_QueryInterface(saveNode);
|
||||
|
||||
result = iter->PositionAt(content);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
while (iter->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
{
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(saveNode));
|
||||
|
||||
result = iter->PositionAt(content);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
}
|
||||
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
nsIContent *content = iter->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -3758,10 +3607,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
|||
|
||||
node = nsnull;
|
||||
|
||||
result = iter->Next();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Next();
|
||||
}
|
||||
|
||||
if (!node)
|
||||
|
@ -3986,26 +3832,17 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
|||
// Find the first text node in the range.
|
||||
|
||||
PRBool found;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsIContent *content;
|
||||
|
||||
result = iter->First();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->First();
|
||||
|
||||
if (! IsTextNode(p1))
|
||||
if (!IsTextNode(p1))
|
||||
{
|
||||
found = PR_FALSE;
|
||||
|
||||
while (iter->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
content = iter->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4020,10 +3857,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
|||
break;
|
||||
}
|
||||
|
||||
result = iter->Next();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Next();
|
||||
}
|
||||
|
||||
if (!found)
|
||||
|
@ -4032,24 +3866,15 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
|||
|
||||
// Find the last text node in the range.
|
||||
|
||||
result = iter->Last();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Last();
|
||||
|
||||
if (! IsTextNode(p2))
|
||||
{
|
||||
found = PR_FALSE;
|
||||
|
||||
while (iter->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
content = iter->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4071,10 +3896,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
|||
break;
|
||||
}
|
||||
|
||||
result = iter->Prev();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Prev();
|
||||
}
|
||||
|
||||
if (!found)
|
||||
|
@ -4269,15 +4091,11 @@ nsTextServicesDocument::FirstTextNode(nsIContentIterator *aIterator,
|
|||
if (aIteratorStatus)
|
||||
*aIteratorStatus = nsTextServicesDocument::eIsDone;
|
||||
|
||||
nsresult result = aIterator->First();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aIterator->First();
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
while (NS_ENUMERATOR_FALSE == aIterator->IsDone())
|
||||
while (!aIterator->IsDone())
|
||||
{
|
||||
result = aIterator->CurrentNode(getter_AddRefs(content));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsIContent *content = aIterator->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4286,8 +4104,7 @@ nsTextServicesDocument::FirstTextNode(nsIContentIterator *aIterator,
|
|||
break;
|
||||
}
|
||||
|
||||
result = aIterator->Next();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aIterator->Next();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -4300,15 +4117,11 @@ nsTextServicesDocument::LastTextNode(nsIContentIterator *aIterator,
|
|||
if (aIteratorStatus)
|
||||
*aIteratorStatus = nsTextServicesDocument::eIsDone;
|
||||
|
||||
nsresult result = aIterator->Last();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aIterator->Last();
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
while (NS_ENUMERATOR_FALSE == aIterator->IsDone())
|
||||
while (!aIterator->IsDone())
|
||||
{
|
||||
result = aIterator->CurrentNode(getter_AddRefs(content));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsIContent *content = aIterator->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4317,8 +4130,7 @@ nsTextServicesDocument::LastTextNode(nsIContentIterator *aIterator,
|
|||
break;
|
||||
}
|
||||
|
||||
result = aIterator->Prev();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aIterator->Prev();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -4327,25 +4139,19 @@ nsTextServicesDocument::LastTextNode(nsIContentIterator *aIterator,
|
|||
nsresult
|
||||
nsTextServicesDocument::FirstTextNodeInCurrentBlock(nsIContentIterator *iter)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
if (!iter)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ClearDidSkip(iter);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIContent> last;
|
||||
|
||||
// Walk backwards over adjacent text nodes until
|
||||
// we hit a block boundary:
|
||||
|
||||
while (NS_ENUMERATOR_FALSE == iter->IsDone())
|
||||
while (!iter->IsDone())
|
||||
{
|
||||
result = iter->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
nsIContent *content = iter->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4361,17 +4167,14 @@ nsTextServicesDocument::FirstTextNodeInCurrentBlock(nsIContentIterator *iter)
|
|||
else if (last && IsBlockNode(content))
|
||||
break;
|
||||
|
||||
result = iter->Prev();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
iter->Prev();
|
||||
|
||||
if (DidSkip(iter))
|
||||
break;
|
||||
}
|
||||
|
||||
if (last)
|
||||
result = iter->PositionAt(last);
|
||||
iter->PositionAt(last);
|
||||
|
||||
// XXX: What should we return if last is null?
|
||||
|
||||
|
@ -4399,10 +4202,10 @@ nsTextServicesDocument::FirstTextNodeInPrevBlock(nsIContentIterator *aIterator)
|
|||
|
||||
// Point mIterator to the first node before the first text node:
|
||||
|
||||
result = aIterator->Prev();
|
||||
aIterator->Prev();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
if (aIterator->IsDone())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now find the first text node of the next block:
|
||||
|
||||
|
@ -4412,24 +4215,17 @@ nsTextServicesDocument::FirstTextNodeInPrevBlock(nsIContentIterator *aIterator)
|
|||
nsresult
|
||||
nsTextServicesDocument::FirstTextNodeInNextBlock(nsIContentIterator *aIterator)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIContent> prev;
|
||||
PRBool crossedBlockBoundary = PR_FALSE;
|
||||
nsresult result;
|
||||
|
||||
if (!aIterator)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ClearDidSkip(aIterator);
|
||||
|
||||
while (NS_ENUMERATOR_FALSE == aIterator->IsDone())
|
||||
while (!aIterator->IsDone())
|
||||
{
|
||||
result = aIterator->CurrentNode(getter_AddRefs(content));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIContent *content = aIterator->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4441,10 +4237,7 @@ nsTextServicesDocument::FirstTextNodeInNextBlock(nsIContentIterator *aIterator)
|
|||
else if (!crossedBlockBoundary && IsBlockNode(content))
|
||||
crossedBlockBoundary = PR_TRUE;
|
||||
|
||||
result = aIterator->Next();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
aIterator->Next();
|
||||
|
||||
if (!crossedBlockBoundary && DidSkip(aIterator))
|
||||
crossedBlockBoundary = PR_TRUE;
|
||||
|
@ -4456,7 +4249,6 @@ nsTextServicesDocument::FirstTextNodeInNextBlock(nsIContentIterator *aIterator)
|
|||
nsresult
|
||||
nsTextServicesDocument::GetFirstTextNodeInPrevBlock(nsIContent **aContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult result;
|
||||
|
||||
if (!aContent)
|
||||
|
@ -4467,7 +4259,7 @@ nsTextServicesDocument::GetFirstTextNodeInPrevBlock(nsIContent **aContent)
|
|||
// Save the iterator's current content node so we can restore
|
||||
// it when we are done:
|
||||
|
||||
mIterator->CurrentNode(getter_AddRefs(content));
|
||||
nsIContent *content = mIterator->GetCurrentNode();
|
||||
|
||||
result = FirstTextNodeInPrevBlock(mIterator);
|
||||
|
||||
|
@ -4478,16 +4270,9 @@ nsTextServicesDocument::GetFirstTextNodeInPrevBlock(nsIContent **aContent)
|
|||
return result;
|
||||
}
|
||||
|
||||
if (mIterator->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
if (!mIterator->IsDone())
|
||||
{
|
||||
result = mIterator->CurrentNode(aContent);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
// Try to restore the iterator before returning.
|
||||
mIterator->PositionAt(content);
|
||||
return result;
|
||||
}
|
||||
content = mIterator->GetCurrentNode();
|
||||
}
|
||||
|
||||
// Restore the iterator:
|
||||
|
@ -4500,7 +4285,6 @@ nsTextServicesDocument::GetFirstTextNodeInPrevBlock(nsIContent **aContent)
|
|||
nsresult
|
||||
nsTextServicesDocument::GetFirstTextNodeInNextBlock(nsIContent **aContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult result;
|
||||
|
||||
if (!aContent)
|
||||
|
@ -4511,7 +4295,7 @@ nsTextServicesDocument::GetFirstTextNodeInNextBlock(nsIContent **aContent)
|
|||
// Save the iterator's current content node so we can restore
|
||||
// it when we are done:
|
||||
|
||||
mIterator->CurrentNode(getter_AddRefs(content));
|
||||
nsIContent *content = mIterator->GetCurrentNode();
|
||||
|
||||
result = FirstTextNodeInNextBlock(mIterator);
|
||||
|
||||
|
@ -4522,16 +4306,10 @@ nsTextServicesDocument::GetFirstTextNodeInNextBlock(nsIContent **aContent)
|
|||
return result;
|
||||
}
|
||||
|
||||
if (mIterator->IsDone() == NS_ENUMERATOR_FALSE)
|
||||
if (!mIterator->IsDone())
|
||||
{
|
||||
result = mIterator->CurrentNode(aContent);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
// Try to restore the iterator before returning.
|
||||
mIterator->PositionAt(content);
|
||||
return result;
|
||||
}
|
||||
*aContent = mIterator->GetCurrentNode();
|
||||
NS_ADDREF(*aContent);
|
||||
}
|
||||
|
||||
// Restore the iterator:
|
||||
|
@ -4550,7 +4328,6 @@ nsTextServicesDocument::CreateOffsetTable(nsVoidArray *aOffsetTable,
|
|||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIContent> first;
|
||||
nsCOMPtr<nsIContent> prev;
|
||||
|
||||
|
@ -4594,15 +4371,9 @@ nsTextServicesDocument::CreateOffsetTable(nsVoidArray *aOffsetTable,
|
|||
|
||||
ClearDidSkip(aIterator);
|
||||
|
||||
while (NS_ENUMERATOR_FALSE == aIterator->IsDone())
|
||||
while (!aIterator->IsDone())
|
||||
{
|
||||
result = aIterator->CurrentNode(getter_AddRefs(content));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIContent *content = aIterator->GetCurrentNode();
|
||||
|
||||
if (IsTextNode(content))
|
||||
{
|
||||
|
@ -4680,10 +4451,7 @@ nsTextServicesDocument::CreateOffsetTable(nsVoidArray *aOffsetTable,
|
|||
else if (IsBlockNode(content))
|
||||
break;
|
||||
|
||||
result = aIterator->Next();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
aIterator->Next();
|
||||
|
||||
if (DidSkip(aIterator))
|
||||
break;
|
||||
|
|
|
@ -280,7 +280,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsIContent *content = nsnull;
|
||||
nsCOMPtr<nsITextContent> tc;
|
||||
|
||||
if (!mIterator || aContinueOk)
|
||||
|
@ -343,7 +343,7 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
|
|||
if (!aStartPoint)
|
||||
aStartPoint = aSearchRange;
|
||||
|
||||
rv = mIterator->CurrentNode(getter_AddRefs(content));
|
||||
content = mIterator->GetCurrentNode();
|
||||
#ifdef DEBUG_FIND
|
||||
nsCOMPtr<nsIDOMNode> dnode (do_QueryInterface(content));
|
||||
printf(":::::: Got the first node "); DumpNode(dnode);
|
||||
|
@ -379,19 +379,18 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
|
|||
while (1)
|
||||
{
|
||||
if (mFindBackward)
|
||||
rv = mIterator->Prev();
|
||||
mIterator->Prev();
|
||||
else
|
||||
rv = mIterator->Next();
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = mIterator->CurrentNode(getter_AddRefs(content));
|
||||
mIterator->Next();
|
||||
|
||||
content = mIterator->GetCurrentNode();
|
||||
if (!content)
|
||||
break;
|
||||
|
||||
#ifdef DEBUG_FIND
|
||||
nsCOMPtr<nsIDOMNode> dnode (do_QueryInterface(content));
|
||||
printf(":::::: Got another node "); DumpNode(dnode);
|
||||
#endif
|
||||
// nsIContentIterator.h says Next() will return error at end,
|
||||
// but it doesn't really, so we have to check:
|
||||
if (NS_FAILED(rv) || !content)
|
||||
break;
|
||||
|
||||
// If we ever cross a block node, we might want to reset
|
||||
// the match anchor:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- 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
|
||||
*
|
||||
|
@ -90,7 +91,7 @@ inDOMViewNode::inDOMViewNode(nsIDOMNode* aNode) :
|
|||
hasAnonymous(PR_FALSE),
|
||||
hasSubDocument(PR_FALSE)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
inDOMViewNode::~inDOMViewNode()
|
||||
|
@ -179,7 +180,7 @@ inDOMView::SetRootNode(nsIDOMNode* aNode)
|
|||
if (doc)
|
||||
doc->RemoveObserver(this);
|
||||
}
|
||||
|
||||
|
||||
RemoveAllNodes();
|
||||
|
||||
mRootNode = aNode;
|
||||
|
@ -236,14 +237,14 @@ inDOMView::GetRowIndexFromNode(nsIDOMNode *node, PRInt32 *_retval)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
inDOMView::GetShowAnonymousContent(PRBool *aShowAnonymousContent)
|
||||
{
|
||||
*aShowAnonymousContent = mShowAnonymous;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
inDOMView::SetShowAnonymousContent(PRBool aShowAnonymousContent)
|
||||
{
|
||||
mShowAnonymous = aShowAnonymousContent;
|
||||
|
@ -264,14 +265,14 @@ inDOMView::SetShowSubDocuments(PRBool aShowSubDocuments)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
inDOMView::GetShowWhitespaceNodes(PRBool *aShowWhitespaceNodes)
|
||||
{
|
||||
*aShowWhitespaceNodes = mShowWhitespaceNodes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
inDOMView::SetShowWhitespaceNodes(PRBool aShowWhitespaceNodes)
|
||||
{
|
||||
mShowWhitespaceNodes = aShowWhitespaceNodes;
|
||||
|
@ -402,7 +403,7 @@ inDOMView::GetCellText(PRInt32 row, const PRUnichar *colID, nsAString& _retval)
|
|||
inDOMViewNode* node = nsnull;
|
||||
RowToNode(row, &node);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
nsIDOMNode* domNode = node->node;
|
||||
|
||||
nsAutoString col(colID);
|
||||
|
@ -486,7 +487,7 @@ inDOMView::GetParentIndex(PRInt32 rowIndex, PRInt32 *_retval)
|
|||
inDOMViewNode* node = nsnull;
|
||||
RowToNode(rowIndex, &node);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
inDOMViewNode* checkNode = nsnull;
|
||||
PRUint32 i = rowIndex - 1;
|
||||
do {
|
||||
|
@ -507,7 +508,7 @@ inDOMView::HasNextSibling(PRInt32 rowIndex, PRInt32 afterIndex, PRBool *_retval)
|
|||
inDOMViewNode* node = nsnull;
|
||||
RowToNode(rowIndex, &node);
|
||||
if (!node) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
*_retval = node->next != nsnull;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -523,14 +524,14 @@ inDOMView::ToggleOpenState(PRInt32 index)
|
|||
PRInt32 oldCount = GetRowCount();
|
||||
if (node->isOpen)
|
||||
CollapseNode(index);
|
||||
else
|
||||
else
|
||||
ExpandNode(index);
|
||||
|
||||
// Update the twisty.
|
||||
mTree->InvalidateRow(index);
|
||||
|
||||
mTree->RowCountChanged(index+1, GetRowCount() - oldCount);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -642,16 +643,16 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(inDOMView)
|
|||
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(inDOMView)
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(inDOMView)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute, PRInt32 aModType)
|
||||
{
|
||||
if (!mTree) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mWhatToShow & nsIDOMNodeFilter::SHOW_ATTRIBUTE)) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// get the dom attribute node, if there is any
|
||||
|
@ -660,7 +661,7 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt3
|
|||
nsCOMPtr<nsIDOMAttr> domAttr;
|
||||
nsAutoString attrStr;
|
||||
aAttribute->ToString(attrStr);
|
||||
el->GetAttributeNode(attrStr, getter_AddRefs(domAttr));
|
||||
el->GetAttributeNode(attrStr, getter_AddRefs(domAttr));
|
||||
|
||||
if (aModType == nsIDOMMutationEvent::MODIFICATION) {
|
||||
// No fancy stuff here, just invalidate the changed row
|
||||
|
@ -673,16 +674,16 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt3
|
|||
content->GetAttributes(getter_AddRefs(attrs));
|
||||
PRUint32 attrCount;
|
||||
attrs->GetLength(&attrCount);
|
||||
|
||||
|
||||
inDOMViewNode* contentNode = nsnull;
|
||||
PRInt32 contentRow;
|
||||
PRInt32 attrRow;
|
||||
if (NS_FAILED(NodeToRow(content, &contentRow))) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
RowToNode(contentRow, &contentNode);
|
||||
if (!contentRow || !contentNode->isOpen) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
if (mRootNode == content) {
|
||||
// if this view has a root node but is not displaying it,
|
||||
|
@ -699,13 +700,13 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt3
|
|||
if (insertNode->level <= contentNode->level) {
|
||||
RowToNode(attrRow-1, &insertNode);
|
||||
InsertLinkAfter(newNode, insertNode);
|
||||
} else
|
||||
} else
|
||||
InsertLinkBefore(newNode, insertNode);
|
||||
}
|
||||
InsertNode(newNode, attrRow);
|
||||
mTree->RowCountChanged(attrRow, 1);
|
||||
} else if (aModType == nsIDOMMutationEvent::REMOVAL) {
|
||||
// At this point, the attribute is already gone from the DOM, but is still represented
|
||||
// At this point, the attribute is already gone from the DOM, but is still represented
|
||||
// in our mRows array. Search through the content node's children for the corresponding
|
||||
// node and remove it.
|
||||
|
||||
|
@ -719,9 +720,9 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt3
|
|||
} else {
|
||||
if (mRootNode == content) {
|
||||
contentRow = -1;
|
||||
baseLevel = -1;
|
||||
baseLevel = -1;
|
||||
} else
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// search for the attribute node that was removed
|
||||
|
@ -741,44 +742,42 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt3
|
|||
mTree->RowCountChanged(row, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (checkNode->level <= baseLevel)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
inDOMView::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
if (!mTree) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
nsIContent *child = aContainer->GetChildAt(aNewIndexInContainer);
|
||||
|
||||
return ContentInserted(aDocument, aContainer, child,
|
||||
aNewIndexInContainer);
|
||||
ContentInserted(aDocument, aContainer, child, aNewIndexInContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
inDOMView::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer)
|
||||
void
|
||||
inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (!mTree)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMNode> childDOMNode(do_QueryInterface(aChild));
|
||||
|
@ -786,19 +785,19 @@ inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsICo
|
|||
if (!mDOMUtils) {
|
||||
mDOMUtils = do_GetService("@mozilla.org/inspector/dom-utils;1");
|
||||
if (!mDOMUtils) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
mDOMUtils->GetParentForNode(childDOMNode, mShowAnonymous,
|
||||
getter_AddRefs(parent));
|
||||
|
||||
getter_AddRefs(parent));
|
||||
|
||||
// find the inDOMViewNode for the parent of the inserted content
|
||||
PRInt32 parentRow = 0;
|
||||
if (NS_FAILED(rv = NodeToRow(parent, &parentRow)))
|
||||
return rv;
|
||||
return;
|
||||
inDOMViewNode* parentNode = nsnull;
|
||||
if (NS_FAILED(rv = RowToNode(parentRow, &parentNode)))
|
||||
return rv;
|
||||
return;
|
||||
|
||||
// get the previous sibling of the inserted content
|
||||
nsCOMPtr<nsIDOMNode> previous;
|
||||
|
@ -810,9 +809,9 @@ inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsICo
|
|||
// find the inDOMViewNode for the previous sibling of the inserted content
|
||||
PRInt32 previousRow = 0;
|
||||
if (NS_FAILED(rv = NodeToRow(previous, &previousRow)))
|
||||
return rv;
|
||||
return;
|
||||
if (NS_FAILED(rv = RowToNode(previousRow, &previousNode)))
|
||||
return rv;
|
||||
return;
|
||||
|
||||
// get the last descendant of the previous row, which is the row
|
||||
// after which to insert this new row
|
||||
|
@ -840,15 +839,13 @@ inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsICo
|
|||
InsertNode(newNode, row);
|
||||
|
||||
mTree->RowCountChanged(row, 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
inDOMView::ContentReplaced(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aOldChild, nsIContent* aNewChild, PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (!mTree)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
@ -857,10 +854,10 @@ inDOMView::ContentReplaced(nsIDocument *aDocument, nsIContent* aContainer, nsICo
|
|||
nsCOMPtr<nsIDOMNode> newDOMNode(do_QueryInterface(aNewChild));
|
||||
PRInt32 row = 0;
|
||||
if (NS_FAILED(rv = NodeToRow(oldDOMNode, &row)))
|
||||
return rv;
|
||||
return;
|
||||
inDOMViewNode* oldNode;
|
||||
if (NS_FAILED(rv = RowToNode(row, &oldNode)))
|
||||
return rv;
|
||||
return;
|
||||
|
||||
PRInt32 oldRowCount = GetRowCount();
|
||||
if (oldNode->isOpen)
|
||||
|
@ -873,15 +870,13 @@ inDOMView::ContentReplaced(nsIDocument *aDocument, nsIContent* aContainer, nsICo
|
|||
|
||||
// XXX can this go into ReplaceNode?
|
||||
mTree->InvalidateRange(row, oldRowCount-1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (!mTree)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
@ -889,10 +884,10 @@ inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsICon
|
|||
nsCOMPtr<nsIDOMNode> oldDOMNode(do_QueryInterface(aChild));
|
||||
PRInt32 row = 0;
|
||||
if (NS_FAILED(rv = NodeToRow(oldDOMNode, &row)))
|
||||
return rv;
|
||||
return;
|
||||
inDOMViewNode* oldNode;
|
||||
if (NS_FAILED(rv = RowToNode(row, &oldNode)))
|
||||
return rv;
|
||||
return;
|
||||
|
||||
if (oldNode->isOpen)
|
||||
CollapseNode(row);
|
||||
|
@ -901,8 +896,6 @@ inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsICon
|
|||
RemoveNode(row);
|
||||
|
||||
mTree->RowCountChanged(row, -1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -1018,7 +1011,7 @@ inDOMView::ExpandNode(PRInt32 aRow)
|
|||
|
||||
nsCOMArray<nsIDOMNode> kids;
|
||||
GetChildNodesFor(node ? node->node : mRootNode,
|
||||
kids);
|
||||
kids);
|
||||
PRInt32 kidCount = kids.Count();
|
||||
|
||||
nsVoidArray list(kidCount);
|
||||
|
@ -1047,7 +1040,7 @@ inDOMView::CollapseNode(PRInt32 aRow)
|
|||
{
|
||||
inDOMViewNode* node = nsnull;
|
||||
RowToNode(aRow, &node);
|
||||
|
||||
|
||||
PRInt32 row = 0;
|
||||
GetLastDescendantOf(node, aRow, &row);
|
||||
|
||||
|
@ -1085,7 +1078,7 @@ inDOMView::NodeToRow(nsIDOMNode* aNode, PRInt32* aRow)
|
|||
|
||||
//////// NODE HIERARCHY MUTATION
|
||||
|
||||
void
|
||||
void
|
||||
inDOMView::InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter)
|
||||
{
|
||||
if (aInsertAfter->next)
|
||||
|
@ -1095,7 +1088,7 @@ inDOMView::InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter)
|
|||
aNode->previous = aInsertAfter;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
inDOMView::InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore)
|
||||
{
|
||||
if (aInsertBefore->previous)
|
||||
|
@ -1163,7 +1156,7 @@ inDOMView::GetLastDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aRes
|
|||
nsresult
|
||||
inDOMView::GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult)
|
||||
{
|
||||
// Need to do this test to prevent unfortunate NYI assertion
|
||||
// Need to do this test to prevent unfortunate NYI assertion
|
||||
// on nsXULAttribute::GetChildNodes
|
||||
nsCOMPtr<nsIDOMAttr> attr = do_QueryInterface(aNode);
|
||||
if (!attr) {
|
||||
|
@ -1189,7 +1182,7 @@ inDOMView::GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult)
|
|||
bindingManager->GetContentListFor(content, getter_AddRefs(kids));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!kids) {
|
||||
|
|
|
@ -268,12 +268,12 @@ PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode)
|
|||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
nsINodeInfo *ni;
|
||||
if (content) {
|
||||
ni = content->GetNodeInfo();
|
||||
}
|
||||
else {
|
||||
attr->GetNodeInfo(getter_AddRefs(ni));
|
||||
ni = attr->NodeInfo();
|
||||
}
|
||||
|
||||
if (!ni) {
|
||||
|
|
|
@ -201,16 +201,15 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsXPathResult)
|
|||
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsXPathResult)
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(nsXPathResult)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::ContentChanged(nsIDocument* aDocument,
|
||||
nsIContent *aContent,
|
||||
nsISupports *aSubContent)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -218,29 +217,26 @@ nsXPathResult::AttributeChanged(nsIDocument* aDocument,
|
|||
PRInt32 aModType)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::ContentReplaced(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
|
@ -248,17 +244,15 @@ nsXPathResult::ContentReplaced(nsIDocument* aDocument,
|
|||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsXPathResult::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
Invalidate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -891,11 +891,8 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode)
|
|||
if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) {
|
||||
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(aNode);
|
||||
if (attr) {
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
attr->GetContent(getter_AddRefs(parent));
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
attr->GetNodeInfo(getter_AddRefs(nodeInfo));
|
||||
nsIContent *parent = attr->GetContent();
|
||||
nsINodeInfo *nodeInfo = attr->NodeInfo();
|
||||
|
||||
nsCOMPtr<nsIAtom> attName, attPrefix;
|
||||
PRInt32 attNS;
|
||||
|
|
|
@ -816,25 +816,23 @@ NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(txMozillaXSLTProcessor)
|
|||
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(txMozillaXSLTProcessor)
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(txMozillaXSLTProcessor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::BeginUpdate(nsIDocument* aDocument,
|
||||
nsUpdateType aUpdateType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::EndUpdate(nsIDocument* aDocument,
|
||||
nsUpdateType aUpdateType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::DocumentWillBeDestroyed(nsIDocument* aDocument)
|
||||
{
|
||||
if (NS_FAILED(mCompileResult)) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
mCompileResult = ensureStylesheet();
|
||||
|
@ -845,20 +843,17 @@ txMozillaXSLTProcessor::DocumentWillBeDestroyed(nsIDocument* aDocument)
|
|||
// causing a notification as the document goes away we don't want to
|
||||
// invalidate the stylesheet.
|
||||
aDocument->RemoveObserver(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::ContentChanged(nsIDocument* aDocument,
|
||||
nsIContent *aContent,
|
||||
nsISupports *aSubContent)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -866,29 +861,26 @@ txMozillaXSLTProcessor::AttributeChanged(nsIDocument* aDocument,
|
|||
PRInt32 aModType)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::ContentAppended(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::ContentReplaced(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
|
@ -896,17 +888,15 @@ txMozillaXSLTProcessor::ContentReplaced(nsIDocument* aDocument,
|
|||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static*/
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#define nsDOMParser_h__
|
||||
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#define nsDOMSerializer_h__
|
||||
|
||||
#include "nsIDOMSerializer.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
class nsDOMSerializer : public nsIDOMSerializer
|
||||
{
|
||||
|
|
|
@ -34,17 +34,17 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentIterator
|
||||
NS_IMETHOD Init(nsIContent* aRoot);
|
||||
NS_IMETHOD Init(nsIDOMRange* aRange);
|
||||
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
virtual nsresult Init(nsIContent* aRoot);
|
||||
virtual nsresult Init(nsIDOMRange* aRange);
|
||||
|
||||
NS_IMETHOD CurrentNode(nsIContent **aNode);
|
||||
NS_IMETHOD IsDone();
|
||||
NS_IMETHOD PositionAt(nsIContent* aCurNode);
|
||||
virtual void First();
|
||||
virtual void Last();
|
||||
virtual void Next();
|
||||
virtual void Prev();
|
||||
|
||||
virtual nsIContent *GetCurrentNode();
|
||||
virtual PRBool IsDone();
|
||||
virtual nsresult PositionAt(nsIContent* aCurNode);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIPresContext> mPresContext;
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
};
|
||||
|
||||
nsFrameContentIterator::nsFrameContentIterator(nsIPresContext* aPresContext,
|
||||
nsIFrame* aFrame)
|
||||
nsIFrame* aFrame)
|
||||
: mPresContext(aPresContext), mParentFrame(aFrame), mIsDone(PR_FALSE)
|
||||
{
|
||||
First();
|
||||
|
@ -66,28 +66,25 @@ nsFrameContentIterator::~nsFrameContentIterator()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::Init(nsIContent* aRoot)
|
||||
{
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::Init(nsIDOMRange* aRange)
|
||||
{
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::First()
|
||||
{
|
||||
// Get the first child frame and make it the current node
|
||||
mCurrentChild = mParentFrame->GetFirstChild(nsnull);
|
||||
if (!mCurrentChild) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
||||
mIsDone = !mCurrentChild;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +113,7 @@ GetNextChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
return nextSibling;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Last()
|
||||
{
|
||||
// Starting with the first child walk and find the last child
|
||||
|
@ -127,14 +124,10 @@ nsFrameContentIterator::Last()
|
|||
nextChild = ::GetNextChildFrame(mPresContext, nextChild);
|
||||
}
|
||||
|
||||
if (!mCurrentChild) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
mIsDone = !mCurrentChild;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Next()
|
||||
{
|
||||
nsIFrame* nextChild = ::GetNextChildFrame(mPresContext, mCurrentChild);
|
||||
|
@ -145,10 +138,12 @@ nsFrameContentIterator::Next()
|
|||
|
||||
// If we're at the end then the collection is at the end
|
||||
mIsDone = (nsnull == ::GetNextChildFrame(mPresContext, mCurrentChild));
|
||||
return NS_OK;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// No next frame, we're done.
|
||||
mIsDone = PR_TRUE;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
|
@ -192,7 +187,7 @@ GetPrevChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
return prevSibling;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Prev()
|
||||
{
|
||||
nsIFrame* prevChild = ::GetPrevChildFrame(mPresContext, mCurrentChild);
|
||||
|
@ -203,32 +198,31 @@ nsFrameContentIterator::Prev()
|
|||
|
||||
// If we're at the beginning then the collection is at the end
|
||||
mIsDone = (nsnull == ::GetPrevChildFrame(mPresContext, mCurrentChild));
|
||||
return NS_OK;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// No previous frame, we're done.
|
||||
mIsDone = PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameContentIterator::CurrentNode(nsIContent **aNode)
|
||||
nsIContent *
|
||||
nsFrameContentIterator::GetCurrentNode()
|
||||
{
|
||||
if (mCurrentChild) {
|
||||
*aNode = mCurrentChild->GetContent();
|
||||
NS_IF_ADDREF(*aNode);
|
||||
return NS_OK;
|
||||
} else {
|
||||
*aNode = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
if (mCurrentChild && !mIsDone) {
|
||||
return mCurrentChild->GetContent();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsFrameContentIterator::IsDone()
|
||||
{
|
||||
return mIsDone ? NS_OK : NS_ENUMERATOR_FALSE;
|
||||
return mIsDone;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::PositionAt(nsIContent* aCurNode)
|
||||
{
|
||||
// Starting with the first child frame search for the child frame
|
||||
|
@ -245,10 +239,9 @@ nsFrameContentIterator::PositionAt(nsIContent* aCurNode)
|
|||
// Make it the current child
|
||||
mCurrentChild = child;
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIContentList.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
|
|
@ -3553,7 +3553,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -3561,11 +3561,9 @@ PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
|||
#endif
|
||||
if (aUpdateType & UPDATE_STYLE)
|
||||
mStyleSet->BeginUpdate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -3577,12 +3575,10 @@ PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
|||
mStyleSet->EndUpdate();
|
||||
|
||||
if (mStylesHaveChanged && (aUpdateType & UPDATE_STYLE))
|
||||
return ReconstructStyleData();
|
||||
|
||||
return NS_OK;
|
||||
ReconstructStyleData();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::BeginLoad(nsIDocument *aDocument)
|
||||
{
|
||||
#ifdef MOZ_PERF_METRICS
|
||||
|
@ -3590,10 +3586,9 @@ PresShell::BeginLoad(nsIDocument *aDocument)
|
|||
MOZ_TIMER_DEBUGLOG(("Reset: Style Resolution: PresShell::BeginLoad(), this=%p\n", (void*)this));
|
||||
#endif
|
||||
mDocumentLoading = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::EndLoad(nsIDocument *aDocument)
|
||||
{
|
||||
|
||||
|
@ -3603,11 +3598,11 @@ PresShell::EndLoad(nsIDocument *aDocument)
|
|||
nsCOMPtr<nsISupports> container;
|
||||
mPresContext->GetContainer(getter_AddRefs(container));
|
||||
if (!container)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
if (!docShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsILayoutHistoryState> historyState;
|
||||
docShell->GetLayoutHistoryState(getter_AddRefs(historyState));
|
||||
|
@ -3636,7 +3631,6 @@ PresShell::EndLoad(nsIDocument *aDocument)
|
|||
MOZ_TIMER_DEBUGLOG(("Stop: Style Resolution: PresShell::EndLoad(), this=%p\n", this));
|
||||
#endif
|
||||
mDocumentLoading = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(PresShell)
|
||||
|
@ -5192,103 +5186,90 @@ PresShell::GetReflowBatchingStatus(PRBool* aIsBatching)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentChanged(mPresContext,
|
||||
aContent, aSubContent);
|
||||
mFrameConstructor->ContentChanged(mPresContext, aContent, aSubContent);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentStatesChanged(mPresContext,
|
||||
aContent1,
|
||||
aContent2, aStateMask);
|
||||
mFrameConstructor->ContentStatesChanged(mPresContext, aContent1, aContent2,
|
||||
aStateMask);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// XXXwaterson it might be more elegant to wait until after the
|
||||
// initial reflow to begin observing the document. That would
|
||||
// squelch any other inappropriate notifications as well.
|
||||
if (mDidInitialReflow) {
|
||||
WillCauseReflow();
|
||||
rv = mFrameConstructor->AttributeChanged(mPresContext, aContent,
|
||||
aNameSpaceID, aAttribute,
|
||||
aModType);
|
||||
mFrameConstructor->AttributeChanged(mPresContext, aContent, aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
if (!mDidInitialReflow) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
WillCauseReflow();
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
|
||||
MOZ_TIMER_START(mFrameCreationWatch);
|
||||
|
||||
nsresult rv = mFrameConstructor->ContentAppended(mPresContext, aContainer,
|
||||
aNewIndexInContainer);
|
||||
mFrameConstructor->ContentAppended(mPresContext, aContainer,
|
||||
aNewIndexInContainer);
|
||||
VERIFY_STYLE_TREE;
|
||||
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
|
||||
MOZ_TIMER_STOP(mFrameCreationWatch);
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (!mDidInitialReflow) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentInserted(mPresContext, aContainer,
|
||||
nsnull, aChild,
|
||||
aIndexInContainer, nsnull,
|
||||
PR_FALSE);
|
||||
mFrameConstructor->ContentInserted(mPresContext, aContainer, nsnull, aChild,
|
||||
aIndexInContainer, nsnull, PR_FALSE);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentReplaced(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
|
@ -5303,15 +5284,13 @@ PresShell::ContentReplaced(nsIDocument* aDocument,
|
|||
esm->ContentRemoved(aOldChild);
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentReplaced(mPresContext, aContainer,
|
||||
aOldChild, aNewChild,
|
||||
aIndexInContainer);
|
||||
mFrameConstructor->ContentReplaced(mPresContext, aContainer, aOldChild,
|
||||
aNewChild, aIndexInContainer);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
|
@ -5325,9 +5304,8 @@ PresShell::ContentRemoved(nsIDocument *aDocument,
|
|||
esm->ContentRemoved(aChild);
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentRemoved(mPresContext, aContainer,
|
||||
aChild, aIndexInContainer,
|
||||
PR_FALSE);
|
||||
mFrameConstructor->ContentRemoved(mPresContext, aContainer, aChild,
|
||||
aIndexInContainer, PR_FALSE);
|
||||
|
||||
// If we have no root content node at this point, be sure to reset
|
||||
// mDidInitialReflow to PR_FALSE, this will allow InitialReflow()
|
||||
|
@ -5339,7 +5317,6 @@ PresShell::ContentRemoved(nsIDocument *aDocument,
|
|||
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -5377,11 +5354,11 @@ PresShell::ReconstructStyleData()
|
|||
mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext);
|
||||
|
||||
VERIFY_STYLE_TREE;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
|
@ -5393,11 +5370,9 @@ PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
|||
if (applicable && aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
|
@ -5408,11 +5383,9 @@ PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
|||
if (applicable && aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable)
|
||||
|
@ -5420,42 +5393,36 @@ PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
|||
if (aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
nsIStyleRule* aNewStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1025,7 +1025,7 @@ nsImageMap::IsAncestorOf(nsIContent* aContent,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
|
@ -1039,10 +1039,18 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
|
|||
UpdateAreas();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::MaybeUpdateAreas(nsIContent *aContent)
|
||||
{
|
||||
if (aContent == mMap ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContent, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsImageMap::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1051,64 +1059,43 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
|
|||
{
|
||||
// If the parent of the changing content node is our map then update
|
||||
// the map.
|
||||
nsIContent* parent = aContent->GetParent();
|
||||
if ((parent == mMap) ||
|
||||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContent->GetParent());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -122,6 +122,8 @@ protected:
|
|||
nsresult ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus);
|
||||
nsresult Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& aRect);
|
||||
|
||||
void MaybeUpdateAreas(nsIContent *aContent);
|
||||
|
||||
nsIPresShell* mPresShell; // WEAK - owns the frame that owns us
|
||||
nsIFrame* mImageFrame; // the frame that owns us
|
||||
nsIDocument* mDocument; // WEAK - the imagemap will not outlive the document
|
||||
|
|
|
@ -4933,45 +4933,49 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
|
|||
#endif //OLD_TABLE_SELECTION
|
||||
}
|
||||
// Now iterated through the child frames and set them
|
||||
nsCOMPtr<nsIContent> 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))
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIContentList.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
|
|
@ -1025,7 +1025,7 @@ nsImageMap::IsAncestorOf(nsIContent* aContent,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
|
@ -1039,10 +1039,18 @@ nsImageMap::ContentChanged(nsIDocument *aDocument,
|
|||
UpdateAreas();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::MaybeUpdateAreas(nsIContent *aContent)
|
||||
{
|
||||
if (aContent == mMap ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContent, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsImageMap::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -1051,64 +1059,43 @@ nsImageMap::AttributeChanged(nsIDocument *aDocument,
|
|||
{
|
||||
// If the parent of the changing content node is our map then update
|
||||
// the map.
|
||||
nsIContent* parent = aContent->GetParent();
|
||||
if ((parent == mMap) ||
|
||||
(mContainsBlockContents && IsAncestorOf(parent, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContent->GetParent());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsImageMap::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if ((mMap == aContainer) ||
|
||||
(mContainsBlockContents && IsAncestorOf(aContainer, mMap))) {
|
||||
UpdateAreas();
|
||||
}
|
||||
return NS_OK;
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -122,6 +122,8 @@ protected:
|
|||
nsresult ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus);
|
||||
nsresult Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& aRect);
|
||||
|
||||
void MaybeUpdateAreas(nsIContent *aContent);
|
||||
|
||||
nsIPresShell* mPresShell; // WEAK - owns the frame that owns us
|
||||
nsIFrame* mImageFrame; // the frame that owns us
|
||||
nsIDocument* mDocument; // WEAK - the imagemap will not outlive the document
|
||||
|
|
|
@ -3553,7 +3553,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -3561,11 +3561,9 @@ PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
|||
#endif
|
||||
if (aUpdateType & UPDATE_STYLE)
|
||||
mStyleSet->BeginUpdate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -3577,12 +3575,10 @@ PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
|||
mStyleSet->EndUpdate();
|
||||
|
||||
if (mStylesHaveChanged && (aUpdateType & UPDATE_STYLE))
|
||||
return ReconstructStyleData();
|
||||
|
||||
return NS_OK;
|
||||
ReconstructStyleData();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::BeginLoad(nsIDocument *aDocument)
|
||||
{
|
||||
#ifdef MOZ_PERF_METRICS
|
||||
|
@ -3590,10 +3586,9 @@ PresShell::BeginLoad(nsIDocument *aDocument)
|
|||
MOZ_TIMER_DEBUGLOG(("Reset: Style Resolution: PresShell::BeginLoad(), this=%p\n", (void*)this));
|
||||
#endif
|
||||
mDocumentLoading = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::EndLoad(nsIDocument *aDocument)
|
||||
{
|
||||
|
||||
|
@ -3603,11 +3598,11 @@ PresShell::EndLoad(nsIDocument *aDocument)
|
|||
nsCOMPtr<nsISupports> container;
|
||||
mPresContext->GetContainer(getter_AddRefs(container));
|
||||
if (!container)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
if (!docShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsILayoutHistoryState> historyState;
|
||||
docShell->GetLayoutHistoryState(getter_AddRefs(historyState));
|
||||
|
@ -3636,7 +3631,6 @@ PresShell::EndLoad(nsIDocument *aDocument)
|
|||
MOZ_TIMER_DEBUGLOG(("Stop: Style Resolution: PresShell::EndLoad(), this=%p\n", this));
|
||||
#endif
|
||||
mDocumentLoading = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(PresShell)
|
||||
|
@ -5192,103 +5186,90 @@ PresShell::GetReflowBatchingStatus(PRBool* aIsBatching)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentChanged(mPresContext,
|
||||
aContent, aSubContent);
|
||||
mFrameConstructor->ContentChanged(mPresContext, aContent, aSubContent);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask)
|
||||
{
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentStatesChanged(mPresContext,
|
||||
aContent1,
|
||||
aContent2, aStateMask);
|
||||
mFrameConstructor->ContentStatesChanged(mPresContext, aContent1, aContent2,
|
||||
aStateMask);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// XXXwaterson it might be more elegant to wait until after the
|
||||
// initial reflow to begin observing the document. That would
|
||||
// squelch any other inappropriate notifications as well.
|
||||
if (mDidInitialReflow) {
|
||||
WillCauseReflow();
|
||||
rv = mFrameConstructor->AttributeChanged(mPresContext, aContent,
|
||||
aNameSpaceID, aAttribute,
|
||||
aModType);
|
||||
mFrameConstructor->AttributeChanged(mPresContext, aContent, aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
if (!mDidInitialReflow) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
WillCauseReflow();
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
|
||||
MOZ_TIMER_START(mFrameCreationWatch);
|
||||
|
||||
nsresult rv = mFrameConstructor->ContentAppended(mPresContext, aContainer,
|
||||
aNewIndexInContainer);
|
||||
mFrameConstructor->ContentAppended(mPresContext, aContainer,
|
||||
aNewIndexInContainer);
|
||||
VERIFY_STYLE_TREE;
|
||||
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
|
||||
MOZ_TIMER_STOP(mFrameCreationWatch);
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (!mDidInitialReflow) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentInserted(mPresContext, aContainer,
|
||||
nsnull, aChild,
|
||||
aIndexInContainer, nsnull,
|
||||
PR_FALSE);
|
||||
mFrameConstructor->ContentInserted(mPresContext, aContainer, nsnull, aChild,
|
||||
aIndexInContainer, nsnull, PR_FALSE);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentReplaced(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
|
@ -5303,15 +5284,13 @@ PresShell::ContentReplaced(nsIDocument* aDocument,
|
|||
esm->ContentRemoved(aOldChild);
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentReplaced(mPresContext, aContainer,
|
||||
aOldChild, aNewChild,
|
||||
aIndexInContainer);
|
||||
mFrameConstructor->ContentReplaced(mPresContext, aContainer, aOldChild,
|
||||
aNewChild, aIndexInContainer);
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
|
@ -5325,9 +5304,8 @@ PresShell::ContentRemoved(nsIDocument *aDocument,
|
|||
esm->ContentRemoved(aChild);
|
||||
|
||||
WillCauseReflow();
|
||||
nsresult rv = mFrameConstructor->ContentRemoved(mPresContext, aContainer,
|
||||
aChild, aIndexInContainer,
|
||||
PR_FALSE);
|
||||
mFrameConstructor->ContentRemoved(mPresContext, aContainer, aChild,
|
||||
aIndexInContainer, PR_FALSE);
|
||||
|
||||
// If we have no root content node at this point, be sure to reset
|
||||
// mDidInitialReflow to PR_FALSE, this will allow InitialReflow()
|
||||
|
@ -5339,7 +5317,6 @@ PresShell::ContentRemoved(nsIDocument *aDocument,
|
|||
|
||||
VERIFY_STYLE_TREE;
|
||||
DidCauseReflow();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -5377,11 +5354,11 @@ PresShell::ReconstructStyleData()
|
|||
mFrameConstructor->ProcessRestyledFrames(changeList, mPresContext);
|
||||
|
||||
VERIFY_STYLE_TREE;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
|
@ -5393,11 +5370,9 @@ PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
|||
if (applicable && aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
|
@ -5408,11 +5383,9 @@ PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
|||
if (applicable && aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable)
|
||||
|
@ -5420,42 +5393,36 @@ PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
|||
if (aStyleSheet->HasRules()) {
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
nsIStyleRule* aNewStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule)
|
||||
{
|
||||
mStylesHaveChanged = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
PresShell::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -34,17 +34,17 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentIterator
|
||||
NS_IMETHOD Init(nsIContent* aRoot);
|
||||
NS_IMETHOD Init(nsIDOMRange* aRange);
|
||||
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
virtual nsresult Init(nsIContent* aRoot);
|
||||
virtual nsresult Init(nsIDOMRange* aRange);
|
||||
|
||||
NS_IMETHOD CurrentNode(nsIContent **aNode);
|
||||
NS_IMETHOD IsDone();
|
||||
NS_IMETHOD PositionAt(nsIContent* aCurNode);
|
||||
virtual void First();
|
||||
virtual void Last();
|
||||
virtual void Next();
|
||||
virtual void Prev();
|
||||
|
||||
virtual nsIContent *GetCurrentNode();
|
||||
virtual PRBool IsDone();
|
||||
virtual nsresult PositionAt(nsIContent* aCurNode);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIPresContext> mPresContext;
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
};
|
||||
|
||||
nsFrameContentIterator::nsFrameContentIterator(nsIPresContext* aPresContext,
|
||||
nsIFrame* aFrame)
|
||||
nsIFrame* aFrame)
|
||||
: mPresContext(aPresContext), mParentFrame(aFrame), mIsDone(PR_FALSE)
|
||||
{
|
||||
First();
|
||||
|
@ -66,28 +66,25 @@ nsFrameContentIterator::~nsFrameContentIterator()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::Init(nsIContent* aRoot)
|
||||
{
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::Init(nsIDOMRange* aRange)
|
||||
{
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::First()
|
||||
{
|
||||
// Get the first child frame and make it the current node
|
||||
mCurrentChild = mParentFrame->GetFirstChild(nsnull);
|
||||
if (!mCurrentChild) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
||||
mIsDone = !mCurrentChild;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +113,7 @@ GetNextChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
return nextSibling;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Last()
|
||||
{
|
||||
// Starting with the first child walk and find the last child
|
||||
|
@ -127,14 +124,10 @@ nsFrameContentIterator::Last()
|
|||
nextChild = ::GetNextChildFrame(mPresContext, nextChild);
|
||||
}
|
||||
|
||||
if (!mCurrentChild) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
mIsDone = !mCurrentChild;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Next()
|
||||
{
|
||||
nsIFrame* nextChild = ::GetNextChildFrame(mPresContext, mCurrentChild);
|
||||
|
@ -145,10 +138,12 @@ nsFrameContentIterator::Next()
|
|||
|
||||
// If we're at the end then the collection is at the end
|
||||
mIsDone = (nsnull == ::GetNextChildFrame(mPresContext, mCurrentChild));
|
||||
return NS_OK;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// No next frame, we're done.
|
||||
mIsDone = PR_TRUE;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
|
@ -192,7 +187,7 @@ GetPrevChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
return prevSibling;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsFrameContentIterator::Prev()
|
||||
{
|
||||
nsIFrame* prevChild = ::GetPrevChildFrame(mPresContext, mCurrentChild);
|
||||
|
@ -203,32 +198,31 @@ nsFrameContentIterator::Prev()
|
|||
|
||||
// If we're at the beginning then the collection is at the end
|
||||
mIsDone = (nsnull == ::GetPrevChildFrame(mPresContext, mCurrentChild));
|
||||
return NS_OK;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// No previous frame, we're done.
|
||||
mIsDone = PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameContentIterator::CurrentNode(nsIContent **aNode)
|
||||
nsIContent *
|
||||
nsFrameContentIterator::GetCurrentNode()
|
||||
{
|
||||
if (mCurrentChild) {
|
||||
*aNode = mCurrentChild->GetContent();
|
||||
NS_IF_ADDREF(*aNode);
|
||||
return NS_OK;
|
||||
} else {
|
||||
*aNode = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
if (mCurrentChild && !mIsDone) {
|
||||
return mCurrentChild->GetContent();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsFrameContentIterator::IsDone()
|
||||
{
|
||||
return mIsDone ? NS_OK : NS_ENUMERATOR_FALSE;
|
||||
return mIsDone;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFrameContentIterator::PositionAt(nsIContent* aCurNode)
|
||||
{
|
||||
// Starting with the first child frame search for the child frame
|
||||
|
@ -245,10 +239,9 @@ nsFrameContentIterator::PositionAt(nsIContent* aCurNode)
|
|||
// Make it the current child
|
||||
mCurrentChild = child;
|
||||
mIsDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -688,27 +688,24 @@ NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(nsTreeContentView)
|
|||
NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(nsTreeContentView)
|
||||
NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsTreeContentView)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
|
@ -717,7 +714,7 @@ nsTreeContentView::ContentStatesChanged(nsIDocument* aDocument,
|
|||
if (!aContent1 || !mSelection ||
|
||||
!aContent1->IsContentOfType(nsIContent::eHTML) ||
|
||||
!(aStateMask & NS_EVENT_STATE_CHECKED))
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
if (aContent1->Tag() == nsHTMLAtoms::option) {
|
||||
// update the selected state for this node
|
||||
|
@ -725,11 +722,9 @@ nsTreeContentView::ContentStatesChanged(nsIDocument* aDocument,
|
|||
if (index >= 0)
|
||||
mSelection->ToggleSelect(index);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
|
@ -746,10 +741,10 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
|
|||
tag != nsXULAtoms::treeseparator &&
|
||||
tag != nsXULAtoms::treerow &&
|
||||
tag != nsXULAtoms::treecell)
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
else
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
// If we have a legal tag, go up to the tree and make sure that it's ours.
|
||||
nsCOMPtr<nsIContent> parent = aContent;
|
||||
|
@ -762,7 +757,7 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
|
|||
|
||||
if (parent != mRoot) {
|
||||
// This is not for us, we can bail out.
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle changes of the hidden attribute.
|
||||
|
@ -790,7 +785,7 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tag == nsXULAtoms::treecol) {
|
||||
|
@ -871,22 +866,18 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
nsIContent *child = aContainer->GetChildAt(aNewIndexInContainer);
|
||||
ContentInserted(aDocument, aContainer, child, aNewIndexInContainer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
|
@ -901,16 +892,16 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
|
|||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (childTag != nsHTMLAtoms::option &&
|
||||
childTag != nsHTMLAtoms::optgroup)
|
||||
return NS_OK;
|
||||
return;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (childTag != nsXULAtoms::treeitem &&
|
||||
childTag != nsXULAtoms::treeseparator &&
|
||||
childTag != nsXULAtoms::treechildren &&
|
||||
childTag != nsXULAtoms::treerow &&
|
||||
childTag != nsXULAtoms::treecell)
|
||||
return NS_OK;
|
||||
return;
|
||||
} else
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
// If we have a legal tag, go up to the tree/select and make sure
|
||||
// that it's ours.
|
||||
|
@ -922,7 +913,7 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
|
|||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (childTag == nsXULAtoms::treeitem ||
|
||||
|
@ -969,11 +960,9 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
|
|||
mBoxObject->InvalidateRow(index);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
|
@ -982,11 +971,9 @@ nsTreeContentView::ContentReplaced(nsIDocument *aDocument,
|
|||
{
|
||||
ContentRemoved(aDocument, aContainer, aOldChild, aIndexInContainer);
|
||||
ContentInserted(aDocument, aContainer, aNewChild, aIndexInContainer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
|
@ -1001,16 +988,16 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
|
|||
if (aChild->IsContentOfType(nsIContent::eHTML)) {
|
||||
if (tag != nsHTMLAtoms::option &&
|
||||
tag != nsHTMLAtoms::optgroup)
|
||||
return NS_OK;
|
||||
return;
|
||||
} else if (aChild->IsContentOfType(nsIContent::eXUL)) {
|
||||
if (tag != nsXULAtoms::treeitem &&
|
||||
tag != nsXULAtoms::treeseparator &&
|
||||
tag != nsXULAtoms::treechildren &&
|
||||
tag != nsXULAtoms::treerow &&
|
||||
tag != nsXULAtoms::treecell)
|
||||
return NS_OK;
|
||||
return;
|
||||
} else
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
// If we have a legal tag, go up to the tree/select and make sure
|
||||
// that it's ours.
|
||||
|
@ -1021,7 +1008,7 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
|
|||
if (element == mRoot) // this is for us, stop looking
|
||||
break;
|
||||
else // this is not for us, we can bail out
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tag == nsXULAtoms::treeitem ||
|
||||
|
@ -1069,11 +1056,9 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
|
|||
mBoxObject->InvalidateRow(index);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsTreeContentView::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
// Remove ourselves from mDocument's observers.
|
||||
|
@ -1083,8 +1068,6 @@ nsTreeContentView::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
|||
}
|
||||
|
||||
ClearRows();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1528,21 +1528,22 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsWebShellWindow)
|
|||
// nsIDocumentObserver
|
||||
// this is needed for menu changes
|
||||
///////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType)
|
||||
{
|
||||
// XXX: Uh, none of this nsIDocumentObserver stuff is needed if the
|
||||
// blow code isn't needed.
|
||||
#if 0
|
||||
//printf("AttributeChanged\n");
|
||||
PRInt32 i;
|
||||
|
@ -1563,43 +1564,38 @@ nsWebShellWindow::AttributeChanged(nsIDocument *aDocument,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsWebShellWindow::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This should rightfully be somebody's CONTRACTID?
|
||||
|
|
Загрузка…
Ссылка в новой задаче