From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../sessionstore/SessionStoreFunctions.idl | 23 ------ .../sessionstore/SessionStoreFunctions.sys.mjs | 87 ---------------------- .../sessionstore/SessionStoreListener.cpp | 14 ++-- .../components/sessionstore/SessionStoreParent.cpp | 17 +++-- toolkit/components/sessionstore/moz.build | 6 +- .../sessionstore/nsISessionStoreFunctions.idl | 23 ++++++ 6 files changed, 44 insertions(+), 126 deletions(-) delete mode 100644 toolkit/components/sessionstore/SessionStoreFunctions.idl delete mode 100644 toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs create mode 100644 toolkit/components/sessionstore/nsISessionStoreFunctions.idl (limited to 'toolkit/components/sessionstore') diff --git a/toolkit/components/sessionstore/SessionStoreFunctions.idl b/toolkit/components/sessionstore/SessionStoreFunctions.idl deleted file mode 100644 index 3c17015437..0000000000 --- a/toolkit/components/sessionstore/SessionStoreFunctions.idl +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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 "nsISupports.idl" - -webidl BrowsingContext; -webidl Element; - -[scriptable, uuid(1A060FBA-A19D-11E9-B7EB-580D0EDD8E6F)] -interface nsISessionStoreFunctions : nsISupports { - // update sessionStore from the tabListener implemented by C++ - // aData is a UpdateSessionStoreData dictionary (From SessionStoreUtils.webidl) - void UpdateSessionStore( - in Element aBrowser, in BrowsingContext aBrowsingContext, - in jsval aPermanentKey, in uint32_t aEpoch, in boolean aCollectSHistory, - in jsval aData); - - void UpdateSessionStoreForStorage( - in Element aBrowser, in BrowsingContext aBrowsingContext, - in jsval aPermanentKey, in uint32_t aEpoch, in jsval aData); -}; diff --git a/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs b/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs deleted file mode 100644 index f42c371264..0000000000 --- a/toolkit/components/sessionstore/SessionStoreFunctions.sys.mjs +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- - * 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/. */ -import { SessionStore } from "resource:///modules/sessionstore/SessionStore.sys.mjs"; - -export function UpdateSessionStore( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aCollectSHistory, - aData -) { - return SessionStoreFuncInternal.updateSessionStore( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aCollectSHistory, - aData - ); -} - -export function UpdateSessionStoreForStorage( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aData -) { - return SessionStoreFuncInternal.updateSessionStoreForStorage( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aData - ); -} - -var SessionStoreFuncInternal = { - updateSessionStore: function SSF_updateSessionStore( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aCollectSHistory, - aData - ) { - let { formdata, scroll } = aData; - - if (formdata) { - aData.formdata = formdata.toJSON(); - } - - if (scroll) { - aData.scroll = scroll.toJSON(); - } - - SessionStore.updateSessionStoreFromTablistener( - aBrowser, - aBrowsingContext, - aPermanentKey, - { - data: aData, - epoch: aEpoch, - sHistoryNeeded: aCollectSHistory, - } - ); - }, - - updateSessionStoreForStorage: function SSF_updateSessionStoreForStorage( - aBrowser, - aBrowsingContext, - aPermanentKey, - aEpoch, - aData - ) { - SessionStore.updateSessionStoreFromTablistener( - aBrowser, - aBrowsingContext, - aPermanentKey, - { data: { storage: aData }, epoch: aEpoch }, - true - ); - }, -}; diff --git a/toolkit/components/sessionstore/SessionStoreListener.cpp b/toolkit/components/sessionstore/SessionStoreListener.cpp index 11b9966954..c8135752f5 100644 --- a/toolkit/components/sessionstore/SessionStoreListener.cpp +++ b/toolkit/components/sessionstore/SessionStoreListener.cpp @@ -24,7 +24,7 @@ #include "nsIXULRuntime.h" #include "nsPresContext.h" #include "nsPrintfCString.h" -#include "SessionStoreFunctions.h" +#include "nsISessionStoreFunctions.h" using namespace mozilla; using namespace mozilla::dom; @@ -436,9 +436,13 @@ void TabListener::UpdateSessionStore(bool aIsFlush) { data.mIsPrivate.Construct() = mSessionStore->GetPrivateModeEnabled(); } - nsCOMPtr funcs = do_ImportESModule( - "resource://gre/modules/SessionStoreFunctions.sys.mjs", fallible); - nsCOMPtr wrapped = do_QueryInterface(funcs); + nsCOMPtr sessionStoreFuncs = + do_GetService("@mozilla.org/toolkit/sessionstore-functions;1"); + if (!sessionStoreFuncs) { + return; + } + nsCOMPtr wrapped = + do_QueryInterface(sessionStoreFuncs); if (!wrapped) { return; } @@ -456,7 +460,7 @@ void TabListener::UpdateSessionStore(bool aIsFlush) { JS::Rooted key(jsapi.cx(), context->Canonical()->Top()->PermanentKey()); - nsresult rv = funcs->UpdateSessionStore( + nsresult rv = sessionStoreFuncs->UpdateSessionStore( mOwnerContent, context, key, mEpoch, mSessionStore->GetAndClearSHistoryChanged(), update); if (NS_FAILED(rv)) { diff --git a/toolkit/components/sessionstore/SessionStoreParent.cpp b/toolkit/components/sessionstore/SessionStoreParent.cpp index 58be84d4d9..b917990633 100644 --- a/toolkit/components/sessionstore/SessionStoreParent.cpp +++ b/toolkit/components/sessionstore/SessionStoreParent.cpp @@ -19,7 +19,7 @@ #include "mozilla/dom/InProcessParent.h" #include "mozilla/dom/SessionStoreChild.h" #include "mozilla/dom/SessionStoreUtilsBinding.h" -#include "SessionStoreFunctions.h" +#include "nsISessionStoreFunctions.h" #include "nsISupports.h" #include "nsIXULRuntime.h" #include "nsImportModule.h" @@ -146,9 +146,14 @@ static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext, data.mScroll.Construct(aScroll); } - nsCOMPtr funcs = do_ImportESModule( - "resource://gre/modules/SessionStoreFunctions.sys.mjs", fallible); - nsCOMPtr wrapped = do_QueryInterface(funcs); + nsCOMPtr sessionStoreFuncs = + do_GetService("@mozilla.org/toolkit/sessionstore-functions;1"); + if (!sessionStoreFuncs) { + return; + } + + nsCOMPtr wrapped = + do_QueryInterface(sessionStoreFuncs); if (!wrapped) { return; } @@ -166,8 +171,8 @@ static void DoSessionStoreUpdate(CanonicalBrowsingContext* aBrowsingContext, JS::Rooted key(jsapi.cx(), aBrowsingContext->Top()->PermanentKey()); - Unused << funcs->UpdateSessionStore(nullptr, aBrowsingContext, key, aEpoch, - aNeedCollectSHistory, update); + Unused << sessionStoreFuncs->UpdateSessionStore( + nullptr, aBrowsingContext, key, aEpoch, aNeedCollectSHistory, update); } #endif diff --git a/toolkit/components/sessionstore/moz.build b/toolkit/components/sessionstore/moz.build index 9e8d2eb45e..b80dd70644 100644 --- a/toolkit/components/sessionstore/moz.build +++ b/toolkit/components/sessionstore/moz.build @@ -31,15 +31,11 @@ UNIFIED_SOURCES += [ "SessionStoreUtils.cpp", ] -EXTRA_JS_MODULES += [ - "SessionStoreFunctions.sys.mjs", -] - XPIDL_MODULE = "sessionstore" XPIDL_SOURCES += [ + "nsISessionStoreFunctions.idl", "nsISessionStoreRestoreData.idl", - "SessionStoreFunctions.idl", ] IPDL_SOURCES += [ diff --git a/toolkit/components/sessionstore/nsISessionStoreFunctions.idl b/toolkit/components/sessionstore/nsISessionStoreFunctions.idl new file mode 100644 index 0000000000..3c17015437 --- /dev/null +++ b/toolkit/components/sessionstore/nsISessionStoreFunctions.idl @@ -0,0 +1,23 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* 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 "nsISupports.idl" + +webidl BrowsingContext; +webidl Element; + +[scriptable, uuid(1A060FBA-A19D-11E9-B7EB-580D0EDD8E6F)] +interface nsISessionStoreFunctions : nsISupports { + // update sessionStore from the tabListener implemented by C++ + // aData is a UpdateSessionStoreData dictionary (From SessionStoreUtils.webidl) + void UpdateSessionStore( + in Element aBrowser, in BrowsingContext aBrowsingContext, + in jsval aPermanentKey, in uint32_t aEpoch, in boolean aCollectSHistory, + in jsval aData); + + void UpdateSessionStoreForStorage( + in Element aBrowser, in BrowsingContext aBrowsingContext, + in jsval aPermanentKey, in uint32_t aEpoch, in jsval aData); +}; -- cgit v1.2.3