summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-01 23:45:36 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:26:11 +0200
commit4acc0d58cb0fa989d609972493be363c105f2594 (patch)
treeb0c4dfd608561041b83da74a1eba5739ab3931ec /toolkit
parenta1c9dd468daa6d729c9d11416fb8a5c2dceb2c88 (diff)
downloadUXP-4acc0d58cb0fa989d609972493be363c105f2594.tar
UXP-4acc0d58cb0fa989d609972493be363c105f2594.tar.gz
UXP-4acc0d58cb0fa989d609972493be363c105f2594.tar.lz
UXP-4acc0d58cb0fa989d609972493be363c105f2594.tar.xz
UXP-4acc0d58cb0fa989d609972493be363c105f2594.zip
Issue #65 - Remove AppConstants from toolkit/content
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/content/aboutProfiles.js12
-rw-r--r--toolkit/content/aboutSupport.js71
-rw-r--r--toolkit/content/aboutTelemetry.js25
-rw-r--r--toolkit/content/browser-child.js1
-rw-r--r--toolkit/content/contentAreaUtils.js10
-rw-r--r--toolkit/content/customizeToolbar.js9
-rw-r--r--toolkit/content/globalOverlay.js44
-rw-r--r--toolkit/content/jar.mn12
8 files changed, 88 insertions, 96 deletions
diff --git a/toolkit/content/aboutProfiles.js b/toolkit/content/aboutProfiles.js
index cddf88819..29c5f67ad 100644
--- a/toolkit/content/aboutProfiles.js
+++ b/toolkit/content/aboutProfiles.js
@@ -8,7 +8,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import('resource://gre/modules/AppConstants.jsm');
XPCOMUtils.defineLazyServiceGetter(
this,
@@ -130,12 +129,13 @@ function display(profileData) {
if (dir) {
td.appendChild(document.createTextNode(' '));
let button = document.createElement('button');
+#ifdef XP_WIN
+ let string = 'winOpenDir2';
+#elifdef XP_MACOSX
+ let string = 'macOpenDir';
+#else
let string = 'openDir';
- if (AppConstants.platform == "win") {
- string = 'winOpenDir2';
- } else if (AppConstants.platform == "macosx") {
- string = 'macOpenDir';
- }
+#endif
let buttonText = document.createTextNode(bundle.GetStringFromName(string));
button.appendChild(buttonText);
td.appendChild(button);
diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js
index 5c889c18f..4e58bbef9 100644
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -10,7 +10,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Troubleshoot.jsm");
Cu.import("resource://gre/modules/ResetProfile.jsm");
-Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
@@ -42,7 +41,7 @@ var snapshotFormatters = {
$("os-box").textContent = data.osVersion;
$("binary-box").textContent = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
$("supportLink").href = data.supportURL;
- let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
+ let version = Services.appinfo.version;
if (data.versionArch) {
version += " (" + data.versionArch + ")";
}
@@ -197,23 +196,23 @@ var snapshotFormatters = {
delete data.info;
}
- if (AppConstants.NIGHTLY_BUILD) {
- let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
- let gpuProcessPid = windowUtils.gpuProcessPid;
+#ifdef NIGHTLY_BUILD
+ let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ let gpuProcessPid = windowUtils.gpuProcessPid;
- if (gpuProcessPid != -1) {
- let gpuProcessKillButton = $.new("button");
+ if (gpuProcessPid != -1) {
+ let gpuProcessKillButton = $.new("button");
- gpuProcessKillButton.addEventListener("click", function() {
- windowUtils.terminateGPUProcess();
- });
+ gpuProcessKillButton.addEventListener("click", function() {
+ windowUtils.terminateGPUProcess();
+ });
- gpuProcessKillButton.textContent = strings.GetStringFromName("gpuProcessKillButton");
- addRow("diagnostics", "GPUProcessPid", gpuProcessPid);
- addRow("diagnostics", "GPUProcess", [gpuProcessKillButton]);
- }
+ gpuProcessKillButton.textContent = strings.GetStringFromName("gpuProcessKillButton");
+ addRow("diagnostics", "GPUProcessPid", gpuProcessPid);
+ addRow("diagnostics", "GPUProcess", [gpuProcessKillButton]);
}
+#endif
// graphics-failures-tbody tbody
if ("failures" in data) {
@@ -583,15 +582,15 @@ function copyRawDataToClipboard(button) {
Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard).
setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
- if (AppConstants.platform == "android") {
- // Present a toast notification.
- let message = {
- type: "Toast:Show",
- message: stringBundle().GetStringFromName("rawDataCopied"),
- duration: "short"
- };
- Services.androidBridge.handleGeckoMessage(message);
- }
+#ifdef MOZ_WIDGET_ANDROID
+ // Present a toast notification.
+ let message = {
+ type: "Toast:Show",
+ message: stringBundle().GetStringFromName("rawDataCopied"),
+ duration: "short"
+ };
+ Services.androidBridge.handleGeckoMessage(message);
+#endif
});
}
catch (err) {
@@ -637,15 +636,15 @@ function copyContentsToClipboard() {
.getService(Ci.nsIClipboard);
clipboard.setData(transferable, null, clipboard.kGlobalClipboard);
- if (AppConstants.platform == "android") {
- // Present a toast notification.
- let message = {
- type: "Toast:Show",
- message: stringBundle().GetStringFromName("textCopied"),
- duration: "short"
- };
- Services.androidBridge.handleGeckoMessage(message);
- }
+#ifdef MOZ_WIDGET_ANDROID
+ // Present a toast notification.
+ let message = {
+ type: "Toast:Show",
+ message: stringBundle().GetStringFromName("textCopied"),
+ duration: "short"
+ };
+ Services.androidBridge.handleGeckoMessage(message);
+#endif
}
// Return the plain text representation of an element. Do a little bit
@@ -654,10 +653,10 @@ function createTextForElement(elem) {
let serializer = new Serializer();
let text = serializer.serialize(elem);
+#ifdef XP_WIN
// Actual CR/LF pairs are needed for some Windows text editors.
- if (AppConstants.platform == "win") {
- text = text.replace(/\n/g, "\r\n");
- }
+ text = text.replace(/\n/g, "\r\n");
+#endif
return text;
}
diff --git a/toolkit/content/aboutTelemetry.js b/toolkit/content/aboutTelemetry.js
index c73a979c6..0829fe7e2 100644
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -19,9 +19,6 @@ Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
- "resource://gre/modules/AppConstants.jsm");
-
const Telemetry = Services.telemetry;
const bundle = Services.strings.createBundle(
"chrome://global/locale/aboutTelemetry.properties");
@@ -236,17 +233,17 @@ var Settings = {
let elements = document.getElementsByClassName("change-data-choices-link");
for (let el of elements) {
el.addEventListener("click", function() {
- if (AppConstants.platform == "android") {
- Cu.import("resource://gre/modules/Messaging.jsm");
- Messaging.sendRequest({
- type: "Settings:Show",
- resource: "preferences_privacy",
- });
- } else {
- // Show the data choices preferences on desktop.
- let mainWindow = getMainWindowWithPreferencesPane();
- mainWindow.openAdvancedPreferences("dataChoicesTab");
- }
+#ifdef MOZ_WIDGET_ANDROID
+ Cu.import("resource://gre/modules/Messaging.jsm");
+ Messaging.sendRequest({
+ type: "Settings:Show",
+ resource: "preferences_privacy",
+ });
+#else
+ // Show the data choices preferences on desktop.
+ let mainWindow = getMainWindowWithPreferencesPane();
+ mainWindow.openAdvancedPreferences("dataChoicesTab");
+#endif
}, false);
}
},
diff --git a/toolkit/content/browser-child.js b/toolkit/content/browser-child.js
index 7d0fe18c5..ffb07dde2 100644
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -7,7 +7,6 @@ var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
-Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/BrowserUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js
index 736fb7dfc..2512804fa 100644
--- a/toolkit/content/contentAreaUtils.js
+++ b/toolkit/content/contentAreaUtils.js
@@ -24,8 +24,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
- "resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
@@ -1161,10 +1159,10 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
if (!aDefaultExtension)
return aFile;
- if (AppConstants.platform == "win") {
- // Remove trailing dots and spaces on windows
- aFile = aFile.replace(/[\s.]+$/, "");
- }
+#ifdef XP_WIN
+ // Remove trailing dots and spaces on windows
+ aFile = aFile.replace(/[\s.]+$/, "");
+#endif
// Remove leading dots
aFile = aFile.replace(/^\.+/, "");
diff --git a/toolkit/content/customizeToolbar.js b/toolkit/content/customizeToolbar.js
index 7400aaadc..05151b905 100644
--- a/toolkit/content/customizeToolbar.js
+++ b/toolkit/content/customizeToolbar.js
@@ -12,7 +12,6 @@ var gToolboxSheet = false;
var gPaletteBox = null;
Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/AppConstants.jsm");
function onLoad()
{
@@ -213,10 +212,10 @@ function wrapToolbarItems()
{
forEachCustomizableToolbar(function (toolbar) {
Array.forEach(toolbar.childNodes, function (item) {
- if (AppConstants.platform == "macosx") {
- if (item.firstChild && item.firstChild.localName == "menubar")
- return;
- }
+#ifdef XP_MACOSX
+ if (item.firstChild && item.firstChild.localName == "menubar")
+ return;
+#endif
if (isToolbarItem(item)) {
let wrapper = wrapToolbarItem(item);
cleanupItemForToolbar(item, wrapper);
diff --git a/toolkit/content/globalOverlay.js b/toolkit/content/globalOverlay.js
index 1df3d65fc..d8467f0a1 100644
--- a/toolkit/content/globalOverlay.js
+++ b/toolkit/content/globalOverlay.js
@@ -4,32 +4,32 @@
function closeWindow(aClose, aPromptFunction)
{
- let { AppConstants } = Components.utils.import("resource://gre/modules/AppConstants.jsm");
-
+#ifdef XP_MACOSX
// Closing the last window doesn't quit the application on OS X.
- if (AppConstants.platform != "macosx") {
- var windowCount = 0;
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var e = wm.getEnumerator(null);
-
- while (e.hasMoreElements()) {
- var w = e.getNext();
- if (w.closed) {
- continue;
- }
- if (++windowCount == 2)
- break;
+ if (typeof(aPromptFunction) == "function" && !aPromptFunction()) {
+ return false;
+ }
+#else
+ var windowCount = 0;
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ var e = wm.getEnumerator(null);
+
+ while (e.hasMoreElements()) {
+ var w = e.getNext();
+ if (w.closed) {
+ continue;
}
+ if (++windowCount == 2)
+ break;
+ }
- // If we're down to the last window and someone tries to shut down, check to make sure we can!
- if (windowCount == 1 && !canQuitApplication("lastwindow"))
- return false;
- if (windowCount != 1 && typeof(aPromptFunction) == "function" && !aPromptFunction())
- return false;
- } else if (typeof(aPromptFunction) == "function" && !aPromptFunction()) {
+ // If we're down to the last window and someone tries to shut down, check to make sure we can!
+ if (windowCount == 1 && !canQuitApplication("lastwindow"))
return false;
- }
+ if (windowCount != 1 && typeof(aPromptFunction) == "function" && !aPromptFunction())
+ return false;
+#endif
if (aClose) {
window.close();
diff --git a/toolkit/content/jar.mn b/toolkit/content/jar.mn
index 5a940679b..96c559bb2 100644
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -20,7 +20,7 @@ toolkit.jar:
content/global/aboutNetworking.js
content/global/aboutNetworking.xhtml
#ifndef ANDROID
- content/global/aboutProfiles.js
+* content/global/aboutProfiles.js
content/global/aboutProfiles.xhtml
#endif
content/global/aboutServiceWorkers.js
@@ -32,18 +32,18 @@ toolkit.jar:
#endif
* content/global/aboutSupport.js
* content/global/aboutSupport.xhtml
- content/global/aboutTelemetry.js
+* content/global/aboutTelemetry.js
content/global/aboutTelemetry.xhtml
content/global/aboutTelemetry.css
content/global/directionDetector.html
content/global/plugins.html
content/global/plugins.css
- content/global/browser-child.js
+* content/global/browser-child.js
content/global/browser-content.js
* content/global/buildconfig.html
- content/global/contentAreaUtils.js
+* content/global/contentAreaUtils.js
content/global/customizeToolbar.css
- content/global/customizeToolbar.js
+* content/global/customizeToolbar.js
content/global/customizeToolbar.xul
content/global/datepicker.xhtml
content/global/editMenuOverlay.js
@@ -52,7 +52,7 @@ toolkit.jar:
* content/global/finddialog.xul
content/global/findUtils.js
content/global/filepicker.properties
- content/global/globalOverlay.js
+* content/global/globalOverlay.js
content/global/mozilla.xhtml
#ifdef MOZ_PHOENIX
content/global/logopage.xhtml