2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-11-25 08:14:47 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-11-25 08:14:47 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* 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.
|
1998-11-25 08:14:47 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-11-25 08:14:47 +00:00
|
|
|
|
2006-03-30 08:03:04 +00:00
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's DocumentFragment.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 03:54:26 +00:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
|
|
|
#include "nsGenericElement.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2000-05-10 13:13:39 +00:00
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
1998-11-25 08:14:47 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2004-07-16 06:32:16 +00:00
|
|
|
#include "nsIDOMAttr.h"
|
1999-09-08 23:18:27 +00:00
|
|
|
#include "nsDOMError.h"
|
2003-06-16 11:17:18 +00:00
|
|
|
#include "nsIDOM3Node.h"
|
2004-01-18 14:52:21 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
2004-04-01 19:44:17 +00:00
|
|
|
#include "nsDOMString.h"
|
2005-10-27 14:09:23 +00:00
|
|
|
#include "nsIDOMUserDataHandler.h"
|
1999-01-19 03:54:26 +00:00
|
|
|
|
2004-03-05 23:13:50 +00:00
|
|
|
class nsDocumentFragment : public nsGenericElement,
|
2006-03-24 00:09:50 +00:00
|
|
|
public nsIDOMDocumentFragment,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
public nsIDOM3Node
|
1999-01-19 03:54:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-09-11 17:15:08 +00:00
|
|
|
nsDocumentFragment(nsINodeInfo *aNodeInfo);
|
1999-01-19 03:54:26 +00:00
|
|
|
virtual ~nsDocumentFragment();
|
|
|
|
|
|
|
|
// nsISupports
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-01-19 03:54:26 +00:00
|
|
|
|
|
|
|
// interface nsIDOMDocumentFragment
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD GetNodeName(nsAString& aNodeName)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetNodeName(aNodeName); }
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD GetNodeValue(nsAString& aNodeValue)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetNodeValue(aNodeValue); }
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::SetNodeValue(aNodeValue); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
|
|
|
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetParentNode(aParentNode); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetChildNodes(aChildNodes); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetFirstChild(aFirstChild); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetLastChild(aLastChild); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetPreviousSibling(aPreviousSibling); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetNextSibling(aNextSibling); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
|
|
|
{
|
|
|
|
*aAttributes = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-09-11 17:15:08 +00:00
|
|
|
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
|
|
|
{ return nsGenericElement::GetOwnerDocument(aOwnerDocument); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
|
|
|
nsIDOMNode** aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::InsertBefore(aNewChild, aRefChild, aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
|
|
|
nsIDOMNode** aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::ReplaceChild(aNewChild, aOldChild, aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::RemoveChild(aOldChild, aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::AppendChild(aNewChild, aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD HasChildNodes(PRBool* aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::HasChildNodes(aReturn); }
|
2000-09-14 05:19:00 +00:00
|
|
|
NS_IMETHOD HasAttributes(PRBool* aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::HasAttributes(aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD GetPrefix(nsAString& aPrefix)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetPrefix(aPrefix); }
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
|
|
|
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetNamespaceURI(aNamespaceURI); }
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD GetLocalName(nsAString& aLocalName)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::GetLocalName(aLocalName); }
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_IMETHOD Normalize()
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::Normalize(); }
|
2002-03-23 23:54:46 +00:00
|
|
|
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
|
|
|
const nsAString& aVersion,
|
2000-12-23 10:56:31 +00:00
|
|
|
PRBool* aReturn)
|
2004-03-05 23:13:50 +00:00
|
|
|
{ return nsGenericElement::IsSupported(aFeature, aVersion, aReturn); }
|
1999-01-19 03:54:26 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
// nsIDOM3Node
|
2003-06-24 21:39:39 +00:00
|
|
|
NS_DECL_NSIDOM3NODE
|
1999-01-19 03:54:26 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
// nsIContent
|
2004-01-09 23:54:21 +00:00
|
|
|
virtual void SetParent(nsIContent* aParent) { }
|
2004-01-15 17:07:27 +00:00
|
|
|
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAString& aValue, PRBool aNotify)
|
2004-01-09 23:54:21 +00:00
|
|
|
{
|
2004-01-15 17:07:27 +00:00
|
|
|
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
|
2004-01-09 23:54:21 +00:00
|
|
|
}
|
2004-01-15 17:07:27 +00:00
|
|
|
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2004-01-09 23:54:21 +00:00
|
|
|
PRBool aNotify)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-10-28 11:25:24 +00:00
|
|
|
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsAString& aResult) const
|
2004-01-09 23:54:21 +00:00
|
|
|
{
|
2005-10-28 11:25:24 +00:00
|
|
|
return PR_FALSE;
|
2004-01-09 23:54:21 +00:00
|
|
|
}
|
|
|
|
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
PRBool aNotify)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-12-29 00:38:55 +00:00
|
|
|
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const
|
2004-01-09 23:54:21 +00:00
|
|
|
{
|
2005-12-28 21:52:39 +00:00
|
|
|
return nsnull;
|
2004-01-09 23:54:21 +00:00
|
|
|
}
|
1999-08-31 10:06:17 +00:00
|
|
|
|
1999-01-19 03:54:26 +00:00
|
|
|
protected:
|
2005-09-11 17:15:08 +00:00
|
|
|
nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep,
|
2005-09-12 07:34:25 +00:00
|
|
|
nsIContent **aResult) const;
|
1999-01-19 03:54:26 +00:00
|
|
|
};
|
|
|
|
|
1998-11-25 08:14:47 +00:00
|
|
|
nsresult
|
|
|
|
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
2005-09-24 18:43:15 +00:00
|
|
|
nsNodeInfoManager *aNodeInfoManager)
|
1998-11-25 08:14:47 +00:00
|
|
|
{
|
2005-09-24 18:43:15 +00:00
|
|
|
NS_ENSURE_ARG(aNodeInfoManager);
|
2000-05-10 13:13:39 +00:00
|
|
|
|
2004-01-18 14:52:21 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2005-09-24 18:43:15 +00:00
|
|
|
nsresult rv =
|
|
|
|
aNodeInfoManager->GetNodeInfo(nsLayoutAtoms::documentFragmentNodeName,
|
|
|
|
nsnull, kNameSpaceID_None,
|
|
|
|
getter_AddRefs(nodeInfo));
|
2000-05-10 13:13:39 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2005-09-24 18:43:15 +00:00
|
|
|
nsDocumentFragment *it = new nsDocumentFragment(nodeInfo);
|
2000-12-23 10:56:31 +00:00
|
|
|
if (!it) {
|
1998-11-25 08:14:47 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2005-09-11 17:15:08 +00:00
|
|
|
NS_ADDREF(*aInstancePtrResult = it);
|
2000-12-23 10:56:31 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-11-25 08:14:47 +00:00
|
|
|
}
|
|
|
|
|
2005-09-11 17:15:08 +00:00
|
|
|
nsDocumentFragment::nsDocumentFragment(nsINodeInfo *aNodeInfo)
|
2004-05-18 20:58:12 +00:00
|
|
|
: nsGenericElement(aNodeInfo)
|
1998-11-25 08:14:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDocumentFragment::~nsDocumentFragment()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
// QueryInterface implementation for nsDocumentFragment
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDocumentFragment)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
2006-01-19 03:34:18 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsINode)
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentFragment)
|
2000-12-23 10:56:31 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-11-25 08:14:47 +00:00
|
|
|
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_IMPL_ADDREF(nsDocumentFragment)
|
|
|
|
NS_IMPL_RELEASE(nsDocumentFragment)
|
|
|
|
|
1998-11-25 08:14:47 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::GetNodeType(PRUint16* aNodeType)
|
|
|
|
{
|
|
|
|
*aNodeType = (PRUint16)nsIDOMNode::DOCUMENT_FRAGMENT_NODE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-01 13:31:23 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 23:54:46 +00:00
|
|
|
nsDocumentFragment::SetPrefix(const nsAString& aPrefix)
|
2000-04-01 13:31:23 +00:00
|
|
|
{
|
2000-05-17 00:21:53 +00:00
|
|
|
return NS_ERROR_DOM_NAMESPACE_ERR;
|
2000-04-01 13:31:23 +00:00
|
|
|
}
|
|
|
|
|
2005-09-11 17:15:08 +00:00
|
|
|
NS_IMPL_DOM_CLONENODE(nsDocumentFragment)
|
2002-05-14 01:28:17 +00:00
|
|
|
|
2003-06-24 21:39:39 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::GetBaseURI(nsAString& aURI)
|
|
|
|
{
|
|
|
|
aURI.Truncate();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::LookupPrefix(const nsAString& aNamespaceURI,
|
|
|
|
nsAString& aPrefix)
|
|
|
|
{
|
|
|
|
aPrefix.Truncate();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
|
|
|
nsAString& aNamespaceURI)
|
|
|
|
{
|
|
|
|
aNamespaceURI.Truncate();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::IsDefaultNamespace(const nsAString& aNamespaceURI,
|
|
|
|
PRBool* aReturn)
|
|
|
|
{
|
2004-11-28 10:57:22 +00:00
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
return NS_OK;
|
2003-06-24 21:39:39 +00:00
|
|
|
}
|
|
|
|
|
2002-05-14 01:28:17 +00:00
|
|
|
NS_IMETHODIMP
|
2002-12-04 05:18:39 +00:00
|
|
|
nsDocumentFragment::CompareDocumentPosition(nsIDOMNode* aOther,
|
|
|
|
PRUint16* aReturn)
|
2002-05-14 01:28:17 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aOther);
|
2002-12-04 05:18:39 +00:00
|
|
|
NS_PRECONDITION(aReturn, "Must have an out parameter");
|
2002-05-14 01:28:17 +00:00
|
|
|
|
2002-12-04 05:18:39 +00:00
|
|
|
if (this == aOther) {
|
|
|
|
// If the two nodes being compared are the same node,
|
|
|
|
// then no flags are set on the return.
|
|
|
|
*aReturn = 0;
|
|
|
|
return NS_OK;
|
2002-05-14 01:28:17 +00:00
|
|
|
}
|
|
|
|
|
2002-12-04 05:18:39 +00:00
|
|
|
PRUint16 mask = 0;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> other(aOther);
|
|
|
|
do {
|
|
|
|
nsCOMPtr<nsIDOMNode> tmp(other);
|
|
|
|
tmp->GetParentNode(getter_AddRefs(other));
|
|
|
|
if (!other) {
|
|
|
|
// No parent. Check to see if we're at an attribute node.
|
|
|
|
PRUint16 nodeType = 0;
|
|
|
|
tmp->GetNodeType(&nodeType);
|
|
|
|
if (nodeType != nsIDOMNode::ATTRIBUTE_NODE) {
|
|
|
|
// If there is no common container node, then the order
|
|
|
|
// is based upon order between the root container of each
|
|
|
|
// node that is in no container. In this case, the result
|
|
|
|
// is disconnected and implementation-dependent.
|
2003-06-12 02:54:16 +00:00
|
|
|
mask |= (nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED |
|
|
|
|
nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
|
2002-12-04 05:18:39 +00:00
|
|
|
|
2002-05-14 01:28:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-12-04 05:18:39 +00:00
|
|
|
|
|
|
|
// If we are, let's get the owner element and continue up the tree
|
|
|
|
nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(tmp));
|
|
|
|
nsCOMPtr<nsIDOMElement> owner;
|
|
|
|
attr->GetOwnerElement(getter_AddRefs(owner));
|
|
|
|
other = do_QueryInterface(owner);
|
2002-05-14 01:28:17 +00:00
|
|
|
}
|
2002-12-04 05:18:39 +00:00
|
|
|
|
|
|
|
if (NS_STATIC_CAST(nsIDOMNode*, this) == other) {
|
|
|
|
// If the node being compared is contained by our node,
|
|
|
|
// then it follows it.
|
2003-06-12 02:54:16 +00:00
|
|
|
mask |= (nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY |
|
|
|
|
nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING);
|
2002-12-04 05:18:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (other);
|
2002-05-14 01:28:17 +00:00
|
|
|
|
|
|
|
*aReturn = mask;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::IsSameNode(nsIDOMNode* aOther,
|
|
|
|
PRBool* aReturn)
|
|
|
|
{
|
|
|
|
PRBool sameNode = PR_FALSE;
|
|
|
|
|
2002-12-04 05:18:39 +00:00
|
|
|
if (NS_STATIC_CAST(nsIDOMNode*, this) == aOther) {
|
2002-05-14 01:28:17 +00:00
|
|
|
sameNode = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aReturn = sameNode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-24 21:39:39 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
|
|
|
|
{
|
|
|
|
NS_NOTYETIMPLEMENTED("nsDocumentFragment::IsEqualNode()");
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::GetFeature(const nsAString& aFeature,
|
|
|
|
const nsAString& aVersion,
|
|
|
|
nsISupports** aReturn)
|
|
|
|
{
|
|
|
|
NS_NOTYETIMPLEMENTED("nsDocumentFragment::GetFeature()");
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::SetUserData(const nsAString& aKey,
|
|
|
|
nsIVariant* aData,
|
|
|
|
nsIDOMUserDataHandler* aHandler,
|
2005-10-27 14:09:23 +00:00
|
|
|
nsIVariant** aResult)
|
2003-06-24 21:39:39 +00:00
|
|
|
{
|
2005-10-27 14:09:23 +00:00
|
|
|
nsIDocument *document = GetOwnerDoc();
|
|
|
|
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
2003-06-24 21:39:39 +00:00
|
|
|
|
2005-10-27 14:09:23 +00:00
|
|
|
return document->SetUserData(NS_STATIC_CAST(nsIContent*, this), aKey, aData,
|
|
|
|
aHandler, aResult);
|
2003-06-24 21:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::GetUserData(const nsAString& aKey,
|
2005-10-27 14:09:23 +00:00
|
|
|
nsIVariant** aResult)
|
2003-06-24 21:39:39 +00:00
|
|
|
{
|
2005-10-27 14:09:23 +00:00
|
|
|
nsIDocument *document = GetOwnerDoc();
|
|
|
|
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
2003-06-24 21:39:39 +00:00
|
|
|
|
2005-10-27 14:09:23 +00:00
|
|
|
return document->GetUserData(NS_STATIC_CAST(nsIContent*, this), aKey,
|
|
|
|
aResult);
|
2003-06-24 21:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::GetTextContent(nsAString &aTextContent)
|
|
|
|
{
|
2005-06-01 13:59:38 +00:00
|
|
|
return nsNode3Tearoff::GetTextContent(this, aTextContent);
|
2003-06-24 21:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocumentFragment::SetTextContent(const nsAString& aTextContent)
|
|
|
|
{
|
2003-06-24 23:05:59 +00:00
|
|
|
return nsNode3Tearoff::SetTextContent(this, aTextContent);
|
2003-06-24 21:39:39 +00:00
|
|
|
}
|
|
|
|
|