/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement() { if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
Document* nsGenericHTMLFrameElement::GetContentDocument(
nsIPrincipal& aSubjectPrincipal) {
RefPtr<BrowsingContext> bc = GetContentWindowInternal(); if (!bc) { return nullptr;
}
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;
}
Document* doc = window->GetDoc(); if (!doc) { return nullptr;
}
// Return null for cross-origin contentDocument. if (!aSubjectPrincipal.SubsumesConsideringDomain(doc->NodePrincipal())) { return nullptr;
} return doc;
}
if (mFrameLoader->DepthTooGreat()) { // Claim to have no contentWindow return nullptr;
}
RefPtr<BrowsingContext> bc = mFrameLoader->GetBrowsingContext(); return bc;
}
Nullable<WindowProxyHolder> nsGenericHTMLFrameElement::GetContentWindow() {
RefPtr<BrowsingContext> bc = GetContentWindowInternal(); if (!bc) { return nullptr;
} return WindowProxyHolder(bc);
}
void nsGenericHTMLFrameElement::EnsureFrameLoader() { if (!IsInComposedDoc() || mFrameLoader || OwnerDoc()->IsStaticDocument()) { // 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.
mFrameLoader = nsFrameLoader::Create(this, mNetworkCreated);
}
void nsGenericHTMLFrameElement::SwapFrameLoaders(
HTMLIFrameElement& aOtherLoaderOwner, ErrorResult& rv) { if (&aOtherLoaderOwner == this) { // nothing to do return;
}
if (mLazyLoading) { // Waiting for lazy load, do nothing. if (!mFrameLoader->GetExtantBrowsingContext()) { // We still want to initialize the frame loader for the browsing // context to exist, so that it can be found by name and such.
nsContentUtils::AddScriptRunner(
NewRunnableMethod("InitializeLazyFrameLoader", mFrameLoader.get(),
&nsFrameLoader::GetBrowsingContext));
} return;
}
// 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(UnbindContext& aContext) { 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();
mFrameLoader = nullptr;
}
if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::scrolling) { if (mFrameLoader) {
ScrollbarPreference pref = MapScrollingAttribute(aValue); if (nsDocShell* docshell = mFrameLoader->GetExistingDocShell()) {
docshell->SetScrollbarPreference(pref);
} elseif (auto* child = mFrameLoader->GetBrowserBridgeChild()) { // NOTE(emilio): We intentionally don't deal with the // GetBrowserParent() case, and only deal with the fission iframe // case. We could make it work, but it's a bit of boilerplate for // something that we don't use, and we'd need to think how it // interacts with the scrollbar window flags...
child->SendScrollbarPreferenceChanged(pref);
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.