Bug 1553077 - Port [Bug 1479538 - Rewrite callers of document.createElementNS(XUL_NS, ...) to use document.createXULElement(...)]. r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Tue, 21 May 2019 12:35:48 +0300
changeset 35651 55a4d4b9df15087febdee6fe660f4449a5a8be0b
parent 35650 ac1f260073e5ef47212ab252cb662d7328c1949d
child 35652 eed232c00d45912004ab57cb301e54b645583aae
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersjorgk
bugs1553077, 1479538
Bug 1553077 - Port [Bug 1479538 - Rewrite callers of document.createElementNS(XUL_NS, ...) to use document.createXULElement(...)]. r=jorgk find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*" -name '*.js' -exec sed -r -i 's/createElementNS[(]XULNS, /createXULElement(/g' {} \; find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*" -name '*.xml' -exec sed -r -i 's/createElementNS[(]XULNS, /createXULElement(/g' {} \; find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*" -name '*.js' -exec sed -r -i 's#createElementNS[(]"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",#createXULElement(#g' {} \; + some manual fixups
chat/content/imtooltip.xml
common/src/customizeToolbar.js
editor/ui/dialogs/content/EdInsertMath.js
editor/ui/dialogs/content/EdSpellCheck.js
mail/components/preferences/display.js
--- a/chat/content/imtooltip.xml
+++ b/chat/content/imtooltip.xml
@@ -153,45 +153,40 @@
        <body>
        <![CDATA[
          let description;
          let row = [...this.rows.querySelectorAll("row")].find(row => {
            return row.querySelector("label").getAttribute("value") == aLabel;
          });
          if (!row) {
            // Create a new row for this label.
-           const XULNS =
-             "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-           row = document.createElementNS(XULNS, "row");
-           let label = document.createElementNS(XULNS, "label");
+           row = document.createXULElement("row");
+           let label = document.createXULElement("label");
            label.className = "header";
            label.setAttribute("value", aLabel);
            row.appendChild(label);
-           description = document.createElementNS(XULNS, "description");
+           description = document.createXULElement("description");
            row.appendChild(description);
            row.setAttribute("align", "baseline");
            this.rows.appendChild(row);
          }
          else {
            // Row with this label already exists - just update.
            description = row.querySelector("description");
          }
          description.textContent = aValue;
        ]]>
        </body>
      </method>
 
      <method name="addSeparator">
        <body>
        <![CDATA[
-         const XULNS =
-           "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
-         var row = document.createElementNS(XULNS, "row");
-         var separator = document.createElementNS(XULNS, "separator");
+         var row = document.createXULElement("row");
+         var separator = document.createXULElement("separator");
          separator.className = "thin";
          row.appendChild(separator);
          this.rows.appendChild(row);
        ]]>
        </body>
      </method>
 
      <method name="requestBuddyInfo">
--- a/common/src/customizeToolbar.js
+++ b/common/src/customizeToolbar.js
@@ -232,18 +232,17 @@ function unwrapToolbarItems() {
   }
 }
 
 /**
  * Creates a wrapper that can be used to contain a toolbaritem and prevent
  * it from receiving UI events.
  */
 function createWrapper(aId, aDocument) {
-  var wrapper = aDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                         "toolbarpaletteitem");
+  let wrapper = aDocument.createXULElement("toolbarpaletteitem");
 
   wrapper.id = "wrapper-" + aId;
   return wrapper;
 }
 
 /**
  * Wraps an item that has been cloned from a template and adds
  * it to the end of the palette.
@@ -298,31 +297,28 @@ function getCurrentItemIds() {
  * Builds the palette of draggable items that are not yet in a toolbar.
  */
 function buildPalette() {
   // Empty the palette first.
   while (gPaletteBox.lastChild)
     gPaletteBox.removeChild(gPaletteBox.lastChild);
 
   // Add the toolbar separator item.
-  var templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                              "toolbarseparator");
+  var templateNode = document.createXULElement("toolbarseparator");
   templateNode.id = "separator";
   wrapPaletteItem(templateNode);
 
   // Add the toolbar spring item.
-  templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                              "toolbarspring");
+  templateNode = document.createXULElement("toolbarspring");
   templateNode.id = "spring";
   templateNode.flex = 1;
   wrapPaletteItem(templateNode);
 
   // Add the toolbar spacer item.
-  templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                              "toolbarspacer");
+  templateNode = document.createXULElement("toolbarspacer");
   templateNode.id = "spacer";
   templateNode.flex = 1;
   wrapPaletteItem(templateNode);
 
   var currentItems = getCurrentItemIds();
   templateNode = gToolbox.palette.firstChild;
   while (templateNode) {
     // Check if the item is already in a toolbar before adding it to the palette.
--- a/editor/ui/dialogs/content/EdInsertMath.js
+++ b/editor/ui/dialogs/content/EdInsertMath.js
@@ -3,18 +3,16 @@
  * 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/. */
 
 /* Insert MathML dialog */
 
 /* import-globals-from ../../composer/content/editorUtilities.js */
 /* import-globals-from EdDialogCommon.js */
 
-var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
 document.addEventListener("dialogaccept", onAccept);
 document.addEventListener("dialogcancel", onCancel);
 
 function Startup() {
   var editor = GetCurrentEditor();
   if (!editor) {
     window.close();
     return;
@@ -152,101 +150,101 @@ function insertLaTeXCommand(aButton) {
 
 function createCommandPanel(aCommandPanelList) {
   const columnCount = 10;
 
   for (var label in aCommandPanelList) {
     var commands = aCommandPanelList[label];
 
     // Create a <rows> element with some LaTeX commands.
-    var rows = document.createElementNS(XULNS, "rows");
+    var rows = document.createXULElement("rows");
 
     var i = 0, row;
     for (var command of commands) {
       if (i % columnCount == 0) {
         // Create a new row.
-        row = document.createElementNS(XULNS, "row");
+        row = document.createXULElement("row");
         rows.appendChild(row);
       }
 
       // Create a new button to insert the symbol.
-      var button = document.createElementNS(XULNS, "toolbarbutton");
+      var button = document.createXULElement("toolbarbutton");
       button.setAttribute("class", "tabbable");
       button.appendChild(TeXZilla.toMathML(command));
       row.appendChild(button);
 
       i++;
     }
 
     // Create a <columns> element with the desired number of columns.
-    var columns = document.createElementNS(XULNS, "columns");
+    var columns = document.createXULElement("columns");
     for (i = 0; i < columnCount; i++) {
-      var column = document.createElementNS(XULNS, "column");
+      var column = document.createXULElement("column");
       column.setAttribute("flex", "1");
       columns.appendChild(column);
     }
 
     // Create the <grid> element with the <rows> and <columns> children.
-    var grid = document.createElementNS(XULNS, "grid");
+    var grid = document.createXULElement("grid");
     grid.appendChild(columns);
     grid.appendChild(rows);
 
     // Create a new <tab> element.
-    var tab = document.createElementNS(XULNS, "tab");
+    var tab = document.createXULElement("tab");
     tab.setAttribute("label", label);
     gDialog.tabbox.tabs.appendChild(tab);
 
     // Append the new tab panel.
     gDialog.tabbox.tabpanels.appendChild(grid);
   }
 }
 
 function createSymbolPanels(aSymbolPanelList) {
   const columnCount = 13, tabLabelLength = 3;
 
   for (var symbols of aSymbolPanelList) {
     // Create a <rows> element with the symbols of the i-th panel.
-    var rows = document.createElementNS(XULNS, "rows");
+    var rows = document.createXULElement("rows");
     var i = 0, tabLabel = "", row;
     for (var symbol of symbols) {
       if (i % columnCount == 0) {
         // Create a new row.
-        row = document.createElementNS(XULNS, "row");
+        row = document.createXULElement("row");
         rows.appendChild(row);
       }
 
       // Build the tab label from the first symbols of this tab.
       if (i < tabLabelLength) {
         tabLabel += symbol;
       }
 
       // Create a new button to insert the symbol.
-      var button = document.createElementNS(XULNS, "toolbarbutton");
+      var button = document.createXULElement("toolbarbutton");
       button.setAttribute("label", symbol);
       button.setAttribute("class", "tabbable");
       row.appendChild(button);
 
       i++;
     }
 
     // Create a <columns> element with the desired number of columns.
-    var columns = document.createElementNS(XULNS, "columns");
+    var columns = document.createXULElement("columns");
     for (i = 0; i < columnCount; i++) {
-      var column = document.createElementNS(XULNS, "column");
+      var column = document.createXULElement("column");
       column.setAttribute("flex", "1");
       columns.appendChild(column);
     }
 
     // Create the <grid> element with the <rows> and <columns> children.
-    var grid = document.createElementNS(XULNS, "grid");
+    var grid = document.createXULElement("grid");
     grid.appendChild(columns);
     grid.appendChild(rows);
 
     // Create a new <tab> element with the label determined above.
-    var tab = document.createElementNS(XULNS, "tab");
+    var tab = document.createXULElement("tab");
     tab.setAttribute("label", tabLabel);
     gDialog.tabbox.tabs.appendChild(tab);
 
     // Append the new tab panel.
     gDialog.tabbox.tabpanels.appendChild(grid);
   }
 }
 
--- a/editor/ui/dialogs/content/EdSpellCheck.js
+++ b/editor/ui/dialogs/content/EdSpellCheck.js
@@ -136,17 +136,17 @@ function InitLanguageMenu(aCurLang) {
   // Remove any languages from the list.
   var languageMenuPopup = gDialog.LanguageMenulist.menupopup;
   while (languageMenuPopup.firstChild.localName != "menuseparator")
     languageMenuPopup.firstChild.remove();
 
   var defaultItem = null;
 
   for (var i = 0; i < count; i++) {
-    let item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
+    let item = document.createXULElement("menuitem");
     item.setAttribute("label", sortedList[i].displayName);
     item.setAttribute("value", sortedList[i].localeCode);
     let beforeItem = gDialog.LanguageMenulist.getItemAtIndex(i);
     languageMenuPopup.insertBefore(item, beforeItem);
 
     if (aCurLang && sortedList[i].localeCode == aCurLang)
       defaultItem = item;
   }
--- a/mail/components/preferences/display.js
+++ b/mail/components/preferences/display.js
@@ -51,17 +51,17 @@ var gDisplayPane = {
         document.getElementById("displayPrefs").selectedIndex = preference.value;
     }
     this._rebuildFonts();
     this.updateMarkAsReadOptions();
 
     var menulist = document.getElementById("defaultFont");
     if (menulist.selectedIndex == -1) {
       // Prepend menuitem with empty name and value.
-      let item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
+      let item = document.createXULElement("menuitem");
       item.setAttribute("label", "");
       item.setAttribute("value", "");
       menulist.menupopup.insertBefore(item, menulist.menupopup.firstChild);
       menulist.selectedIndex = 0;
     }
 
     this.mInitialized = true;