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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsGenericHTMLFrameElement_h
8 #define nsGenericHTMLFrameElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/nsBrowserElement.h"
13 #include "nsFrameLoader.h"
14 #include "nsFrameLoaderOwner.h"
15 #include "nsGenericHTMLElement.h"
16 #include "nsIMozBrowserFrame.h"
25 class WindowProxyHolder
;
26 class XULFrameElement
;
28 } // namespace mozilla
30 #define NS_GENERICHTMLFRAMEELEMENT_IID \
32 0x8190db72, 0xdab0, 0x4d72, { \
33 0x94, 0x26, 0x87, 0x5f, 0x5a, 0x8a, 0x2a, 0xe5 \
38 * A helper class for frame elements
40 class nsGenericHTMLFrameElement
: public nsGenericHTMLElement
,
41 public nsFrameLoaderOwner
,
42 public mozilla::nsBrowserElement
,
43 public nsIMozBrowserFrame
{
45 nsGenericHTMLFrameElement(
46 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
47 mozilla::dom::FromParser aFromParser
)
48 : nsGenericHTMLElement(std::move(aNodeInfo
)),
49 mSrcLoadHappened(false),
50 mNetworkCreated(aFromParser
== mozilla::dom::FROM_PARSER_NETWORK
),
51 mBrowserFrameListenersRegistered(false),
52 mReallyIsBrowser(false) {}
54 NS_DECL_ISUPPORTS_INHERITED
56 NS_DECL_NSIDOMMOZBROWSERFRAME
57 NS_DECL_NSIMOZBROWSERFRAME
59 NS_DECLARE_STATIC_IID_ACCESSOR(NS_GENERICHTMLFRAMEELEMENT_IID
)
62 virtual bool IsHTMLFocusable(bool aWithMouse
, bool* aIsFocusable
,
63 int32_t* aTabIndex
) override
;
64 virtual nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
65 virtual void UnbindFromTree(bool aNullParent
= true) override
;
66 virtual void DestroyContent() override
;
68 nsresult
CopyInnerTo(mozilla::dom::Element
* aDest
);
70 virtual int32_t TabIndexDefault() override
;
72 virtual nsIMozBrowserFrame
* GetAsMozBrowserFrame() override
{ return this; }
74 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGenericHTMLFrameElement
,
77 void SwapFrameLoaders(mozilla::dom::HTMLIFrameElement
& aOtherLoaderOwner
,
78 mozilla::ErrorResult
& aError
);
80 void SwapFrameLoaders(mozilla::dom::XULFrameElement
& aOtherLoaderOwner
,
81 mozilla::ErrorResult
& aError
);
83 void SwapFrameLoaders(nsFrameLoaderOwner
* aOtherLoaderOwner
,
84 mozilla::ErrorResult
& rv
);
87 * Helper method to map a HTML 'scrolling' attribute value (which can be null)
88 * to a ScrollbarPreference value value. scrolling="no" (and its synonyms)
89 * map to Never, and anything else to Auto.
91 static mozilla::ScrollbarPreference
MapScrollingAttribute(const nsAttrValue
*);
93 nsIPrincipal
* GetSrcTriggeringPrincipal() const {
94 return mSrcTriggeringPrincipal
;
97 // Needed for nsBrowserElement
98 already_AddRefed
<nsFrameLoader
> GetFrameLoader() override
{
99 return nsFrameLoaderOwner::GetFrameLoader();
103 virtual ~nsGenericHTMLFrameElement();
105 // This doesn't really ensure a frame loader in all cases, only when
107 void EnsureFrameLoader();
109 Document
* GetContentDocument(nsIPrincipal
& aSubjectPrincipal
);
110 mozilla::dom::Nullable
<mozilla::dom::WindowProxyHolder
> GetContentWindow();
112 virtual void AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
113 const nsAttrValue
* aValue
,
114 const nsAttrValue
* aOldValue
,
115 nsIPrincipal
* aSubjectPrincipal
,
116 bool aNotify
) override
;
117 virtual void OnAttrSetButNotChanged(int32_t aNamespaceID
, nsAtom
* aName
,
118 const nsAttrValueOrString
& aValue
,
119 bool aNotify
) override
;
121 nsCOMPtr
<nsIPrincipal
> mSrcTriggeringPrincipal
;
124 * True if we have already loaded the frame's original src
126 bool mSrcLoadHappened
;
129 * True when the element is created by the parser using the
130 * NS_FROM_PARSER_NETWORK flag.
131 * If the element is modified, it may lose the flag.
133 bool mNetworkCreated
;
135 bool mBrowserFrameListenersRegistered
;
136 bool mReallyIsBrowser
;
138 // This flag is only used by <iframe>. See HTMLIFrameElement::
139 // FullscreenFlag() for details. It is placed here so that we
140 // do not bloat any struct.
141 bool mFullscreenFlag
= false;
144 * Represents the iframe is deferred loading until this element gets visible.
145 * We just do not load if set and leave specific elements to set it (see
146 * HTMLIFrameElement).
148 bool mLazyLoading
= false;
151 void GetManifestURL(nsAString
& aOut
);
154 * This function is called by AfterSetAttr and OnAttrSetButNotChanged.
155 * It will be called whether the value is being set or unset.
157 * @param aNamespaceID the namespace of the attr being set
158 * @param aName the localname of the attribute being set
159 * @param aValue the value being set or null if the value is being unset
160 * @param aNotify Whether we plan to notify document observers.
162 void AfterMaybeChangeAttr(int32_t aNamespaceID
, nsAtom
* aName
,
163 const nsAttrValueOrString
* aValue
,
164 nsIPrincipal
* aMaybeScriptedPrincipal
,
167 mozilla::dom::BrowsingContext
* GetContentWindowInternal();
170 NS_DEFINE_STATIC_IID_ACCESSOR(nsGenericHTMLFrameElement
,
171 NS_GENERICHTMLFRAMEELEMENT_IID
)
173 #endif // nsGenericHTMLFrameElement_h