2012-11-14 10:05:41 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et :
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_DocumentFragment_h__
|
|
|
|
#define mozilla_dom_DocumentFragment_h__
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-11-14 10:05:41 -08:00
|
|
|
#include "mozilla/dom/FragmentOrElement.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
|
|
|
|
|
|
|
class nsINodeInfo;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsAString;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIContent;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Element;
|
2013-03-26 00:15:23 -07:00
|
|
|
class HTMLTemplateElement;
|
2012-11-14 10:05:41 -08:00
|
|
|
|
2013-07-11 14:26:54 -07:00
|
|
|
class DocumentFragment MOZ_FINAL : public FragmentOrElement,
|
|
|
|
public nsIDOMDocumentFragment
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
2013-04-10 07:15:54 -07:00
|
|
|
private:
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
|
|
|
|
nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
|
|
|
|
kNameSpaceID_None),
|
|
|
|
"Bad NodeType in aNodeInfo");
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-07-08 05:09:18 -07:00
|
|
|
using FragmentOrElement::GetFirstChild;
|
|
|
|
using nsINode::QuerySelector;
|
|
|
|
using nsINode::QuerySelectorAll;
|
2013-11-01 12:39:25 -07:00
|
|
|
// Make sure bindings can see our superclass' protected GetElementById method.
|
|
|
|
using nsINode::GetElementById;
|
2013-07-08 05:09:18 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// interface nsIDOMNode
|
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
|
|
|
|
|
|
|
// interface nsIDOMDocumentFragment
|
|
|
|
NS_DECL_NSIDOMDOCUMENTFRAGMENT
|
|
|
|
|
2013-04-10 07:15:54 -07:00
|
|
|
DocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
|
|
|
|
: FragmentOrElement(aNodeInfo), mHost(nullptr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
|
|
|
|
: FragmentOrElement(aNodeInfoManager->GetNodeInfo(
|
|
|
|
nsGkAtoms::documentFragmentNodeName,
|
|
|
|
nullptr, kNameSpaceID_None,
|
|
|
|
nsIDOMNode::DOCUMENT_FRAGMENT_NODE)),
|
|
|
|
mHost(nullptr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
virtual ~DocumentFragment()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2012-12-24 19:35:19 -08:00
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
// nsIContent
|
|
|
|
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAString& aValue, bool aNotify)
|
|
|
|
{
|
|
|
|
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
|
|
|
|
}
|
|
|
|
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual uint32_t GetAttrCount() const MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
|
2012-11-14 10:05:41 -08:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }
|
2012-11-14 10:05:41 -08:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual nsIAtom* DoGetID() const MOZ_OVERRIDE;
|
|
|
|
virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE;
|
2012-11-14 10:05:41 -08:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(false, "Trying to bind a fragment to a tree");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE
|
2012-11-14 10:05:41 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Element* GetNameSpaceElement()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-03-26 00:15:23 -07:00
|
|
|
HTMLTemplateElement* GetHost() const
|
|
|
|
{
|
|
|
|
return mHost;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHost(HTMLTemplateElement* aHost)
|
|
|
|
{
|
|
|
|
mHost = aHost;
|
|
|
|
}
|
|
|
|
|
2013-05-23 03:59:00 -07:00
|
|
|
static already_AddRefed<DocumentFragment>
|
|
|
|
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
#ifdef DEBUG
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE;
|
|
|
|
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE;
|
2012-11-14 10:05:41 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2013-05-29 13:43:41 -07:00
|
|
|
nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2013-03-26 00:15:23 -07:00
|
|
|
mozilla::dom::HTMLTemplateElement* mHost; // Weak
|
2012-11-14 10:05:41 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
|
|
|
#endif // mozilla_dom_DocumentFragment_h__
|