Bug 1445764 - Move Places imports from XUL to JS for the Places documents;r=Standard8 draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 03 Jul 2018 14:26:49 -0700
changeset 813781 3da36fddc0fe6d6fbc03474e557ff206875cae0d
parent 813581 a0e47ebc4c06e652b919dabee711fdbd6bfd31b5
child 813782 ff283c5ec16470585985c3a8c9389ea79ff08c12
push id115004
push userbgrinstead@mozilla.com
push dateTue, 03 Jul 2018 21:27:14 +0000
reviewersStandard8
bugs1445764
milestone63.0a1
Bug 1445764 - Move Places imports from XUL to JS for the Places documents;r=Standard8 MozReview-Commit-ID: 1LKRgTlaupu
browser/components/places/content/bookmarkProperties.js
browser/components/places/content/bookmarkProperties.xul
browser/components/places/content/bookmarksSidebar.js
browser/components/places/content/bookmarksSidebar.xul
browser/components/places/content/controller.js
browser/components/places/content/historySidebar.js
browser/components/places/content/historySidebar.xul
browser/components/places/content/places.js
browser/components/places/content/places.xul
browser/components/preferences/selectBookmark.js
browser/components/preferences/selectBookmark.xul
--- a/browser/components/places/content/bookmarkProperties.js
+++ b/browser/components/places/content/bookmarkProperties.js
@@ -49,19 +49,31 @@
  *
  * window.arguments[0].bookmarkGuid is set to the guid of the item, if the
  * dialog is accepted.
  */
 
 /* import-globals-from editBookmark.js */
 /* import-globals-from controller.js */
 
+/* Shared Places Import - change other consumers if you change this: */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
-                               "resource://gre/modules/PrivateBrowsingUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
+  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
+});
+XPCOMUtils.defineLazyScriptGetter(this, "PlacesTreeView",
+                                  "chrome://browser/content/places/treeView.js");
+XPCOMUtils.defineLazyScriptGetter(this, ["PlacesInsertionPoint", "PlacesController",
+                                         "PlacesControllerDragHelper"],
+                                  "chrome://browser/content/places/controller.js");
+/* End Shared Places Import */
 
 const BOOKMARK_ITEM = 0;
 const BOOKMARK_FOLDER = 1;
 const LIVEMARK_CONTAINER = 2;
 
 const ACTION_EDIT = 0;
 const ACTION_ADD = 1;
 
--- a/browser/components/places/content/bookmarkProperties.xul
+++ b/browser/components/places/content/bookmarkProperties.xul
@@ -33,27 +33,12 @@
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmark.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/places/bookmarkProperties.js"/>
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
-  <script type="application/javascript"><![CDATA[
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesTransactions", "resource://gre/modules/PlacesTransactions.jsm");
-
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-    XPCOMUtils.defineLazyScriptGetter(window, "PlacesTreeView",
-      "chrome://browser/content/places/treeView.js");
-    XPCOMUtils.defineLazyScriptGetter(window,
-      ["PlacesInsertionPoint", "PlacesController", "PlacesControllerDragHelper"],
-       "chrome://browser/content/places/controller.js");
-  ]]></script>
 
 #include editBookmarkPanel.inc.xul
 
 </dialog>
--- a/browser/components/places/content/bookmarksSidebar.js
+++ b/browser/components/places/content/bookmarksSidebar.js
@@ -1,14 +1,28 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
 
-/* import-globals-from ../../../../toolkit/components/places/PlacesUtils.jsm */
+/* Shared Places Import - change other consumers if you change this: */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
+  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
+});
+XPCOMUtils.defineLazyScriptGetter(this, "PlacesTreeView",
+                                  "chrome://browser/content/places/treeView.js");
+XPCOMUtils.defineLazyScriptGetter(this, ["PlacesInsertionPoint", "PlacesController",
+                                         "PlacesControllerDragHelper"],
+                                  "chrome://browser/content/places/controller.js");
+/* End Shared Places Import */
 
 function init() {
   let uidensity = window.top.document.documentElement.getAttribute("uidensity");
   if (uidensity) {
     document.documentElement.setAttribute("uidensity", uidensity);
   }
 
   document.getElementById("bookmarks-view").place =
--- a/browser/components/places/content/bookmarksSidebar.xul
+++ b/browser/components/places/content/bookmarksSidebar.xul
@@ -24,31 +24,16 @@
       aria-label="&bookmarksButton.label;">
 
   <script type="application/javascript"
           src="chrome://browser/content/places/bookmarksSidebar.js"/>
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
-  <script type="application/javascript"><![CDATA[
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesTransactions", "resource://gre/modules/PlacesTransactions.jsm");
-
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-    XPCOMUtils.defineLazyScriptGetter(window, "PlacesTreeView",
-      "chrome://browser/content/places/treeView.js");
-    XPCOMUtils.defineLazyScriptGetter(window,
-      ["PlacesInsertionPoint", "PlacesController", "PlacesControllerDragHelper"],
-       "chrome://browser/content/places/controller.js");
-  ]]></script>
 
 #include placesCommands.inc.xul
 #include ../../../../toolkit/content/editMenuCommands.inc.xul
 #include placesContextMenu.inc.xul
 #include bookmarksHistoryTooltip.inc.xul
 
   <hbox id="sidebar-search-container" align="center">
     <textbox id="search-box" flex="1" type="search"
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1,15 +1,15 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
 
+/* import-globals-from ../../../base/content/utilityOverlay.js */
 /* import-globals-from ../PlacesUIUtils.jsm */
-/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
 /* import-globals-from ../../../../toolkit/components/places/PlacesUtils.jsm */
 /* import-globals-from ../../../../toolkit/components/places/PlacesTransactions.jsm */
 
 /**
  * Represents an insertion point within a container where we can insert
  * items.
  * @param {object} an object containing the following properties:
  *   - parentId
--- a/browser/components/places/content/historySidebar.js
+++ b/browser/components/places/content/historySidebar.js
@@ -1,14 +1,28 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
 /* 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/. */
 
-/* import-globals-from ../../../../toolkit/components/places/PlacesUtils.jsm */
+/* Shared Places Import - change other consumers if you change this: */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
+  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
+});
+XPCOMUtils.defineLazyScriptGetter(this, "PlacesTreeView",
+                                  "chrome://browser/content/places/treeView.js");
+XPCOMUtils.defineLazyScriptGetter(this, ["PlacesInsertionPoint", "PlacesController",
+                                         "PlacesControllerDragHelper"],
+                                  "chrome://browser/content/places/controller.js");
+/* End Shared Places Import */
 
 ChromeUtils.import("resource://gre/modules/TelemetryStopwatch.jsm");
 
 var gHistoryTree;
 var gSearchBox;
 var gHistoryGrouping = "";
 var gSearching = false;
 
--- a/browser/components/places/content/historySidebar.xul
+++ b/browser/components/places/content/historySidebar.xul
@@ -24,31 +24,16 @@
       aria-label="&historyButton.label;">
 
   <script type="application/javascript"
           src="chrome://browser/content/places/historySidebar.js"/>
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
-  <script type="application/javascript"><![CDATA[
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesTransactions", "resource://gre/modules/PlacesTransactions.jsm");
-
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-    XPCOMUtils.defineLazyScriptGetter(window, "PlacesTreeView",
-      "chrome://browser/content/places/treeView.js");
-    XPCOMUtils.defineLazyScriptGetter(window,
-      ["PlacesInsertionPoint", "PlacesController", "PlacesControllerDragHelper"],
-       "chrome://browser/content/places/controller.js");
-  ]]></script>
 
 #include ../../../../toolkit/content/editMenuCommands.inc.xul
 
 #include placesCommands.inc.xul
 
 #include ../../../../toolkit/content/editMenuKeys.inc.xul
 #ifdef XP_MACOSX
   <keyset id="editMenuKeysExtra">
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -1,23 +1,35 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
 
 /* import-globals-from editBookmark.js */
 /* import-globals-from ../../../../toolkit/content/contentAreaUtils.js */
-/* import-globals-from ../PlacesUIUtils.jsm */
-/* import-globals-from ../../../../toolkit/components/places/PlacesUtils.jsm */
 /* import-globals-from ../../downloads/content/allDownloadsView.js */
 
-ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+/* Shared Places Import - change other consumers if you change this: */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
+  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
+});
+XPCOMUtils.defineLazyScriptGetter(this, "PlacesTreeView",
+                                  "chrome://browser/content/places/treeView.js");
+XPCOMUtils.defineLazyScriptGetter(this, ["PlacesInsertionPoint", "PlacesController",
+                                         "PlacesControllerDragHelper"],
+                                  "chrome://browser/content/places/controller.js");
+/* End Shared Places Import */
+
+ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/TelemetryStopwatch.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.defineModuleGetter(this, "MigrationUtils",
                                "resource:///modules/MigrationUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "BookmarkJSONUtils",
                                "resource://gre/modules/BookmarkJSONUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "PlacesBackups",
                                "resource://gre/modules/PlacesBackups.jsm");
 ChromeUtils.defineModuleGetter(this, "DownloadUtils",
                                "resource://gre/modules/DownloadUtils.jsm");
--- a/browser/components/places/content/places.xul
+++ b/browser/components/places/content/places.xul
@@ -48,32 +48,16 @@
   <!-- On Mac, this is included via macWindow.inc.xul -> global-scripts.inc -> browser.js -> defineLazyScriptGetter -->
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmark.js"/>
   <!-- On Mac, thes are included via macWindow.inc.xul -> global-scripts.inc -->
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
-  <!-- On Mac, these are included via macWindow.inc.xul -->
-  <script type="application/javascript"><![CDATA[
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesTransactions", "resource://gre/modules/PlacesTransactions.jsm");
-
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-    XPCOMUtils.defineLazyScriptGetter(window, "PlacesTreeView",
-      "chrome://browser/content/places/treeView.js");
-    XPCOMUtils.defineLazyScriptGetter(window,
-      ["PlacesInsertionPoint", "PlacesController", "PlacesControllerDragHelper"],
-       "chrome://browser/content/places/controller.js");
-  ]]></script>
 #endif
 
   <stringbundleset id="placesStringSet">
     <stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
   </stringbundleset>
 
 #ifdef XP_MACOSX
 #include ../../../base/content/macWindow.inc.xul
--- a/browser/components/preferences/selectBookmark.js
+++ b/browser/components/preferences/selectBookmark.js
@@ -1,15 +1,28 @@
 //* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
 
-/* import-globals-from ../../../toolkit/components/places/PlacesUtils.jsm */
-/* import-globals-from ../../../toolkit/content/globalOverlay.js */
+/* Shared Places Import - change other consumers if you change this: */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, {
+  PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
+  PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
+  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
+});
+XPCOMUtils.defineLazyScriptGetter(this, "PlacesTreeView",
+                                  "chrome://browser/content/places/treeView.js");
+XPCOMUtils.defineLazyScriptGetter(this, ["PlacesInsertionPoint", "PlacesController",
+                                         "PlacesControllerDragHelper"],
+                                  "chrome://browser/content/places/controller.js");
+/* End Shared Places Import */
 
 /**
  * SelectBookmarkDialog controls the user interface for the "Use Bookmark for
  * Home Page" dialog.
  *
  * The caller (gMainPane.setHomePageToBookmark in main.js) invokes this dialog
  * with a single argument - a reference to an object with a .urls property and
  * a .names property.  This dialog is responsible for updating the contents of
--- a/browser/components/preferences/selectBookmark.xul
+++ b/browser/components/preferences/selectBookmark.xul
@@ -21,31 +21,16 @@
   <script type="application/javascript" src="chrome://global/content/l10n.js"></script>
 
   <script type="application/javascript"
           src="chrome://browser/content/preferences/selectBookmark.js"/>
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
-  <script type="application/javascript"><![CDATA[
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesUIUtils", "resource:///modules/PlacesUIUtils.jsm");
-    ChromeUtils.defineModuleGetter(window,
-      "PlacesTransactions", "resource://gre/modules/PlacesTransactions.jsm");
-
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-    XPCOMUtils.defineLazyScriptGetter(window, "PlacesTreeView",
-      "chrome://browser/content/places/treeView.js");
-    XPCOMUtils.defineLazyScriptGetter(window,
-      ["PlacesInsertionPoint", "PlacesController", "PlacesControllerDragHelper"],
-       "chrome://browser/content/places/controller.js");
-  ]]></script>
   <description data-l10n-id="select-bookmark-desc"/>
 
   <separator class="thin"/>
 
   <tree id="bookmarks" flex="1" type="places"
         style="height: 15em;"
         hidecolumnpicker="true"
         seltype="single"