mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Started implementation of Node properties and methods for documents.
This commit is contained in:
parent
f53f3619cd
commit
f052b61c9d
@ -30,7 +30,10 @@ typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent);
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsContentList : public nsIDOMNodeList, public nsIDOMHTMLCollection, public nsIScriptObjectOwner, public nsIDocumentObserver {
|
||||
class nsContentList : public nsIDOMNodeList,
|
||||
public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDocumentObserver {
|
||||
protected:
|
||||
nsContentList(nsIDocument *aDocument);
|
||||
public:
|
||||
|
@ -395,48 +395,15 @@ nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
|
||||
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// Don't increment the reference count. The attribute will tell
|
||||
// us when it's going away
|
||||
mAttribute = aAttribute;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsAttributeChildList::~nsAttributeChildList()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeChildList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
nsIDOMNodeList* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMNodeList* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAttributeChildList)
|
||||
NS_IMPL_RELEASE(nsAttributeChildList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
@ -464,36 +431,6 @@ nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::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->NewScriptNodeList(aContext,
|
||||
(nsISupports *)(nsIDOMNodeList *)this,
|
||||
(nsISupports *)(nsIDOMAttr*)mAttribute,
|
||||
(void **)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttributeChildList::DropReference()
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
@ -40,28 +41,20 @@ public:
|
||||
};
|
||||
|
||||
// bogus child list for an attribute
|
||||
class nsAttributeChildList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
class nsAttributeChildList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsAttributeChildList(nsDOMAttribute* aAttribute);
|
||||
~nsAttributeChildList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// interface nsIDOMNodeList
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
// interface nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsDOMAttribute* mAttribute;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
|
@ -1274,22 +1274,21 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aNodeName.SetString("#document");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aNodeValue.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1300,86 +1299,86 @@ nsDocument::GetNodeType(PRUint16* aNodeType)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
nsDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::HasChildNodes(PRBool* aHasChildNodes)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -77,72 +77,9 @@ static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
|
||||
|
||||
nsChildContentList::nsChildContentList(nsIContent *aContent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// This reference is not reference-counted. The content
|
||||
// object tells us when its about to go away.
|
||||
mContent = aContent;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsChildContentList);
|
||||
NS_IMPL_RELEASE(nsChildContentList);
|
||||
|
||||
nsresult
|
||||
nsChildContentList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
nsIDOMNodeList* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMNodeList* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChildContentList::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->NewScriptNodeList(aContext,
|
||||
(nsISupports *)(nsIDOMNodeList *)this,
|
||||
mContent,
|
||||
(void**)&mScriptObject);
|
||||
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChildContentList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
@ -51,18 +52,12 @@ class nsIURL;
|
||||
|
||||
// Class that holds the child list of a content element and also
|
||||
// implements the nsIDOMNodeList interface.
|
||||
class nsChildContentList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
class nsChildContentList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsIContent *aContent);
|
||||
~nsChildContentList() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
~nsChildContentList() {}
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
@ -70,7 +65,6 @@ public:
|
||||
|
||||
private:
|
||||
nsIContent *mContent;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
|
@ -28,14 +28,14 @@
|
||||
* This is a base class for a generic HTML collection. The base class
|
||||
* provides implementations for nsISupports and nsIScriptObjectOwner,
|
||||
* but it is up to the subclass to implement the core HTML collection
|
||||
* method:
|
||||
* methods:
|
||||
* GetLength
|
||||
* Item
|
||||
* NameItem
|
||||
* NamedItem
|
||||
*
|
||||
*/
|
||||
class nsGenericDOMHTMLCollection : public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsGenericDOMHTMLCollection();
|
||||
@ -46,7 +46,7 @@ public:
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// The following need to be defined in the base class
|
||||
// The following need to be defined in the subclass
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||
|
@ -50,12 +50,15 @@
|
||||
#include "nsIFrame.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
|
||||
// XXX Go through a factory for this one
|
||||
#include "nsICSSParser.h"
|
||||
|
||||
@ -180,7 +183,6 @@ public:
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIHTMLDocument* mHTMLDocument;
|
||||
nsIScriptObjectOwner* mDocumentScript;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIURL* mDocumentBaseURL;
|
||||
nsIWebShell* mWebShell;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
|
||||
#ifdef PCB_USE_PROTOCOL_CONNECTION
|
||||
// beard: how else would we get the referrer to a URL?
|
||||
@ -82,6 +83,63 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
class nsHTMLDocumentChildNodes : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsHTMLDocumentChildNodes(nsIDOMDocument* aDocument);
|
||||
~nsHTMLDocumentChildNodes();
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
protected:
|
||||
nsIDOMDocument* mDocument;
|
||||
};
|
||||
|
||||
nsHTMLDocumentChildNodes::nsHTMLDocumentChildNodes(nsIDOMDocument* aDocument)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
}
|
||||
|
||||
nsHTMLDocumentChildNodes::~nsHTMLDocumentChildNodes()
|
||||
{
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocumentChildNodes::GetLength(PRUint32* aLength)
|
||||
{
|
||||
*aLength = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (0 == aIndex) {
|
||||
nsIDOMElement* root;
|
||||
|
||||
result = mDocument->GetDocumentElement(&root);
|
||||
if (NS_OK == result) {
|
||||
result = root->QueryInterface(kIDOMNodeIID, (void**)aReturn);
|
||||
NS_RELEASE(root);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
|
||||
{
|
||||
@ -640,6 +698,181 @@ nsHTMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{
|
||||
return nsDocument::GetImplementation(aImplementation);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
|
||||
{
|
||||
return nsDocument::GetDocumentElement(aDocumentElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
return nsDocument::CreateDocumentFragment(aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
|
||||
{
|
||||
return nsDocument::CreateComment(aData, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{
|
||||
return nsDocument::CreateAttribute(aName, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{
|
||||
return nsDocument::CreateTextNode(aData, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn)
|
||||
{
|
||||
return nsDocument::GetElementsByTagName(aTagname, aReturn);
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode interface implementation
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return mRootContent->QueryInterface(kIDOMNodeIID, (void**)aFirstChild);
|
||||
}
|
||||
else {
|
||||
*aFirstChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return mRootContent->QueryInterface(kIDOMNodeIID, (void**)aLastChild);
|
||||
}
|
||||
else {
|
||||
*aLastChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::InsertBefore(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::ReplaceChild(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
return nsDocument::GetNodeName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
return nsDocument::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
return nsDocument::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
return nsDocument::GetNodeType(aNodeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
return nsDocument::GetParentNode(aParentNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
return nsDocument::GetPreviousSibling(aPreviousSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
return nsDocument::GetNextSibling(aNextSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
return nsDocument::GetAttributes(aAttributes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
return nsDocument::GetOwnerDocument(aOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::CloneNode(aDeep, aReturn);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsIDOMHTMLDocument interface implementation
|
||||
//
|
||||
|
@ -86,29 +86,10 @@ public:
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{ return nsDocument::GetImplementation(aImplementation); }
|
||||
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement)
|
||||
{ return nsDocument::GetDocumentElement(aDocumentElement); }
|
||||
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
|
||||
{ return nsDocument::CreateDocumentFragment(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 CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{ return nsDocument::CreateAttribute(aName, aReturn); }
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{ return nsDocument::CreateTextNode(aData, aReturn); }
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn)
|
||||
{ return nsDocument::GetElementsByTagName(aTagname, aReturn); }
|
||||
NS_DECL_IDOMDOCUMENT
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_FORWARD_IDOMNODE(nsDocument::)
|
||||
NS_DECL_IDOMNODE
|
||||
|
||||
// nsIDOMHTMLDocument interface
|
||||
NS_DECL_IDOMHTMLDOCUMENT
|
||||
|
@ -31,6 +31,7 @@ CPPSRCS = \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericDOMNodeList.cpp \
|
||||
nsContentList.cpp \
|
||||
nsDocument.cpp \
|
||||
nsDocumentFragment.cpp \
|
||||
|
@ -27,6 +27,7 @@ CPPSRCS = \
|
||||
nsCommentNode.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericDOMNodeList.cpp \
|
||||
nsContentList.cpp \
|
||||
nsContentIterator.cpp \
|
||||
nsDocument.cpp \
|
||||
@ -59,6 +60,7 @@ EXPORTS=nsSelectionRange.h nsSelectionPoint.h
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCommentNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMNodeList.obj \
|
||||
.\$(OBJDIR)\nsGenericElement.obj \
|
||||
.\$(OBJDIR)\nsContentList.obj \
|
||||
.\$(OBJDIR)\nsContentIterator.obj \
|
||||
|
@ -30,7 +30,10 @@ typedef PRBool (*nsContentListMatchFunc)(nsIContent *aContent);
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsContentList : public nsIDOMNodeList, public nsIDOMHTMLCollection, public nsIScriptObjectOwner, public nsIDocumentObserver {
|
||||
class nsContentList : public nsIDOMNodeList,
|
||||
public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDocumentObserver {
|
||||
protected:
|
||||
nsContentList(nsIDocument *aDocument);
|
||||
public:
|
||||
|
@ -395,48 +395,15 @@ nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
|
||||
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// Don't increment the reference count. The attribute will tell
|
||||
// us when it's going away
|
||||
mAttribute = aAttribute;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
nsAttributeChildList::~nsAttributeChildList()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttributeChildList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
nsIDOMNodeList* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMNodeList* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAttributeChildList)
|
||||
NS_IMPL_RELEASE(nsAttributeChildList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
@ -464,36 +431,6 @@ nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::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->NewScriptNodeList(aContext,
|
||||
(nsISupports *)(nsIDOMNodeList *)this,
|
||||
(nsISupports *)(nsIDOMAttr*)mAttribute,
|
||||
(void **)&mScriptObject);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttributeChildList::DropReference()
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
@ -40,28 +41,20 @@ public:
|
||||
};
|
||||
|
||||
// bogus child list for an attribute
|
||||
class nsAttributeChildList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
class nsAttributeChildList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsAttributeChildList(nsDOMAttribute* aAttribute);
|
||||
~nsAttributeChildList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// interface nsIDOMNodeList
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
// interface nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsDOMAttribute* mAttribute;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
|
@ -1274,22 +1274,21 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aNodeName.SetString("#document");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aNodeValue.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1300,86 +1299,86 @@ nsDocument::GetNodeType(PRUint16* aNodeType)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
nsDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::HasChildNodes(PRBool* aHasChildNodes)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
// XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX TBI
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -77,72 +77,9 @@ static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
|
||||
|
||||
nsChildContentList::nsChildContentList(nsIContent *aContent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// This reference is not reference-counted. The content
|
||||
// object tells us when its about to go away.
|
||||
mContent = aContent;
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsChildContentList);
|
||||
NS_IMPL_RELEASE(nsChildContentList);
|
||||
|
||||
nsresult
|
||||
nsChildContentList::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIDOMNodeListIID)) {
|
||||
nsIDOMNodeList* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
nsIScriptObjectOwner* tmp = this;
|
||||
*aInstancePtr = (void*)tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIDOMNodeList* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*)tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChildContentList::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->NewScriptNodeList(aContext,
|
||||
(nsISupports *)(nsIDOMNodeList *)this,
|
||||
mContent,
|
||||
(void**)&mScriptObject);
|
||||
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChildContentList::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
|
||||
extern const nsIID kIDOMNodeIID;
|
||||
extern const nsIID kIDOMElementIID;
|
||||
@ -51,18 +52,12 @@ class nsIURL;
|
||||
|
||||
// Class that holds the child list of a content element and also
|
||||
// implements the nsIDOMNodeList interface.
|
||||
class nsChildContentList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
class nsChildContentList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsIContent *aContent);
|
||||
~nsChildContentList() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
~nsChildContentList() {}
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
@ -70,7 +65,6 @@ public:
|
||||
|
||||
private:
|
||||
nsIContent *mContent;
|
||||
void *mScriptObject;
|
||||
};
|
||||
|
||||
// There are a set of DOM- and scripting-specific instance variables
|
||||
|
@ -28,14 +28,14 @@
|
||||
* This is a base class for a generic HTML collection. The base class
|
||||
* provides implementations for nsISupports and nsIScriptObjectOwner,
|
||||
* but it is up to the subclass to implement the core HTML collection
|
||||
* method:
|
||||
* methods:
|
||||
* GetLength
|
||||
* Item
|
||||
* NameItem
|
||||
* NamedItem
|
||||
*
|
||||
*/
|
||||
class nsGenericDOMHTMLCollection : public nsIDOMHTMLCollection,
|
||||
public nsIScriptObjectOwner
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
nsGenericDOMHTMLCollection();
|
||||
@ -46,7 +46,7 @@ public:
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// The following need to be defined in the base class
|
||||
// The following need to be defined in the subclass
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||
|
@ -50,12 +50,15 @@
|
||||
#include "nsIFrame.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
|
||||
// XXX Go through a factory for this one
|
||||
#include "nsICSSParser.h"
|
||||
|
||||
@ -180,7 +183,6 @@ public:
|
||||
|
||||
nsIDocument* mDocument;
|
||||
nsIHTMLDocument* mHTMLDocument;
|
||||
nsIScriptObjectOwner* mDocumentScript;
|
||||
nsIURL* mDocumentURL;
|
||||
nsIURL* mDocumentBaseURL;
|
||||
nsIWebShell* mWebShell;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
|
||||
#ifdef PCB_USE_PROTOCOL_CONNECTION
|
||||
// beard: how else would we get the referrer to a URL?
|
||||
@ -82,6 +83,63 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
class nsHTMLDocumentChildNodes : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsHTMLDocumentChildNodes(nsIDOMDocument* aDocument);
|
||||
~nsHTMLDocumentChildNodes();
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
protected:
|
||||
nsIDOMDocument* mDocument;
|
||||
};
|
||||
|
||||
nsHTMLDocumentChildNodes::nsHTMLDocumentChildNodes(nsIDOMDocument* aDocument)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
}
|
||||
|
||||
nsHTMLDocumentChildNodes::~nsHTMLDocumentChildNodes()
|
||||
{
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocumentChildNodes::GetLength(PRUint32* aLength)
|
||||
{
|
||||
*aLength = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (0 == aIndex) {
|
||||
nsIDOMElement* root;
|
||||
|
||||
result = mDocument->GetDocumentElement(&root);
|
||||
if (NS_OK == result) {
|
||||
result = root->QueryInterface(kIDOMNodeIID, (void**)aReturn);
|
||||
NS_RELEASE(root);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
|
||||
{
|
||||
@ -640,6 +698,181 @@ nsHTMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{
|
||||
return nsDocument::GetImplementation(aImplementation);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
|
||||
{
|
||||
return nsDocument::GetDocumentElement(aDocumentElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
return nsDocument::CreateDocumentFragment(aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateComment(const nsString& aData, nsIDOMComment** aReturn)
|
||||
{
|
||||
return nsDocument::CreateComment(aData, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{
|
||||
return nsDocument::CreateAttribute(aName, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{
|
||||
return nsDocument::CreateTextNode(aData, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn)
|
||||
{
|
||||
return nsDocument::GetElementsByTagName(aTagname, aReturn);
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode interface implementation
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return mRootContent->QueryInterface(kIDOMNodeIID, (void**)aFirstChild);
|
||||
}
|
||||
else {
|
||||
*aFirstChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return mRootContent->QueryInterface(kIDOMNodeIID, (void**)aLastChild);
|
||||
}
|
||||
else {
|
||||
*aLastChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::InsertBefore(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::ReplaceChild(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
return nsDocument::GetNodeName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
return nsDocument::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
return nsDocument::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
return nsDocument::GetNodeType(aNodeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
return nsDocument::GetParentNode(aParentNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
return nsDocument::GetPreviousSibling(aPreviousSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
return nsDocument::GetNextSibling(aNextSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
return nsDocument::GetAttributes(aAttributes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
return nsDocument::GetOwnerDocument(aOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::CloneNode(aDeep, aReturn);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsIDOMHTMLDocument interface implementation
|
||||
//
|
||||
|
@ -86,29 +86,10 @@ public:
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
||||
{ return nsDocument::GetImplementation(aImplementation); }
|
||||
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement)
|
||||
{ return nsDocument::GetDocumentElement(aDocumentElement); }
|
||||
NS_IMETHOD CreateCDATASection(const nsString& aData, nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsString& aName, nsIDOMEntityReference** aReturn);
|
||||
NS_IMETHOD CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
|
||||
{ return nsDocument::CreateDocumentFragment(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 CreateAttribute(const nsString& aName, nsIDOMAttr** aReturn)
|
||||
{ return nsDocument::CreateAttribute(aName, aReturn); }
|
||||
NS_IMETHOD CreateElement(const nsString& aTagName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateTextNode(const nsString& aData, nsIDOMText** aReturn)
|
||||
{ return nsDocument::CreateTextNode(aData, aReturn); }
|
||||
NS_IMETHOD GetElementsByTagName(const nsString& aTagname, nsIDOMNodeList** aReturn)
|
||||
{ return nsDocument::GetElementsByTagName(aTagname, aReturn); }
|
||||
NS_DECL_IDOMDOCUMENT
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_FORWARD_IDOMNODE(nsDocument::)
|
||||
NS_DECL_IDOMNODE
|
||||
|
||||
// nsIDOMHTMLDocument interface
|
||||
NS_DECL_IDOMHTMLDOCUMENT
|
||||
|
Loading…
Reference in New Issue
Block a user