2015-05-03 19:32:37 +00: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-01-20 17:02:48 +00: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-27 15:38:32 +00:00
|
|
|
#ifndef nsGenericHTMLFrameElement_h
|
|
|
|
#define nsGenericHTMLFrameElement_h
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-11-21 10:56:27 +00:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/nsBrowserElement.h"
|
|
|
|
|
|
|
|
#include "nsFrameLoader.h"
|
2019-02-15 22:20:53 +00:00
|
|
|
#include "nsFrameLoaderOwner.h"
|
2012-01-20 17:02:48 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-03-04 16:02:00 +00:00
|
|
|
#include "nsIMozBrowserFrame.h"
|
2012-06-06 07:40:02 +00:00
|
|
|
|
2018-07-06 00:14:29 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2019-04-25 04:25:56 +00:00
|
|
|
class BrowserParent;
|
2019-01-02 13:26:56 +00:00
|
|
|
template <typename>
|
|
|
|
struct Nullable;
|
|
|
|
class WindowProxyHolder;
|
2018-07-06 00:14:29 +00:00
|
|
|
class XULFrameElement;
|
2019-01-02 13:26:56 +00:00
|
|
|
} // namespace dom
|
2018-07-06 00:14:29 +00:00
|
|
|
} // namespace mozilla
|
2013-02-26 17:02:32 +00:00
|
|
|
|
2017-10-05 05:59:44 +00:00
|
|
|
#define NS_GENERICHTMLFRAMEELEMENT_IID \
|
2018-11-30 10:46:48 +00:00
|
|
|
{ \
|
2017-10-05 05:59:44 +00:00
|
|
|
0x8190db72, 0xdab0, 0x4d72, { \
|
|
|
|
0x94, 0x26, 0x87, 0x5f, 0x5a, 0x8a, 0x2a, 0xe5 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2012-01-20 17:02:48 +00:00
|
|
|
/**
|
|
|
|
* A helper class for frame elements
|
|
|
|
*/
|
|
|
|
class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
|
2019-02-15 22:20:53 +00:00
|
|
|
public nsFrameLoaderOwner,
|
2014-11-21 10:56:27 +00:00
|
|
|
public mozilla::nsBrowserElement,
|
2012-03-28 18:36:04 +00:00
|
|
|
public nsIMozBrowserFrame {
|
2012-01-20 17:02:48 +00:00
|
|
|
public:
|
2018-09-21 20:45:49 +00:00
|
|
|
nsGenericHTMLFrameElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2012-01-20 17:02:48 +00:00
|
|
|
mozilla::dom::FromParser aFromParser)
|
2018-09-21 20:45:49 +00:00
|
|
|
: nsGenericHTMLElement(std::move(aNodeInfo)),
|
2014-11-21 10:56:27 +00:00
|
|
|
nsBrowserElement(),
|
2017-11-05 04:06:20 +00:00
|
|
|
mSrcLoadHappened(false),
|
2015-02-11 11:20:50 +00:00
|
|
|
mNetworkCreated(aFromParser == mozilla::dom::FROM_PARSER_NETWORK),
|
|
|
|
mBrowserFrameListenersRegistered(false),
|
|
|
|
mFrameLoaderCreationDisallowed(false),
|
2017-02-17 00:16:00 +00:00
|
|
|
mReallyIsBrowser(false) {}
|
2012-01-26 23:03:22 +00:00
|
|
|
|
2013-08-07 20:23:08 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2012-01-20 17:02:48 +00:00
|
|
|
NS_DECL_NSIDOMMOZBROWSERFRAME
|
2012-03-04 16:02:00 +00:00
|
|
|
NS_DECL_NSIMOZBROWSERFRAME
|
2012-01-20 17:02:48 +00:00
|
|
|
|
2017-10-05 05:59:44 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_GENERICHTMLFRAMEELEMENT_IID)
|
|
|
|
|
2012-01-20 17:02:48 +00:00
|
|
|
// nsIContent
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|
|
|
int32_t* aTabIndex) override;
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 04:27:04 +00:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-28 22:47:08 +00:00
|
|
|
virtual void UnbindFromTree(bool aNullParent = true) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DestroyContent() override;
|
2012-01-20 17:02:48 +00:00
|
|
|
|
2018-08-08 23:58:44 +00:00
|
|
|
nsresult CopyInnerTo(mozilla::dom::Element* aDest);
|
2012-01-20 17:02:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual int32_t TabIndexDefault() override;
|
2012-01-20 17:02:48 +00:00
|
|
|
|
2017-02-02 21:47:58 +00:00
|
|
|
virtual nsIMozBrowserFrame* GetAsMozBrowserFrame() override { return this; }
|
|
|
|
|
2015-07-10 16:38:44 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGenericHTMLFrameElement,
|
|
|
|
nsGenericHTMLElement)
|
2012-01-20 17:02:48 +00:00
|
|
|
|
2016-01-09 00:11:58 +00:00
|
|
|
void SwapFrameLoaders(mozilla::dom::HTMLIFrameElement& aOtherLoaderOwner,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
2018-07-06 00:14:29 +00:00
|
|
|
void SwapFrameLoaders(mozilla::dom::XULFrameElement& aOtherLoaderOwner,
|
2016-01-09 00:11:58 +00:00
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
|
2019-02-15 22:20:53 +00:00
|
|
|
void SwapFrameLoaders(nsFrameLoaderOwner* aOtherLoaderOwner,
|
2016-01-09 00:11:58 +00:00
|
|
|
mozilla::ErrorResult& rv);
|
2014-01-12 04:05:49 +00:00
|
|
|
|
2019-01-02 13:26:56 +00:00
|
|
|
void PresetOpenerWindow(const mozilla::dom::Nullable<
|
|
|
|
mozilla::dom::WindowProxyHolder>& aOpenerWindow,
|
2016-10-07 18:59:59 +00:00
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
|
2019-04-25 04:25:56 +00:00
|
|
|
/**
|
|
|
|
* Normally, a frame tries to create its frame loader when its src is
|
|
|
|
* modified, or its contentWindow is accessed.
|
|
|
|
*
|
|
|
|
* disallowCreateFrameLoader prevents the frame element from creating its
|
|
|
|
* frame loader (in the same way that not being inside a document prevents the
|
|
|
|
* creation of a frame loader). allowCreateFrameLoader lifts this
|
|
|
|
* restriction.
|
|
|
|
*
|
|
|
|
* These methods are not re-entrant -- it is an error to call
|
|
|
|
* disallowCreateFrameLoader twice without first calling allowFrameLoader.
|
|
|
|
*
|
|
|
|
* It's also an error to call either method if we already have a frame loader.
|
|
|
|
*/
|
|
|
|
void DisallowCreateFrameLoader();
|
|
|
|
void AllowCreateFrameLoader();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a remote (i.e., out-of-process) frame loader attached to the given
|
|
|
|
* remote tab.
|
|
|
|
*
|
|
|
|
* It is an error to call this method if we already have a frame loader.
|
|
|
|
*/
|
|
|
|
void CreateRemoteFrameLoader(mozilla::dom::BrowserParent* aBrowserParent);
|
|
|
|
|
2014-01-12 04:05:49 +00:00
|
|
|
/**
|
2019-12-15 22:56:23 +00:00
|
|
|
* Helper method to map a HTML 'scrolling' attribute value (which can be null)
|
|
|
|
* to a ScrollbarPreference value value. scrolling="no" (and its synonyms)
|
|
|
|
* map to Never, and anything else to Auto.
|
2014-01-12 04:05:49 +00:00
|
|
|
*/
|
2019-12-15 22:56:23 +00:00
|
|
|
static mozilla::ScrollbarPreference MapScrollingAttribute(const nsAttrValue*);
|
2014-01-12 04:05:49 +00:00
|
|
|
|
2017-10-05 05:59:44 +00:00
|
|
|
nsIPrincipal* GetSrcTriggeringPrincipal() const {
|
|
|
|
return mSrcTriggeringPrincipal;
|
|
|
|
}
|
|
|
|
|
2019-02-15 22:20:53 +00:00
|
|
|
// Needed for nsBrowserElement
|
|
|
|
already_AddRefed<nsFrameLoader> GetFrameLoader() override {
|
|
|
|
return nsFrameLoaderOwner::GetFrameLoader();
|
|
|
|
}
|
2019-02-16 19:20:37 +00:00
|
|
|
|
2012-01-20 17:02:48 +00:00
|
|
|
protected:
|
2015-02-11 11:20:50 +00:00
|
|
|
virtual ~nsGenericHTMLFrameElement();
|
2014-07-08 21:23:16 +00:00
|
|
|
|
2015-02-11 11:20:50 +00:00
|
|
|
// This doesn't really ensure a frame loader in all cases, only when
|
|
|
|
// it makes sense.
|
|
|
|
void EnsureFrameLoader();
|
2018-03-22 02:43:16 +00:00
|
|
|
void LoadSrc();
|
2019-01-02 13:05:23 +00:00
|
|
|
Document* GetContentDocument(nsIPrincipal& aSubjectPrincipal);
|
2019-01-02 13:26:56 +00:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetContentWindow();
|
2015-02-11 11:20:50 +00:00
|
|
|
|
2017-10-02 22:05:19 +00:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-06-07 17:28:20 +00:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-09 21:33:38 +00:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-06-07 17:28:20 +00:00
|
|
|
bool aNotify) override;
|
2017-10-02 22:05:19 +00:00
|
|
|
virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
|
2017-06-07 17:28:20 +00:00
|
|
|
const nsAttrValueOrString& aValue,
|
|
|
|
bool aNotify) override;
|
|
|
|
|
2019-01-02 13:27:05 +00:00
|
|
|
RefPtr<mozilla::dom::BrowsingContext> mOpenerWindow;
|
2015-02-11 11:20:50 +00:00
|
|
|
|
2017-10-05 05:59:44 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
|
|
|
|
2017-11-05 04:06:20 +00:00
|
|
|
/**
|
|
|
|
* True if we have already loaded the frame's original src
|
|
|
|
*/
|
|
|
|
bool mSrcLoadHappened;
|
|
|
|
|
2015-02-11 11:20:50 +00:00
|
|
|
/**
|
|
|
|
* True when the element is created by the parser using the
|
|
|
|
* NS_FROM_PARSER_NETWORK flag.
|
|
|
|
* If the element is modified, it may lose the flag.
|
|
|
|
*/
|
|
|
|
bool mNetworkCreated;
|
|
|
|
|
|
|
|
bool mBrowserFrameListenersRegistered;
|
|
|
|
bool mFrameLoaderCreationDisallowed;
|
2017-02-17 00:16:00 +00:00
|
|
|
bool mReallyIsBrowser;
|
2014-08-19 14:14:08 +00:00
|
|
|
|
2015-10-08 06:47:39 +00:00
|
|
|
// This flag is only used by <iframe>. See HTMLIFrameElement::
|
|
|
|
// FullscreenFlag() for details. It is placed here so that we
|
|
|
|
// do not bloat any struct.
|
|
|
|
bool mFullscreenFlag = false;
|
|
|
|
|
2014-08-19 14:14:08 +00:00
|
|
|
private:
|
2016-10-15 00:38:21 +00:00
|
|
|
void GetManifestURL(nsAString& aOut);
|
2017-06-07 17:28:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is called by AfterSetAttr and OnAttrSetButNotChanged.
|
|
|
|
* It will be called whether the value is being set or unset.
|
|
|
|
*
|
|
|
|
* @param aNamespaceID the namespace of the attr being set
|
|
|
|
* @param aName the localname of the attribute being set
|
|
|
|
* @param aValue the value being set or null if the value is being unset
|
|
|
|
* @param aNotify Whether we plan to notify document observers.
|
|
|
|
*/
|
2017-10-02 22:05:19 +00:00
|
|
|
void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-10-05 05:59:44 +00:00
|
|
|
const nsAttrValueOrString* aValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify);
|
2019-01-02 13:26:56 +00:00
|
|
|
|
2019-01-02 13:27:05 +00:00
|
|
|
mozilla::dom::BrowsingContext* GetContentWindowInternal();
|
2012-01-20 17:02:48 +00:00
|
|
|
};
|
2013-02-27 15:38:32 +00:00
|
|
|
|
2017-10-05 05:59:44 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsGenericHTMLFrameElement,
|
|
|
|
NS_GENERICHTMLFRAMEELEMENT_IID)
|
|
|
|
|
2013-02-27 15:38:32 +00:00
|
|
|
#endif // nsGenericHTMLFrameElement_h
|