Issue #65 - Remove AppConstants from toolkit/modules

Except for secondscreen
This commit is contained in:
Matt A. Tobin 2020-02-02 04:25:47 -05:00 committed by Roy Tam
commit cc403750d3
10 changed files with 174 additions and 168 deletions

View file

@ -8,7 +8,6 @@ const {utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
"resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
@ -148,12 +147,13 @@ LightweightThemeConsumer.prototype = {
footer.removeAttribute("lwthemefooter");
}
#ifdef XP_MACOSX
// On OS X, we extend the lightweight theme into the titlebar, which means setting
// the chromemargin attribute. Some XUL applications already draw in the titlebar,
// so we need to save the chromemargin value before we overwrite it with the value
// that lets us draw in the titlebar. We stash this value on the root attribute so
// that XUL applications have the ability to invalidate the saved value.
if (AppConstants.platform == "macosx" && stateChanging) {
if (stateChanging) {
if (!root.hasAttribute("chromemargin-nonlwtheme")) {
root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
}
@ -169,6 +169,7 @@ LightweightThemeConsumer.prototype = {
}
}
}
#endif
Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
JSON.stringify(aData));
}

View file

@ -9,14 +9,21 @@ this.EXPORTED_SYMBOLS = ["ResetProfile"];
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
// For Basilisk and Pale Moon
// Hard-code MOZ_APP_NAME to firefox because of hard-coded type in migrator.
const MOZ_APP_NAME = (((AppConstants.MOZ_APP_NAME == "basilisk")
|| (AppConstants.MOZ_APP_NAME == "palemoon"))
? "firefox" : AppConstants.MOZ_APP_NAME);
const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
// We need to tell the migrator that many different applications are Mozilla applications
#ifdef MOZ_PHOENIX
const MOZ_APP_NAME = "firefox";
const MOZ_BUILD_APP = "browser";
#elifdef MOZ_THUNDERBIRD
const MOZ_APP_NAME = "thunderbird";
const MOZ_BUILD_APP = "mail";
#elif defined(MOZ_SUITE) && !defined(BINOC_BOREALIS)
const MOZ_APP_NAME = "seamonkey";
const MOZ_BUILD_APP = "suite";
#else
#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__";
#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__".match(/([^\/]*)\/*$/)[1];
#endif
this.ResetProfile = {
/**

View file

@ -8,7 +8,6 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
this.Services = {};

View file

@ -8,7 +8,6 @@ this.EXPORTED_SYMBOLS = ["UpdateUtils"];
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
@ -33,9 +32,8 @@ this.UpdateUtils = {
* Whether or not to include the partner bits. Default: true.
*/
getUpdateChannel(aIncludePartners = true) {
let channel = defaults.getCharPref("app.update.channel",
AppConstants.MOZ_UPDATE_CHANNEL);
let defaults = Services.prefs.getDefaultBranch(null);
#expand let channel = defaults.getCharPref("app.update.channel", "__MOZ_UPDATE_CHANNEL__");
if (aIncludePartners) {
try {
@ -132,49 +130,48 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "Locale", function() {
* Provides adhoc system capability information for application update.
*/
XPCOMUtils.defineLazyGetter(this, "gSystemCapabilities", function aus_gSC() {
if (AppConstants.platform == "win") {
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
#ifdef XP_WIN
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
let lib = ctypes.open("kernel32.dll");
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
ctypes.winapi_abi,
ctypes.int32_t, /* success */
ctypes.uint32_t); /* DWORD */
let instructionSet = "unknown";
try {
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE3";
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE2";
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE";
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "MMX";
}
} catch (e) {
instructionSet = "error";
Cu.reportError("Error getting processor instruction set. " +
"Exception: " + e);
}
lib.close();
return instructionSet;
}
if (AppConstants == "linux") {
let instructionSet = "unknown";
if (navigator.cpuHasSSE2) {
let lib = ctypes.open("kernel32.dll");
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
ctypes.winapi_abi,
ctypes.int32_t, /* success */
ctypes.uint32_t); /* DWORD */
let instructionSet = "unknown";
try {
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE3";
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE2";
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE";
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "MMX";
}
return instructionSet;
} catch (e) {
instructionSet = "error";
Cu.reportError("Error getting processor instruction set. " +
"Exception: " + e);
}
lib.close();
return instructionSet;
#elifdef XP_LINUX
let instructionSet = "unknown";
if (navigator.cpuHasSSE2) {
instructionSet = "SSE2";
}
return instructionSet;
#else
return "NA"
#endif
});
#ifdef XP_WIN
/* Windows only getter that returns the processor architecture. */
XPCOMUtils.defineLazyGetter(this, "gWinCPUArch", function aus_gWinCPUArch() {
// Get processor architecture
@ -239,6 +236,7 @@ XPCOMUtils.defineLazyGetter(this, "gWinCPUArch", function aus_gWinCPUArch() {
return arch;
});
#endif
XPCOMUtils.defineLazyGetter(UpdateUtils, "ABI", function() {
let abi = null;
@ -249,19 +247,20 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "ABI", function() {
Cu.reportError("XPCOM ABI unknown");
}
if (AppConstants.platform == "macosx") {
// Mac universal build should report a different ABI than either macppc
// or mactel.
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
#ifdef XP_MACOSX
// Mac universal build should report a different ABI than either macppc
// or mactel.
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
if (macutils.isUniversalBinary) {
abi += "-u-" + macutils.architecturesInBinary;
}
} else if (AppConstants.platform == "win") {
// Windows build should report the CPU architecture that it's running on.
abi += "-" + gWinCPUArch;
if (macutils.isUniversalBinary) {
abi += "-u-" + macutils.architecturesInBinary;
}
#elifdef XP_WIN
// Windows build should report the CPU architecture that it's running on.
abi += "-" + gWinCPUArch;
#endif
return abi;
});
@ -275,95 +274,96 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "OSVersion", function() {
Cu.reportError("OS Version unknown.");
}
#ifdef XP_WIN
if (osVersion) {
if (AppConstants.platform == "win") {
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
let kernel32 = false;
let kernel32 = false;
try {
kernel32 = ctypes.open("Kernel32");
} catch (e) {
Cu.reportError("Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if (kernel32) {
try {
kernel32 = ctypes.open("Kernel32");
} catch (e) {
Cu.reportError("Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if (kernel32) {
// Get Service pack info
try {
// Get Service pack info
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if (0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor +
"." + winVer.wServicePackMinor;
} else {
Cu.reportError("Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} catch (e) {
Cu.reportError("Error getting service pack information. Exception: " + e);
if (0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor +
"." + winVer.wServicePackMinor;
} else {
Cu.reportError("Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} finally {
kernel32.close();
} catch (e) {
Cu.reportError("Error getting service pack information. Exception: " + e);
osVersion += ".unknown";
}
// Add processor architecture
osVersion += " (" + gWinCPUArch + ")";
} finally {
kernel32.close();
}
}
try {
osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
// Add processor architecture
osVersion += " (" + gWinCPUArch + ")";
}
catch (e) {
// Not all platforms have a secondary widget library, so an error is nothing to worry about.
}
osVersion = encodeURIComponent(osVersion);
}
try {
osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
}
catch (e) {
// Not all platforms have a secondary widget library, so an error is nothing to worry about.
}
osVersion = encodeURIComponent(osVersion);
#endif
return osVersion;
});

View file

@ -2,9 +2,11 @@
* 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/. */
Components.utils.import("resource://gre/modules/AppConstants.jsm");
const HAVE_CSS_WINDOW_DRAG_SUPPORT = ["win", "macosx"].includes(AppConstants.platform);
#if defined(XP_WIN) || defined(XP_MACOSX)
const HAVE_CSS_WINDOW_DRAG_SUPPORT = true;
#else
const HAVE_CSS_WINDOW_DRAG_SUPPORT = false;
#endif
this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
@ -62,12 +64,13 @@ WindowDraggingElement.prototype = {
if (!this.shouldDrag(aEvent))
return;
if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
break;
}
#ifdef MOZ_WIDGET_GTK
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
break;
#endif
if (isPanel) {
let screenRect = this._elem.getOuterScreenRect();
this._deltaX = aEvent.screenX - screenRect.left;

View file

@ -19,8 +19,6 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
"resource://gre/modules/BrowserUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionUtils",
@ -846,9 +844,9 @@ var onBeforeRequest = {
get allowedOptions() {
delete this.allowedOptions;
this.allowedOptions = ["blocking"];
if (!AppConstants.RELEASE_OR_BETA) {
this.allowedOptions.push("requestBody");
}
#ifndef RELEASE_OR_BETA
this.allowedOptions.push("requestBody");
#endif
return this.allowedOptions;
},
addListener(callback, filter = null, opt_extraInfoSpec = null) {

View file

@ -74,7 +74,6 @@ EXTRA_JS_MODULES += [
'RemotePageManager.jsm',
'RemoteSecurityUI.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',
'ResponsivenessMonitor.jsm',
'secondscreen/PresentationApp.jsm',
'secondscreen/RokuApp.jsm',
@ -93,7 +92,6 @@ EXTRA_JS_MODULES += [
'Task.jsm',
'Timer.jsm',
'WebChannel.jsm',
'WindowDraggingUtils.jsm',
'ZipUtils.jsm',
]
EXTRA_JS_MODULES.third_party.jsesc += ['third_party/jsesc/jsesc.js']
@ -101,8 +99,10 @@ EXTRA_JS_MODULES.sessionstore += ['sessionstore/Utils.jsm']
EXTRA_PP_JS_MODULES += [
'NewTabUtils.jsm',
'ResetProfile.jsm',
'Troubleshoot.jsm',
'UpdateUtils.jsm',
'WindowDraggingUtils.jsm',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
@ -120,7 +120,7 @@ EXTRA_PP_JS_MODULES += [
]
if 'Android' != CONFIG['OS_TARGET']:
EXTRA_JS_MODULES += [
EXTRA_PP_JS_MODULES += [
'LightweightThemeConsumer.jsm',
]

View file

@ -18,17 +18,16 @@ let EXPORTED_SYMBOLS = ["Subprocess"];
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/subprocess/subprocess_common.jsm");
if (AppConstants.platform == "win") {
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_win.jsm");
} else {
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_unix.jsm");
}
#ifdef XP_WIN
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_win.jsm");
#else
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_unix.jsm");
#endif
/**
* Allows for creation of and communication with OS-level sub-processes.

View file

@ -4,7 +4,7 @@
# 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/.
EXTRA_JS_MODULES += [
EXTRA_PP_JS_MODULES += [
'Subprocess.jsm',
]

View file

@ -15,7 +15,6 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
var EXPORTED_SYMBOLS = ["SubprocessImpl"];
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -35,7 +34,7 @@ class WinPromiseWorker extends PromiseWorker {
this.signalEvent = libc.CreateSemaphoreW(null, 0, 32, null);
this.call("init", [{
breakAwayFromJob: !AppConstants.isPlatformAndVersionAtLeast("win", "6.2"),
breakAwayFromJob: Services.vc.compare(Services.sysinfo.getProperty("version"), "6.2") <= 0,
comspec: env.get("COMSPEC"),
signalEvent: String(ctypes.cast(this.signalEvent, ctypes.uintptr_t).value),
}]);