michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_DocumentFragment_h__ michael@0: #define mozilla_dom_DocumentFragment_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/dom/FragmentOrElement.h" michael@0: #include "nsIDOMDocumentFragment.h" michael@0: michael@0: class nsINodeInfo; michael@0: class nsIAtom; michael@0: class nsAString; michael@0: class nsIDocument; michael@0: class nsIContent; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class Element; michael@0: michael@0: class DocumentFragment : public FragmentOrElement, michael@0: public nsIDOMDocumentFragment michael@0: { michael@0: private: michael@0: void Init() michael@0: { michael@0: NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == michael@0: nsIDOMNode::DOCUMENT_FRAGMENT_NODE && michael@0: mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName, michael@0: kNameSpaceID_None), michael@0: "Bad NodeType in aNodeInfo"); michael@0: } michael@0: michael@0: public: michael@0: using FragmentOrElement::GetFirstChild; michael@0: using nsINode::QuerySelector; michael@0: using nsINode::QuerySelectorAll; michael@0: // Make sure bindings can see our superclass' protected GetElementById method. michael@0: using nsINode::GetElementById; michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // interface nsIDOMNode michael@0: NS_FORWARD_NSIDOMNODE_TO_NSINODE michael@0: michael@0: // interface nsIDOMDocumentFragment michael@0: NS_DECL_NSIDOMDOCUMENTFRAGMENT michael@0: michael@0: DocumentFragment(already_AddRefed& aNodeInfo) michael@0: : FragmentOrElement(aNodeInfo), mHost(nullptr) michael@0: { michael@0: Init(); michael@0: } michael@0: michael@0: DocumentFragment(nsNodeInfoManager* aNodeInfoManager) michael@0: : FragmentOrElement(aNodeInfoManager->GetNodeInfo( michael@0: nsGkAtoms::documentFragmentNodeName, michael@0: nullptr, kNameSpaceID_None, michael@0: nsIDOMNode::DOCUMENT_FRAGMENT_NODE)), michael@0: mHost(nullptr) michael@0: { michael@0: Init(); michael@0: } michael@0: michael@0: virtual ~DocumentFragment() michael@0: { michael@0: } michael@0: michael@0: virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; michael@0: michael@0: // nsIContent michael@0: nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, michael@0: const nsAString& aValue, bool aNotify) michael@0: { michael@0: return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); michael@0: } michael@0: virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, michael@0: nsIAtom* aPrefix, const nsAString& aValue, michael@0: bool aNotify) MOZ_OVERRIDE michael@0: { michael@0: return NS_OK; michael@0: } michael@0: virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, michael@0: bool aNotify) MOZ_OVERRIDE michael@0: { michael@0: return NS_OK; michael@0: } michael@0: virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const MOZ_OVERRIDE michael@0: { michael@0: return nullptr; michael@0: } michael@0: virtual uint32_t GetAttrCount() const MOZ_OVERRIDE michael@0: { michael@0: return 0; michael@0: } michael@0: michael@0: virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; michael@0: michael@0: virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } michael@0: michael@0: virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; michael@0: virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, michael@0: nsIContent* aBindingParent, michael@0: bool aCompileEventHandlers) MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(false, "Trying to bind a fragment to a tree"); michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: } michael@0: michael@0: virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(false, "Trying to unbind a fragment from a tree"); michael@0: return; michael@0: } michael@0: michael@0: virtual Element* GetNameSpaceElement() michael@0: { michael@0: return nullptr; michael@0: } michael@0: michael@0: nsIContent* GetHost() const michael@0: { michael@0: return mHost; michael@0: } michael@0: michael@0: void SetHost(nsIContent* aHost) michael@0: { michael@0: mHost = aHost; michael@0: } michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); michael@0: michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE; michael@0: virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: protected: michael@0: nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; michael@0: nsIContent* mHost; // Weak michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: michael@0: #endif // mozilla_dom_DocumentFragment_h__