2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMDocumentFragment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
|
|
|
#include "nsGenericElement.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsDOMError.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsDOMString.h"
|
2012-05-18 01:29:38 -07:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-14 00:56:49 -07:00
|
|
|
class nsDocumentFragment : public nsGenericElement,
|
|
|
|
public nsIDOMDocumentFragment
|
2011-06-14 00:56:48 -07:00
|
|
|
{
|
|
|
|
public:
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2011-06-14 00:56:48 -07:00
|
|
|
// interface nsIDOMNode
|
2011-06-14 00:56:49 -07:00
|
|
|
NS_FORWARD_NSIDOMNODE(nsGenericElement::)
|
2011-06-14 00:56:48 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// interface nsIDOMDocumentFragment
|
2011-06-14 00:56:48 -07:00
|
|
|
// NS_DECL_NSIDOCUMENTFRAGMENT Empty
|
|
|
|
|
|
|
|
nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo);
|
|
|
|
virtual ~nsDocumentFragment()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIContent
|
|
|
|
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsAString& aValue, bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
|
|
|
|
}
|
|
|
|
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAString& aResult) const
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const
|
|
|
|
{
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsNodeOfType(PRUint32 aFlags) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
virtual nsXPCClassInfo* GetClassInfo();
|
|
|
|
|
2012-04-25 06:47:30 -07:00
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
|
|
|
|
2010-06-03 18:09:20 -07:00
|
|
|
virtual nsIAtom* DoGetID() const;
|
|
|
|
virtual nsIAtom *GetIDAttributeName() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
|
|
|
nsNodeInfoManager *aNodeInfoManager)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aNodeInfoManager);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2008-09-12 15:32:18 -07:00
|
|
|
nodeInfo = aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
|
2011-06-14 00:56:49 -07:00
|
|
|
nsnull, kNameSpaceID_None,
|
|
|
|
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
|
2008-09-25 15:46:52 -07:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
nsDocumentFragment *it = new nsDocumentFragment(nodeInfo.forget());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aInstancePtrResult = it);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
nsDocumentFragment::nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
|
2011-06-14 00:56:49 -07:00
|
|
|
: nsGenericElement(aNodeInfo)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-07 19:29:49 -07:00
|
|
|
ClearIsElement();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDocumentFragment::IsNodeOfType(PRUint32 aFlags) const
|
|
|
|
{
|
|
|
|
return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
|
|
|
|
}
|
|
|
|
|
2010-06-03 18:09:20 -07:00
|
|
|
nsIAtom*
|
|
|
|
nsDocumentFragment::DoGetID() const
|
|
|
|
{
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsDocumentFragment::GetIDAttributeName() const
|
|
|
|
{
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
DOMCI_NODE_DATA(DocumentFragment, nsDocumentFragment)
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// QueryInterface implementation for nsDocumentFragment
|
2012-05-18 01:29:38 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDocumentFragment)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDocumentFragment)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsINode)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
|
|
|
new nsNodeSupportsWeakRefTearoff(this))
|
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNodeSelector,
|
|
|
|
new nsNodeSelectorTearoff(this))
|
|
|
|
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
|
|
|
// same as nsINode (which nsIContent inherits), so if you change the
|
|
|
|
// below line, make sure nsNodeSH::PreCreate() still does the right
|
|
|
|
// thing!
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
2010-03-17 08:09:05 -07:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DocumentFragment)
|
2012-05-18 01:29:38 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDocumentFragment, nsGenericElement)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDocumentFragment, nsGenericElement)
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE(nsDocumentFragment)
|