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-01-20 21:02:48 +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/. */
|
|
|
|
|
|
|
|
#include "nsGenericHTMLFrameElement.h"
|
2013-08-22 10:30:55 +04:00
|
|
|
|
2016-01-09 03:11:58 +03:00
|
|
|
#include "mozilla/dom/HTMLIFrameElement.h"
|
2018-07-06 03:14:29 +03:00
|
|
|
#include "mozilla/dom/XULFrameElement.h"
|
2019-01-03 10:11:00 +03:00
|
|
|
#include "mozilla/dom/WindowProxyHolder.h"
|
2012-01-20 21:02:48 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-02-26 21:02:32 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2014-01-12 08:05:49 +04:00
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "nsAttrValueInlines.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2012-08-15 21:22:30 +04:00
|
|
|
#include "nsIPermissionManager.h"
|
2014-01-12 08:05:49 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIScrollable.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
2014-08-08 21:23:51 +04:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2017-09-25 18:09:26 +03:00
|
|
|
#include "nsAttrValueOrString.h"
|
2012-01-20 21:02:48 +04:00
|
|
|
|
2012-01-20 21:02:48 +04:00
|
|
|
using namespace mozilla;
|
2012-01-20 21:02:48 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
|
|
|
|
|
2012-01-20 21:02:48 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
|
|
|
|
nsGenericHTMLElement)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameLoader)
|
2016-10-07 21:59:59 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerWindow)
|
2014-11-21 13:56:27 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserElementAPI)
|
2012-01-20 21:02:48 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2015-07-10 19:38:44 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsGenericHTMLFrameElement,
|
|
|
|
nsGenericHTMLElement)
|
|
|
|
if (tmp->mFrameLoader) {
|
|
|
|
tmp->mFrameLoader->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameLoader)
|
2016-10-07 21:59:59 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerWindow)
|
2015-07-10 19:38:44 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowserElementAPI)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2017-09-01 02:29:22 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(
|
2019-02-16 01:20:53 +03:00
|
|
|
nsGenericHTMLFrameElement, nsGenericHTMLElement, nsFrameLoaderOwner,
|
2017-10-05 08:59:44 +03:00
|
|
|
nsIDOMMozBrowserFrame, nsIMozBrowserFrame, nsGenericHTMLFrameElement)
|
2013-08-08 00:23:08 +04:00
|
|
|
|
2018-02-24 22:20:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::GetMozbrowser(bool* aValue) {
|
|
|
|
*aValue = GetBoolAttr(nsGkAtoms::mozbrowser);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::SetMozbrowser(bool aValue) {
|
|
|
|
return SetBoolAttr(nsGkAtoms::mozbrowser, aValue);
|
|
|
|
}
|
2012-01-20 21:02:48 +04:00
|
|
|
|
2012-10-06 11:19:51 +04:00
|
|
|
int32_t nsGenericHTMLFrameElement::TabIndexDefault() { return 0; }
|
|
|
|
|
2015-02-11 14:20:50 +03:00
|
|
|
nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement() {
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* nsGenericHTMLFrameElement::GetContentDocument(
|
2016-10-11 04:07:48 +03:00
|
|
|
nsIPrincipal& aSubjectPrincipal) {
|
2019-01-02 16:27:05 +03:00
|
|
|
RefPtr<BrowsingContext> bc = GetContentWindowInternal();
|
|
|
|
if (!bc) {
|
2015-02-11 14:20:50 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-03 23:37:01 +03:00
|
|
|
nsPIDOMWindowOuter* window = bc->GetDOMWindow();
|
|
|
|
if (!window) {
|
|
|
|
// Either our browsing context contents are out-of-process (in which case
|
|
|
|
// clearly this is a cross-origin call and we should return null), or our
|
|
|
|
// browsing context is torn-down enough to no longer have a window or a
|
|
|
|
// document, and we should still return null.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-01-04 02:03:06 +03:00
|
|
|
Document* doc = window->GetDoc();
|
2015-07-30 20:55:16 +03:00
|
|
|
if (!doc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-02-11 14:20:50 +03:00
|
|
|
|
|
|
|
// Return null for cross-origin contentDocument.
|
2016-10-11 04:07:48 +03:00
|
|
|
if (!aSubjectPrincipal.SubsumesConsideringDomain(doc->NodePrincipal())) {
|
2015-02-11 14:20:50 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
BrowsingContext* nsGenericHTMLFrameElement::GetContentWindowInternal() {
|
2015-02-11 14:20:50 +03:00
|
|
|
EnsureFrameLoader();
|
|
|
|
|
|
|
|
if (!mFrameLoader) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-03-22 05:43:16 +03:00
|
|
|
if (mFrameLoader->DepthTooGreat()) {
|
2015-02-11 14:20:50 +03:00
|
|
|
// Claim to have no contentWindow
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
RefPtr<nsDocShell> doc_shell = mFrameLoader->GetDocShell(IgnoreErrors());
|
2016-04-12 09:37:05 +03:00
|
|
|
if (!doc_shell) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-02-11 14:20:50 +03:00
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
return doc_shell->GetBrowsingContext();
|
2019-01-02 16:26:56 +03:00
|
|
|
}
|
2015-02-11 14:20:50 +03:00
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
Nullable<WindowProxyHolder> nsGenericHTMLFrameElement::GetContentWindow() {
|
2019-01-02 16:27:05 +03:00
|
|
|
RefPtr<BrowsingContext> bc = GetContentWindowInternal();
|
|
|
|
if (!bc) {
|
2015-02-11 14:20:50 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-01-02 16:27:05 +03:00
|
|
|
return WindowProxyHolder(bc);
|
2015-02-11 14:20:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsGenericHTMLFrameElement::EnsureFrameLoader() {
|
2015-02-24 17:41:43 +03:00
|
|
|
if (!IsInComposedDoc() || mFrameLoader || mFrameLoaderCreationDisallowed) {
|
2015-02-11 14:20:50 +03:00
|
|
|
// If frame loader is there, we just keep it around, cached
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Strangely enough, this method doesn't actually ensure that the
|
|
|
|
// frameloader exists. It's more of a best-effort kind of thing.
|
2016-10-17 17:37:50 +03:00
|
|
|
mFrameLoader = nsFrameLoader::Create(
|
2019-01-02 16:27:05 +03:00
|
|
|
this, mOpenerWindow ? mOpenerWindow->GetDOMWindow() : nullptr,
|
|
|
|
mNetworkCreated);
|
2015-02-11 14:20:50 +03:00
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
nsresult nsGenericHTMLFrameElement::CreateRemoteFrameLoader(
|
|
|
|
nsITabParent* aTabParent) {
|
|
|
|
MOZ_ASSERT(!mFrameLoader);
|
|
|
|
EnsureFrameLoader();
|
|
|
|
NS_ENSURE_STATE(mFrameLoader);
|
|
|
|
mFrameLoader->SetRemoteBrowser(aTabParent);
|
2014-08-08 21:23:51 +04:00
|
|
|
|
|
|
|
if (nsSubDocumentFrame* subdocFrame = do_QueryFrame(GetPrimaryFrame())) {
|
|
|
|
// The reflow for this element already happened while we were waiting
|
|
|
|
// for the iframe creation. Therefore the subdoc frame didn't have a
|
|
|
|
// frameloader when UpdatePositionAndSize was supposed to be called in
|
|
|
|
// ReflowFinished, and we need to do it properly now.
|
|
|
|
mFrameLoader->UpdatePositionAndSize(subdocFrame);
|
|
|
|
}
|
2012-06-13 02:01:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
void nsGenericHTMLFrameElement::PresetOpenerWindow(
|
|
|
|
const Nullable<WindowProxyHolder>& aOpenerWindow, ErrorResult& aRv) {
|
2016-10-07 21:59:59 +03:00
|
|
|
MOZ_ASSERT(!mFrameLoader);
|
2019-01-02 16:26:56 +03:00
|
|
|
mOpenerWindow =
|
|
|
|
aOpenerWindow.IsNull() ? nullptr : aOpenerWindow.Value().get();
|
2016-10-07 21:59:59 +03:00
|
|
|
}
|
|
|
|
|
2016-01-09 03:11:58 +03:00
|
|
|
void nsGenericHTMLFrameElement::SwapFrameLoaders(
|
|
|
|
HTMLIFrameElement& aOtherLoaderOwner, ErrorResult& rv) {
|
|
|
|
if (&aOtherLoaderOwner == this) {
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-17 17:37:50 +03:00
|
|
|
aOtherLoaderOwner.SwapFrameLoaders(this, rv);
|
2016-01-09 03:11:58 +03:00
|
|
|
}
|
|
|
|
|
2018-07-06 03:14:29 +03:00
|
|
|
void nsGenericHTMLFrameElement::SwapFrameLoaders(
|
|
|
|
XULFrameElement& aOtherLoaderOwner, ErrorResult& rv) {
|
2016-10-17 17:37:50 +03:00
|
|
|
aOtherLoaderOwner.SwapFrameLoaders(this, rv);
|
2016-01-09 03:11:58 +03:00
|
|
|
}
|
|
|
|
|
2016-10-17 17:37:50 +03:00
|
|
|
void nsGenericHTMLFrameElement::SwapFrameLoaders(
|
2019-02-16 01:20:53 +03:00
|
|
|
nsFrameLoaderOwner* aOtherLoaderOwner, mozilla::ErrorResult& rv) {
|
2016-10-17 17:37:50 +03:00
|
|
|
RefPtr<nsFrameLoader> loader = GetFrameLoader();
|
|
|
|
RefPtr<nsFrameLoader> otherLoader = aOtherLoaderOwner->GetFrameLoader();
|
|
|
|
if (!loader || !otherLoader) {
|
2016-01-09 03:11:58 +03:00
|
|
|
rv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-17 17:37:50 +03:00
|
|
|
rv = loader->SwapWithOtherLoader(otherLoader, this, aOtherLoaderOwner);
|
2015-02-11 14:20:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsGenericHTMLFrameElement::LoadSrc() {
|
|
|
|
EnsureFrameLoader();
|
|
|
|
|
|
|
|
if (!mFrameLoader) {
|
2018-03-22 05:43:16 +03:00
|
|
|
return;
|
2015-02-11 14:20:50 +03:00
|
|
|
}
|
|
|
|
|
2017-11-05 07:06:20 +03:00
|
|
|
bool origSrc = !mSrcLoadHappened;
|
|
|
|
mSrcLoadHappened = true;
|
2018-03-22 05:43:16 +03:00
|
|
|
mFrameLoader->LoadFrame(origSrc);
|
2015-02-11 14:20:50 +03:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult nsGenericHTMLFrameElement::BindToTree(Document* aDocument,
|
2012-01-20 21:02:48 +04:00
|
|
|
nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) {
|
2012-01-20 21:02:48 +04:00
|
|
|
nsresult rv =
|
|
|
|
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2015-02-24 17:41:43 +03:00
|
|
|
if (IsInComposedDoc()) {
|
2012-01-20 21:02:48 +04:00
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"Missing a script blocker!");
|
2013-01-31 10:40:43 +04:00
|
|
|
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("nsGenericHTMLFrameElement::BindToTree", OTHER);
|
2013-01-31 10:40:43 +04:00
|
|
|
|
2012-01-20 21:02:48 +04:00
|
|
|
// We're in a document now. Kick off the frame load.
|
|
|
|
LoadSrc();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're now in document and scripts may move us, so clear
|
|
|
|
// the mNetworkCreated flag.
|
|
|
|
mNetworkCreated = false;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsGenericHTMLFrameElement::UnbindFromTree(bool aDeep, bool aNullParent) {
|
|
|
|
if (mFrameLoader) {
|
|
|
|
// This iframe is being taken out of the document, destroy the
|
|
|
|
// iframe's frame loader (doing that will tear down the window in
|
|
|
|
// this iframe).
|
|
|
|
// XXXbz we really want to only partially destroy the frame
|
|
|
|
// loader... we don't want to tear down the docshell. Food for
|
|
|
|
// later bug.
|
|
|
|
mFrameLoader->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrameLoader = nullptr;
|
2012-01-20 21:02:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
int32_t nsGenericHTMLFrameElement::MapScrollingAttribute(
|
2014-01-12 08:05:49 +04:00
|
|
|
const nsAttrValue* aValue) {
|
|
|
|
int32_t mappedValue = nsIScrollable::Scrollbar_Auto;
|
|
|
|
if (aValue && aValue->Type() == nsAttrValue::eEnum) {
|
|
|
|
switch (aValue->GetEnumValue()) {
|
|
|
|
case NS_STYLE_FRAME_OFF:
|
|
|
|
case NS_STYLE_FRAME_NOSCROLL:
|
|
|
|
case NS_STYLE_FRAME_NO:
|
|
|
|
mappedValue = nsIScrollable::Scrollbar_Never;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mappedValue;
|
|
|
|
}
|
|
|
|
|
2017-02-17 03:16:00 +03:00
|
|
|
static bool PrincipalAllowsBrowserFrame(nsIPrincipal* aPrincipal) {
|
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr =
|
|
|
|
mozilla::services::GetPermissionManager();
|
|
|
|
NS_ENSURE_TRUE(permMgr, false);
|
|
|
|
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
2019-02-22 01:54:28 +03:00
|
|
|
nsresult rv = permMgr->TestPermissionFromPrincipal(
|
|
|
|
aPrincipal, NS_LITERAL_CSTRING("browser"), &permission);
|
2017-02-17 03:16:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
return permission == nsIPermissionManager::ALLOW_ACTION;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* virtual */
|
|
|
|
nsresult nsGenericHTMLFrameElement::AfterSetAttr(
|
2017-10-03 01:05:19 +03:00
|
|
|
int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue,
|
2017-10-05 08:59:44 +03:00
|
|
|
const nsAttrValue* aOldValue, nsIPrincipal* aMaybeScriptedPrincipal,
|
2017-10-10 00:33:38 +03:00
|
|
|
bool aNotify) {
|
2017-06-07 20:28:20 +03:00
|
|
|
if (aValue) {
|
|
|
|
nsAttrValueOrString value(aValue);
|
2017-10-05 08:59:44 +03:00
|
|
|
AfterMaybeChangeAttr(aNameSpaceID, aName, &value, aMaybeScriptedPrincipal,
|
|
|
|
aNotify);
|
2017-06-07 20:28:20 +03:00
|
|
|
} else {
|
2017-10-05 08:59:44 +03:00
|
|
|
AfterMaybeChangeAttr(aNameSpaceID, aName, nullptr, aMaybeScriptedPrincipal,
|
|
|
|
aNotify);
|
2017-06-07 20:28:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
|
|
|
if (aName == nsGkAtoms::scrolling) {
|
|
|
|
if (mFrameLoader) {
|
|
|
|
nsIDocShell* docshell = mFrameLoader->GetExistingDocShell();
|
|
|
|
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(docshell);
|
|
|
|
if (scrollable) {
|
|
|
|
int32_t cur;
|
|
|
|
scrollable->GetDefaultScrollbarPreferences(
|
|
|
|
nsIScrollable::ScrollOrientation_X, &cur);
|
|
|
|
int32_t val = MapScrollingAttribute(aValue);
|
|
|
|
if (cur != val) {
|
|
|
|
scrollable->SetDefaultScrollbarPreferences(
|
|
|
|
nsIScrollable::ScrollOrientation_X, val);
|
|
|
|
scrollable->SetDefaultScrollbarPreferences(
|
|
|
|
nsIScrollable::ScrollOrientation_Y, val);
|
2018-11-20 04:17:53 +03:00
|
|
|
RefPtr<nsPresContext> presContext = docshell->GetPresContext();
|
2017-06-07 20:28:20 +03:00
|
|
|
nsIPresShell* shell =
|
|
|
|
presContext ? presContext->GetPresShell() : nullptr;
|
|
|
|
nsIFrame* rootScroll =
|
|
|
|
shell ? shell->GetRootScrollFrame() : nullptr;
|
|
|
|
if (rootScroll) {
|
|
|
|
shell->FrameNeedsReflow(rootScroll, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
2014-01-12 08:05:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-07 20:28:20 +03:00
|
|
|
} else if (aName == nsGkAtoms::mozbrowser) {
|
|
|
|
mReallyIsBrowser = !!aValue && BrowserFramesEnabled() &&
|
|
|
|
PrincipalAllowsBrowserFrame(NodePrincipal());
|
2014-01-12 08:05:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::AfterSetAttr(
|
2017-10-05 08:59:44 +03:00
|
|
|
aNameSpaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
|
2014-01-12 08:05:49 +04:00
|
|
|
}
|
|
|
|
|
2017-06-07 20:28:20 +03:00
|
|
|
nsresult nsGenericHTMLFrameElement::OnAttrSetButNotChanged(
|
|
|
|
int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue,
|
|
|
|
bool aNotify) {
|
2017-10-05 08:59:44 +03:00
|
|
|
AfterMaybeChangeAttr(aNamespaceID, aName, &aValue, nullptr, aNotify);
|
2017-06-07 20:28:20 +03:00
|
|
|
|
|
|
|
return nsGenericHTMLElement::OnAttrSetButNotChanged(aNamespaceID, aName,
|
|
|
|
aValue, aNotify);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsGenericHTMLFrameElement::AfterMaybeChangeAttr(
|
|
|
|
int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString* aValue,
|
2017-10-05 08:59:44 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) {
|
2017-06-07 20:28:20 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aName == nsGkAtoms::src) {
|
2017-10-05 08:59:44 +03:00
|
|
|
mSrcTriggeringPrincipal = nsContentUtils::GetAttrTriggeringPrincipal(
|
|
|
|
this, aValue ? aValue->String() : EmptyString(),
|
|
|
|
aMaybeScriptedPrincipal);
|
2018-11-20 04:20:23 +03:00
|
|
|
if (!IsHTMLElement(nsGkAtoms::iframe) ||
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::srcdoc)) {
|
|
|
|
// Don't propagate error here. The attribute was successfully
|
|
|
|
// set or removed; that's what we should reflect.
|
2017-06-07 20:28:20 +03:00
|
|
|
LoadSrc();
|
|
|
|
}
|
|
|
|
} else if (aName == nsGkAtoms::name) {
|
|
|
|
// Propagate "name" to the docshell to make browsing context names live,
|
|
|
|
// per HTML5.
|
|
|
|
nsIDocShell* docShell =
|
|
|
|
mFrameLoader ? mFrameLoader->GetExistingDocShell() : nullptr;
|
|
|
|
if (docShell) {
|
|
|
|
if (aValue) {
|
|
|
|
docShell->SetName(aValue->String());
|
|
|
|
} else {
|
|
|
|
docShell->SetName(EmptyString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-20 21:02:48 +04:00
|
|
|
void nsGenericHTMLFrameElement::DestroyContent() {
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrameLoader = nullptr;
|
2012-01-20 21:02:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::DestroyContent();
|
|
|
|
}
|
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult nsGenericHTMLFrameElement::CopyInnerTo(Element* aDest) {
|
|
|
|
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
|
2012-01-20 21:02:48 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = aDest->OwnerDoc();
|
2012-01-20 21:02:48 +04:00
|
|
|
if (doc->IsStaticDocument() && mFrameLoader) {
|
|
|
|
nsGenericHTMLFrameElement* dest =
|
|
|
|
static_cast<nsGenericHTMLFrameElement*>(aDest);
|
2016-10-17 17:37:50 +03:00
|
|
|
nsFrameLoader* fl = nsFrameLoader::Create(dest, nullptr, false);
|
2012-01-20 21:02:48 +04:00
|
|
|
NS_ENSURE_STATE(fl);
|
|
|
|
dest->mFrameLoader = fl;
|
2018-03-22 05:43:17 +03:00
|
|
|
mFrameLoader->CreateStaticClone(fl);
|
2012-01-20 21:02:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nsGenericHTMLFrameElement::IsHTMLFocusable(bool aWithMouse,
|
|
|
|
bool* aIsFocusable,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aTabIndex) {
|
2012-01-20 21:02:48 +04:00
|
|
|
if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable,
|
|
|
|
aTabIndex)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aIsFocusable = nsContentUtils::IsSubDocumentTabbable(this);
|
|
|
|
|
|
|
|
if (!*aIsFocusable && aTabIndex) {
|
|
|
|
*aTabIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-03 01:26:39 +03:00
|
|
|
static bool sMozBrowserFramesEnabled = false;
|
|
|
|
#ifdef DEBUG
|
|
|
|
static bool sBoolVarCacheInitialized = false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void nsGenericHTMLFrameElement::InitStatics() {
|
|
|
|
MOZ_ASSERT(!sBoolVarCacheInitialized);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
Preferences::AddBoolVarCache(&sMozBrowserFramesEnabled,
|
|
|
|
"dom.mozBrowserFramesEnabled");
|
|
|
|
#ifdef DEBUG
|
|
|
|
sBoolVarCacheInitialized = true;
|
|
|
|
#endif
|
|
|
|
}
|
2013-11-20 02:21:16 +04:00
|
|
|
|
2017-02-03 01:26:39 +03:00
|
|
|
bool nsGenericHTMLFrameElement::BrowserFramesEnabled() {
|
|
|
|
MOZ_ASSERT(sBoolVarCacheInitialized);
|
2013-11-20 02:21:16 +04:00
|
|
|
return sMozBrowserFramesEnabled;
|
|
|
|
}
|
|
|
|
|
2012-01-20 21:02:48 +04:00
|
|
|
/**
|
2016-10-15 04:46:26 +03:00
|
|
|
* Return true if this frame element really is a mozbrowser. (It
|
2012-07-14 01:10:20 +04:00
|
|
|
* needs to have the right attributes, and its creator must have the right
|
|
|
|
* permissions.)
|
2012-01-20 21:02:48 +04:00
|
|
|
*/
|
2019-02-26 01:05:29 +03:00
|
|
|
/* [infallible] */
|
|
|
|
nsresult nsGenericHTMLFrameElement::GetReallyIsBrowser(bool* aOut) {
|
2017-02-17 03:16:00 +03:00
|
|
|
*aOut = mReallyIsBrowser;
|
2012-03-28 22:36:50 +04:00
|
|
|
return NS_OK;
|
2012-01-20 21:02:48 +04:00
|
|
|
}
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* [infallible] */
|
|
|
|
NS_IMETHODIMP nsGenericHTMLFrameElement::GetIsolated(bool* aOut) {
|
2016-02-18 06:31:29 +03:00
|
|
|
*aOut = true;
|
|
|
|
|
|
|
|
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Isolation is only disabled if the attribute is present
|
|
|
|
*aOut = !HasAttr(kNameSpaceID_None, nsGkAtoms::noisolation);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::DisallowCreateFrameLoader() {
|
|
|
|
MOZ_ASSERT(!mFrameLoader);
|
|
|
|
MOZ_ASSERT(!mFrameLoaderCreationDisallowed);
|
|
|
|
mFrameLoaderCreationDisallowed = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::AllowCreateFrameLoader() {
|
|
|
|
MOZ_ASSERT(!mFrameLoader);
|
|
|
|
MOZ_ASSERT(mFrameLoaderCreationDisallowed);
|
|
|
|
mFrameLoaderCreationDisallowed = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-02-09 10:04:18 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::InitializeBrowserAPI() {
|
|
|
|
MOZ_ASSERT(mFrameLoader);
|
|
|
|
InitBrowserElementAPI();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-09-09 00:00:12 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericHTMLFrameElement::DestroyBrowserFrameScripts() {
|
|
|
|
MOZ_ASSERT(mFrameLoader);
|
|
|
|
DestroyBrowserElementFrameScripts();
|
|
|
|
return NS_OK;
|
|
|
|
}
|