Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_HTMLIFrameElement_h
8 : #define mozilla_dom_HTMLIFrameElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsGenericHTMLFrameElement.h"
12 : #include "nsIDOMHTMLIFrameElement.h"
13 : #include "nsDOMTokenList.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class HTMLIFrameElement final : public nsGenericHTMLFrameElement
19 : , public nsIDOMHTMLIFrameElement
20 : {
21 : public:
22 : explicit HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
23 : FromParser aFromParser = NOT_FROM_PARSER);
24 :
25 4 : NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLIFrameElement, iframe)
26 :
27 : // nsISupports
28 : NS_DECL_ISUPPORTS_INHERITED
29 :
30 : // Element
31 0 : virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
32 : {
33 0 : return true;
34 : }
35 :
36 : // nsIDOMHTMLIFrameElement
37 : NS_DECL_NSIDOMHTMLIFRAMEELEMENT
38 :
39 : // nsIContent
40 : virtual bool ParseAttribute(int32_t aNamespaceID,
41 : nsIAtom* aAttribute,
42 : const nsAString& aValue,
43 : nsAttrValue& aResult) override;
44 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
45 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
46 :
47 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
48 : bool aPreallocateChildren) const override;
49 :
50 : uint32_t GetSandboxFlags();
51 :
52 : // Web IDL binding methods
53 : // The XPCOM GetSrc is fine for our purposes
54 0 : void SetSrc(const nsAString& aSrc, ErrorResult& aError)
55 : {
56 0 : SetHTMLAttr(nsGkAtoms::src, aSrc, aError);
57 0 : }
58 0 : void GetSrcdoc(DOMString& aSrcdoc)
59 : {
60 0 : GetHTMLAttr(nsGkAtoms::srcdoc, aSrcdoc);
61 0 : }
62 0 : void SetSrcdoc(const nsAString& aSrcdoc, ErrorResult& aError)
63 : {
64 0 : SetHTMLAttr(nsGkAtoms::srcdoc, aSrcdoc, aError);
65 0 : }
66 0 : void GetName(DOMString& aName)
67 : {
68 0 : GetHTMLAttr(nsGkAtoms::name, aName);
69 0 : }
70 0 : void SetName(const nsAString& aName, ErrorResult& aError)
71 : {
72 0 : SetHTMLAttr(nsGkAtoms::name, aName, aError);
73 0 : }
74 0 : nsDOMTokenList* Sandbox()
75 : {
76 0 : return GetTokenList(nsGkAtoms::sandbox, sSupportedSandboxTokens);
77 : }
78 0 : bool AllowFullscreen() const
79 : {
80 0 : return GetBoolAttr(nsGkAtoms::allowfullscreen);
81 : }
82 0 : void SetAllowFullscreen(bool aAllow, ErrorResult& aError)
83 : {
84 0 : SetHTMLBoolAttr(nsGkAtoms::allowfullscreen, aAllow, aError);
85 0 : }
86 0 : void GetWidth(DOMString& aWidth)
87 : {
88 0 : GetHTMLAttr(nsGkAtoms::width, aWidth);
89 0 : }
90 0 : void SetWidth(const nsAString& aWidth, ErrorResult& aError)
91 : {
92 0 : SetHTMLAttr(nsGkAtoms::width, aWidth, aError);
93 0 : }
94 0 : void GetHeight(DOMString& aHeight)
95 : {
96 0 : GetHTMLAttr(nsGkAtoms::height, aHeight);
97 0 : }
98 0 : void SetHeight(const nsAString& aHeight, ErrorResult& aError)
99 : {
100 0 : SetHTMLAttr(nsGkAtoms::height, aHeight, aError);
101 0 : }
102 : using nsGenericHTMLFrameElement::GetContentDocument;
103 : using nsGenericHTMLFrameElement::GetContentWindow;
104 0 : void GetAlign(DOMString& aAlign)
105 : {
106 0 : GetHTMLAttr(nsGkAtoms::align, aAlign);
107 0 : }
108 0 : void SetAlign(const nsAString& aAlign, ErrorResult& aError)
109 : {
110 0 : SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
111 0 : }
112 0 : void GetScrolling(DOMString& aScrolling)
113 : {
114 0 : GetHTMLAttr(nsGkAtoms::scrolling, aScrolling);
115 0 : }
116 0 : void SetScrolling(const nsAString& aScrolling, ErrorResult& aError)
117 : {
118 0 : SetHTMLAttr(nsGkAtoms::scrolling, aScrolling, aError);
119 0 : }
120 0 : void GetFrameBorder(DOMString& aFrameBorder)
121 : {
122 0 : GetHTMLAttr(nsGkAtoms::frameborder, aFrameBorder);
123 0 : }
124 0 : void SetFrameBorder(const nsAString& aFrameBorder, ErrorResult& aError)
125 : {
126 0 : SetHTMLAttr(nsGkAtoms::frameborder, aFrameBorder, aError);
127 0 : }
128 : // The XPCOM GetLongDesc is fine
129 0 : void SetLongDesc(const nsAString& aLongDesc, ErrorResult& aError)
130 : {
131 0 : SetHTMLAttr(nsGkAtoms::longdesc, aLongDesc, aError);
132 0 : }
133 0 : void GetMarginWidth(DOMString& aMarginWidth)
134 : {
135 0 : GetHTMLAttr(nsGkAtoms::marginwidth, aMarginWidth);
136 0 : }
137 0 : void SetMarginWidth(const nsAString& aMarginWidth, ErrorResult& aError)
138 : {
139 0 : SetHTMLAttr(nsGkAtoms::marginwidth, aMarginWidth, aError);
140 0 : }
141 0 : void GetMarginHeight(DOMString& aMarginHeight)
142 : {
143 0 : GetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight);
144 0 : }
145 0 : void SetMarginHeight(const nsAString& aMarginHeight, ErrorResult& aError)
146 : {
147 0 : SetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight, aError);
148 0 : }
149 0 : void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError)
150 : {
151 0 : SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError);
152 0 : }
153 0 : void GetReferrerPolicy(nsAString& aReferrer)
154 : {
155 0 : GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
156 0 : }
157 : nsIDocument*
158 0 : GetSVGDocument(nsIPrincipal& aSubjectPrincipal)
159 : {
160 0 : return GetContentDocument(aSubjectPrincipal);
161 : }
162 0 : bool Mozbrowser() const
163 : {
164 0 : return GetBoolAttr(nsGkAtoms::mozbrowser);
165 : }
166 0 : void SetMozbrowser(bool aAllow, ErrorResult& aError)
167 : {
168 0 : SetHTMLBoolAttr(nsGkAtoms::mozbrowser, aAllow, aError);
169 0 : }
170 : using nsGenericHTMLFrameElement::SetMozbrowser;
171 : // nsGenericHTMLFrameElement::GetFrameLoader is fine
172 : // nsGenericHTMLFrameElement::GetAppManifestURL is fine
173 :
174 : // The fullscreen flag is set to true only when requestFullscreen is
175 : // explicitly called on this <iframe> element. In case this flag is
176 : // set, the fullscreen state of this element will not be reverted
177 : // automatically when its subdocument exits fullscreen.
178 0 : bool FullscreenFlag() const { return mFullscreenFlag; }
179 0 : void SetFullscreenFlag(bool aValue) { mFullscreenFlag = aValue; }
180 :
181 : protected:
182 : virtual ~HTMLIFrameElement();
183 :
184 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
185 :
186 : virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
187 : const nsAttrValue* aValue,
188 : const nsAttrValue* aOldValue,
189 : bool aNotify) override;
190 : virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName,
191 : const nsAttrValueOrString& aValue,
192 : bool aNotify) override;
193 :
194 : private:
195 : static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
196 : GenericSpecifiedValues* aGenericData);
197 :
198 : static const DOMTokenListSupportedToken sSupportedSandboxTokens[];
199 :
200 : /**
201 : * This function is called by AfterSetAttr and OnAttrSetButNotChanged.
202 : * This function will be called by AfterSetAttr whether the attribute is being
203 : * set or unset.
204 : *
205 : * @param aNamespaceID the namespace of the attr being set
206 : * @param aName the localname of the attribute being set
207 : * @param aNotify Whether we plan to notify document observers.
208 : */
209 : void AfterMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName, bool aNotify);
210 : };
211 :
212 : } // namespace dom
213 : } // namespace mozilla
214 :
215 : #endif
|