Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / content / base / src / Attr.h
blob756c260df65e8dc9fbb8309456e44fb2cbfd4da1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Implementation of DOM Core's nsIDOMAttr node.
8 */
10 #ifndef mozilla_dom_Attr_h
11 #define mozilla_dom_Attr_h
13 #include "mozilla/Attributes.h"
14 #include "nsIAttribute.h"
15 #include "nsIDOMAttr.h"
16 #include "nsIDOMText.h"
17 #include "nsIDOMNodeList.h"
18 #include "nsString.h"
19 #include "nsCOMPtr.h"
20 #include "nsCycleCollectionParticipant.h"
21 #include "nsStubMutationObserver.h"
23 class nsIDocument;
25 namespace mozilla {
26 class EventChainPreVisitor;
27 namespace dom {
29 // Attribute helper class used to wrap up an attribute with a dom
30 // object that implements nsIDOMAttr and nsIDOMNode
31 class Attr MOZ_FINAL : public nsIAttribute,
32 public nsIDOMAttr
34 virtual ~Attr() {}
36 public:
37 Attr(nsDOMAttributeMap* aAttrMap,
38 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
39 const nsAString& aValue,
40 bool aNsAware);
42 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
44 // nsIDOMNode interface
45 NS_FORWARD_NSIDOMNODE_TO_NSINODE
46 virtual void GetTextContentInternal(nsAString& aTextContent,
47 ErrorResult& aError) MOZ_OVERRIDE;
48 virtual void SetTextContentInternal(const nsAString& aTextContent,
49 ErrorResult& aError) MOZ_OVERRIDE;
50 virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE;
51 virtual void SetNodeValueInternal(const nsAString& aNodeValue,
52 ErrorResult& aError) MOZ_OVERRIDE;
54 // nsIDOMAttr interface
55 NS_DECL_NSIDOMATTR
57 virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
59 // nsIAttribute interface
60 void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
61 Element* GetElement() const;
62 nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
64 // nsINode interface
65 virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
66 virtual uint32_t GetChildCount() const MOZ_OVERRIDE;
67 virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
68 virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE;
69 virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
70 virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
71 bool aNotify) MOZ_OVERRIDE;
72 virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
73 virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
74 virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE;
76 static void Initialize();
77 static void Shutdown();
79 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
80 nsIAttribute)
82 virtual nsIDOMNode* AsDOMNode() { return this; }
84 // WebIDL
85 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
87 // XPCOM GetName() is OK
88 // XPCOM GetValue() is OK
90 void SetValue(const nsAString& aValue, ErrorResult& aRv);
92 bool Specified() const;
94 // XPCOM GetNamespaceURI() is OK
95 // XPCOM GetPrefix() is OK
96 // XPCOM GetLocalName() is OK
98 Element* GetOwnerElement(ErrorResult& aRv);
100 protected:
101 virtual Element* GetNameSpaceElement()
103 return GetElement();
106 static bool sInitialized;
108 private:
109 already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
111 nsString mValue;
114 } // namespace dom
115 } // namespace mozilla
117 #endif /* mozilla_dom_Attr_h */