Bug 1278082 - remove preprocessing from mailCore.js by using AppConstants.jsm. r=mkmelin AURORA_BASE_20160606
authoraceman <acelists@atlas.sk>
Mon, 06 Jun 2016 21:10:09 +0200
changeset 25116 a7e40a6802fe951017bcc75689a8cb44d95031b7
parent 25115 4e2619025b77ac6beca689dc4ad22d05ee6f982b
child 25117 4107a4bd88f9260f50dbb471a3ffdd9c5c01d609
push id1688
push userclokep@gmail.com
push dateMon, 01 Aug 2016 16:45:40 +0000
treeherdercomm-beta@9abd7cedb2af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1278082
Bug 1278082 - remove preprocessing from mailCore.js by using AppConstants.jsm. r=mkmelin
mail/base/content/mailCore.js
mail/base/jar.mn
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -1,23 +1,24 @@
-# -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-# 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/.
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * 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/. */
 
 /*
  * Core mail routines used by all of the major mail windows (address book,
  * 3-pane, compose and stand alone message window).
  * Routines to support custom toolbars in mail windows, opening up a new window
  * of a particular type all live here.
  * Before adding to this file, ask yourself, is this a JS routine that is going
  * to be used by all of the main mail windows?
  */
 
 Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/AppConstants.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 
 var gCustomizeSheet = false;
 
 function overlayRestoreDefaultSet() {
   let toolbox = null;
   if ("arguments" in window && window.arguments[0])
     toolbox = window.arguments[0];
@@ -488,26 +489,27 @@ function openIMAccountMgr()
 }
 
 function openIMAccountWizard()
 {
   const kFeatures = "chrome,centerscreen,modal,titlebar";
   const kUrl = "chrome://messenger/content/chat/imAccountWizard.xul";
   const kName = "IMAccountWizard";
 
-#ifdef XP_MACOSX
-  // On Mac, avoid using the hidden window as a parent as that would
-  // make it visible.
-  let hiddenWindowUrl =
-    Services.prefs.getCharPref("browser.hiddenWindowChromeURL");
-  if (window.location.href == hiddenWindowUrl) {
-    Services.ww.openWindow(null, kUrl, kName, kFeatures, null);
-    return;
+  if (AppConstants.platform == "macosx") {
+    // On Mac, avoid using the hidden window as a parent as that would
+    // make it visible.
+    let hiddenWindowUrl =
+      Services.prefs.getCharPref("browser.hiddenWindowChromeURL");
+    if (window.location.href == hiddenWindowUrl) {
+      Services.ww.openWindow(null, kUrl, kName, kFeatures, null);
+      return;
+    }
   }
-#endif
+
   window.openDialog(kUrl, kName, kFeatures);
 }
 
 function openSavedFilesWnd()
 {
   let tabmail = document.getElementById("tabmail");
   let downloadsBrowser = tabmail.getBrowserForDocumentId("aboutDownloads");
   if (downloadsBrowser)
@@ -542,23 +544,24 @@ function openAboutDialog()
   let enumerator = Services.wm.getEnumerator("Mail:About");
   while (enumerator.hasMoreElements()) {
     // Only open one about window
     let win = enumerator.getNext();
     win.focus();
     return;
   }
 
-#ifdef XP_WIN
-  var features = "chrome,centerscreen,dependent";
-#elifdef XP_MACOSX
-  var features = "chrome,resizable=no,minimizable=no";
-#else
-  var features = "chrome,centerscreen,dependent,dialog=no";
-#endif
+  let features;
+  if (AppConstants.platform == "win")
+    features = "chrome,centerscreen,dependent";
+  else if (AppConstants.platform == "macosx")
+    features = "chrome,resizable=no,minimizable=no";
+  else
+    features = "chrome,centerscreen,dependent,dialog=no";
+
   window.openDialog("chrome://messenger/content/aboutDialog.xul", "About", features);
 }
 
 /**
  * Opens the support page based on the app.support.baseURL pref.
  */
 function openSupportURL()
 {
@@ -605,70 +608,66 @@ function safeModeRestart()
   if (rv == 0) {
     let environment = Components.classes["@mozilla.org/process/environment;1"]
                                 .getService(Components.interfaces.nsIEnvironment);
     environment.set("MOZ_SAFE_MODE_RESTART", "1");
     Application.restart();
   }
 }
 
-#ifndef XP_WIN
-#define BROKEN_WM_Z_ORDER
-#endif
-
 function getMostRecentMailWindow() {
-#ifdef BROKEN_WM_Z_ORDER
-  let win = Services.wm.getMostRecentWindow("mail:3pane", true);
+  let win = null;
+  if (AppConstants.platform != "win") {
+    // Platforms other than Windows have a broken z-order...
+    win = Services.wm.getMostRecentWindow("mail:3pane", true);
 
-  // if we're lucky, this isn't a popup, and we can just return this
-  if (win && win.document.documentElement.getAttribute("chromehidden")) {
-    win = null;
-    var windowList = Services.wm.getEnumerator("mail:3pane", true);
-    // this is oldest to newest, so this gets a bit ugly
-    while (windowList.hasMoreElements()) {
-      var nextWin = windowList.getNext();
-      if (!nextWin.document.documentElement.getAttribute("chromehidden"))
-        win = nextWin;
+    // If we're lucky, this isn't a popup, and we can just return this.
+    if (win && win.document.documentElement.getAttribute("chromehidden")) {
+      win = null;
+      let windowList = Services.wm.getEnumerator("mail:3pane", true);
+      // This is oldest to newest, so this gets a bit ugly.
+      while (windowList.hasMoreElements()) {
+        let nextWin = windowList.getNext();
+        if (!nextWin.document.documentElement.getAttribute("chromehidden"))
+          win = nextWin;
+      }
     }
-  }
-#else
-  var windowList = Services.wm.getZOrderDOMWindowEnumerator("mail:3pane", true);
-  if (!windowList.hasMoreElements())
-    return null;
-
-  var win = windowList.getNext();
-  while (win.document.documentElement.getAttribute("chromehidden")) {
+  } else {
+    let windowList = Services.wm.getZOrderDOMWindowEnumerator("mail:3pane", true);
     if (!windowList.hasMoreElements())
       return null;
 
     win = windowList.getNext();
+    while (win.document.documentElement.getAttribute("chromehidden")) {
+      if (!windowList.hasMoreElements())
+        return null;
+
+      win = windowList.getNext();
+    }
   }
-#endif
 
   return win;
 }
 
 /**
  * Create a sanitized display name for an attachment in order to help prevent
  * people from hiding malicious extensions behind a run of spaces, etc. To do
  * this, we strip leading/trailing whitespace and collapse long runs of either
  * whitespace or identical characters. Windows especially will drop trailing
  * dots and whitespace from filename extensions.
  *
  * @param aAttachment the AttachmentInfo object
  * @return a sanitized display name for the attachment
  */
 function SanitizeAttachmentDisplayName(aAttachment)
 {
-  let displayName = aAttachment.name.trim();
-  return displayName.replace(/\s+/g, " ")
-#ifdef XP_WIN
-                    .replace(/[ \.]+$/, "")
-#endif
-                    .replace(/(.)\1{9,}/g, "$1…$1");
+  let displayName = aAttachment.name.trim().replace(/\s+/g, " ");
+  if (AppConstants.platform == "win")
+    displayName = displayName.replace(/[ \.]+$/, "");
+  return displayName.replace(/(.)\1{9,}/g, "$1…$1");
 }
 
 /**
  * Create a TransferData object for a message attachment, either from the
  * message reader or the composer.
  *
  * @param aAttachment the attachment object
  * @return the TransferData
--- a/mail/base/jar.mn
+++ b/mail/base/jar.mn
@@ -32,17 +32,17 @@ messenger.jar:
     content/messenger/msgViewNavigation.js          (content/msgViewNavigation.js)
     content/messenger/mailWidgets.xml               (content/mailWidgets.xml)
     content/messenger/nsDragAndDrop.js              (content/nsDragAndDrop.js)
     content/messenger/editContactOverlay.js         (content/editContactOverlay.js)
 *   content/messenger/editContactOverlay.xul        (content/editContactOverlay.xul)
 *   content/messenger/msgMail3PaneWindow.js         (content/msgMail3PaneWindow.js)
     content/messenger/mail3PaneWindowCommands.js    (content/mail3PaneWindowCommands.js)
     content/messenger/mailCommands.js               (content/mailCommands.js)
-*   content/messenger/mailCore.js                   (content/mailCore.js)
+    content/messenger/mailCore.js                   (content/mailCore.js)
     content/messenger/customizeToolbarOverlay.xul   (content/customizeToolbarOverlay.xul)
     content/messenger/mailTabs.js                   (content/mailTabs.js)
     content/messenger/commandglue.js                (content/commandglue.js)
 *   content/messenger/SearchDialog.xul              (content/SearchDialog.xul)
     content/messenger/SearchDialog.js               (content/SearchDialog.js)
     content/messenger/ABSearchDialog.xul            (content/ABSearchDialog.xul)
     content/messenger/ABSearchDialog.js             (content/ABSearchDialog.js)
     content/messenger/FilterListDialog.xul          (content/FilterListDialog.xul)