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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * Implementation of DOM Core's nsIDOMAttr node. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | #ifndef mozilla_dom_Attr_h |
michael@0 | 11 | #define mozilla_dom_Attr_h |
michael@0 | 12 | |
michael@0 | 13 | #include "mozilla/Attributes.h" |
michael@0 | 14 | #include "nsIAttribute.h" |
michael@0 | 15 | #include "nsIDOMAttr.h" |
michael@0 | 16 | #include "nsIDOMText.h" |
michael@0 | 17 | #include "nsIDOMNodeList.h" |
michael@0 | 18 | #include "nsString.h" |
michael@0 | 19 | #include "nsCOMPtr.h" |
michael@0 | 20 | #include "nsINodeInfo.h" |
michael@0 | 21 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 22 | #include "nsStubMutationObserver.h" |
michael@0 | 23 | #include "nsIDocument.h" |
michael@0 | 24 | |
michael@0 | 25 | namespace mozilla { |
michael@0 | 26 | class EventChainPreVisitor; |
michael@0 | 27 | namespace dom { |
michael@0 | 28 | |
michael@0 | 29 | // Attribute helper class used to wrap up an attribute with a dom |
michael@0 | 30 | // object that implements nsIDOMAttr and nsIDOMNode |
michael@0 | 31 | class Attr MOZ_FINAL : public nsIAttribute, |
michael@0 | 32 | public nsIDOMAttr |
michael@0 | 33 | { |
michael@0 | 34 | public: |
michael@0 | 35 | Attr(nsDOMAttributeMap* aAttrMap, |
michael@0 | 36 | already_AddRefed<nsINodeInfo>&& aNodeInfo, |
michael@0 | 37 | const nsAString& aValue, |
michael@0 | 38 | bool aNsAware); |
michael@0 | 39 | virtual ~Attr() {} |
michael@0 | 40 | |
michael@0 | 41 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 42 | |
michael@0 | 43 | // nsIDOMNode interface |
michael@0 | 44 | NS_FORWARD_NSIDOMNODE_TO_NSINODE |
michael@0 | 45 | virtual void GetTextContentInternal(nsAString& aTextContent) MOZ_OVERRIDE; |
michael@0 | 46 | virtual void SetTextContentInternal(const nsAString& aTextContent, |
michael@0 | 47 | ErrorResult& aError) MOZ_OVERRIDE; |
michael@0 | 48 | virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE; |
michael@0 | 49 | virtual void SetNodeValueInternal(const nsAString& aNodeValue, |
michael@0 | 50 | ErrorResult& aError) MOZ_OVERRIDE; |
michael@0 | 51 | |
michael@0 | 52 | // nsIDOMAttr interface |
michael@0 | 53 | NS_DECL_NSIDOMATTR |
michael@0 | 54 | |
michael@0 | 55 | virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; |
michael@0 | 56 | |
michael@0 | 57 | // nsIAttribute interface |
michael@0 | 58 | void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE; |
michael@0 | 59 | Element* GetElement() const; |
michael@0 | 60 | nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | // nsINode interface |
michael@0 | 63 | virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; |
michael@0 | 64 | virtual uint32_t GetChildCount() const MOZ_OVERRIDE; |
michael@0 | 65 | virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 66 | virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE; |
michael@0 | 67 | virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE; |
michael@0 | 68 | virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, |
michael@0 | 69 | bool aNotify) MOZ_OVERRIDE; |
michael@0 | 70 | virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE; |
michael@0 | 71 | virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; |
michael@0 | 72 | virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE; |
michael@0 | 73 | |
michael@0 | 74 | static void Initialize(); |
michael@0 | 75 | static void Shutdown(); |
michael@0 | 76 | |
michael@0 | 77 | NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr, |
michael@0 | 78 | nsIAttribute) |
michael@0 | 79 | |
michael@0 | 80 | virtual nsIDOMNode* AsDOMNode() { return this; } |
michael@0 | 81 | |
michael@0 | 82 | // WebIDL |
michael@0 | 83 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 84 | |
michael@0 | 85 | // XPCOM GetName() is OK |
michael@0 | 86 | // XPCOM GetValue() is OK |
michael@0 | 87 | |
michael@0 | 88 | void SetValue(const nsAString& aValue, ErrorResult& aRv); |
michael@0 | 89 | |
michael@0 | 90 | bool Specified() const; |
michael@0 | 91 | |
michael@0 | 92 | // XPCOM GetNamespaceURI() is OK |
michael@0 | 93 | // XPCOM GetPrefix() is OK |
michael@0 | 94 | // XPCOM GetLocalName() is OK |
michael@0 | 95 | |
michael@0 | 96 | Element* GetOwnerElement(ErrorResult& aRv); |
michael@0 | 97 | |
michael@0 | 98 | protected: |
michael@0 | 99 | virtual Element* GetNameSpaceElement() |
michael@0 | 100 | { |
michael@0 | 101 | return GetElement(); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | static bool sInitialized; |
michael@0 | 105 | |
michael@0 | 106 | private: |
michael@0 | 107 | already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent); |
michael@0 | 108 | |
michael@0 | 109 | nsString mValue; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | } // namespace dom |
michael@0 | 113 | } // namespace mozilla |
michael@0 | 114 | |
michael@0 | 115 | #endif /* mozilla_dom_Attr_h */ |