Bug 1554951 [wpt PR 17043] - wake-lock: Fix invalid types test in wakelock-type.https...
[gecko.git] / dom / html / HTMLEmbedElement.h
blob93d38e13808960c234e085651f32e15d3246a6a1
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 #ifndef mozilla_dom_HTMLEmbedElement_h
8 #define mozilla_dom_HTMLEmbedElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 #include "nsObjectLoadingContent.h"
13 #include "nsGkAtoms.h"
14 #include "nsError.h"
16 namespace mozilla {
17 namespace dom {
19 class HTMLEmbedElement final : public nsGenericHTMLElement,
20 public nsObjectLoadingContent {
21 public:
22 explicit HTMLEmbedElement(
23 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
24 mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
26 // nsISupports
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLEmbedElement, embed)
29 virtual int32_t TabIndexDefault() override;
31 #ifdef XP_MACOSX
32 // EventTarget
33 NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override;
34 #endif
36 // EventTarget
37 virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
39 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
40 virtual void UnbindFromTree(bool aNullParent = true) override;
42 virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
43 int32_t* aTabIndex) override;
44 virtual IMEState GetDesiredIMEState() override;
46 virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
47 const nsAString& aValue,
48 nsIPrincipal* aMaybeScriptedPrincipal,
49 nsAttrValue& aResult) override;
50 virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
51 const override;
52 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
53 virtual EventStates IntrinsicState() const override;
54 virtual void DestroyContent() override;
56 // nsObjectLoadingContent
57 virtual uint32_t GetCapabilities() const override;
59 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
61 nsresult CopyInnerTo(HTMLEmbedElement* aDest);
63 void StartObjectLoad() { StartObjectLoad(true, false); }
65 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLEmbedElement,
66 nsGenericHTMLElement)
68 // WebIDL <embed> api
69 void GetAlign(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::align, aValue); }
70 void SetAlign(const nsAString& aValue, ErrorResult& aRv) {
71 SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
73 void GetHeight(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::height, aValue); }
74 void SetHeight(const nsAString& aValue, ErrorResult& aRv) {
75 SetHTMLAttr(nsGkAtoms::height, aValue, aRv);
77 void GetName(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
78 void SetName(const nsAString& aValue, ErrorResult& aRv) {
79 SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
81 void GetWidth(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::width, aValue); }
82 void SetWidth(const nsAString& aValue, ErrorResult& aRv) {
83 SetHTMLAttr(nsGkAtoms::width, aValue, aRv);
85 // WebIDL <embed> api
86 void GetSrc(DOMString& aValue) {
87 GetURIAttr(nsGkAtoms::src, nullptr, aValue);
89 void SetSrc(const nsAString& aValue, ErrorResult& aRv) {
90 SetHTMLAttr(nsGkAtoms::src, aValue, aRv);
92 void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
93 void SetType(const nsAString& aValue, ErrorResult& aRv) {
94 SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
96 Document* GetSVGDocument(nsIPrincipal& aSubjectPrincipal) {
97 return GetContentDocument(aSubjectPrincipal);
101 * Calls LoadObject with the correct arguments to start the plugin load.
103 void StartObjectLoad(bool aNotify, bool aForceLoad);
105 protected:
106 // Override for nsImageLoadingContent.
107 nsIContent* AsContent() override { return this; }
109 virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
110 const nsAttrValue* aValue,
111 const nsAttrValue* aOldValue,
112 nsIPrincipal* aSubjectPrincipal,
113 bool aNotify) override;
114 virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
115 const nsAttrValueOrString& aValue,
116 bool aNotify) override;
118 private:
119 ~HTMLEmbedElement();
121 nsContentPolicyType GetContentPolicyType() const override;
123 virtual JSObject* WrapNode(JSContext* aCx,
124 JS::Handle<JSObject*> aGivenProto) override;
126 static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
127 MappedDeclarations&);
130 * This function is called by AfterSetAttr and OnAttrSetButNotChanged.
131 * It will not be called if the value is being unset.
133 * @param aNamespaceID the namespace of the attr being set
134 * @param aName the localname of the attribute being set
135 * @param aNotify Whether we plan to notify document observers.
137 nsresult AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
138 bool aNotify);
141 } // namespace dom
142 } // namespace mozilla
144 #endif // mozilla_dom_HTMLEmbedElement_h