Bug 1553077 - Part 2: more createElementNS(XUL_NS,...) -> createXULElement(...) conversions. r=jorgk DONTBUILD
find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*"
-name '*.js' -exec sed -r -i 's/createElementNS[(]XUL_NS, /createXULElement(/g' {} \;
find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*"
-name '*.jsm' -exec sed -r -i 's/createElementNS[(]XUL_NS, /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[(]XUL_NS, /createXULElement(/g' {} \;
and some manual fixups of XUL_NS declarations
--- a/calendar/base/modules/utils/calAlarmUtils.jsm
+++ b/calendar/base/modules/utils/calAlarmUtils.jsm
@@ -130,23 +130,18 @@ var calalarms = {
/**
* Adds reminder images to a given node, making sure only one icon per alarm
* action is added.
*
* @param aElement The element to add the images to.
* @param aReminders The set of reminders to add images for.
*/
addReminderImages: function(aElement, aReminders) {
- function createOwnedXULNode(elem) {
- const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- return aElement.ownerDocument.createElementNS(XUL_NS, elem);
- }
-
function setupActionImage(node, reminder) {
- let image = node || createOwnedXULNode("image");
+ let image = node || aElement.ownerDocument.createXULElement("image");
image.setAttribute("class", "reminder-icon");
image.setAttribute("value", reminder.action);
return image;
}
// Fill up the icon box with the alarm icons, show max one icon per
// alarm type.
let countIconChildren = aElement.childNodes.length;
--- a/common/bindings/toolbar.xml
+++ b/common/bindings/toolbar.xml
@@ -62,18 +62,17 @@
<method name="appendCustomToolbar">
<parameter name="aName"/>
<parameter name="aCurrentSet"/>
<body>
<![CDATA[
if (!this.toolbarset)
return null;
- var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "toolbar");
+ var toolbar = document.createXULElement("toolbar");
toolbar.id = "__customToolbar_" + aName.replace(" ", "_");
toolbar.setAttribute("customizable", "true");
toolbar.setAttribute("customindex", ++this.customToolbarCount);
toolbar.setAttribute("toolbarname", aName);
toolbar.setAttribute("currentset", aCurrentSet);
toolbar.setAttribute("mode", this.getAttribute("mode"));
toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
@@ -291,26 +290,23 @@
</setter>
</property>
<field name="_newElementCount">0</field>
<method name="_getToolbarItem">
<parameter name="aId"/>
<body>
<![CDATA[
- const XUL_NS = "http://www.mozilla.org/keymaster/" +
- "gatekeeper/there.is.only.xul";
-
var newItem = null;
switch (aId) {
// Handle special cases
case "separator":
case "spring":
case "spacer":
- newItem = document.createElementNS(XUL_NS, "toolbar" + aId);
+ newItem = document.createXULElement("toolbar" + aId);
// Due to timers resolution Date.now() can be the same for
// elements created in small timeframes. So ids are
// differentiated through a unique count suffix.
newItem.id = aId + Date.now() + (++this._newElementCount);
if (aId == "spring")
newItem.flex = 1;
break;
default:
--- a/editor/ui/composer/content/StructBarContextMenu.js
+++ b/editor/ui/composer/content/StructBarContextMenu.js
@@ -104,17 +104,17 @@ function MoveChildNodesAfterElement(edit
for (i = childNodesLength - 1; i >= 0; i--) {
var clone = childNodes.item(i).cloneNode(true);
editor.insertNode(clone, targetElement.parentNode, targetOffset + 1);
}
}
function StructChangeTag()
{
- var textbox = document.createElementNS(XUL_NS, "textbox");
+ var textbox = document.createXULElement("textbox");
textbox.setAttribute("value", gContextMenuNode.getAttribute("value"));
textbox.setAttribute("width", gContextMenuNode.getBoundingClientRect().width);
textbox.className = "struct-textbox";
gContextMenuNode.parentNode.replaceChild(textbox, gContextMenuNode);
textbox.addEventListener("keypress", OnKeyPress);
textbox.addEventListener("blur", ResetStructToolbar, true);
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -986,17 +986,17 @@ function initLocalFontFaceMenu(menuPopup
* but does not add it automatically to the menupopup.
*
* @param aFontLabel Label to be displayed for the item.
* @param aFontName The font face value to be used for the item.
* Will be used in <font face="value"> in the edited document.
* @param aMenuPopup The menupopup for which this menuitem is created.
*/
function createFontFaceMenuitem(aFontLabel, aFontName, aMenuPopup) {
- let itemNode = document.createElementNS(XUL_NS, "menuitem");
+ let itemNode = document.createXULElement("menuitem");
itemNode.setAttribute("label", aFontLabel);
itemNode.setAttribute("value", aFontName);
itemNode.setAttribute("value_parsed", aFontName.toLowerCase().replace(/, /g, ","));
itemNode.setAttribute("tooltiptext", aFontLabel);
if (aMenuPopup.getAttribute("useRadios") == "true") {
itemNode.setAttribute("type", "radio");
itemNode.setAttribute("observes", "cmd_renderedHTMLEnabler");
}
@@ -2746,17 +2746,17 @@ function UpdateStructToolbar() {
var tag, button;
var bodyElement = GetBodyElement();
var isFocusNode = true;
var tmp;
do {
tag = element.nodeName.toLowerCase();
- button = document.createElementNS(XUL_NS, "toolbarbutton");
+ button = document.createXULElement("toolbarbutton");
button.setAttribute("label", "<" + tag + ">");
button.setAttribute("value", tag);
button.setAttribute("context", "structToolbarContext");
button.className = "struct-button";
toolbar.insertBefore(button, toolbar.firstChild);
button.addEventListener("command", newCommandListener(element));
--- a/editor/ui/composer/content/editorUtilities.js
+++ b/editor/ui/composer/content/editorUtilities.js
@@ -2,19 +2,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/. */
/* import-globals-from editor.js */
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
-/** ** NAMESPACES ****/
-const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
// Each editor window must include this file
// Variables shared by all dialogs:
// Object to attach commonly-used widgets (all dialogs should use this)
var gDialog = {};
var kOutputEncodeBasicEntities = Ci.nsIDocumentEncoder.OutputEncodeBasicEntities;
var kOutputEncodeHTMLEntities = Ci.nsIDocumentEncoder.OutputEncodeHTMLEntities;
--- a/editor/ui/dialogs/content/EdAEHTMLAttributes.js
+++ b/editor/ui/dialogs/content/EdAEHTMLAttributes.js
@@ -32,17 +32,17 @@ function BuildHTMLAttributeNameList() {
} else {
gDialog.AddHTMLAttributeNameInput.appendItem(name, name);
}
}
} else if (name == "-") {
// Signal for separator
var popup = gDialog.AddHTMLAttributeNameInput.menupopup;
if (popup) {
- var sep = document.createElementNS(XUL_NS, "menuseparator");
+ var sep = document.createXULElement("menuseparator");
if (sep)
popup.appendChild(sep);
}
} else {
// Get information about value filtering
let forceOneChar = name.includes("!");
let forceInteger = name.includes("#");
let forceSignedInteger = name.includes("+");
@@ -178,17 +178,17 @@ function onInputHTMLAttributeName() {
gDialog.AddHTMLAttributeValueDeck.setAttribute("selectedIndex", "1");
}
// Rebuild the list
for (var i = 0; i < listLen; i++) {
if (valueList[i] == "-") {
// Signal for separator
var popup = gDialog.AddHTMLAttributeValueInput.menupopup;
if (popup) {
- var sep = document.createElementNS(XUL_NS, "menuseparator");
+ var sep = document.createXULElement("menuseparator");
if (sep)
popup.appendChild(sep);
}
} else {
gDialog.AddHTMLAttributeValueMenulist.appendItem(valueList[i], valueList[i]);
}
}
}
--- a/editor/ui/dialogs/content/EdAEJSEAttributes.js
+++ b/editor/ui/dialogs/content/EdAEJSEAttributes.js
@@ -28,30 +28,30 @@ function BuildJSEAttributeNameList() {
return;
}
for (i = 0; i < attNames.length; i++)
gDialog.AddJSEAttributeNameList.appendItem(attNames[i], attNames[i]);
popup = gDialog.AddJSEAttributeNameList.firstChild;
if (popup) {
- sep = document.createElementNS(XUL_NS, "menuseparator");
+ sep = document.createXULElement("menuseparator");
if (sep)
popup.appendChild(sep);
}
}
}
// Always add core JS events unless we aborted above
for (i = 0; i < gCoreJSEvents.length; i++) {
if (gCoreJSEvents[i] == "-") {
if (!popup)
popup = gDialog.AddJSEAttributeNameList.firstChild;
- sep = document.createElementNS(XUL_NS, "menuseparator");
+ sep = document.createXULElement("menuseparator");
if (popup && sep)
popup.appendChild(sep);
} else {
gDialog.AddJSEAttributeNameList.appendItem(gCoreJSEvents[i], gCoreJSEvents[i]);
}
}
--- a/editor/ui/dialogs/content/EdAdvancedEdit.js
+++ b/editor/ui/dialogs/content/EdAdvancedEdit.js
@@ -272,35 +272,34 @@ function RemoveNameFromAttArray(attName,
break;
}
}
}
// adds a generalised treeitem.
function AddTreeItem(name, value, treeChildrenId, attArray) {
attArray[attArray.length] = name;
- var treeChildren = document.getElementById(treeChildrenId);
- var treeitem = document.createElementNS(XUL_NS, "treeitem");
- var treerow = document.createElementNS(XUL_NS, "treerow");
+ var treeChildren = document.getElementById(treeChildrenId);
+ var treeitem = document.createXULElement("treeitem");
+ var treerow = document.createXULElement("treerow");
- var attrCell = document.createElementNS(XUL_NS, "treecell");
+ var attrCell = document.createXULElement("treecell");
attrCell.setAttribute("class", "propertylist");
attrCell.setAttribute("label", name);
- var valueCell = document.createElementNS(XUL_NS, "treecell");
+ var valueCell = document.createXULElement("treecell");
valueCell.setAttribute("class", "propertylist");
valueCell.setAttribute("label", value);
treerow.appendChild(attrCell);
treerow.appendChild(valueCell);
treeitem.appendChild(treerow);
treeChildren.appendChild(treeitem);
- // Select item just added,
- // but suppress calling the onSelect handler
+ // Select item just added, but suppress calling the onSelect handler.
gDoOnSelectTree = false;
try {
selectTreeItem(treeChildren, treeitem);
} catch (e) {}
gDoOnSelectTree = true;
return treeitem;
}
--- a/editor/ui/dialogs/content/EdLinkChecker.js
+++ b/editor/ui/dialogs/content/EdLinkChecker.js
@@ -161,17 +161,17 @@ function SetItemStatus(url, status)
let listitem = document.querySelector('listitem[label="' + url + '"]');
if (listitem)
{
listitem.setAttribute("progress", status);
return true;
}
// We're adding a new item to list
- listitem = document.createElementNS(XUL_NS, "listitem");
+ listitem = document.createXULElement("listitem");
if (listitem)
{
listitem.setAttribute("class", "listitem-iconic progressitem");
// This triggers CSS to show icon for each status state
listitem.setAttribute("progress", status);
listitem.setAttribute("label", url);
gDialog.LinksList.appendChild(listitem);
}
--- a/editor/ui/dialogs/content/EditorPublishProgress.js
+++ b/editor/ui/dialogs/content/EditorPublishProgress.js
@@ -148,17 +148,17 @@ function SetProgressStatus(filename, sta
if (listitem)
{
listitem.setAttribute("progress", status);
return true;
}
// We're adding a new file item to list
gTotalFileCount++;
- listitem = document.createElementNS(XUL_NS, "listitem");
+ listitem = document.createXULElement("listitem");
if (listitem)
{
listitem.setAttribute("class", "listitem-iconic progressitem");
// This triggers CSS to show icon for each status state
listitem.setAttribute("progress", status);
listitem.setAttribute("label", filename);
gDialog.FileList.appendChild(listitem);
}
--- a/mail/base/content/folderDisplay.js
+++ b/mail/base/content/folderDisplay.js
@@ -156,18 +156,17 @@ function FolderDisplayWidget(aTabInfo, a
/**
* A list of methods to call on 'this' object when we are next made active.
* This list is populated by calls to |_notifyWhenActive| when we are
* not active at the moment.
*/
this._notificationsPendingActivation = [];
// Create a DOM node for the fake tree box below.
- let domNode = document.createElementNS(
- "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
+ let domNode = document.createXULElement("vbox");
// We care about onselect events, so add a listener for that.
let self = this;
domNode.addEventListener("select", function() {
self.view.dbView.selectionChanged();
});
/**
--- a/mail/base/content/tabmail.xml
+++ b/mail/base/content/tabmail.xml
@@ -578,19 +578,17 @@
this.tabContainer.selectedIndex =
this.tabContainer.childNodes.length - 1;
}
// make sure we are on the right panel
if (tab.mode.tabType.perTabPanel) {
// should we create the element for them, or will they do it?
if (typeof(tab.mode.tabType.perTabPanel) == "string") {
- tab.panel = document.createElementNS(
- "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- tab.mode.tabType.perTabPanel);
+ tab.panel = document.createXULElement(tab.mode.tabType.perTabPanel);
} else {
tab.panel = tab.mode.tabType.perTabPanel(tab);
}
this.panelContainer.appendChild(tab.panel);
if (!background) {
this.panelContainer.selectedPanel = tab.panel;
}
} else {
--- a/mail/components/extensions/ExtensionToolbarButtons.jsm
+++ b/mail/components/extensions/ExtensionToolbarButtons.jsm
@@ -25,17 +25,16 @@ var {
var {
DefaultWeakMap,
ExtensionError,
} = ExtensionUtils;
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
-var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var DEFAULT_ICON = "chrome://messenger/content/extension.svg";
this.ToolbarButtonAPI = class extends ExtensionAPI {
/**
* Called when the extension is enabled.
*
* @param {String} entryName
* The name of the property in the extension manifest
@@ -101,17 +100,17 @@ this.ToolbarButtonAPI = class extends Ex
/**
* Creates a toolbar button.
*
* @param {Window} window
*/
makeButton(window) {
let {document} = window;
- let button = document.createElementNS(XUL_NS, "toolbarbutton");
+ let button = document.createXULElement("toolbarbutton");
button.id = this.id;
button.classList.add("toolbarbutton-1");
button.classList.add("webextension-action");
button.classList.add("badged-button");
button.setAttribute("data-extensionid", this.extension.id);
button.addEventListener("mousedown", this);
this.updateButton(button, this.globals);
return button;