Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=2 et : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_DocumentFragment_h__ |
michael@0 | 8 | #define mozilla_dom_DocumentFragment_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "mozilla/dom/FragmentOrElement.h" |
michael@0 | 12 | #include "nsIDOMDocumentFragment.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsINodeInfo; |
michael@0 | 15 | class nsIAtom; |
michael@0 | 16 | class nsAString; |
michael@0 | 17 | class nsIDocument; |
michael@0 | 18 | class nsIContent; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace dom { |
michael@0 | 22 | |
michael@0 | 23 | class Element; |
michael@0 | 24 | |
michael@0 | 25 | class DocumentFragment : public FragmentOrElement, |
michael@0 | 26 | public nsIDOMDocumentFragment |
michael@0 | 27 | { |
michael@0 | 28 | private: |
michael@0 | 29 | void Init() |
michael@0 | 30 | { |
michael@0 | 31 | NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == |
michael@0 | 32 | nsIDOMNode::DOCUMENT_FRAGMENT_NODE && |
michael@0 | 33 | mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName, |
michael@0 | 34 | kNameSpaceID_None), |
michael@0 | 35 | "Bad NodeType in aNodeInfo"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | public: |
michael@0 | 39 | using FragmentOrElement::GetFirstChild; |
michael@0 | 40 | using nsINode::QuerySelector; |
michael@0 | 41 | using nsINode::QuerySelectorAll; |
michael@0 | 42 | // Make sure bindings can see our superclass' protected GetElementById method. |
michael@0 | 43 | using nsINode::GetElementById; |
michael@0 | 44 | |
michael@0 | 45 | // nsISupports |
michael@0 | 46 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 47 | |
michael@0 | 48 | // interface nsIDOMNode |
michael@0 | 49 | NS_FORWARD_NSIDOMNODE_TO_NSINODE |
michael@0 | 50 | |
michael@0 | 51 | // interface nsIDOMDocumentFragment |
michael@0 | 52 | NS_DECL_NSIDOMDOCUMENTFRAGMENT |
michael@0 | 53 | |
michael@0 | 54 | DocumentFragment(already_AddRefed<nsINodeInfo>& aNodeInfo) |
michael@0 | 55 | : FragmentOrElement(aNodeInfo), mHost(nullptr) |
michael@0 | 56 | { |
michael@0 | 57 | Init(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | DocumentFragment(nsNodeInfoManager* aNodeInfoManager) |
michael@0 | 61 | : FragmentOrElement(aNodeInfoManager->GetNodeInfo( |
michael@0 | 62 | nsGkAtoms::documentFragmentNodeName, |
michael@0 | 63 | nullptr, kNameSpaceID_None, |
michael@0 | 64 | nsIDOMNode::DOCUMENT_FRAGMENT_NODE)), |
michael@0 | 65 | mHost(nullptr) |
michael@0 | 66 | { |
michael@0 | 67 | Init(); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | virtual ~DocumentFragment() |
michael@0 | 71 | { |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | // nsIContent |
michael@0 | 77 | nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, |
michael@0 | 78 | const nsAString& aValue, bool aNotify) |
michael@0 | 79 | { |
michael@0 | 80 | return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); |
michael@0 | 81 | } |
michael@0 | 82 | virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, |
michael@0 | 83 | nsIAtom* aPrefix, const nsAString& aValue, |
michael@0 | 84 | bool aNotify) MOZ_OVERRIDE |
michael@0 | 85 | { |
michael@0 | 86 | return NS_OK; |
michael@0 | 87 | } |
michael@0 | 88 | virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, |
michael@0 | 89 | bool aNotify) MOZ_OVERRIDE |
michael@0 | 90 | { |
michael@0 | 91 | return NS_OK; |
michael@0 | 92 | } |
michael@0 | 93 | virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const MOZ_OVERRIDE |
michael@0 | 94 | { |
michael@0 | 95 | return nullptr; |
michael@0 | 96 | } |
michael@0 | 97 | virtual uint32_t GetAttrCount() const MOZ_OVERRIDE |
michael@0 | 98 | { |
michael@0 | 99 | return 0; |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; |
michael@0 | 103 | |
michael@0 | 104 | virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } |
michael@0 | 105 | |
michael@0 | 106 | virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; |
michael@0 | 107 | virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE; |
michael@0 | 108 | |
michael@0 | 109 | virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
michael@0 | 110 | nsIContent* aBindingParent, |
michael@0 | 111 | bool aCompileEventHandlers) MOZ_OVERRIDE |
michael@0 | 112 | { |
michael@0 | 113 | NS_ASSERTION(false, "Trying to bind a fragment to a tree"); |
michael@0 | 114 | return NS_ERROR_NOT_IMPLEMENTED; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE |
michael@0 | 118 | { |
michael@0 | 119 | NS_ASSERTION(false, "Trying to unbind a fragment from a tree"); |
michael@0 | 120 | return; |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | virtual Element* GetNameSpaceElement() |
michael@0 | 124 | { |
michael@0 | 125 | return nullptr; |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | nsIContent* GetHost() const |
michael@0 | 129 | { |
michael@0 | 130 | return mHost; |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | void SetHost(nsIContent* aHost) |
michael@0 | 134 | { |
michael@0 | 135 | mHost = aHost; |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | static already_AddRefed<DocumentFragment> |
michael@0 | 139 | Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); |
michael@0 | 140 | |
michael@0 | 141 | #ifdef DEBUG |
michael@0 | 142 | virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE; |
michael@0 | 143 | virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE; |
michael@0 | 144 | #endif |
michael@0 | 145 | |
michael@0 | 146 | protected: |
michael@0 | 147 | nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; |
michael@0 | 148 | nsIContent* mHost; // Weak |
michael@0 | 149 | }; |
michael@0 | 150 | |
michael@0 | 151 | } // namespace dom |
michael@0 | 152 | } // namespace mozilla |
michael@0 | 153 | |
michael@0 | 154 | |
michael@0 | 155 | #endif // mozilla_dom_DocumentFragment_h__ |