Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / dom / base / Attr.h
blobc921221fe4735ac379ff2b405533c1d7987e4d21
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * Implementation of DOM Core's Attr node.
9 */
11 #ifndef mozilla_dom_Attr_h
12 #define mozilla_dom_Attr_h
14 #include "mozilla/Attributes.h"
15 #include "nsDOMAttributeMap.h"
16 #include "nsINode.h"
17 #include "nsString.h"
18 #include "nsCOMPtr.h"
19 #include "nsCycleCollectionParticipant.h"
20 #include "nsStubMutationObserver.h"
22 namespace mozilla {
23 class EventChainPreVisitor;
24 namespace dom {
26 class Document;
28 // Attribute helper class used to wrap up an attribute with a dom
29 // object that implements the DOM Attr interface.
30 class Attr final : public nsINode {
31 virtual ~Attr() = default;
33 public:
34 Attr(nsDOMAttributeMap* aAttrMap, already_AddRefed<dom::NodeInfo>&& aNodeInfo,
35 const nsAString& aValue);
37 NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL_DELETECYCLECOLLECTABLE
39 NS_DECL_DOMARENA_DESTROY
41 NS_IMPL_FROMNODE_HELPER(Attr, IsAttr())
43 // nsINode interface
44 virtual void GetTextContentInternal(nsAString& aTextContent,
45 OOMReporter& aError) override;
46 virtual void SetTextContentInternal(const nsAString& aTextContent,
47 nsIPrincipal* aSubjectPrincipal,
48 ErrorResult& aError) override;
49 virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
50 virtual void SetNodeValueInternal(const nsAString& aNodeValue,
51 ErrorResult& aError) override;
53 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
55 void ConstructUbiNode(void* storage) override;
57 nsDOMAttributeMap* GetMap() { return mAttrMap; }
59 void SetMap(nsDOMAttributeMap* aMap);
61 Element* GetElement() const;
63 /**
64 * Called when our ownerElement is moved into a new document.
65 * Updates the nodeinfo of this node.
67 nsresult SetOwnerDocument(Document* aDocument);
69 // nsINode interface
70 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
71 nsIURI* GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
73 static void Initialize();
74 static void Shutdown();
76 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS(Attr)
78 // WebIDL
79 virtual JSObject* WrapNode(JSContext* aCx,
80 JS::Handle<JSObject*> aGivenProto) override;
82 void GetName(nsAString& aName);
83 void GetValue(nsAString& aValue);
85 void SetValue(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal,
86 ErrorResult& aRv);
87 void SetValue(const nsAString& aValue, ErrorResult& aRv);
89 bool Specified() const;
91 // XPCOM GetNamespaceURI() is OK
92 // XPCOM GetPrefix() is OK
93 // XPCOM GetLocalName() is OK
95 Element* GetOwnerElement();
97 protected:
98 virtual Element* GetNameSpaceElement() override { return GetElement(); }
100 static bool sInitialized;
102 private:
103 RefPtr<nsDOMAttributeMap> mAttrMap;
104 nsString mValue;
107 } // namespace dom
108 } // namespace mozilla
110 #endif /* mozilla_dom_Attr_h */