|
Packit |
f0b94e |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
Packit |
f0b94e |
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
Packit |
f0b94e |
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
Packit |
f0b94e |
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
Packit |
f0b94e |
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#ifndef nsGenericHTMLFrameElement_h
|
|
Packit |
f0b94e |
#define nsGenericHTMLFrameElement_h
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#include "mozilla/Attributes.h"
|
|
Packit |
f0b94e |
#include "mozilla/ErrorResult.h"
|
|
Packit |
f0b94e |
#include "mozilla/dom/nsBrowserElement.h"
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#include "nsFrameLoader.h"
|
|
Packit |
f0b94e |
#include "nsGenericHTMLElement.h"
|
|
Packit |
f0b94e |
#include "nsIDOMEventListener.h"
|
|
Packit |
f0b94e |
#include "nsIFrameLoader.h"
|
|
Packit |
f0b94e |
#include "nsIMozBrowserFrame.h"
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
class nsXULElement;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#define NS_GENERICHTMLFRAMEELEMENT_IID \
|
|
Packit |
f0b94e |
{ \
|
|
Packit |
f0b94e |
0x8190db72, 0xdab0, 0x4d72, { \
|
|
Packit |
f0b94e |
0x94, 0x26, 0x87, 0x5f, 0x5a, 0x8a, 0x2a, 0xe5 \
|
|
Packit |
f0b94e |
} \
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/**
|
|
Packit |
f0b94e |
* A helper class for frame elements
|
|
Packit |
f0b94e |
*/
|
|
Packit |
f0b94e |
class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
|
|
Packit |
f0b94e |
public nsIFrameLoaderOwner,
|
|
Packit |
f0b94e |
public mozilla::nsBrowserElement,
|
|
Packit |
f0b94e |
public nsIMozBrowserFrame {
|
|
Packit |
f0b94e |
public:
|
|
Packit |
f0b94e |
nsGenericHTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|
Packit |
f0b94e |
mozilla::dom::FromParser aFromParser)
|
|
Packit |
f0b94e |
: nsGenericHTMLElement(aNodeInfo),
|
|
Packit |
f0b94e |
nsBrowserElement(),
|
|
Packit |
f0b94e |
mSrcLoadHappened(false),
|
|
Packit |
f0b94e |
mNetworkCreated(aFromParser == mozilla::dom::FROM_PARSER_NETWORK),
|
|
Packit |
f0b94e |
mBrowserFrameListenersRegistered(false),
|
|
Packit |
f0b94e |
mFrameLoaderCreationDisallowed(false),
|
|
Packit |
f0b94e |
mReallyIsBrowser(false) {}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NS_DECL_ISUPPORTS_INHERITED
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NS_DECL_NSIFRAMELOADEROWNER
|
|
Packit |
f0b94e |
NS_DECL_NSIDOMMOZBROWSERFRAME
|
|
Packit |
f0b94e |
NS_DECL_NSIMOZBROWSERFRAME
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NS_DECLARE_STATIC_IID_ACCESSOR(NS_GENERICHTMLFRAMEELEMENT_IID)
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// nsIContent
|
|
Packit |
f0b94e |
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|
Packit |
f0b94e |
int32_t* aTabIndex) override;
|
|
Packit |
f0b94e |
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
Packit |
f0b94e |
nsIContent* aBindingParent,
|
|
Packit |
f0b94e |
bool aCompileEventHandlers) override;
|
|
Packit |
f0b94e |
virtual void UnbindFromTree(bool aDeep = true,
|
|
Packit |
f0b94e |
bool aNullParent = true) override;
|
|
Packit |
f0b94e |
virtual void DestroyContent() override;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsresult CopyInnerTo(mozilla::dom::Element* aDest, bool aPreallocateChildren);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
virtual int32_t TabIndexDefault() override;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
virtual nsIMozBrowserFrame* GetAsMozBrowserFrame() override { return this; }
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGenericHTMLFrameElement,
|
|
Packit |
f0b94e |
nsGenericHTMLElement)
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
void SwapFrameLoaders(mozilla::dom::HTMLIFrameElement& aOtherLoaderOwner,
|
|
Packit |
f0b94e |
mozilla::ErrorResult& aError);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
void SwapFrameLoaders(nsXULElement& aOtherLoaderOwner,
|
|
Packit |
f0b94e |
mozilla::ErrorResult& aError);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
void SwapFrameLoaders(nsIFrameLoaderOwner* aOtherLoaderOwner,
|
|
Packit |
f0b94e |
mozilla::ErrorResult& rv);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
void PresetOpenerWindow(mozIDOMWindowProxy* aOpenerWindow,
|
|
Packit |
f0b94e |
mozilla::ErrorResult& aRv);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
static void InitStatics();
|
|
Packit |
f0b94e |
static bool BrowserFramesEnabled();
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/**
|
|
Packit |
f0b94e |
* Helper method to map a HTML 'scrolling' attribute value to a nsIScrollable
|
|
Packit |
f0b94e |
* enum value. scrolling="no" (and its synonyms) maps to
|
|
Packit |
f0b94e |
* nsIScrollable::Scrollbar_Never, and anything else (including nullptr) maps
|
|
Packit |
f0b94e |
* to nsIScrollable::Scrollbar_Auto.
|
|
Packit |
f0b94e |
* @param aValue the attribute value to map or nullptr
|
|
Packit |
f0b94e |
* @return nsIScrollable::Scrollbar_Never or nsIScrollable::Scrollbar_Auto
|
|
Packit |
f0b94e |
*/
|
|
Packit |
f0b94e |
static int32_t MapScrollingAttribute(const nsAttrValue* aValue);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsIPrincipal* GetSrcTriggeringPrincipal() const {
|
|
Packit |
f0b94e |
return mSrcTriggeringPrincipal;
|
|
Packit |
f0b94e |
}
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
protected:
|
|
Packit |
f0b94e |
virtual ~nsGenericHTMLFrameElement();
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// This doesn't really ensure a frame loader in all cases, only when
|
|
Packit |
f0b94e |
// it makes sense.
|
|
Packit |
f0b94e |
void EnsureFrameLoader();
|
|
Packit |
f0b94e |
nsresult LoadSrc();
|
|
Packit |
f0b94e |
nsIDocument* GetContentDocument(nsIPrincipal& aSubjectPrincipal);
|
|
Packit |
f0b94e |
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
|
|
Packit |
f0b94e |
already_AddRefed<nsPIDOMWindowOuter> GetContentWindow();
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
Packit |
f0b94e |
const nsAttrValue* aValue,
|
|
Packit |
f0b94e |
const nsAttrValue* aOldValue,
|
|
Packit |
f0b94e |
nsIPrincipal* aSubjectPrincipal,
|
|
Packit |
f0b94e |
bool aNotify) override;
|
|
Packit |
f0b94e |
virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
|
|
Packit |
f0b94e |
const nsAttrValueOrString& aValue,
|
|
Packit |
f0b94e |
bool aNotify) override;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
RefPtr<nsFrameLoader> mFrameLoader;
|
|
Packit |
f0b94e |
nsCOMPtr<nsPIDOMWindowOuter> mOpenerWindow;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/**
|
|
Packit |
f0b94e |
* True if we have already loaded the frame's original src
|
|
Packit |
f0b94e |
*/
|
|
Packit |
f0b94e |
bool mSrcLoadHappened;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/**
|
|
Packit |
f0b94e |
* True when the element is created by the parser using the
|
|
Packit |
f0b94e |
* NS_FROM_PARSER_NETWORK flag.
|
|
Packit |
f0b94e |
* If the element is modified, it may lose the flag.
|
|
Packit |
f0b94e |
*/
|
|
Packit |
f0b94e |
bool mNetworkCreated;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
bool mBrowserFrameListenersRegistered;
|
|
Packit |
f0b94e |
bool mFrameLoaderCreationDisallowed;
|
|
Packit |
f0b94e |
bool mReallyIsBrowser;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
// This flag is only used by <iframe>. See HTMLIFrameElement::
|
|
Packit |
f0b94e |
// FullscreenFlag() for details. It is placed here so that we
|
|
Packit |
f0b94e |
// do not bloat any struct.
|
|
Packit |
f0b94e |
bool mFullscreenFlag = false;
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
private:
|
|
Packit |
f0b94e |
void GetManifestURL(nsAString& aOut);
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
/**
|
|
Packit |
f0b94e |
* This function is called by AfterSetAttr and OnAttrSetButNotChanged.
|
|
Packit |
f0b94e |
* It will be called whether the value is being set or unset.
|
|
Packit |
f0b94e |
*
|
|
Packit |
f0b94e |
* @param aNamespaceID the namespace of the attr being set
|
|
Packit |
f0b94e |
* @param aName the localname of the attribute being set
|
|
Packit |
f0b94e |
* @param aValue the value being set or null if the value is being unset
|
|
Packit |
f0b94e |
* @param aNotify Whether we plan to notify document observers.
|
|
Packit |
f0b94e |
*/
|
|
Packit |
f0b94e |
void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
|
|
Packit |
f0b94e |
const nsAttrValueOrString* aValue,
|
|
Packit |
f0b94e |
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
Packit |
f0b94e |
bool aNotify);
|
|
Packit |
f0b94e |
};
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
NS_DEFINE_STATIC_IID_ACCESSOR(nsGenericHTMLFrameElement,
|
|
Packit |
f0b94e |
NS_GENERICHTMLFRAMEELEMENT_IID)
|
|
Packit |
f0b94e |
|
|
Packit |
f0b94e |
#endif // nsGenericHTMLFrameElement_h
|