1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #65 - Remove AppConstants from toolkit/content

This commit is contained in:
Matt A. Tobin
2020-02-01 23:45:36 -05:00
committed by Roy Tam
parent ef27cc7fd0
commit cf41a9dd87
8 changed files with 89 additions and 97 deletions
+6 -6
View File
@@ -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);
+35 -36
View File
@@ -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;
}
+11 -14
View File
@@ -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);
}
},
-1
View File
@@ -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');
+4 -6
View File
@@ -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(/^\.+/, "");
+4 -5
View File
@@ -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);
+23 -23
View File
@@ -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 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 (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;
#endif
if (aClose) {
window.close();
+6 -6
View File
@@ -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