Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / html / HTMLEmbedElement.h
blob8e7bcd4166bbcefe60540acfe1a7022a8de034db
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::dom {
18 class HTMLEmbedElement final : public nsGenericHTMLElement,
19 public nsObjectLoadingContent {
20 public:
21 explicit HTMLEmbedElement(
22 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
23 mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
25 // nsISupports
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
31 // them.
32 return IsRewrittenYoutubeEmbed() && GetBoolAttr(nsGkAtoms::allowfullscreen);
35 // nsObjectLoadingContent
36 const Element* AsElement() const final { return this; }
38 nsresult BindToTree(BindContext&, nsINode& aParent) override;
39 void UnbindFromTree(UnbindContext&) 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,
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 void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
107 const nsAttrValue* aValue, const nsAttrValue* aOldValue,
108 nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
109 void OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
110 const nsAttrValueOrString& aValue,
111 bool aNotify) override;
113 private:
114 ~HTMLEmbedElement();
116 nsContentPolicyType GetContentPolicyType() const override;
118 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
120 static void MapAttributesIntoRule(MappedDeclarationsBuilder&);
123 * This function is called by AfterSetAttr and OnAttrSetButNotChanged.
124 * It will not be called if the value is being unset.
126 * @param aNamespaceID the namespace of the attr being set
127 * @param aName the localname of the attribute being set
128 * @param aNotify Whether we plan to notify document observers.
130 void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, bool aNotify);
133 } // namespace mozilla::dom
135 #endif // mozilla_dom_HTMLEmbedElement_h