forked from mirrors/gecko-dev
Bug 1873772 - Only report XULStore load errors in the parent process; r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D198086
This commit is contained in:
parent
5d785358b6
commit
44b676d37a
5 changed files with 43 additions and 1 deletions
|
|
@ -12249,7 +12249,7 @@ void Document::SetReadyStateInternal(ReadyState aReadyState,
|
||||||
|
|
||||||
if (READYSTATE_INTERACTIVE == aReadyState &&
|
if (READYSTATE_INTERACTIVE == aReadyState &&
|
||||||
NodePrincipal()->IsSystemPrincipal()) {
|
NodePrincipal()->IsSystemPrincipal()) {
|
||||||
if (!mXULPersist) {
|
if (!mXULPersist && XRE_IsParentProcess()) {
|
||||||
mXULPersist = new XULPersist(this);
|
mXULPersist = new XULPersist(this);
|
||||||
mXULPersist->Init();
|
mXULPersist->Init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ class nsCOMArray;
|
||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class synchronizes element attributes (such as window sizing) with the
|
||||||
|
* live elements in a Document and with the XULStore. The XULStore persists
|
||||||
|
* these attributes to the file system. This class is created and owned by the
|
||||||
|
* Document and must only be created in the parent process. It only presists
|
||||||
|
* chrome document element attributes.
|
||||||
|
*/
|
||||||
class XULPersist final : public nsStubDocumentObserver {
|
class XULPersist final : public nsStubDocumentObserver {
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,30 @@ const WRITE_DELAY_MS = (debugMode ? 3 : 30) * 1000;
|
||||||
const XULSTORE_CID = Components.ID("{6f46b6f4-c8b1-4bd4-a4fa-9ebbed0753ea}");
|
const XULSTORE_CID = Components.ID("{6f46b6f4-c8b1-4bd4-a4fa-9ebbed0753ea}");
|
||||||
const STOREDB_FILENAME = "xulstore.json";
|
const STOREDB_FILENAME = "xulstore.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XULStore retains XULElement attributes such as the sizing and styling. These are
|
||||||
|
* stored in the user's profile directory inside of "xulstore.json". The JSON is
|
||||||
|
* stored based on the chrome URL of the resource.
|
||||||
|
*
|
||||||
|
* For instance the "chrome://browser/content/browser.xhtml" main window sizing could be
|
||||||
|
* stored like so:
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* "chrome://browser/content/browser.xhtml": {
|
||||||
|
* "main-window": {
|
||||||
|
* "screenX": "1104",
|
||||||
|
* "screenY": "25",
|
||||||
|
* "width": "1904",
|
||||||
|
* "height": "1612",
|
||||||
|
* "sizemode": "normal"
|
||||||
|
* },
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* The XULStore can only be loaded in the parent process. See the XULStore
|
||||||
|
* and XULPersist C++ classes for how this is integrated from the C++ side.
|
||||||
|
*/
|
||||||
export function XULStore() {
|
export function XULStore() {
|
||||||
if (!Services.appinfo.inSafeMode) {
|
if (!Services.appinfo.inSafeMode) {
|
||||||
this.load();
|
this.load();
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,6 @@ Classes = [
|
||||||
'interfaces': ['nsIXULStore'],
|
'interfaces': ['nsIXULStore'],
|
||||||
'esModule': 'resource://gre/modules/XULStore.sys.mjs',
|
'esModule': 'resource://gre/modules/XULStore.sys.mjs',
|
||||||
'constructor': 'XULStore',
|
'constructor': 'XULStore',
|
||||||
|
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1704,6 +1704,11 @@ static void ConvertWindowSize(nsIAppWindow* aWin, const nsAtom* aAttr,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult AppWindow::GetPersistentValue(const nsAtom* aAttr, nsAString& aValue) {
|
nsresult AppWindow::GetPersistentValue(const nsAtom* aAttr, nsAString& aValue) {
|
||||||
|
if (!XRE_IsParentProcess()) {
|
||||||
|
// The XULStore is only available in the parent process.
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<dom::Element> docShellElement = GetWindowDOMElement();
|
nsCOMPtr<dom::Element> docShellElement = GetWindowDOMElement();
|
||||||
if (!docShellElement) {
|
if (!docShellElement) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
@ -1941,6 +1946,11 @@ nsresult AppWindow::MaybeSaveEarlyWindowPersistentValues(
|
||||||
|
|
||||||
nsresult AppWindow::SetPersistentValue(const nsAtom* aAttr,
|
nsresult AppWindow::SetPersistentValue(const nsAtom* aAttr,
|
||||||
const nsAString& aValue) {
|
const nsAString& aValue) {
|
||||||
|
if (!XRE_IsParentProcess()) {
|
||||||
|
// The XULStore is only available in the parent process.
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoString uri;
|
nsAutoString uri;
|
||||||
nsAutoString windowElementId;
|
nsAutoString windowElementId;
|
||||||
nsresult rv = GetDocXulStoreKeys(uri, windowElementId);
|
nsresult rv = GetDocXulStoreKeys(uri, windowElementId);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue