Moved text and comment code out of HTML-specific directories. Completed CloneNode for elements. Completed factory methods for intersection of XML and HTML.

git-svn-id: svn://10.0.0.236/trunk@17775 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
vidur%netscape.com 1999-01-14 23:14:02 +00:00
parent 9b8f7545fe
commit d81e61b1ff
170 changed files with 2142 additions and 548 deletions

View File

@ -21,6 +21,7 @@
#include "nslayout.h" #include "nslayout.h"
class nsString; class nsString;
class nsTextFragment; class nsTextFragment;
class nsIContent;
// IID for the nsITextContent interface // IID for the nsITextContent interface
#define NS_ITEXT_CONTENT_IID \ #define NS_ITEXT_CONTENT_IID \
@ -55,4 +56,12 @@ public:
PRBool aNotify) = 0; PRBool aNotify) = 0;
}; };
// XXX These belong elsewhere
extern nsresult
NS_NewTextNode(nsIContent** aResult);
extern nsresult
NS_NewCommentNode(nsIContent** aResult);
#endif /* nsITextContent_h___ */ #endif /* nsITextContent_h___ */

View File

@ -20,7 +20,7 @@
#include "nsGenericDOMDataNode.h" #include "nsGenericDOMDataNode.h"
#include "nsIScriptObjectOwner.h" #include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h" #include "nsIDOMEventReceiver.h"
#include "nsIHTMLContent.h" #include "nsIContent.h"
#include "nsFrame.h" #include "nsFrame.h"
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID); static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
@ -28,7 +28,7 @@ static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
class nsCommentNode : public nsIDOMComment, class nsCommentNode : public nsIDOMComment,
public nsIScriptObjectOwner, public nsIScriptObjectOwner,
public nsIDOMEventReceiver, public nsIDOMEventReceiver,
public nsIHTMLContent public nsIContent
{ {
public: public:
nsCommentNode(); nsCommentNode();
@ -54,26 +54,23 @@ public:
// nsIContent // nsIContent
NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner) NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
// nsIHTMLContent
NS_IMPL_IHTMLCONTENT_USING_GENERIC_DOM_DATA(mInner)
protected: protected:
nsGenericDOMDataNode mInner; nsGenericDOMDataNode mInner;
}; };
nsresult NS_NewCommentNode(nsIHTMLContent** aInstancePtrResult); nsresult NS_NewCommentNode(nsIContent** aInstancePtrResult);
nsresult nsresult
NS_NewCommentNode(nsIHTMLContent** aInstancePtrResult) NS_NewCommentNode(nsIContent** aInstancePtrResult)
{ {
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) { if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
nsIHTMLContent* it = new nsCommentNode(); nsIContent* it = new nsCommentNode();
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
} }
nsCommentNode::nsCommentNode() nsCommentNode::nsCommentNode()
@ -147,27 +144,6 @@ nsCommentNode::List(FILE* out, PRInt32 aIndent) const
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsCommentNode::ToHTML(FILE* out) const
{
nsAutoString tmp;
tmp.Append("<!--");
mInner.mText.AppendTo(tmp);
tmp.Append(">");
fputs(tmp, out);
return NS_OK;
}
NS_IMETHODIMP
nsCommentNode::ToHTMLString(nsString& aBuf) const
{
aBuf.Truncate(0);
aBuf.Append("<!--");
mInner.mText.AppendTo(aBuf);
aBuf.Append(">");
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsCommentNode::HandleDOMEvent(nsIPresContext& aPresContext, nsCommentNode::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent, nsEvent* aEvent,

View File

@ -21,10 +21,7 @@
#include "nsGenericElement.h" #include "nsGenericElement.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDOMScriptObjectFactory.h" #include "nsIDOMScriptObjectFactory.h"
// XXX Need to move text node and comment creation #include "nsITextContent.h"
// out of HTML.
#include "nsHTMLParts.h"
#include "nsIHTMLContent.h"
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID); static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID); static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
@ -293,7 +290,7 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
} }
if (0 < value.Length()) { if (0 < value.Length()) {
if (nsnull == mChild) { if (nsnull == mChild) {
nsIHTMLContent* content; nsIContent* content;
result = NS_NewTextNode(&content); result = NS_NewTextNode(&content);
if (NS_OK != result) { if (NS_OK != result) {

View File

@ -61,6 +61,8 @@ protected:
private: private:
nsIContent* mContent; nsIContent* mContent;
// XXX We really don't need to use a hashtable here.
// We generally deal with a small number of attributes
PLHashTable* mAttributes; PLHashTable* mAttributes;
void* mScriptObject; void* mScriptObject;
}; };

View File

@ -52,6 +52,7 @@
#include "nsXIFConverter.h" #include "nsXIFConverter.h"
#include "nsIDOMText.h" #include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsDocumentFragment.h" #include "nsDocumentFragment.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
@ -62,6 +63,7 @@
#include "nsIEnumerator.h" #include "nsIEnumerator.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -1069,8 +1071,15 @@ nsDocument::CreateElement(const nsString& aTagName,
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn) nsDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
{ {
// Should be implemented by subclass nsIContent* text = nsnull;
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_NewTextNode(&text);
if (NS_OK == rv) {
rv = text->QueryInterface(kIDOMTextIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1082,8 +1091,15 @@ nsDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn) nsDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
{ {
// Should be implemented by subclass nsIContent* comment = nsnull;
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_NewCommentNode(&comment);
if (NS_OK == rv) {
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1275,8 +1291,9 @@ nsDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) nsDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{ {
// XXX TBI // We don't allow cloning of a document
return NS_ERROR_NOT_IMPLEMENTED; *aReturn = nsnull;
return NS_OK;
} }

View File

@ -17,7 +17,7 @@
* Netscape Communications Corporation. All Rights Reserved. * Netscape Communications Corporation. All Rights Reserved.
*/ */
#include "nsGenericDOMDataNode.h" #include "nsGenericDOMDataNode.h"
#include "nsGenericHTMLElement.h" #include "nsGenericElement.h"
#include "nsIEventListenerManager.h" #include "nsIEventListenerManager.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMRange.h" #include "nsIDOMRange.h"
@ -36,7 +36,6 @@
// XXX share all id's in this dir // XXX share all id's in this dir
NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID); NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID);
extern void NS_QuoteForHTML(const nsString& aValue, nsString& aResult);
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMNODE_IID);
@ -62,7 +61,7 @@ nsGenericDOMDataNode::~nsGenericDOMDataNode()
} }
void void
nsGenericDOMDataNode::Init(nsIHTMLContent* aOuterContentObject) nsGenericDOMDataNode::Init(nsIContent* aOuterContentObject)
{ {
NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject), NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject),
"null ptr"); "null ptr");
@ -687,14 +686,6 @@ nsGenericDOMDataNode::GetRangeList(nsVoidArray*& aResult) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation of nsIHTMLContent
nsresult
nsGenericDOMDataNode::Compact()
{
return NS_OK;
}
// XXX not really implemented (yet) // XXX not really implemented (yet)
nsresult nsresult
nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aHandler) const nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aHandler) const

View File

@ -22,9 +22,8 @@
#include "nsIDOMCharacterData.h" #include "nsIDOMCharacterData.h"
#include "nsIScriptObjectOwner.h" #include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h" #include "nsIDOMEventReceiver.h"
#include "nsIHTMLContent.h" #include "nsIContent.h"
#include "nsTextFragment.h" #include "nsTextFragment.h"
#include "nsHTMLValue.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
@ -34,15 +33,12 @@ extern const nsIID kIDOMEventReceiverIID;
extern const nsIID kIScriptObjectOwnerIID; extern const nsIID kIScriptObjectOwnerIID;
extern const nsIID kISupportsIID; extern const nsIID kISupportsIID;
extern const nsIID kIContentIID; extern const nsIID kIContentIID;
extern const nsIID kIHTMLContentIID;
class nsIDOMAttr; class nsIDOMAttr;
class nsIDOMEventListener; class nsIDOMEventListener;
class nsIDOMNodeList; class nsIDOMNodeList;
class nsIEventListenerManager; class nsIEventListenerManager;
class nsIFrame; class nsIFrame;
class nsIHTMLAttributes;
class nsIHTMLContent;
class nsIStyleContext; class nsIStyleContext;
class nsIStyleRule; class nsIStyleRule;
class nsISupportsArray; class nsISupportsArray;
@ -51,7 +47,7 @@ struct nsGenericDOMDataNode {
nsGenericDOMDataNode(); nsGenericDOMDataNode();
~nsGenericDOMDataNode(); ~nsGenericDOMDataNode();
void Init(nsIHTMLContent* aOuterContentObject); void Init(nsIContent* aOuterContentObject);
// Implementation for nsIDOMNode // Implementation for nsIDOMNode
nsresult GetNodeName(nsString& aNodeName) { nsresult GetNodeName(nsString& aNodeName) {
@ -178,41 +174,7 @@ struct nsGenericDOMDataNode {
nsresult RangeRemove(nsIDOMRange& aRange); nsresult RangeRemove(nsIDOMRange& aRange);
nsresult GetRangeList(nsVoidArray*& aResult) const; nsresult GetRangeList(nsVoidArray*& aResult) const;
// Implementation for nsIHTMLContent // Implementation for nsIContent
nsresult Compact();
nsresult SetHTMLAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRBool aNotify) {
return NS_OK;
}
nsresult GetHTMLAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const {
return NS_CONTENT_ATTR_NOT_THERE;
}
nsresult GetID(nsIAtom*& aResult) const {
aResult = nsnull;
return NS_OK;
}
nsresult GetClasses(nsVoidArray& aArray) const {
return NS_OK;
}
NS_IMETHOD HasClass(nsIAtom* aClass) const {
return NS_COMFALSE;
}
nsresult GetContentStyleRule(nsIStyleRule*& aResult) {
aResult = nsnull;
return NS_OK;
}
nsresult GetInlineStyleRule(nsIStyleRule*& aResult) {
aResult = nsnull;
return NS_OK;
}
nsresult MapAttributesInto(nsIStyleContext* aStyleContext,
nsIPresContext* aPresContext) {
return NS_OK;
}
static void MapNoAttributes(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext) {
}
nsresult SizeOf(nsISizeOfHandler* aHandler) const; nsresult SizeOf(nsISizeOfHandler* aHandler) const;
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const; nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const; nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
@ -254,7 +216,7 @@ struct nsGenericDOMDataNode {
// supporting. Sometimes there is work that we just can't do // supporting. Sometimes there is work that we just can't do
// ourselves, so this is needed to ask the real object to do the // ourselves, so this is needed to ask the real object to do the
// work. // work.
nsIHTMLContent* mContent; nsIContent* mContent;
nsIDocument* mDocument; nsIDocument* mDocument;
nsIContent* mParent; nsIContent* mParent;
@ -498,66 +460,13 @@ struct nsGenericDOMDataNode {
return _g.GetRangeList(aResult); \ return _g.GetRangeList(aResult); \
} }
#define NS_IMPL_IHTMLCONTENT_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD Compact() { \
return _g.Compact(); \
} \
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetHTMLAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute, \
nsHTMLValue& aValue) const { \
return _g.GetHTMLAttribute(aAttribute, aValue); \
} \
NS_IMETHOD GetID(nsIAtom*& aResult) const { \
return _g.GetID(aResult); \
} \
NS_IMETHOD GetClasses(nsVoidArray& aArray) const { \
return _g.GetClasses(aArray); \
} \
NS_IMETHOD HasClass(nsIAtom* aClass) const { \
return _g.HasClass(aClass); \
} \
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult) { \
return _g.GetContentStyleRule(aResult); \
} \
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult) { \
return _g.GetInlineStyleRule(aResult); \
} \
NS_IMETHOD ToHTMLString(nsString& aResult) const; \
NS_IMETHOD ToHTML(FILE* out) const; \
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \
const nsString& aValue, \
nsHTMLValue& aResult) { \
return NS_CONTENT_ATTR_NOT_THERE; \
} \
NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \
const nsHTMLValue& aValue, \
nsString& aResult) const { \
return NS_CONTENT_ATTR_NOT_THERE; \
} \
NS_IMETHOD \
GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const { \
aMapFunc = nsGenericDOMDataNode::MapNoAttributes; \
return NS_OK; \
} \
NS_IMETHOD GetStyleHintForAttributeChange( \
const nsIAtom* aAttribute, \
PRInt32 *aHint) const \
{ \
return NS_OK; \
}
/** /**
* This macro implements the portion of query interface that is * This macro implements the portion of query interface that is
* generic to all html content objects. * generic to all html content objects.
*/ */
#define NS_IMPL_DOM_DATA_QUERY_INTERFACE(_id, _iptr, _this) \ #define NS_IMPL_DOM_DATA_QUERY_INTERFACE(_id, _iptr, _this) \
if (_id.Equals(kISupportsIID)) { \ if (_id.Equals(kISupportsIID)) { \
nsIHTMLContent* tmp = _this; \ nsIContent* tmp = _this; \
nsISupports* tmp2 = tmp; \ nsISupports* tmp2 = tmp; \
*_iptr = (void*) tmp2; \ *_iptr = (void*) tmp2; \
NS_ADDREF_THIS(); \ NS_ADDREF_THIS(); \
@ -592,12 +501,6 @@ struct nsGenericDOMDataNode {
*_iptr = (void*) tmp; \ *_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \ NS_ADDREF_THIS(); \
return NS_OK; \ return NS_OK; \
} \
if (_id.Equals(kIHTMLContentIID)) { \
nsIHTMLContent* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
} }
#endif /* nsGenericDOMDataNode_h___ */ #endif /* nsGenericDOMDataNode_h___ */

View File

@ -1202,11 +1202,60 @@ nsGenericContainerElement::~nsGenericContainerElement()
nsresult nsresult
nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericContainerElement* aDst) nsGenericContainerElement* aDst,
PRBool aDeep)
{ {
// XXX copy attributes not yet impelemented nsresult result = NS_OK;
// XXX deep copy?
return NS_OK; if (nsnull != mAttributes) {
nsGenericAttribute* attr;
PRInt32 index;
PRInt32 count = mAttributes->Count();
for (index = 0; index < count; index++) {
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
// XXX Not very efficient, since SetAttribute does a linear search
// through its attributes before setting each attribute.
result = aDst->SetAttribute(attr->mNameSpaceID, attr->mName,
attr->mValue, PR_FALSE);
if (NS_OK != result) {
return result;
}
}
}
if (aDeep) {
PRInt32 index;
PRInt32 count = mChildren.Count();
for (index = 0; index < count; index++) {
nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
if (nsnull != child) {
nsIDOMNode* node;
result = child->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_OK == result) {
nsIDOMNode* newNode;
result = node->CloneNode(aDeep, &newNode);
if (NS_OK == result) {
nsIContent* newContent;
result = newNode->QueryInterface(kIContentIID, (void**)&newContent);
if (NS_OK == result) {
result = aDst->AppendChildTo(newContent, PR_FALSE);
NS_RELEASE(newContent);
}
NS_RELEASE(newNode);
}
NS_RELEASE(node);
}
if (NS_OK != result) {
return result;
}
}
}
}
return result;
} }
nsresult nsresult

View File

@ -84,7 +84,6 @@ typedef struct {
nsDOMCSSDeclaration *mStyle; nsDOMCSSDeclaration *mStyle;
nsDOMAttributeMap* mAttributeMap; nsDOMAttributeMap* mAttributeMap;
nsVoidArray *mRangeList; nsVoidArray *mRangeList;
PRBool mIsContainer;
} nsDOMSlots; } nsDOMSlots;
class nsGenericElement : public nsIJSScriptObject { class nsGenericElement : public nsIJSScriptObject {
@ -210,7 +209,8 @@ public:
~nsGenericContainerElement(); ~nsGenericContainerElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericContainerElement* aDest); nsGenericContainerElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetAttribute(const nsString& aName, nsString& aReturn) nsresult GetAttribute(const nsString& aName, nsString& aReturn)

View File

@ -20,7 +20,7 @@
#include "nsGenericDOMDataNode.h" #include "nsGenericDOMDataNode.h"
#include "nsIScriptObjectOwner.h" #include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h" #include "nsIDOMEventReceiver.h"
#include "nsIHTMLContent.h" #include "nsIContent.h"
#include "nsITextContent.h" #include "nsITextContent.h"
#include "nsFrame.h" #include "nsFrame.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -34,7 +34,7 @@ static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
class nsTextNode : public nsIDOMText, class nsTextNode : public nsIDOMText,
public nsIScriptObjectOwner, public nsIScriptObjectOwner,
public nsIDOMEventReceiver, public nsIDOMEventReceiver,
public nsIHTMLContent, public nsIContent,
public nsITextContent public nsITextContent
{ {
public: public:
@ -62,9 +62,6 @@ public:
// nsIContent // nsIContent
NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner) NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
// nsIHTMLContent
NS_IMPL_IHTMLCONTENT_USING_GENERIC_DOM_DATA(mInner)
// nsITextContent // nsITextContent
NS_IMETHOD GetText(const nsTextFragment*& aFragmentsResult, NS_IMETHOD GetText(const nsTextFragment*& aFragmentsResult,
PRInt32& aNumFragmentsResult); PRInt32& aNumFragmentsResult);
@ -79,9 +76,9 @@ protected:
nsGenericDOMDataNode mInner; nsGenericDOMDataNode mInner;
}; };
nsresult NS_NewTextNode(nsIHTMLContent** aInstancePtrResult); nsresult NS_NewTextNode(nsIContent** aInstancePtrResult);
nsresult nsresult
NS_NewTextNode(nsIHTMLContent** aInstancePtrResult) NS_NewTextNode(nsIContent** aInstancePtrResult)
{ {
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) { if (nsnull == aInstancePtrResult) {
@ -92,7 +89,7 @@ NS_NewTextNode(nsIHTMLContent** aInstancePtrResult)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
} }
nsTextNode::nsTextNode() nsTextNode::nsTextNode()
@ -172,23 +169,6 @@ nsTextNode::List(FILE* out, PRInt32 aIndent) const
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsTextNode::ToHTML(FILE* out) const
{
nsAutoString tmp;
mInner.mText.AppendTo(tmp);
fputs(tmp, out);
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::ToHTMLString(nsString& aBuf) const
{
aBuf.Truncate(0);
mInner.mText.AppendTo(aBuf);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsTextNode::HandleDOMEvent(nsIPresContext& aPresContext, nsTextNode::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent, nsEvent* aEvent,

View File

@ -26,8 +26,6 @@ LIBRARY_NAME = nglhtmlcon_s
# Note the sophisticated alphabetical ordering :-| # Note the sophisticated alphabetical ordering :-|
CPPSRCS= \ CPPSRCS= \
nsCommentNode.cpp \
nsGenericDOMDataNode.cpp \
nsGenericHTMLElement.cpp \ nsGenericHTMLElement.cpp \
nsGenericDOMHTMLCollection.cpp \ nsGenericDOMHTMLCollection.cpp \
GenericElementCollection.cpp \ GenericElementCollection.cpp \
@ -91,7 +89,6 @@ CPPSRCS= \
nsHTMLTitleElement.cpp \ nsHTMLTitleElement.cpp \
nsHTMLUListElement.cpp \ nsHTMLUListElement.cpp \
nsHTMLWBRElement.cpp \ nsHTMLWBRElement.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
MODULE=layout MODULE=layout

View File

@ -26,8 +26,6 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION
!endif !endif
CPPSRCS= \ CPPSRCS= \
nsCommentNode.cpp \
nsGenericDOMDataNode.cpp \
nsGenericHTMLElement.cpp \ nsGenericHTMLElement.cpp \
nsGenericDOMHTMLCollection.cpp \ nsGenericDOMHTMLCollection.cpp \
GenericElementCollection.cpp \ GenericElementCollection.cpp \
@ -44,7 +42,7 @@ CPPSRCS= \
nsHTMLDirectoryElement.cpp \ nsHTMLDirectoryElement.cpp \
nsHTMLDivElement.cpp \ nsHTMLDivElement.cpp \
nsHTMLEmbedElement.cpp \ nsHTMLEmbedElement.cpp \
nsHTMLFieldSetElement.cpp \ nsHTMLFieldSetElement.cpp \
nsHTMLFontElement.cpp \ nsHTMLFontElement.cpp \
nsHTMLFormElement.cpp \ nsHTMLFormElement.cpp \
nsHTMLFrameElement.cpp \ nsHTMLFrameElement.cpp \
@ -91,12 +89,9 @@ CPPSRCS= \
nsHTMLTitleElement.cpp \ nsHTMLTitleElement.cpp \
nsHTMLUListElement.cpp \ nsHTMLUListElement.cpp \
nsHTMLWBRElement.cpp \ nsHTMLWBRElement.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
CPP_OBJS= \ CPP_OBJS= \
.\$(OBJDIR)\nsCommentNode.obj \
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
.\$(OBJDIR)\nsGenericHTMLElement.obj \ .\$(OBJDIR)\nsGenericHTMLElement.obj \
.\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \ .\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \
.\$(OBJDIR)\GenericElementCollection.obj \ .\$(OBJDIR)\GenericElementCollection.obj \
@ -160,7 +155,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTMLTitleElement.obj \ .\$(OBJDIR)\nsHTMLTitleElement.obj \
.\$(OBJDIR)\nsHTMLUListElement.obj \ .\$(OBJDIR)\nsHTMLUListElement.obj \
.\$(OBJDIR)\nsHTMLWBRElement.obj \ .\$(OBJDIR)\nsHTMLWBRElement.obj \
.\$(OBJDIR)\nsTextNode.obj \
$(NULL) $(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \

View File

@ -244,6 +244,22 @@ nsGenericHTMLElement::~nsGenericHTMLElement()
} }
} }
nsresult
nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLElement* aDst,
PRBool aDeep)
{
nsresult result = NS_OK;
if (nsnull != mAttributes) {
aDst->mAttributes = mAttributes;
NS_ADDREF(mAttributes);
mAttributes->AddContentRef();
}
return result;
}
// Implementation for nsIDOMHTMLElement // Implementation for nsIDOMHTMLElement
nsresult nsresult
nsGenericHTMLElement::GetId(nsString& aId) nsGenericHTMLElement::GetId(nsString& aId)
@ -1772,12 +1788,13 @@ nsGenericHTMLLeafElement::~nsGenericHTMLLeafElement()
nsresult nsresult
nsGenericHTMLLeafElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericHTMLLeafElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLLeafElement* aDst) nsGenericHTMLLeafElement* aDst,
PRBool aDeep)
{ {
aDst->mContent = aSrcContent; nsresult result = nsGenericHTMLElement::CopyInnerTo(aSrcContent,
// XXX should the node's document be set? aDst,
// XXX copy attributes not yet impelemented aDeep);
return NS_OK; return result;
} }
nsresult nsresult
@ -1872,12 +1889,48 @@ nsGenericHTMLContainerElement::~nsGenericHTMLContainerElement()
nsresult nsresult
nsGenericHTMLContainerElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericHTMLContainerElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLContainerElement* aDst) nsGenericHTMLContainerElement* aDst,
PRBool aDeep)
{ {
aDst->mContent = aSrcContent; nsresult result = nsGenericHTMLElement::CopyInnerTo(aSrcContent,
// XXX should the node's document be set? aDst,
// XXX copy attributes not yet impelemented aDeep);
// XXX deep copy? if (NS_OK != result) {
return result;
}
if (aDeep) {
PRInt32 index;
PRInt32 count = mChildren.Count();
for (index = 0; index < count; index++) {
nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
if (nsnull != child) {
nsIDOMNode* node;
result = child->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_OK == result) {
nsIDOMNode* newNode;
result = node->CloneNode(aDeep, &newNode);
if (NS_OK == result) {
nsIContent* newContent;
result = newNode->QueryInterface(kIContentIID, (void**)&newContent);
if (NS_OK == result) {
result = aDst->AppendChildTo(newContent, PR_FALSE);
NS_RELEASE(newContent);
}
NS_RELEASE(newNode);
}
NS_RELEASE(node);
}
if (NS_OK != result) {
return result;
}
}
}
}
return NS_OK; return NS_OK;
} }

View File

@ -51,6 +51,10 @@ public:
nsGenericHTMLElement(); nsGenericHTMLElement();
~nsGenericHTMLElement(); ~nsGenericHTMLElement();
nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLElement* aDest,
PRBool aDeep);
// Implementation for nsIDOMElement // Implementation for nsIDOMElement
nsresult GetAttribute(const nsString& aName, nsString& aReturn) nsresult GetAttribute(const nsString& aName, nsString& aReturn)
{ {
@ -241,7 +245,8 @@ public:
~nsGenericHTMLLeafElement(); ~nsGenericHTMLLeafElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLLeafElement* aDest); nsGenericHTMLLeafElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
@ -318,7 +323,8 @@ public:
~nsGenericHTMLContainerElement(); ~nsGenericHTMLContainerElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLContainerElement* aDest); nsGenericHTMLContainerElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);

View File

@ -151,7 +151,7 @@ nsHTMLAnchorElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -326,4 +326,4 @@ nsHTMLAnchorElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -138,7 +138,7 @@ nsHTMLAppletElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -227,4 +227,4 @@ nsHTMLAppletElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -132,7 +132,7 @@ nsHTMLAreaElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLBRElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -203,4 +203,4 @@ nsHTMLBRElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -120,7 +120,7 @@ nsHTMLBaseElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -177,4 +177,4 @@ nsHTMLBaseElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -122,7 +122,7 @@ nsHTMLBaseFontElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -184,4 +184,4 @@ nsHTMLBaseFontElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -549,7 +549,7 @@ nsHTMLBodyElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -798,4 +798,4 @@ nsHTMLBodyElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -189,7 +189,7 @@ nsHTMLButtonElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -424,4 +424,4 @@ nsHTMLButtonElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -119,7 +119,7 @@ nsHTMLDListElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -190,4 +190,4 @@ nsHTMLDListElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -120,7 +120,7 @@ nsHTMLDelElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -180,4 +180,4 @@ nsHTMLDelElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -123,7 +123,7 @@ nsHTMLDirectoryElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -216,4 +216,4 @@ nsHTMLDirectoryElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -121,7 +121,7 @@ nsHTMLDivElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -210,4 +210,4 @@ nsHTMLDivElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -120,7 +120,7 @@ nsHTMLEmbedElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -196,4 +196,4 @@ nsHTMLEmbedElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -161,7 +161,7 @@ nsHTMLFieldSetElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -274,4 +274,4 @@ nsHTMLFieldSetElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -125,7 +125,7 @@ nsHTMLFontElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }
@ -339,4 +339,4 @@ nsHTMLFontElement::GetStyleHintForAttributeChange(
{ {
nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint); nsGenericHTMLElement::SetStyleHintForCommonAttributes(this, aAttribute, aHint);
return NS_OK; return NS_OK;
} }

View File

@ -237,7 +237,7 @@ nsHTMLFormElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -132,7 +132,7 @@ nsHTMLFrameElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -120,7 +120,7 @@ nsHTMLFrameSetElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -125,7 +125,7 @@ nsHTMLHRElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -118,7 +118,7 @@ nsHTMLHeadElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLHeadingElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -124,7 +124,7 @@ nsHTMLHtmlElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
it->mInner.Init(it, mInner.mTag); it->mInner.Init(it, mInner.mTag);
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -144,7 +144,7 @@ nsHTMLIFrameElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -163,7 +163,7 @@ nsHTMLImageElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -230,7 +230,7 @@ nsHTMLInputElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -120,7 +120,7 @@ nsHTMLInsElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLIsIndexElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -121,7 +121,7 @@ nsHTMLLIElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -165,7 +165,7 @@ nsHTMLLabelElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -130,7 +130,7 @@ nsHTMLLegendElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -134,7 +134,7 @@ nsHTMLLinkElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -126,7 +126,7 @@ nsHTMLMapElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -123,7 +123,7 @@ nsHTMLMenuElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -124,7 +124,7 @@ nsHTMLMetaElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -120,7 +120,7 @@ nsHTMLModElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -123,7 +123,7 @@ nsHTMLOListElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -151,7 +151,7 @@ nsHTMLObjectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -120,7 +120,7 @@ nsHTMLOptGroupElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -161,7 +161,7 @@ nsHTMLOptionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -126,7 +126,7 @@ nsHTMLParagraphElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
it->mInner.Init(it, mInner.mTag); it->mInner.Init(it, mInner.mTag);
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -124,7 +124,7 @@ nsHTMLParamElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -121,7 +121,7 @@ nsHTMLPreElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -118,7 +118,7 @@ nsHTMLQuoteElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -131,7 +131,7 @@ nsHTMLScriptElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -229,7 +229,7 @@ nsHTMLSelectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -151,7 +151,7 @@ nsHTMLObjectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLSpacerElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -106,7 +106,7 @@ nsHTMLSpanElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -124,7 +124,7 @@ nsHTMLStyleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLTableCaptionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -172,7 +172,7 @@ nsHTMLTableCellElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -141,7 +141,7 @@ nsHTMLTableColElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -130,7 +130,7 @@ nsHTMLTableColGroupElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -370,7 +370,7 @@ nsHTMLTableElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -184,7 +184,7 @@ nsHTMLTableRowElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -139,7 +139,7 @@ nsHTMLTableSectionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -191,7 +191,7 @@ nsHTMLTextAreaElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -119,7 +119,7 @@ nsHTMLTitleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -124,7 +124,7 @@ nsHTMLUListElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -118,7 +118,7 @@ nsHTMLWBRElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo(this, &it->mInner); mInner.CopyInnerTo(this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -1237,7 +1237,7 @@ SinkContext::FlushText(PRBool* aDidFlush)
nsresult rv = NS_OK; nsresult rv = NS_OK;
PRBool didFlush = PR_FALSE; PRBool didFlush = PR_FALSE;
if (0 != mTextLength) { if (0 != mTextLength) {
nsIHTMLContent* content; nsIContent* content;
rv = NS_NewTextNode(&content); rv = NS_NewTextNode(&content);
if (NS_OK == rv) { if (NS_OK == rv) {
// Set the content's document // Set the content's document

View File

@ -72,7 +72,6 @@ static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
@ -532,35 +531,6 @@ nsHTMLDocument::CreateElement(const nsString& aTagName,
return rv; return rv;
} }
NS_IMETHODIMP
nsHTMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aTextNode)
{
nsIHTMLContent* text = nsnull;
nsresult rv = NS_NewTextNode(&text);
if (NS_OK == rv) {
rv = text->QueryInterface(kIDOMTextIID, (void**)aTextNode);
(*aTextNode)->AppendData(aData);
}
return rv;
}
NS_IMETHODIMP
nsHTMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
{
nsIHTMLContent* comment = nsnull;
nsresult rv = NS_NewCommentNode(&comment);
if (NS_OK == rv) {
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
}
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::CreateProcessingInstruction(const nsString& aTarget, nsHTMLDocument::CreateProcessingInstruction(const nsString& aTarget,
const nsString& aData, const nsString& aData,

View File

@ -90,13 +90,15 @@ public:
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn); NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn) NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
{ return nsDocument::CreateDocumentFragment(aReturn); } { return nsDocument::CreateDocumentFragment(aReturn); }
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn); NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn)
{ return nsDocument::CreateComment(aData, aReturn); }
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn); NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn) NS_IMETHOD CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
{ return nsDocument::CreateAttribute(aName, aReturn); } { return nsDocument::CreateAttribute(aName, aReturn); }
NS_IMETHOD CreateElement(const nsString& aTagName, NS_IMETHOD CreateElement(const nsString& aTagName,
nsIDOMElement** aReturn); nsIDOMElement** aReturn);
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn); NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
{ return nsDocument::CreateTextNode(aData, aReturn); }
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn) NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn)
{ return nsDocument::GetElementsByTagName(aTagname, aReturn); } { return nsDocument::GetElementsByTagName(aTagname, aReturn); }

View File

@ -202,7 +202,7 @@ nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
mInner.CopyInnerTo((nsIContent *)(nsIXMLContent *)this, &it->mInner); mInner.CopyInnerTo((nsIContent *)(nsIXMLContent *)this, &it->mInner, aDeep);
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
} }

View File

@ -739,7 +739,7 @@ nsXMLContentSink::AddComment(const nsIParserNode& aNode)
FlushText(); FlushText();
nsAutoString text; nsAutoString text;
nsIHTMLContent *comment; nsIContent *comment;
nsIDOMComment *domComment; nsIDOMComment *domComment;
nsresult result = NS_OK; nsresult result = NS_OK;
@ -1139,7 +1139,7 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
PRBool didFlush = PR_FALSE; PRBool didFlush = PR_FALSE;
if (0 != mTextLength) { if (0 != mTextLength) {
if (aCreateTextNode) { if (aCreateTextNode) {
nsIHTMLContent* content; nsIContent* content;
rv = NS_NewTextNode(&content); rv = NS_NewTextNode(&content);
if (NS_OK == rv) { if (NS_OK == rv) {
// Set the content's document // Set the content's document

View File

@ -278,21 +278,6 @@ nsXMLDocument::CreateEntityReference(const nsString& aName, nsIDOMEntityReferenc
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP
nsXMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
{
// XXX Should just be regular nsIContent
nsIHTMLContent* comment = nsnull;
nsresult rv = NS_NewCommentNode(&comment);
if (NS_OK == rv) {
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
}
NS_IMETHODIMP NS_IMETHODIMP
nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn) nsXMLDocument::CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn)
{ {
@ -320,21 +305,6 @@ nsXMLDocument::CreateElement(const nsString& aTagName,
return rv; return rv;
} }
NS_IMETHODIMP
nsXMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
{
// XXX Should just be regular nsIContent
nsIHTMLContent* text = nsnull;
nsresult rv = NS_NewTextNode(&text);
if (NS_OK == rv) {
rv = text->QueryInterface(kIDOMTextIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
}
// nsIXMLDocument interface // nsIXMLDocument interface
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -50,11 +50,9 @@ public:
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType); NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn); NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn); NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
NS_IMETHOD CreateComment(const nsString& aData, nsIDOMComment** aReturn);
NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn); NS_IMETHOD CreateProcessingInstruction(const nsString& aTarget, const nsString& aData, nsIDOMProcessingInstruction** aReturn);
NS_IMETHOD CreateElement(const nsString& aTagName, NS_IMETHOD CreateElement(const nsString& aTagName,
nsIDOMElement** aReturn); nsIDOMElement** aReturn);
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn);
// nsIXMLDocument interface // nsIXMLDocument interface
NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent); NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent);

View File

@ -21,6 +21,7 @@
#include "nslayout.h" #include "nslayout.h"
class nsString; class nsString;
class nsTextFragment; class nsTextFragment;
class nsIContent;
// IID for the nsITextContent interface // IID for the nsITextContent interface
#define NS_ITEXT_CONTENT_IID \ #define NS_ITEXT_CONTENT_IID \
@ -55,4 +56,12 @@ public:
PRBool aNotify) = 0; PRBool aNotify) = 0;
}; };
// XXX These belong elsewhere
extern nsresult
NS_NewTextNode(nsIContent** aResult);
extern nsresult
NS_NewCommentNode(nsIContent** aResult);
#endif /* nsITextContent_h___ */ #endif /* nsITextContent_h___ */

View File

@ -28,7 +28,9 @@ LIBRARY_NAME = raptorlayout_s
DEFINES += -D_IMPL_NS_LAYOUT DEFINES += -D_IMPL_NS_LAYOUT
CPPSRCS = \ CPPSRCS = \
nsCommentNode.cpp \
nsGenericElement.cpp \ nsGenericElement.cpp \
nsGenericDOMDataNode.cpp \
nsContentList.cpp \ nsContentList.cpp \
nsDocument.cpp \ nsDocument.cpp \
nsDocumentFragment.cpp \ nsDocumentFragment.cpp \
@ -51,6 +53,7 @@ CPPSRCS = \
nsRangeList.cpp \ nsRangeList.cpp \
nsContentIterator.cpp \ nsContentIterator.cpp \
nsLayoutAtoms.cpp \ nsLayoutAtoms.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
MODULE=layout MODULE=layout

View File

@ -24,7 +24,9 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION
!endif !endif
CPPSRCS = \ CPPSRCS = \
nsCommentNode.cpp \
nsGenericElement.cpp \ nsGenericElement.cpp \
nsGenericDOMDataNode.cpp \
nsContentList.cpp \ nsContentList.cpp \
nsContentIterator.cpp \ nsContentIterator.cpp \
nsDocument.cpp \ nsDocument.cpp \
@ -47,6 +49,7 @@ CPPSRCS = \
nsRangeList.cpp \ nsRangeList.cpp \
nsLayoutAtoms.cpp \ nsLayoutAtoms.cpp \
nsRange.cpp \ nsRange.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
MODULE=raptor MODULE=raptor
@ -54,6 +57,8 @@ REQUIRES=xpcom raptor dom
EXPORTS=nsSelectionRange.h nsSelectionPoint.h EXPORTS=nsSelectionRange.h nsSelectionPoint.h
CPP_OBJS= \ CPP_OBJS= \
.\$(OBJDIR)\nsCommentNode.obj \
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
.\$(OBJDIR)\nsGenericElement.obj \ .\$(OBJDIR)\nsGenericElement.obj \
.\$(OBJDIR)\nsContentList.obj \ .\$(OBJDIR)\nsContentList.obj \
.\$(OBJDIR)\nsContentIterator.obj \ .\$(OBJDIR)\nsContentIterator.obj \
@ -64,7 +69,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsFrameImageLoader.obj \ .\$(OBJDIR)\nsFrameImageLoader.obj \
.\$(OBJDIR)\nsFrameUtil.obj \ .\$(OBJDIR)\nsFrameUtil.obj \
.\$(OBJDIR)\nsGalleyContext.obj \ .\$(OBJDIR)\nsGalleyContext.obj \
.\$(OBJDIR)\nsNameSpaceManager.obj \ .\$(OBJDIR)\nsNameSpaceManager.obj \
.\$(OBJDIR)\nsPresContext.obj \ .\$(OBJDIR)\nsPresContext.obj \
.\$(OBJDIR)\nsPrintContext.obj \ .\$(OBJDIR)\nsPrintContext.obj \
.\$(OBJDIR)\nsPrintPreviewContext.obj \ .\$(OBJDIR)\nsPrintPreviewContext.obj \
@ -77,6 +82,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsRangeList.obj \ .\$(OBJDIR)\nsRangeList.obj \
.\$(OBJDIR)\nsLayoutAtoms.obj \ .\$(OBJDIR)\nsLayoutAtoms.obj \
.\$(OBJDIR)\nsRange.obj \ .\$(OBJDIR)\nsRange.obj \
.\$(OBJDIR)\nsTextNode.obj \
$(NULL) $(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \

View File

@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsIDOMComment.h"
#include "nsGenericDOMDataNode.h"
#include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h"
#include "nsIContent.h"
#include "nsFrame.h"
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
class nsCommentNode : public nsIDOMComment,
public nsIScriptObjectOwner,
public nsIDOMEventReceiver,
public nsIContent
{
public:
nsCommentNode();
~nsCommentNode();
// nsISupports
NS_DECL_ISUPPORTS
// nsIDOMNode
NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMCharacterData
NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMComment
// nsIScriptObjectOwner
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMEventReceiver
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(mInner)
// nsIContent
NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
protected:
nsGenericDOMDataNode mInner;
};
nsresult NS_NewCommentNode(nsIContent** aInstancePtrResult);
nsresult
NS_NewCommentNode(nsIContent** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsIContent* it = new nsCommentNode();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
}
nsCommentNode::nsCommentNode()
{
NS_INIT_REFCNT();
mInner.Init(this);
}
nsCommentNode::~nsCommentNode()
{
}
NS_IMPL_ADDREF(nsCommentNode)
NS_IMPL_RELEASE(nsCommentNode)
NS_IMETHODIMP
nsCommentNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
NS_IMPL_DOM_DATA_QUERY_INTERFACE(aIID, aInstancePtr, this)
if (aIID.Equals(kIDOMCommentIID)) {
nsIDOMComment* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsCommentNode::GetNodeType(PRUint16* aNodeType)
{
*aNodeType = (PRUint16)nsIDOMNode::COMMENT_NODE;
return NS_OK;
}
NS_IMETHODIMP
nsCommentNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
nsCommentNode* it = new nsCommentNode();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsAutoString data;
nsresult result = GetData(data);
if (NS_FAILED(result)) {
return result;
}
result = it->SetData(data);
if (NS_FAILED(result)) {
return result;
}
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
}
NS_IMETHODIMP
nsCommentNode::List(FILE* out, PRInt32 aIndent) const
{
NS_PRECONDITION(nsnull != mInner.mDocument, "bad content");
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, " refcount=%d<", mRefCnt);
nsAutoString tmp;
mInner.ToCString(tmp, 0, mInner.mText.GetLength());
fputs(tmp, out);
fputs(">\n", out);
return NS_OK;
}
NS_IMETHODIMP
nsCommentNode::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}
nsresult NS_NewCommentFrame(nsIFrame*& aResult);
nsresult
NS_NewCommentFrame(nsIFrame*& aResult)
{
nsIFrame* frame;
NS_NewEmptyFrame(&frame);
if (nsnull == frame) {
return NS_ERROR_OUT_OF_MEMORY;
}
aResult = frame;
return NS_OK;
}

View File

@ -21,10 +21,7 @@
#include "nsGenericElement.h" #include "nsGenericElement.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDOMScriptObjectFactory.h" #include "nsIDOMScriptObjectFactory.h"
// XXX Need to move text node and comment creation #include "nsITextContent.h"
// out of HTML.
#include "nsHTMLParts.h"
#include "nsIHTMLContent.h"
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID); static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID); static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
@ -293,7 +290,7 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
} }
if (0 < value.Length()) { if (0 < value.Length()) {
if (nsnull == mChild) { if (nsnull == mChild) {
nsIHTMLContent* content; nsIContent* content;
result = NS_NewTextNode(&content); result = NS_NewTextNode(&content);
if (NS_OK != result) { if (NS_OK != result) {

View File

@ -61,6 +61,8 @@ protected:
private: private:
nsIContent* mContent; nsIContent* mContent;
// XXX We really don't need to use a hashtable here.
// We generally deal with a small number of attributes
PLHashTable* mAttributes; PLHashTable* mAttributes;
void* mScriptObject; void* mScriptObject;
}; };

View File

@ -52,6 +52,7 @@
#include "nsXIFConverter.h" #include "nsXIFConverter.h"
#include "nsIDOMText.h" #include "nsIDOMText.h"
#include "nsIDOMComment.h"
#include "nsDocumentFragment.h" #include "nsDocumentFragment.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
@ -62,6 +63,7 @@
#include "nsIEnumerator.h" #include "nsIEnumerator.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID); static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -1069,8 +1071,15 @@ nsDocument::CreateElement(const nsString& aTagName,
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn) nsDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
{ {
// Should be implemented by subclass nsIContent* text = nsnull;
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_NewTextNode(&text);
if (NS_OK == rv) {
rv = text->QueryInterface(kIDOMTextIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1082,8 +1091,15 @@ nsDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn) nsDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
{ {
// Should be implemented by subclass nsIContent* comment = nsnull;
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_NewCommentNode(&comment);
if (NS_OK == rv) {
rv = comment->QueryInterface(kIDOMCommentIID, (void**)aReturn);
(*aReturn)->AppendData(aData);
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1275,8 +1291,9 @@ nsDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) nsDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{ {
// XXX TBI // We don't allow cloning of a document
return NS_ERROR_NOT_IMPLEMENTED; *aReturn = nsnull;
return NS_OK;
} }

View File

@ -0,0 +1,696 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsGenericDOMDataNode.h"
#include "nsGenericElement.h"
#include "nsIEventListenerManager.h"
#include "nsIDocument.h"
#include "nsIDOMRange.h"
#include "nsXIFConverter.h"
#include "nsSelectionRange.h"
#include "nsRange.h"
#include "nsCRT.h"
#include "nsIEventStateManager.h"
#include "nsIPrivateDOMEvent.h"
#include "nsISizeOfHandler.h"
#include "nsDOMEvent.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIScriptContextOwner.h"
#include "prprf.h"
// XXX share all id's in this dir
NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID);
static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID);
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMNODE_IID);
//----------------------------------------------------------------------
nsGenericDOMDataNode::nsGenericDOMDataNode()
: mText()
{
mDocument = nsnull;
mParent = nsnull;
mContent = nsnull;
mScriptObject = nsnull;
mListenerManager = nsnull;
mRangeList = nsnull;
}
nsGenericDOMDataNode::~nsGenericDOMDataNode()
{
NS_IF_RELEASE(mListenerManager);
// XXX what about mScriptObject? its now safe to GC it...
delete mRangeList;
}
void
nsGenericDOMDataNode::Init(nsIContent* aOuterContentObject)
{
NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject),
"null ptr");
mContent = aOuterContentObject;
}
nsresult
nsGenericDOMDataNode::GetNodeValue(nsString& aNodeValue)
{
aNodeValue.Truncate();
mText.AppendTo(aNodeValue);
return NS_OK;
}
nsresult
nsGenericDOMDataNode::SetNodeValue(const nsString& aNodeValue)
{
mText = aNodeValue;
// Trigger a reflow
if (nsnull != mDocument) {
mDocument->ContentChanged(mContent, nsnull);
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode)
{
if (nsnull != mParent) {
nsresult res = mParent->QueryInterface(kIDOMNodeIID, (void**)aParentNode);
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
return res;
}
else {
*aParentNode = nsnull;
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aNode)
{
if (nsnull != mParent) {
PRInt32 pos;
mParent->IndexOf(mContent, pos);
if (pos > -1) {
nsIContent* prev;
mParent->ChildAt(--pos, prev);
if (nsnull != prev) {
nsresult res = prev->QueryInterface(kIDOMNodeIID, (void**)aNode);
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
NS_RELEASE(prev); // balance the AddRef in ChildAt()
return res;
}
}
}
*aNode = nsnull;
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling)
{
if (nsnull != mParent) {
PRInt32 pos;
mParent->IndexOf(mContent, pos);
if (pos > -1 ) {
nsIContent* prev;
mParent->ChildAt(++pos, prev);
if (nsnull != prev) {
nsresult res = prev->QueryInterface(kIDOMNodeIID,(void**)aNextSibling);
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
NS_RELEASE(prev); // balance the AddRef in ChildAt()
return res;
}
}
}
*aNextSibling = nsnull;
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
{
// XXX Actually the owner document is the document in whose context
// the node has been created. We should be able to get at it
// whether or not we are attached to the document.
if (nsnull != mDocument) {
return mDocument->QueryInterface(kIDOMDocumentIID, (void **)aOwnerDocument);
}
else {
*aOwnerDocument = nsnull;
return NS_OK;
}
}
#if 0
nsresult
nsGenericDOMDataNode::Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn)
{
*aReturn = PR_FALSE;
PRInt32 nt1, nt2;
GetNodeType(&nt1);
aNode->GetNodeType(&nt2);
if (nt1 != nt2) {
return NS_OK;
}
return NS_OK;
}
#endif
//----------------------------------------------------------------------
// Implementation of nsIDOMCharacterData
nsresult
nsGenericDOMDataNode::GetData(nsString& aData)
{
if (mText.Is2b()) {
aData.SetString(mText.Get2b(), mText.GetLength());
}
else {
aData.SetString(mText.Get1b(), mText.GetLength());
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::SetData(const nsString& aData)
{
// inform any enclosed ranges of change
// we can lie and say we are deleting all the text, since in a total
// text replacement we should just collapse all the ranges.
if (mRangeList) nsRange::TextOwnerChanged(mContent, 0, mText.GetLength(), 0);
mText = aData;
// Notify the document that the text changed
if (nsnull != mDocument) {
mDocument->ContentChanged(mContent, nsnull);
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetLength(PRUint32* aLength)
{
*aLength = mText.GetLength();
return NS_OK;
}
// XXX temporary; none of these methods try to return error codes as
// per the spec
#define NS_DOM_INDEX_SIZE_ERR NS_ERROR_FAILURE
nsresult
nsGenericDOMDataNode::SubstringData(PRUint32 aStart,
PRUint32 aCount,
nsString& aReturn)
{
aReturn.Truncate();
// XXX add <0 checks if types change
PRUint32 textLength = PRUint32( mText.GetLength() );
if (aStart >= textLength) {
return NS_DOM_INDEX_SIZE_ERR;
}
PRUint32 amount = aCount;
if (aStart + amount > textLength) {
amount = textLength - aStart;
}
if (mText.Is2b()) {
aReturn.SetString(mText.Get2b() + aStart, amount);
}
else {
aReturn.SetString(mText.Get1b() + aStart, amount);
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::AppendData(const nsString& aData)
{
return ReplaceData(mText.GetLength(), 0, aData);
}
nsresult
nsGenericDOMDataNode::InsertData(PRUint32 aOffset, const nsString& aData)
{
return ReplaceData(aOffset, 0, aData);
}
nsresult
nsGenericDOMDataNode::DeleteData(PRUint32 aOffset, PRUint32 aCount)
{
nsAutoString empty;
return ReplaceData(aOffset, aCount, empty);
}
nsresult
nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
const nsString& aData)
{
// sanitize arguments
PRUint32 textLength = mText.GetLength();
if (aOffset > textLength) {
aOffset = textLength;
}
// Allocate new buffer
PRUint32 endOffset = aOffset + aCount;
if (endOffset > textLength) {
aCount = textLength - aOffset;
endOffset = textLength;
}
PRInt32 dataLength = aData.Length();
PRInt32 newLength = textLength - aCount + dataLength;
PRUnichar* to = new PRUnichar[newLength ? newLength : 1];
if (nsnull == to) {
return NS_ERROR_OUT_OF_MEMORY;
}
// inform any enclosed ranges of change
if (mRangeList) nsRange::TextOwnerChanged(mContent, aOffset, endOffset, dataLength);
// Copy over appropriate data
if (0 != aOffset) {
mText.CopyTo(to, 0, aOffset);
}
if (0 != dataLength) {
nsCRT::memcpy(to + aOffset, aData.GetUnicode(),
sizeof(PRUnichar) * dataLength);
}
if (endOffset != textLength) {
mText.CopyTo(to + aOffset + dataLength, endOffset, textLength - endOffset);
}
// Switch to new buffer
mText.SetTo(to, newLength);
delete [] to;
// Notify the document that the text changed
if (nsnull != mDocument) {
mDocument->ContentChanged(mContent, nsnull);
}
return NS_OK;
}
//----------------------------------------------------------------------
// nsIScriptObjectOwner implementation
nsresult
nsGenericDOMDataNode::GetScriptObject(nsIScriptContext* aContext,
void** aScriptObject)
{
nsresult res = NS_OK;
if (nsnull == mScriptObject) {
nsIDOMScriptObjectFactory *factory;
res = nsGenericElement::GetScriptObjectFactory(&factory);
if (NS_OK != res) {
return res;
}
res = factory->NewScriptCharacterData(nsIDOMNode::TEXT_NODE,
aContext, mContent,
mParent, (void**)&mScriptObject);
if (nsnull != mDocument) {
aContext->AddNamedReference((void *)&mScriptObject,
mScriptObject,
"Text");
}
NS_RELEASE(factory);
}
*aScriptObject = mScriptObject;
return res;
}
nsresult
nsGenericDOMDataNode::SetScriptObject(void *aScriptObject)
{
mScriptObject = aScriptObject;
return NS_OK;
}
//----------------------------------------------------------------------
// nsIDOMEventReceiver implementation
nsresult
nsGenericDOMDataNode::GetListenerManager(nsIEventListenerManager** aResult)
{
if (nsnull != mListenerManager) {
NS_ADDREF(mListenerManager);
*aResult = mListenerManager;
return NS_OK;
}
nsresult rv = NS_NewEventListenerManager(aResult);
if (NS_OK == rv) {
mListenerManager = *aResult;
NS_ADDREF(mListenerManager);
}
return rv;
}
nsresult
nsGenericDOMDataNode::GetNewListenerManager(nsIEventListenerManager** aResult)
{
return NS_NewEventListenerManager(aResult);
}
nsresult
nsGenericDOMDataNode::AddEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
nsIEventListenerManager *manager;
if (NS_OK == GetListenerManager(&manager)) {
manager->AddEventListener(aListener, aIID);
NS_RELEASE(manager);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult
nsGenericDOMDataNode::RemoveEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
if (nsnull != mListenerManager) {
mListenerManager->RemoveEventListener(aListener, aIID);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
//----------------------------------------------------------------------
// Implementation of nsIContent
nsresult
nsGenericDOMDataNode::BeginConvertToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
nsresult
nsGenericDOMDataNode::FinishConvertToXIF(nsXIFConverter& aConverter) const
{
return NS_OK;
}
/**
* Translate the content object into the (XIF) XML Interchange Format
* XIF is an intermediate form of the content model, the buffer
* will then be parsed into any number of formats including HTML, TXT, etc.
*/
nsresult
nsGenericDOMDataNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
const nsIContent* content = mContent;
#if 0
//DEBUG MJUDGE
if (aConverter.GetUseSelection() == PR_TRUE && mDocument->IsInSelection(content))
{
nsISelection* sel;
mDocument->GetSelection(sel);
if (sel != nsnull)
{
nsSelectionRange* range = sel->GetRange();
if (range != nsnull)
{
nsSelectionPoint* startPoint = range->GetStartPoint();
nsSelectionPoint* endPoint = range->GetEndPoint();
nsIContent* startContent = startPoint->GetContent();
nsIContent* endContent = endPoint->GetContent();
PRInt32 startOffset = startPoint->GetOffset();
PRInt32 endOffset = endPoint->GetOffset();
nsString buffer;
mText.AppendTo(buffer);
if (startContent == content || endContent == content)
{
// NOTE: ORDER MATTERS!
// This must go before the Cut
if (endContent == content)
buffer.Truncate(endOffset);
// This must go after the Trunctate
if (startContent == content)
buffer.Cut(0,startOffset);
}
aConverter.AddContent(buffer);
NS_IF_RELEASE(startContent);
NS_IF_RELEASE(endContent);
}
}
NS_RELEASE(sel);
}
else
#endif //0
{
nsString buffer;
mText.AppendTo(buffer);
aConverter.AddContent(buffer);
}
return NS_OK;
}
void
nsGenericDOMDataNode::ToCString(nsString& aBuf, PRInt32 aOffset,
PRInt32 aLen) const
{
if (mText.Is2b()) {
const PRUnichar* cp = mText.Get2b() + aOffset;
const PRUnichar* end = cp + aLen;
while (cp < end) {
PRUnichar ch = *cp++;
if (ch == '\r') {
aBuf.Append("\\r");
} else if (ch == '\n') {
aBuf.Append("\\n");
} else if (ch == '\t') {
aBuf.Append("\\t");
} else if ((ch < ' ') || (ch >= 127)) {
char buf[10];
PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
aBuf.Append(buf);
} else {
aBuf.Append(ch);
}
}
}
else {
unsigned char* cp = (unsigned char*)mText.Get1b() + aOffset;
const unsigned char* end = cp + aLen;
while (cp < end) {
PRUnichar ch = *cp++;
if (ch == '\r') {
aBuf.Append("\\r");
} else if (ch == '\n') {
aBuf.Append("\\n");
} else if (ch == '\t') {
aBuf.Append("\\t");
} else if ((ch < ' ') || (ch >= 127)) {
char buf[10];
PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
aBuf.Append(buf);
} else {
aBuf.Append(ch);
}
}
}
}
nsresult
nsGenericDOMDataNode::GetDocument(nsIDocument*& aResult) const
{
aResult = mDocument;
NS_IF_ADDREF(mDocument);
return NS_OK;
}
nsresult
nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep)
{
// If we were part of a document, make sure we get rid of the
// script context reference to our script object so that our
// script object can be freed (or collected).
if ((nsnull != mDocument) && (nsnull != mScriptObject)) {
nsIScriptContextOwner *owner = mDocument->GetScriptContextOwner();
if (nsnull != owner) {
nsIScriptContext *context;
if (NS_OK == owner->GetScriptContext(&context)) {
context->RemoveReference((void *)&mScriptObject,
mScriptObject);
NS_RELEASE(context);
}
NS_RELEASE(owner);
}
}
mDocument = aDocument;
// If we already have a script object and now we're being added
// to a document, make sure that the script context adds a
// reference to our script object. This will ensure that it
// won't be freed (or collected) out from under us.
if ((nsnull != mDocument) && (nsnull != mScriptObject)) {
nsIScriptContextOwner *owner = mDocument->GetScriptContextOwner();
if (nsnull != owner) {
nsIScriptContext *context;
if (NS_OK == owner->GetScriptContext(&context)) {
context->AddNamedReference((void *)&mScriptObject,
mScriptObject,
"Text");
NS_RELEASE(context);
}
NS_RELEASE(owner);
}
}
return NS_OK;
}
nsresult
nsGenericDOMDataNode::GetParent(nsIContent*& aResult) const
{
NS_IF_ADDREF(mParent);
aResult = mParent;
return NS_OK;;
}
nsresult
nsGenericDOMDataNode::SetParent(nsIContent* aParent)
{
mParent = aParent;
return NS_OK;
}
nsresult
nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus)
{
nsresult ret = NS_OK;
nsIDOMEvent* domEvent = nsnull;
if (DOM_EVENT_INIT == aFlags) {
aDOMEvent = &domEvent;
}
//Capturing stage
//Local handling stage
if (nsnull != mListenerManager) {
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, aEventStatus);
}
//Bubbling stage
if (DOM_EVENT_CAPTURE != aFlags && mParent != nsnull) {
ret = mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
DOM_EVENT_BUBBLE, aEventStatus);
}
if (DOM_EVENT_INIT == aFlags) {
// We're leaving the DOM event loop so if we created a DOM event,
// release here.
if (nsnull != *aDOMEvent) {
if (0 != (*aDOMEvent)->Release()) {
// Okay, so someone in the DOM loop (a listener, JS object)
// still has a ref to the DOM Event but the internal data
// hasn't been malloc'd. Force a copy of the data here so the
// DOM Event is still valid.
nsIPrivateDOMEvent *privateEvent;
if (NS_OK == (*aDOMEvent)->QueryInterface(kIPrivateDOMEventIID, (void**)&privateEvent)) {
privateEvent->DuplicatePrivateData();
NS_RELEASE(privateEvent);
}
}
}
aDOMEvent = nsnull;
}
return ret;
}
nsresult
nsGenericDOMDataNode::RangeAdd(nsIDOMRange& aRange)
{
// lazy allocation of range list
if (nsnull == mRangeList) {
mRangeList = new nsVoidArray();
}
if (nsnull == mRangeList) {
return NS_ERROR_OUT_OF_MEMORY;
}
// dont need to addref - this call is made by the range object itself
PRBool rv = mRangeList->AppendElement(&aRange);
if (rv) return NS_OK;
return NS_ERROR_FAILURE;
}
nsresult
nsGenericDOMDataNode::RangeRemove(nsIDOMRange& aRange)
{
if (mRangeList) {
// dont need to release - this call is made by the range object itself
PRBool rv = mRangeList->RemoveElement(&aRange);
if (rv) {
if (mRangeList->Count() == 0) {
delete mRangeList;
mRangeList = nsnull;
}
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
nsresult
nsGenericDOMDataNode::GetRangeList(nsVoidArray*& aResult) const
{
aResult = mRangeList;
return NS_OK;
}
//----------------------------------------------------------------------
// XXX not really implemented (yet)
nsresult
nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
return NS_OK;
}

View File

@ -0,0 +1,506 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsGenericDOMDataNode_h___
#define nsGenericDOMDataNode_h___
#include "nsIDOMCharacterData.h"
#include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h"
#include "nsIContent.h"
#include "nsTextFragment.h"
#include "nsVoidArray.h"
#include "nsINameSpaceManager.h"
extern const nsIID kIDOMCharacterDataIID;
extern const nsIID kIDOMNodeIID;
extern const nsIID kIDOMEventReceiverIID;
extern const nsIID kIScriptObjectOwnerIID;
extern const nsIID kISupportsIID;
extern const nsIID kIContentIID;
class nsIDOMAttr;
class nsIDOMEventListener;
class nsIDOMNodeList;
class nsIEventListenerManager;
class nsIFrame;
class nsIStyleContext;
class nsIStyleRule;
class nsISupportsArray;
struct nsGenericDOMDataNode {
nsGenericDOMDataNode();
~nsGenericDOMDataNode();
void Init(nsIContent* aOuterContentObject);
// Implementation for nsIDOMNode
nsresult GetNodeName(nsString& aNodeName) {
aNodeName.Truncate();
return NS_OK;
}
nsresult GetNodeValue(nsString& aNodeValue);
nsresult SetNodeValue(const nsString& aNodeValue);
nsresult GetParentNode(nsIDOMNode** aParentNode);
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes) {
*aAttributes = nsnull;
return NS_OK;
}
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes) {
*aChildNodes = nsnull;
return NS_OK;
}
nsresult HasChildNodes(PRBool* aHasChildNodes) {
*aHasChildNodes = PR_FALSE;
return NS_OK;
}
nsresult GetFirstChild(nsIDOMNode** aFirstChild) {
*aFirstChild = nsnull;
return NS_OK;
}
nsresult GetLastChild(nsIDOMNode** aLastChild) {
*aLastChild = nsnull;
return NS_OK;
}
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
nsIDOMNode** aReturn) {
return NS_ERROR_FAILURE;
}
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
nsIDOMNode** aReturn) {
return NS_ERROR_FAILURE;
}
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) {
return NS_ERROR_FAILURE;
}
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) {
return NS_ERROR_FAILURE;
}
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
// Implementation for nsIDOMCharacterData
nsresult GetData(nsString& aData);
nsresult SetData(const nsString& aData);
nsresult GetLength(PRUint32* aLength);
nsresult SubstringData(PRUint32 aOffset, PRUint32 aCount, nsString& aReturn);
nsresult AppendData(const nsString& aArg);
nsresult InsertData(PRUint32 aOffset, const nsString& aArg);
nsresult DeleteData(PRUint32 aOffset, PRUint32 aCount);
nsresult ReplaceData(PRUint32 aOffset, PRUint32 aCount, const nsString& aArg);
// nsIDOMEventReceiver interface
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID);
nsresult RemoveEventListener(nsIDOMEventListener* aListener,
const nsIID& aIID);
nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult);
// nsIScriptObjectOwner interface
nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
nsresult SetScriptObject(void *aScriptObject);
// Implementation for nsIContent
nsresult GetDocument(nsIDocument*& aResult) const;
nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep);
nsresult GetParent(nsIContent*& aResult) const;
nsresult SetParent(nsIContent* aParent);
nsresult IsSynthetic(PRBool& aResult) {
aResult = PR_FALSE;
return NS_OK;
}
nsresult GetNameSpaceID(PRInt32& aID) const {
aID = kNameSpaceID_None;
return NS_OK;
}
nsresult GetTag(nsIAtom*& aResult) const {
aResult = nsnull;
return NS_OK;
}
nsresult ParseAttributeString(const nsString& aStr,
nsIAtom*& aName,
PRInt32& aNameSpaceID) {
aName = nsnull;
aNameSpaceID = kNameSpaceID_None;
return NS_OK;
}
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
nsIAtom*& aPrefix) {
aPrefix = nsnull;
return NS_OK;
}
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify) {
return NS_OK;
}
nsresult UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify) {
return NS_OK;
}
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, nsString &aResult) const {
return NS_CONTENT_ATTR_NOT_THERE;
}
nsresult GetAttributeNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID,
nsIAtom*& aName) const {
aName = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
}
nsresult GetAttributeCount(PRInt32& aResult) const {
aResult = 0;
return NS_OK;
}
nsresult List(FILE* out, PRInt32 aIndent) const;
nsresult HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus);
nsresult RangeAdd(nsIDOMRange& aRange);
nsresult RangeRemove(nsIDOMRange& aRange);
nsresult GetRangeList(nsVoidArray*& aResult) const;
// Implementation for nsIContent
nsresult SizeOf(nsISizeOfHandler* aHandler) const;
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
nsresult CanContainChildren(PRBool& aResult) const {
aResult = PR_FALSE;
return NS_OK;
}
nsresult ChildCount(PRInt32& aResult) const {
aResult = 0;
return NS_OK;
}
nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const {
aResult = nsnull;
return NS_OK;
}
nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const {
aResult = -1;
return NS_OK;
}
nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
return NS_OK;
}
nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) {
return NS_OK;
}
nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) {
return NS_OK;
}
nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify) {
return NS_OK;
}
//----------------------------------------
void ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
// Up pointer to the real content object that we are
// supporting. Sometimes there is work that we just can't do
// ourselves, so this is needed to ask the real object to do the
// work.
nsIContent* mContent;
nsIDocument* mDocument;
nsIContent* mParent;
void* mScriptObject;
nsIEventListenerManager* mListenerManager;
nsTextFragment mText;
nsVoidArray *mRangeList;
};
//----------------------------------------------------------------------
/**
* Mostly implement the nsIDOMNode API by forwarding the methods to a
* generic content object (either nsGenericHTMLLeafElement or
* nsGenericHTMLContainerContent)
*
* Note that classes using this macro will need to implement:
* NS_IMETHOD GetNodeType(PRUint16* aNodeType);
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
*/
#define NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD GetNodeName(nsString& aNodeName) { \
return _g.GetNodeName(aNodeName); \
} \
NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \
return _g.GetNodeValue(aNodeValue); \
} \
NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \
return _g.SetNodeValue(aNodeValue); \
} \
NS_IMETHOD GetNodeType(PRUint16* aNodeType); \
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
return _g.GetParentNode(aParentNode); \
} \
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
return _g.GetChildNodes(aChildNodes); \
} \
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
return _g.HasChildNodes(aHasChildNodes); \
} \
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
return _g.GetFirstChild(aFirstChild); \
} \
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
return _g.GetLastChild(aLastChild); \
} \
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
return _g.GetPreviousSibling(aPreviousSibling); \
} \
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
return _g.GetNextSibling(aNextSibling); \
} \
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
return _g.GetAttributes(aAttributes); \
} \
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
nsIDOMNode** aReturn) { \
return _g.InsertBefore(aNewChild, aRefChild, aReturn); \
} \
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
return _g.AppendChild(aOldChild, aReturn); \
} \
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
nsIDOMNode** aReturn) { \
return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \
} \
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
return _g.RemoveChild(aOldChild, aReturn); \
} \
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
return _g.GetOwnerDocument(aOwnerDocument); \
} \
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
#define NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD GetData(nsString& aData) { \
return _g.GetData(aData); \
} \
NS_IMETHOD SetData(const nsString& aData) { \
return _g.SetData(aData); \
} \
NS_IMETHOD GetLength(PRUint32* aLength) { \
return _g.GetLength(aLength); \
} \
NS_IMETHOD SubstringData(PRUint32 aStart, PRUint32 aEnd, nsString& aReturn) { \
return _g.SubstringData(aStart, aEnd, aReturn); \
} \
NS_IMETHOD AppendData(const nsString& aData) { \
return _g.AppendData(aData); \
} \
NS_IMETHOD InsertData(PRUint32 aOffset, const nsString& aData) { \
return _g.InsertData(aOffset, aData); \
} \
NS_IMETHOD DeleteData(PRUint32 aOffset, PRUint32 aCount) { \
return _g.DeleteData(aOffset, aCount); \
} \
NS_IMETHOD ReplaceData(PRUint32 aOffset, PRUint32 aCount, \
const nsString& aData) { \
return _g.ReplaceData(aOffset, aCount, aData); \
}
/**
* Implement the nsIDOMEventReceiver API by forwarding the methods to a
* generic content object (either nsGenericHTMLLeafElement or
* nsGenericHTMLContainerContent)
*/
#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \
const nsIID& aIID) { \
return _g.AddEventListener(aListener, aIID); \
} \
NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, \
const nsIID& aIID) { \
return _g.RemoveEventListener(aListener, aIID); \
} \
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \
return _g.GetListenerManager(aResult); \
} \
NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \
return _g.GetNewListenerManager(aResult); \
}
/**
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
* generic content object (either nsGenericHTMLLeafElement or
* nsGenericHTMLContainerContent)
*/
#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \
void** aScriptObject) { \
return _g.GetScriptObject(aContext, aScriptObject); \
} \
NS_IMETHOD SetScriptObject(void *aScriptObject) { \
return _g.SetScriptObject(aScriptObject); \
}
#define NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(_g) \
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
return _g.GetDocument(aResult); \
} \
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \
return _g.SetDocument(aDocument, aDeep); \
} \
NS_IMETHOD GetParent(nsIContent*& aResult) const { \
return _g.GetParent(aResult); \
} \
NS_IMETHOD SetParent(nsIContent* aParent) { \
return _g.SetParent(aParent); \
} \
NS_IMETHOD CanContainChildren(PRBool& aResult) const { \
return _g.CanContainChildren(aResult); \
} \
NS_IMETHOD ChildCount(PRInt32& aResult) const { \
return _g.ChildCount(aResult); \
} \
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \
return _g.ChildAt(aIndex, aResult); \
} \
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \
return _g.IndexOf(aPossibleChild, aResult); \
} \
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \
PRBool aNotify) { \
return _g.InsertChildAt(aKid, aIndex, aNotify); \
} \
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \
PRBool aNotify) { \
return _g.ReplaceChildAt(aKid, aIndex, aNotify); \
} \
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \
return _g.AppendChildTo(aKid, aNotify); \
} \
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \
return _g.RemoveChildAt(aIndex, aNotify); \
} \
NS_IMETHOD IsSynthetic(PRBool& aResult) { \
return _g.IsSynthetic(aResult); \
} \
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const { \
return _g.GetNameSpaceID(aID); \
} \
NS_IMETHOD GetTag(nsIAtom*& aResult) const { \
return _g.GetTag(aResult); \
} \
NS_IMETHOD ParseAttributeString(const nsString& aStr, \
nsIAtom*& aName, \
PRInt32& aNameSpaceID) { \
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
} \
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, \
nsIAtom*& aPrefix) { \
return _g.GetNameSpacePrefix(aNameSpaceID, aPrefix); \
} \
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, \
nsString &aResult) const { \
return _g.GetAttribute(aNameSpaceID, aAttribute, aResult); \
} \
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
const nsString& aValue, PRBool aNotify) { \
return _g.SetAttribute(aNameSpaceID, aAttribute, aValue, aNotify); \
} \
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aAttribute, \
PRBool aNotify) { \
return _g.UnsetAttribute(aNameSpaceID, aAttribute, aNotify); \
} \
NS_IMETHOD GetAttributeNameAt(PRInt32 aIndex, \
PRInt32& aNameSpaceID, \
nsIAtom*& aName) const { \
return _g.GetAttributeNameAt(aIndex, aNameSpaceID, aName); \
} \
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \
return _g.GetAttributeCount(aResult); \
} \
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; \
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \
return _g.BeginConvertToXIF(aConverter); \
} \
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \
return _g.ConvertContentToXIF(aConverter); \
} \
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \
return _g.FinishConvertToXIF(aConverter); \
} \
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \
return _g.SizeOf(aHandler); \
} \
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \
nsEvent* aEvent, \
nsIDOMEvent** aDOMEvent, \
PRUint32 aFlags, \
nsEventStatus& aEventStatus); \
NS_IMETHOD RangeAdd(nsIDOMRange& aRange){ \
return _g.RangeAdd(aRange); \
} \
NS_IMETHOD RangeRemove(nsIDOMRange& aRange){ \
return _g.RangeRemove(aRange); \
} \
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
return _g.GetRangeList(aResult); \
}
/**
* This macro implements the portion of query interface that is
* generic to all html content objects.
*/
#define NS_IMPL_DOM_DATA_QUERY_INTERFACE(_id, _iptr, _this) \
if (_id.Equals(kISupportsIID)) { \
nsIContent* tmp = _this; \
nsISupports* tmp2 = tmp; \
*_iptr = (void*) tmp2; \
NS_ADDREF_THIS(); \
return NS_OK; \
} \
if (_id.Equals(kIDOMNodeIID)) { \
nsIDOMNode* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
} \
if (_id.Equals(kIDOMCharacterDataIID)) { \
nsIDOMCharacterData* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
} \
if (_id.Equals(kIDOMEventReceiverIID)) { \
nsIDOMEventReceiver* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
} \
if (_id.Equals(kIScriptObjectOwnerIID)) { \
nsIScriptObjectOwner* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
} \
if (_id.Equals(kIContentIID)) { \
nsIContent* tmp = _this; \
*_iptr = (void*) tmp; \
NS_ADDREF_THIS(); \
return NS_OK; \
}
#endif /* nsGenericDOMDataNode_h___ */

View File

@ -1202,11 +1202,60 @@ nsGenericContainerElement::~nsGenericContainerElement()
nsresult nsresult
nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericContainerElement* aDst) nsGenericContainerElement* aDst,
PRBool aDeep)
{ {
// XXX copy attributes not yet impelemented nsresult result = NS_OK;
// XXX deep copy?
return NS_OK; if (nsnull != mAttributes) {
nsGenericAttribute* attr;
PRInt32 index;
PRInt32 count = mAttributes->Count();
for (index = 0; index < count; index++) {
attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
// XXX Not very efficient, since SetAttribute does a linear search
// through its attributes before setting each attribute.
result = aDst->SetAttribute(attr->mNameSpaceID, attr->mName,
attr->mValue, PR_FALSE);
if (NS_OK != result) {
return result;
}
}
}
if (aDeep) {
PRInt32 index;
PRInt32 count = mChildren.Count();
for (index = 0; index < count; index++) {
nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
if (nsnull != child) {
nsIDOMNode* node;
result = child->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_OK == result) {
nsIDOMNode* newNode;
result = node->CloneNode(aDeep, &newNode);
if (NS_OK == result) {
nsIContent* newContent;
result = newNode->QueryInterface(kIContentIID, (void**)&newContent);
if (NS_OK == result) {
result = aDst->AppendChildTo(newContent, PR_FALSE);
NS_RELEASE(newContent);
}
NS_RELEASE(newNode);
}
NS_RELEASE(node);
}
if (NS_OK != result) {
return result;
}
}
}
}
return result;
} }
nsresult nsresult

View File

@ -84,7 +84,6 @@ typedef struct {
nsDOMCSSDeclaration *mStyle; nsDOMCSSDeclaration *mStyle;
nsDOMAttributeMap* mAttributeMap; nsDOMAttributeMap* mAttributeMap;
nsVoidArray *mRangeList; nsVoidArray *mRangeList;
PRBool mIsContainer;
} nsDOMSlots; } nsDOMSlots;
class nsGenericElement : public nsIJSScriptObject { class nsGenericElement : public nsIJSScriptObject {
@ -210,7 +209,8 @@ public:
~nsGenericContainerElement(); ~nsGenericContainerElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericContainerElement* aDest); nsGenericContainerElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetAttribute(const nsString& aName, nsString& aReturn) nsresult GetAttribute(const nsString& aName, nsString& aReturn)

View File

@ -0,0 +1,245 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsIDOMText.h"
#include "nsGenericDOMDataNode.h"
#include "nsIScriptObjectOwner.h"
#include "nsIDOMEventReceiver.h"
#include "nsIContent.h"
#include "nsITextContent.h"
#include "nsFrame.h"
#include "nsIDocument.h"
#include "nsCRT.h"
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
/* XXX should not be html content; should be nsITextContent */
class nsTextNode : public nsIDOMText,
public nsIScriptObjectOwner,
public nsIDOMEventReceiver,
public nsIContent,
public nsITextContent
{
public:
nsTextNode();
~nsTextNode();
// nsISupports
NS_DECL_ISUPPORTS
// nsIDOMNode
NS_IMPL_IDOMNODE_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMCharacterData
NS_IMPL_IDOMCHARACTERDATA_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMText
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
// nsIScriptObjectOwner
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC_DOM_DATA(mInner)
// nsIDOMEventReceiver
NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC_DOM_DATA(mInner)
// nsIContent
NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
// nsITextContent
NS_IMETHOD GetText(const nsTextFragment*& aFragmentsResult,
PRInt32& aNumFragmentsResult);
NS_IMETHOD SetText(const PRUnichar* aBuffer,
PRInt32 aLength,
PRBool aNotify);
NS_IMETHOD SetText(const char* aBuffer,
PRInt32 aLength,
PRBool aNotify);
protected:
nsGenericDOMDataNode mInner;
};
nsresult NS_NewTextNode(nsIContent** aInstancePtrResult);
nsresult
NS_NewTextNode(nsIContent** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsTextNode* it;
NS_NEWXPCOM(it, nsTextNode);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIContentIID, (void **) aInstancePtrResult);
}
nsTextNode::nsTextNode()
{
NS_INIT_REFCNT();
mInner.Init(this);
}
nsTextNode::~nsTextNode()
{
}
NS_IMPL_ADDREF(nsTextNode)
NS_IMPL_RELEASE(nsTextNode)
NS_IMETHODIMP
nsTextNode::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
NS_IMPL_DOM_DATA_QUERY_INTERFACE(aIID, aInstancePtr, this)
if (aIID.Equals(kIDOMTextIID)) {
nsIDOMText* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kITextContentIID)) {
nsITextContent* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsTextNode::GetNodeType(PRUint16* aNodeType)
{
*aNodeType = (PRUint16)nsIDOMNode::TEXT_NODE;
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
nsTextNode* it;
NS_NEWXPCOM(it, nsTextNode);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsAutoString data;
nsresult result = GetData(data);
if (NS_FAILED(result)) {
return result;
}
result = it->SetData(data);
if (NS_FAILED(result)) {
return result;
}
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
}
NS_IMETHODIMP
nsTextNode::List(FILE* out, PRInt32 aIndent) const
{
NS_PRECONDITION(nsnull != mInner.mDocument, "bad content");
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, "Text refcount=%d<", mRefCnt);
nsAutoString tmp;
mInner.ToCString(tmp, 0, mInner.mText.GetLength());
fputs(tmp, out);
fputs(">\n", out);
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus)
{
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}
//----------------------------------------------------------------------
// Implementation of the nsIDOMText interface
NS_IMETHODIMP
nsTextNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
{
// XXX To be implemented
return NS_ERROR_NOT_IMPLEMENTED;
}
//----------------------------------------------------------------------
// Implementation of the nsITextContent interface
NS_IMETHODIMP
nsTextNode::GetText(const nsTextFragment*& aFragmentsResult,
PRInt32& aNumFragmentsResult)
{
aFragmentsResult = &mInner.mText;
aNumFragmentsResult = 1;
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::SetText(const PRUnichar* aBuffer, PRInt32 aLength,
PRBool aNotify)
{
NS_PRECONDITION((aLength >= 0) && (nsnull != aBuffer), "bad args");
if (aLength < 0) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (nsnull == aBuffer) {
return NS_ERROR_NULL_POINTER;
}
mInner.mText.SetTo(aBuffer, aLength);
// Trigger a reflow
if (aNotify && (nsnull != mInner.mDocument)) {
mInner.mDocument->ContentChanged(this, nsnull);
}
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::SetText(const char* aBuffer, PRInt32 aLength,
PRBool aNotify)
{
NS_PRECONDITION((aLength >= 0) && (nsnull != aBuffer), "bad args");
if (aLength < 0) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (nsnull == aBuffer) {
return NS_ERROR_NULL_POINTER;
}
mInner.mText.SetTo(aBuffer, aLength);
// Trigger a reflow
if (aNotify && (nsnull != mInner.mDocument)) {
mInner.mDocument->ContentChanged(this, nsnull);
}
return NS_OK;
}

View File

@ -22,6 +22,7 @@
#include "nsLayoutCID.h" #include "nsLayoutCID.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIHTMLContent.h" #include "nsIHTMLContent.h"
#include "nsITextContent.h"
#include "nsICollection.h" #include "nsICollection.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsISelection.h" #include "nsISelection.h"
@ -230,7 +231,7 @@ nsresult nsLayoutFactory::CreateInstance(nsISupports *aOuter,
} }
else if (mClassID.Equals(kTextNodeCID)) { else if (mClassID.Equals(kTextNodeCID)) {
// XXX ibid // XXX ibid
if (NS_FAILED(res = NS_NewTextNode((nsIHTMLContent**) &inst))) if (NS_FAILED(res = NS_NewTextNode((nsIContent**) &inst)))
return res; return res;
refCounted = PR_TRUE; refCounted = PR_TRUE;
} }

View File

@ -223,12 +223,6 @@ NS_NewHTMLUListElement(nsIHTMLContent** aResult, nsIAtom* aTag);
extern nsresult extern nsresult
NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag); NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag);
extern nsresult
NS_NewTextNode(nsIHTMLContent** aResult);
extern nsresult
NS_NewCommentNode(nsIHTMLContent** aResult);
/** /**
* Create a new content object for the given tag. * Create a new content object for the given tag.
* Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag. * Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag.

View File

@ -223,12 +223,6 @@ NS_NewHTMLUListElement(nsIHTMLContent** aResult, nsIAtom* aTag);
extern nsresult extern nsresult
NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag); NS_NewHTMLWBRElement(nsIHTMLContent** aResult, nsIAtom* aTag);
extern nsresult
NS_NewTextNode(nsIHTMLContent** aResult);
extern nsresult
NS_NewCommentNode(nsIHTMLContent** aResult);
/** /**
* Create a new content object for the given tag. * Create a new content object for the given tag.
* Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag. * Returns NS_ERROR_NOT_AVAILABLE for an unknown/unhandled tag.

View File

@ -26,8 +26,6 @@ LIBRARY_NAME = nglhtmlcon_s
# Note the sophisticated alphabetical ordering :-| # Note the sophisticated alphabetical ordering :-|
CPPSRCS= \ CPPSRCS= \
nsCommentNode.cpp \
nsGenericDOMDataNode.cpp \
nsGenericHTMLElement.cpp \ nsGenericHTMLElement.cpp \
nsGenericDOMHTMLCollection.cpp \ nsGenericDOMHTMLCollection.cpp \
GenericElementCollection.cpp \ GenericElementCollection.cpp \
@ -91,7 +89,6 @@ CPPSRCS= \
nsHTMLTitleElement.cpp \ nsHTMLTitleElement.cpp \
nsHTMLUListElement.cpp \ nsHTMLUListElement.cpp \
nsHTMLWBRElement.cpp \ nsHTMLWBRElement.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
MODULE=layout MODULE=layout

View File

@ -26,8 +26,6 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION
!endif !endif
CPPSRCS= \ CPPSRCS= \
nsCommentNode.cpp \
nsGenericDOMDataNode.cpp \
nsGenericHTMLElement.cpp \ nsGenericHTMLElement.cpp \
nsGenericDOMHTMLCollection.cpp \ nsGenericDOMHTMLCollection.cpp \
GenericElementCollection.cpp \ GenericElementCollection.cpp \
@ -44,7 +42,7 @@ CPPSRCS= \
nsHTMLDirectoryElement.cpp \ nsHTMLDirectoryElement.cpp \
nsHTMLDivElement.cpp \ nsHTMLDivElement.cpp \
nsHTMLEmbedElement.cpp \ nsHTMLEmbedElement.cpp \
nsHTMLFieldSetElement.cpp \ nsHTMLFieldSetElement.cpp \
nsHTMLFontElement.cpp \ nsHTMLFontElement.cpp \
nsHTMLFormElement.cpp \ nsHTMLFormElement.cpp \
nsHTMLFrameElement.cpp \ nsHTMLFrameElement.cpp \
@ -91,12 +89,9 @@ CPPSRCS= \
nsHTMLTitleElement.cpp \ nsHTMLTitleElement.cpp \
nsHTMLUListElement.cpp \ nsHTMLUListElement.cpp \
nsHTMLWBRElement.cpp \ nsHTMLWBRElement.cpp \
nsTextNode.cpp \
$(NULL) $(NULL)
CPP_OBJS= \ CPP_OBJS= \
.\$(OBJDIR)\nsCommentNode.obj \
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
.\$(OBJDIR)\nsGenericHTMLElement.obj \ .\$(OBJDIR)\nsGenericHTMLElement.obj \
.\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \ .\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \
.\$(OBJDIR)\GenericElementCollection.obj \ .\$(OBJDIR)\GenericElementCollection.obj \
@ -160,7 +155,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTMLTitleElement.obj \ .\$(OBJDIR)\nsHTMLTitleElement.obj \
.\$(OBJDIR)\nsHTMLUListElement.obj \ .\$(OBJDIR)\nsHTMLUListElement.obj \
.\$(OBJDIR)\nsHTMLWBRElement.obj \ .\$(OBJDIR)\nsHTMLWBRElement.obj \
.\$(OBJDIR)\nsTextNode.obj \
$(NULL) $(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \

View File

@ -244,6 +244,22 @@ nsGenericHTMLElement::~nsGenericHTMLElement()
} }
} }
nsresult
nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLElement* aDst,
PRBool aDeep)
{
nsresult result = NS_OK;
if (nsnull != mAttributes) {
aDst->mAttributes = mAttributes;
NS_ADDREF(mAttributes);
mAttributes->AddContentRef();
}
return result;
}
// Implementation for nsIDOMHTMLElement // Implementation for nsIDOMHTMLElement
nsresult nsresult
nsGenericHTMLElement::GetId(nsString& aId) nsGenericHTMLElement::GetId(nsString& aId)
@ -1772,12 +1788,13 @@ nsGenericHTMLLeafElement::~nsGenericHTMLLeafElement()
nsresult nsresult
nsGenericHTMLLeafElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericHTMLLeafElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLLeafElement* aDst) nsGenericHTMLLeafElement* aDst,
PRBool aDeep)
{ {
aDst->mContent = aSrcContent; nsresult result = nsGenericHTMLElement::CopyInnerTo(aSrcContent,
// XXX should the node's document be set? aDst,
// XXX copy attributes not yet impelemented aDeep);
return NS_OK; return result;
} }
nsresult nsresult
@ -1872,12 +1889,48 @@ nsGenericHTMLContainerElement::~nsGenericHTMLContainerElement()
nsresult nsresult
nsGenericHTMLContainerElement::CopyInnerTo(nsIContent* aSrcContent, nsGenericHTMLContainerElement::CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLContainerElement* aDst) nsGenericHTMLContainerElement* aDst,
PRBool aDeep)
{ {
aDst->mContent = aSrcContent; nsresult result = nsGenericHTMLElement::CopyInnerTo(aSrcContent,
// XXX should the node's document be set? aDst,
// XXX copy attributes not yet impelemented aDeep);
// XXX deep copy? if (NS_OK != result) {
return result;
}
if (aDeep) {
PRInt32 index;
PRInt32 count = mChildren.Count();
for (index = 0; index < count; index++) {
nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
if (nsnull != child) {
nsIDOMNode* node;
result = child->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_OK == result) {
nsIDOMNode* newNode;
result = node->CloneNode(aDeep, &newNode);
if (NS_OK == result) {
nsIContent* newContent;
result = newNode->QueryInterface(kIContentIID, (void**)&newContent);
if (NS_OK == result) {
result = aDst->AppendChildTo(newContent, PR_FALSE);
NS_RELEASE(newContent);
}
NS_RELEASE(newNode);
}
NS_RELEASE(node);
}
if (NS_OK != result) {
return result;
}
}
}
}
return NS_OK; return NS_OK;
} }

View File

@ -51,6 +51,10 @@ public:
nsGenericHTMLElement(); nsGenericHTMLElement();
~nsGenericHTMLElement(); ~nsGenericHTMLElement();
nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLElement* aDest,
PRBool aDeep);
// Implementation for nsIDOMElement // Implementation for nsIDOMElement
nsresult GetAttribute(const nsString& aName, nsString& aReturn) nsresult GetAttribute(const nsString& aName, nsString& aReturn)
{ {
@ -241,7 +245,8 @@ public:
~nsGenericHTMLLeafElement(); ~nsGenericHTMLLeafElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLLeafElement* aDest); nsGenericHTMLLeafElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
@ -318,7 +323,8 @@ public:
~nsGenericHTMLContainerElement(); ~nsGenericHTMLContainerElement();
nsresult CopyInnerTo(nsIContent* aSrcContent, nsresult CopyInnerTo(nsIContent* aSrcContent,
nsGenericHTMLContainerElement* aDest); nsGenericHTMLContainerElement* aDest,
PRBool aDeep);
// Remainder of nsIDOMHTMLElement (and nsIDOMNode) // Remainder of nsIDOMHTMLElement (and nsIDOMNode)
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);

Some files were not shown because too many files have changed in this diff Show More