Bug 1460047 - 3. Make module resource optional; r=esawin

Some modules such as Scroll and SelectionAction only require a frame
script and not a resource. Make the module resource optional so we can
remove the redundant resources for these modules.

MozReview-Commit-ID: 3uCy4xxInJf

--HG--
extra : rebase_source : 940cc493ea1424f792ea31bbe3941740ea59bec0
This commit is contained in:
Jim Chen 2018-05-11 14:59:50 -04:00
Родитель 443cc0dfb7
Коммит 5c27454e73
4 изменённых файлов: 16 добавлений и 44 удалений

Просмотреть файл

@ -94,7 +94,7 @@ var ModuleManager = {
this._frozenSettings = Object.freeze(Object.assign({}, this._settings));
this.forEach(module => {
if (module.enabled) {
if (module.enabled && module.impl) {
module.impl.onSettingsUpdate();
}
});
@ -190,7 +190,9 @@ class ModuleInfo {
}
onInit() {
this._impl.onInit();
if (this._impl) {
this._impl.onInit();
}
this._loadPhase(this._onInitPhase);
this._onInitPhase = null;
@ -217,7 +219,9 @@ class ModuleInfo {
}
if (aPhase.frameScript && !this._contentModuleLoaded) {
this._impl.onLoadContentModule();
if (this._impl) {
this._impl.onLoadContentModule();
}
this._manager.messageManager.loadFrameScript(aPhase.frameScript, true);
this._contentModuleLoaded = true;
}
@ -244,7 +248,7 @@ class ModuleInfo {
return;
}
if (!aEnabled) {
if (!aEnabled && this._impl) {
this._impl.onDisable();
}
@ -253,8 +257,10 @@ class ModuleInfo {
if (aEnabled) {
this._loadPhase(this._onEnablePhase);
this._onEnablePhase = null;
this._impl.onEnable();
this._impl.onSettingsUpdate();
if (this._impl) {
this._impl.onEnable();
this._impl.onSettingsUpdate();
}
}
this._updateContentModuleState(/* includeSettings */ aEnabled);
@ -262,7 +268,10 @@ class ModuleInfo {
onContentModuleLoaded() {
this._updateContentModuleState(/* includeSettings */ true);
this._impl.onContentModuleLoaded();
if (this._impl) {
this._impl.onContentModuleLoaded();
}
}
_updateContentModuleState(aIncludeSettings) {
@ -313,13 +322,11 @@ function startup() {
}, {
name: "GeckoViewScroll",
onEnable: {
resource: "resource://gre/modules/GeckoViewScroll.jsm",
frameScript: "chrome://geckoview/content/GeckoViewScrollContent.js",
},
}, {
name: "GeckoViewSelectionAction",
onEnable: {
resource: "resource://gre/modules/GeckoViewSelectionAction.jsm",
frameScript: "chrome://geckoview/content/GeckoViewSelectionActionContent.js",
},
}, {

Просмотреть файл

@ -1,16 +0,0 @@
/* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["GeckoViewScroll"];
ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
class GeckoViewScroll extends GeckoViewModule {
onEnable() {
debug `onEnable`;
}
}

Просмотреть файл

@ -1,17 +0,0 @@
/* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["GeckoViewSelectionAction"];
ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// Handles inter-op between accessible carets and GeckoSession.
class GeckoViewSelectionAction extends GeckoViewModule {
onEnable() {
debug `onEnable`;
}
}

Просмотреть файл

@ -13,8 +13,6 @@ EXTRA_JS_MODULES += [
'GeckoViewNavigation.jsm',
'GeckoViewProgress.jsm',
'GeckoViewRemoteDebugger.jsm',
'GeckoViewScroll.jsm',
'GeckoViewSelectionAction.jsm',
'GeckoViewSettings.jsm',
'GeckoViewTab.jsm',
'GeckoViewTrackingProtection.jsm',