/* -*- 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/. */
// Explicit specialization of the `Transaction` type. Required by the `extern // template class` declaration in the header. templateclass syncedcontext::Transaction<WindowContext>;
mChildren.AppendElement(aBrowsingContext); if (!aBrowsingContext->IsEmbedderTypeObjectOrEmbed()) {
mNonSyntheticChildren.AppendElement(aBrowsingContext);
}
// If we're the current WindowContext in our BrowsingContext, make sure to // clear any cached `children` value. if (IsCurrent()) {
BrowsingContext_Binding::ClearCachedChildrenValue(mBrowsingContext);
}
}
// If we're the current WindowContext in our BrowsingContext, make sure to // clear any cached `children` value. if (IsCurrent()) {
BrowsingContext_Binding::ClearCachedChildrenValue(mBrowsingContext);
}
}
void WindowContext::UpdateChildSynthetic(BrowsingContext* aBrowsingContext, bool aIsSynthetic) { if (aIsSynthetic) {
mNonSyntheticChildren.RemoveElement(aBrowsingContext);
} else { // The same BrowsingContext will be reused for error pages, so it can be in // the list already. if (!mNonSyntheticChildren.Contains(aBrowsingContext)) {
mNonSyntheticChildren.AppendElement(aBrowsingContext);
}
}
}
void WindowContext::RecomputeCanExecuteScripts(bool aApplyChanges) { constbool old = mCanExecuteScripts; if (!AllowJavascript()) { // Scripting has been explicitly disabled on our WindowContext.
mCanExecuteScripts = false;
} else { // Otherwise, inherit.
mCanExecuteScripts = mBrowsingContext->CanExecuteScripts();
}
if (aApplyChanges && old != mCanExecuteScripts) { // Inform our active DOM window. if (nsGlobalWindowInner* window = GetInnerWindow()) { // Only update scriptability if the window is current. Windows will have // scriptability disabled when entering the bfcache and updated when // coming out. if (window->IsCurrentInnerWindow()) { auto& scriptability =
xpc::Scriptability::Get(window->GetGlobalJSObject());
scriptability.SetWindowAllowsScript(mCanExecuteScripts);
}
}
void WindowContext::DidSet(FieldIndex<IDX_SHEntryHasUserInteraction>, bool aOldValue) {
MOZ_ASSERT(
TopWindowContext() == this, "SHEntryHasUserInteraction can only be set on the top window context"); // This field is set when the child notifies us of new user interaction, so we // also set the currently active shentry in the parent as having interaction. if (XRE_IsParentProcess() && mBrowsingContext) {
SessionHistoryEntry* activeEntry =
mBrowsingContext->Canonical()->GetActiveSessionHistoryEntry(); if (activeEntry && GetSHEntryHasUserInteraction()) {
activeEntry->SetHasUserInteraction(true);
}
}
}
void WindowContext::DidSet(FieldIndex<IDX_UserActivationStateAndModifiers>) {
MOZ_ASSERT_IF(!IsInProcess(), mUserGestureStart.IsNull());
USER_ACTIVATION_LOG("Set user gesture activation 0x%02" PRIu8 " for %s browsing context 0x%08" PRIx64,
GetUserActivationStateAndModifiers(),
XRE_IsParentProcess() ? "Parent" : "Child", Id()); if (IsInProcess()) {
USER_ACTIVATION_LOG( "Set user gesture start time for %s browsing context 0x%08" PRIx64,
XRE_IsParentProcess() ? "Parent" : "Child", Id()); if (GetUserActivationState() == UserActivation::State::FullActivated) {
mUserGestureStart = TimeStamp::Now();
} elseif (GetUserActivationState() == UserActivation::State::None) {
mUserGestureStart = TimeStamp();
}
}
}
void WindowContext::DidSet(FieldIndex<IDX_HasReportedShadowDOMUsage>, bool aOldValue) { if (!aOldValue && GetHasReportedShadowDOMUsage() && IsInProcess()) {
MOZ_ASSERT(TopWindowContext() == this); if (mBrowsingContext) {
Document* topLevelDoc = mBrowsingContext->GetDocument(); if (topLevelDoc) {
nsAutoString uri;
Unused << topLevelDoc->GetDocumentURI(uri); if (!uri.IsEmpty()) {
nsAutoString msg = u"Shadow DOM used in ["_ns + uri +
u"] or in some of its subdocuments."_ns;
nsContentUtils::ReportToConsoleNonLocalized(
msg, nsIScriptError::infoFlag, "DOM"_ns, topLevelDoc);
}
}
}
}
}
void WindowContext::CreateFromIPC(IPCInitializer&& aInit) {
MOZ_RELEASE_ASSERT(XRE_IsContentProcess(), "Should be a WindowGlobalParent in the parent");
RefPtr<BrowsingContext> bc = BrowsingContext::Get(aInit.mBrowsingContextId);
MOZ_RELEASE_ASSERT(bc);
if (bc->IsDiscarded()) { // If we have already closed our browsing context, the // WindowGlobalChild actor is bound to be destroyed soon and it's // safe to ignore creating the WindowContext. return;
}
// Register the WindowContext in the `WindowContextByIdMap`. if (!gWindowContexts) {
gWindowContexts = new WindowContextByIdMap();
ClearOnShutdown(&gWindowContexts);
} auto& entry = gWindowContexts->LookupOrInsert(mInnerWindowId);
MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowContext for ID!");
entry = this;
// Register this to the browsing context.
mBrowsingContext->RegisterWindowContext(this);
Group()->Register(this);
}
if (GetUserActivationState() != UserActivation::State::FullActivated) { // mUserGestureStart should be null if the document hasn't ever been // activated by user gesture
MOZ_ASSERT_IF(GetUserActivationState() == UserActivation::State::None,
mUserGestureStart.IsNull()); returnfalse;
}
MOZ_ASSERT(!mUserGestureStart.IsNull(), "mUserGestureStart shouldn't be null if the document has ever " "been activated by user gesture");
TimeDuration timeout = TimeDuration::FromMilliseconds(
StaticPrefs::dom_user_activation_transient_timeout());
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.