2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-06-13 02:01:25 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-02-23 04:59:26 +04:00
|
|
|
#ifndef mozilla_dom_HTMLIFrameElement_h
|
|
|
|
#define mozilla_dom_HTMLIFrameElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2021-01-14 14:15:22 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-06-13 02:01:25 +04:00
|
|
|
#include "nsGenericHTMLFrameElement.h"
|
2016-02-12 01:50:42 +03:00
|
|
|
#include "nsDOMTokenList.h"
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2013-02-23 04:59:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2021-01-14 14:15:22 +03:00
|
|
|
class FeaturePolicy;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
|
2012-06-13 02:01:25 +04:00
|
|
|
public:
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit HTMLIFrameElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2014-09-02 04:49:25 +04:00
|
|
|
FromParser aFromParser = NOT_FROM_PARSER);
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLIFrameElement, iframe)
|
2012-09-26 18:17:51 +04:00
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
// nsISupports
|
2018-10-12 10:36:33 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLIFrameElement,
|
|
|
|
nsGenericHTMLFrameElement)
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
// Element
|
2020-04-28 14:22:32 +03:00
|
|
|
virtual bool IsInteractiveHTMLContent() const override { return true; }
|
2015-01-20 23:39:28 +03:00
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
// nsIContent
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
2012-06-13 02:01:25 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
|
|
|
|
const override;
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2020-01-24 22:03:10 +03:00
|
|
|
void BindToBrowsingContext(BrowsingContext* aBrowsingContext);
|
|
|
|
|
2018-10-01 09:09:44 +03:00
|
|
|
uint32_t GetSandboxFlags() const;
|
2012-08-20 22:34:32 +04:00
|
|
|
|
2013-02-27 19:38:32 +04:00
|
|
|
// Web IDL binding methods
|
2017-12-06 00:03:18 +03:00
|
|
|
void GetSrc(nsString& aSrc) const {
|
2017-10-05 06:41:24 +03:00
|
|
|
GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
|
|
|
|
}
|
2017-12-21 01:43:18 +03:00
|
|
|
void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal,
|
|
|
|
ErrorResult& aError) {
|
2017-10-05 08:59:44 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aError);
|
2013-02-27 19:38:32 +04:00
|
|
|
}
|
2013-06-29 07:13:23 +04:00
|
|
|
void GetSrcdoc(DOMString& aSrcdoc) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::srcdoc, aSrcdoc);
|
|
|
|
}
|
|
|
|
void SetSrcdoc(const nsAString& aSrcdoc, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::srcdoc, aSrcdoc, aError);
|
|
|
|
}
|
2013-02-27 19:38:32 +04:00
|
|
|
void GetName(DOMString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
|
|
|
|
void SetName(const nsAString& aName, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
|
|
|
}
|
2016-02-12 01:50:42 +03:00
|
|
|
nsDOMTokenList* Sandbox() {
|
2019-10-11 07:09:40 +03:00
|
|
|
if (!mSandbox) {
|
|
|
|
mSandbox =
|
|
|
|
new nsDOMTokenList(this, nsGkAtoms::sandbox, sSupportedSandboxTokens);
|
|
|
|
}
|
|
|
|
return mSandbox;
|
2013-02-27 19:38:32 +04:00
|
|
|
}
|
2020-06-09 00:42:48 +03:00
|
|
|
|
2020-08-12 13:57:04 +03:00
|
|
|
bool AllowFullscreen() const {
|
2013-02-27 19:38:32 +04:00
|
|
|
return GetBoolAttr(nsGkAtoms::allowfullscreen);
|
|
|
|
}
|
2020-06-09 00:42:48 +03:00
|
|
|
|
2020-08-12 13:57:04 +03:00
|
|
|
void SetAllowFullscreen(bool aAllow, ErrorResult& aError) {
|
2013-02-27 19:38:32 +04:00
|
|
|
SetHTMLBoolAttr(nsGkAtoms::allowfullscreen, aAllow, aError);
|
|
|
|
}
|
2020-06-09 00:42:48 +03:00
|
|
|
|
2013-02-27 19:38:32 +04:00
|
|
|
void GetWidth(DOMString& aWidth) { GetHTMLAttr(nsGkAtoms::width, aWidth); }
|
|
|
|
void SetWidth(const nsAString& aWidth, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::width, aWidth, aError);
|
|
|
|
}
|
|
|
|
void GetHeight(DOMString& aHeight) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::height, aHeight);
|
|
|
|
}
|
|
|
|
void SetHeight(const nsAString& aHeight, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::height, aHeight, aError);
|
|
|
|
}
|
|
|
|
using nsGenericHTMLFrameElement::GetContentDocument;
|
|
|
|
using nsGenericHTMLFrameElement::GetContentWindow;
|
|
|
|
void GetAlign(DOMString& aAlign) { GetHTMLAttr(nsGkAtoms::align, aAlign); }
|
|
|
|
void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
|
|
|
|
}
|
2018-10-01 09:09:44 +03:00
|
|
|
void GetAllow(DOMString& aAllow) { GetHTMLAttr(nsGkAtoms::allow, aAllow); }
|
|
|
|
void SetAllow(const nsAString& aAllow, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::allow, aAllow, aError);
|
|
|
|
}
|
2013-02-27 19:38:32 +04:00
|
|
|
void GetScrolling(DOMString& aScrolling) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::scrolling, aScrolling);
|
|
|
|
}
|
|
|
|
void SetScrolling(const nsAString& aScrolling, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::scrolling, aScrolling, aError);
|
|
|
|
}
|
|
|
|
void GetFrameBorder(DOMString& aFrameBorder) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::frameborder, aFrameBorder);
|
|
|
|
}
|
|
|
|
void SetFrameBorder(const nsAString& aFrameBorder, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::frameborder, aFrameBorder, aError);
|
|
|
|
}
|
2017-10-05 06:41:24 +03:00
|
|
|
void GetLongDesc(nsAString& aLongDesc) const {
|
|
|
|
GetURIAttr(nsGkAtoms::longdesc, nullptr, aLongDesc);
|
|
|
|
}
|
2013-02-27 19:38:32 +04:00
|
|
|
void SetLongDesc(const nsAString& aLongDesc, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::longdesc, aLongDesc, aError);
|
|
|
|
}
|
|
|
|
void GetMarginWidth(DOMString& aMarginWidth) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::marginwidth, aMarginWidth);
|
|
|
|
}
|
|
|
|
void SetMarginWidth(const nsAString& aMarginWidth, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::marginwidth, aMarginWidth, aError);
|
|
|
|
}
|
|
|
|
void GetMarginHeight(DOMString& aMarginHeight) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight);
|
|
|
|
}
|
|
|
|
void SetMarginHeight(const nsAString& aMarginHeight, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight, aError);
|
|
|
|
}
|
2015-12-01 03:13:03 +03:00
|
|
|
void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError);
|
2015-07-17 20:46:19 +03:00
|
|
|
}
|
2015-12-01 03:13:03 +03:00
|
|
|
void GetReferrerPolicy(nsAString& aReferrer) {
|
2020-09-23 18:17:15 +03:00
|
|
|
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrer);
|
2015-07-17 20:46:19 +03:00
|
|
|
}
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetSVGDocument(nsIPrincipal& aSubjectPrincipal) {
|
2016-10-03 11:34:14 +03:00
|
|
|
return GetContentDocument(aSubjectPrincipal);
|
2013-02-27 19:38:32 +04:00
|
|
|
}
|
|
|
|
bool Mozbrowser() const { return GetBoolAttr(nsGkAtoms::mozbrowser); }
|
|
|
|
void SetMozbrowser(bool aAllow, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::mozbrowser, aAllow, aError);
|
|
|
|
}
|
|
|
|
using nsGenericHTMLFrameElement::SetMozbrowser;
|
|
|
|
// nsGenericHTMLFrameElement::GetFrameLoader is fine
|
|
|
|
// nsGenericHTMLFrameElement::GetAppManifestURL is fine
|
|
|
|
|
2015-10-08 09:47:39 +03:00
|
|
|
// The fullscreen flag is set to true only when requestFullscreen is
|
|
|
|
// explicitly called on this <iframe> element. In case this flag is
|
|
|
|
// set, the fullscreen state of this element will not be reverted
|
|
|
|
// automatically when its subdocument exits fullscreen.
|
|
|
|
bool FullscreenFlag() const { return mFullscreenFlag; }
|
|
|
|
void SetFullscreenFlag(bool aValue) { mFullscreenFlag = aValue; }
|
|
|
|
|
2019-07-08 03:10:56 +03:00
|
|
|
mozilla::dom::FeaturePolicy* FeaturePolicy() const;
|
2018-10-01 09:09:44 +03:00
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLIFrameElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-11-19 23:21:29 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-06-07 20:28:20 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2017-06-07 20:28:20 +03:00
|
|
|
bool aNotify) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
|
2017-06-07 20:28:20 +03:00
|
|
|
const nsAttrValueOrString& aValue,
|
|
|
|
bool aNotify) override;
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
private:
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2018-06-22 19:48:42 +03:00
|
|
|
MappedDeclarations&);
|
2016-05-05 06:41:24 +03:00
|
|
|
|
|
|
|
static const DOMTokenListSupportedToken sSupportedSandboxTokens[];
|
2017-06-07 20:28:20 +03:00
|
|
|
|
2018-10-20 07:08:46 +03:00
|
|
|
void RefreshFeaturePolicy(bool aParseAllowAttribute);
|
2018-10-01 09:09:44 +03:00
|
|
|
|
2018-10-12 10:49:51 +03:00
|
|
|
// If this iframe has a 'srcdoc' attribute, the document's origin will be
|
|
|
|
// returned. Otherwise, if this iframe has a 'src' attribute, the origin will
|
|
|
|
// be the parsing of its value as URL. If the URL is invalid, or 'src'
|
|
|
|
// attribute doesn't exist, the origin will be the document's origin.
|
|
|
|
already_AddRefed<nsIPrincipal> GetFeaturePolicyDefaultOrigin() const;
|
2018-10-01 09:09:44 +03:00
|
|
|
|
2017-06-07 20:28:20 +03:00
|
|
|
/**
|
|
|
|
* This function is called by AfterSetAttr and OnAttrSetButNotChanged.
|
|
|
|
* This function will be called by AfterSetAttr whether the attribute is being
|
|
|
|
* set or unset.
|
|
|
|
*
|
|
|
|
* @param aNamespaceID the namespace of the attr being set
|
|
|
|
* @param aName the localname of the attribute being set
|
|
|
|
* @param aNotify Whether we plan to notify document observers.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, bool aNotify);
|
2018-10-12 10:36:33 +03:00
|
|
|
|
2019-10-23 22:39:00 +03:00
|
|
|
/**
|
|
|
|
* Feature policy inheritance is broken in cross process model, so we may
|
|
|
|
* have to store feature policy in browsingContext when neccesary.
|
|
|
|
*/
|
|
|
|
void MaybeStoreCrossOriginFeaturePolicy();
|
|
|
|
|
2019-10-11 07:09:40 +03:00
|
|
|
RefPtr<dom::FeaturePolicy> mFeaturePolicy;
|
|
|
|
RefPtr<nsDOMTokenList> mSandbox;
|
2012-06-13 02:01:25 +04:00
|
|
|
};
|
2013-02-23 04:59:26 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|