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"
16 namespace mozilla::dom
{
18 class HTMLEmbedElement final
: public nsGenericHTMLElement
,
19 public nsObjectLoadingContent
{
21 explicit HTMLEmbedElement(
22 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
23 mozilla::dom::FromParser aFromParser
= mozilla::dom::NOT_FROM_PARSER
);
26 NS_DECL_ISUPPORTS_INHERITED
27 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLEmbedElement
, embed
)
29 bool AllowFullscreen() const {
30 // We don't need to check prefixed attributes because Flash does not support
32 return IsRewrittenYoutubeEmbed() && GetBoolAttr(nsGkAtoms::allowfullscreen
);
36 void AsyncEventRunning(AsyncEventDispatcher
* aEvent
) override
;
38 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
39 void UnbindFromTree(bool aNullParent
= true) override
;
41 bool IsHTMLFocusable(bool aWithMouse
, bool* aIsFocusable
,
42 int32_t* aTabIndex
) override
;
44 int32_t TabIndexDefault() override
;
46 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
47 const nsAString
& aValue
,
48 nsIPrincipal
* aMaybeScriptedPrincipal
,
49 nsAttrValue
& aResult
) override
;
50 nsMapRuleToAttributesFunc
GetAttributeMappingFunction() const override
;
51 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
52 void DestroyContent() override
;
54 // nsObjectLoadingContent
55 uint32_t GetCapabilities() const override
;
57 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
59 nsresult
CopyInnerTo(HTMLEmbedElement
* aDest
);
61 void StartObjectLoad() { StartObjectLoad(true, false); }
63 virtual bool IsInteractiveHTMLContent() const override
{ return true; }
65 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEmbedElement
,
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
);
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
);
106 // Override for nsImageLoadingContent.
107 nsIContent
* AsContent() override
{ return this; }
109 void AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
110 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
111 nsIPrincipal
* aSubjectPrincipal
, bool aNotify
) override
;
112 void OnAttrSetButNotChanged(int32_t aNamespaceID
, nsAtom
* aName
,
113 const nsAttrValueOrString
& aValue
,
114 bool aNotify
) override
;
119 nsContentPolicyType
GetContentPolicyType() const override
;
121 JSObject
* WrapNode(JSContext
*, JS::Handle
<JSObject
*> aGivenProto
) override
;
123 static void MapAttributesIntoRule(MappedDeclarationsBuilder
&);
126 * This function is called by AfterSetAttr and OnAttrSetButNotChanged.
127 * It will not be called if the value is being unset.
129 * @param aNamespaceID the namespace of the attr being set
130 * @param aName the localname of the attribute being set
131 * @param aNotify Whether we plan to notify document observers.
133 void AfterMaybeChangeAttr(int32_t aNamespaceID
, nsAtom
* aName
, bool aNotify
);
136 } // namespace mozilla::dom
138 #endif // mozilla_dom_HTMLEmbedElement_h