clean up new Object usage (bug 157970); r=Neil, sr=alecf

This commit is contained in:
brade%netscape.com 2002-08-16 21:37:24 +00:00
parent a7e1410a39
commit f6abb4a220
13 changed files with 82 additions and 86 deletions

View File

@ -601,7 +601,7 @@ function GetSuggestedFileName(aDocumentURLString, aMIMEType, aHTMLDoc)
// returns file picker result
function PromptForSaveLocation(aDoSaveAsText, aEditorType, aMIMEType, ahtmlDocument, aDocumentURLString)
{
var dialogResult = new Object;
var dialogResult = {};
dialogResult.filepickerClick = nsIFilePicker.returnCancel;
dialogResult.resultingURI = "";
dialogResult.resultingLocalFile = null;
@ -3105,8 +3105,8 @@ var nsJoinTableCellsCommand =
{
if (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML())
{
var tagNameObj = new Object;
var countObj = new Object;
var tagNameObj = { value: "" };
var countObj = { value: 0 };
var cell = window.editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
// We need a cell and either > 1 selected cell or a cell to the right
@ -3153,8 +3153,8 @@ var nsSplitTableCellCommand =
{
if (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML())
{
var tagNameObj = new Object;
var countObj = new Object;
var tagNameObj = { value: "" };
var countObj = { value: 0 };
var cell = window.editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
// We need a cell parent and there's just 1 selected cell
// or selection is entirely inside 1 cell

View File

@ -149,13 +149,13 @@ function EditorTestTableLayout()
}
var cell;
var startRowIndexObj = new Object();
var startColIndexObj = new Object();
var rowSpanObj = new Object();
var colSpanObj = new Object();
var actualRowSpanObj = new Object();
var actualColSpanObj = new Object();
var isSelectedObj = new Object();
var startRowIndexObj = { value: null };
var startColIndexObj = { value: null };
var rowSpanObj = { value: null };
var colSpanObj = { value: null };
var actualRowSpanObj = { value: null };
var actualColSpanObj = { value: null };
var isSelectedObj = { value: false };
var startRowIndex = 0;
var startColIndex = 0;
var rowSpan;

View File

@ -70,14 +70,18 @@ var gTagModeButton;
var gSourceModeButton;
var gPreviewModeButton;
var gIsHTMLEditor = false;
var gColorObj = new Object();
var gColorObj = { LastTextColor:"", LastBackgroundColor:"", LastHighlightColor:"",
Type:"", SelectedType:"", NoDefault:false, Cancel:false,
HighlightColor:"", BackgroundColor:"", PageColor:"",
TextColor:"", TableColor:"", CellColor:""
};
var gDefaultTextColor = "";
var gDefaultBackgroundColor = "";
var gCSSPrefListener;
var gPrefs;
// These must be kept in synch with the XUL <options> lists
var gFontSizeNames = new Array("xx-small","x-small","small","medium","large","x-large","xx-large");
var gFontSizeNames = ["xx-small","x-small","small","medium","large","x-large","xx-large"];
const nsIFilePicker = Components.interfaces.nsIFilePicker;
@ -102,11 +106,11 @@ nsButtonPrefListener.prototype =
if (prefName.substr(0, this.domain.length) != this.domain) return;
var cmd = document.getElementById("cmd_highlight");
var mixedObj = new Object();
if (cmd && gIsHTMLEditor) {
var prefs = GetPrefs();
var useCSS = prefs.getBoolPref(prefName);
if (useCSS && gEditor && gIsHTMLEditor) {
var mixedObj = {};
var state = gEditor.getHighlightColorState(mixedObj);
cmd.setAttribute("state", state);
cmd.removeAttribute("collapsed");
@ -128,7 +132,7 @@ function AfterHighlightColorChange()
var button = document.getElementById("cmd_highlight");
if (button) {
var mixedObj = new Object();
var mixedObj = {};
var state = gEditor.getHighlightColorState(mixedObj);
button.setAttribute("state", state);
onHighlightColorChange();
@ -877,10 +881,9 @@ function initFontFaceMenu(menuPopup)
var children = menuPopup.childNodes;
if (!children) return;
var firstHas = new Object();
var anyHas = new Object();
var allHas = new Object();
allHas.value = false;
var firstHas = { value: false };
var anyHas = { value: false };
var allHas = { value: false };
// we need to set or clear the checkmark for each menu item since the selection
// may be in a new location from where it was when the menu was previously opened
@ -919,10 +922,9 @@ function initFontSizeMenu(menuPopup)
var children = menuPopup.childNodes;
if (!children) return;
var firstHas = new Object();
var anyHas = new Object();
var allHas = new Object();
allHas.value = false;
var firstHas = { value: false };
var anyHas = { value: false };
var allHas = { value: false };
var sizeWasFound = false;
@ -1077,11 +1079,11 @@ function GetBackgroundElementWithColor()
gColorObj.BackgroundColor = "";
gColorObj.SelectedType = "";
var tagNameObj = new Object();
var tagNameObj = { value: "" };
var numSelected;
var element;
try {
var elt = new Object();
var elt = { value: null };
numSelected = gEditor.getSelectedOrParentTableElement(elt, tagNameObj);
element = elt.value;
}
@ -2035,7 +2037,7 @@ function InitObjectPropertiesMenuitem(id)
function InitParagraphMenu()
{
var mixedObj = new Object();
var mixedObj = { value: null };
var state;
try {
state = gEditor.getParagraphState(mixedObj);
@ -2063,10 +2065,10 @@ function InitParagraphMenu()
function GetListStateString()
{
var mixedObj = new Object();
var hasOL = new Object();
var hasUL = new Object();
var hasDL = new Object();
var mixedObj = { value: null };
var hasOL = { value: false };
var hasUL = { value: false };
var hasDL = { value: false };
gEditor.getListState(mixedObj, hasOL, hasUL, hasDL);
if (mixedObj.value)
@ -2078,9 +2080,9 @@ function GetListStateString()
if (hasDL.value)
{
var hasLI = new Object();
var hasDT = new Object();
var hasDD = new Object();
var hasLI = { value: false };
var hasDT = { value: false };
var hasDD = { value: false };
gEditor.getListItemState(mixedObj, hasLI, hasDT, hasDD);
if (mixedObj.value)
return "mixed";
@ -2114,8 +2116,8 @@ function InitListMenu()
function GetAlignmentString()
{
var mixedObj = new Object();
var alignObj = new Object();
var mixedObj = { value: null };
var alignObj = { value: null };
gEditor.getAlignment(mixedObj, alignObj);
if (mixedObj.value)
@ -2543,12 +2545,12 @@ function InitJoinCellMenuitem(id)
if (!menuItem) return;
// Use "Join selected cells if there's more than 1 cell selected
var tagNameObj = new Object();
var numSelected;
var foundElement;
try {
var elt = new Object();
var elt = { value: null };
var tagNameObj = {};
numSelected = gEditor.getSelectedOrParentTableElement(elt,
tagNameObj);
foundElement = elt.value;
@ -2607,8 +2609,8 @@ function goUpdateTableMenuItems(commandset)
if (!(flags & nsIPlaintextEditor.eEditorReadonlyMask) &&
IsEditingRenderedHTML())
{
var tagNameObj = new Object();
var element = new Object();
var tagNameObj = { value: "" };
var element = { value: null };
try {
gEditor.getSelectedOrParentTableElement(element, tagNameObj);
}
@ -2740,9 +2742,9 @@ function GetNumberOfContiguousSelectedRows()
{
if (!gIsHTMLEditor) return 0;
var cellObj = new Object();
var rowObj = new Object();
var colObj = new Object();
var cellObj = { value: null };
var rowObj = { value: 0 };
var colObj = { value: 0 };
gEditor.getFirstSelectedCellInTable(cellObj, rowObj, colObj);
var cell = cellObj.value;
if (!cell)
@ -2773,9 +2775,9 @@ function GetNumberOfContiguousSelectedColumns()
{
if (!gIsHTMLEditor) return 0;
var cellObj = new Object();
var colObj = new Object();
var rowObj = new Object();
var cellObj = { value: null };
var colObj = { value: 0 };
var rowObj = { value: 0 };
gEditor.getFirstSelectedCellInTable(cellObj, rowObj, colObj);
var cell = cellObj.value;
if (!cell)

View File

@ -424,10 +424,8 @@ function SaveFilePickerDirectory(filePicker, fileType)
function GetDefaultBrowserColors()
{
var prefs = GetPrefs();
var colors = new Object();
var colors = { TextColor:0, BackgroundColor:0, LinkColor:0, VisitedLinkColor:0 };
var useSysColors = false;
colors.TextColor = 0;
colors.BackgroundColor = 0;
try { useSysColors = prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
if (!useSysColors)

View File

@ -104,12 +104,11 @@ function GetColorAndUpdate(ColorWellID)
// Only allow selecting when in custom mode
if (!gDialog.CustomColorsRadio.selected) return;
var colorObj = new Object;
var colorWell = document.getElementById(ColorWellID);
if (!colorWell) return;
// Don't allow a blank color, i.e., using the "default"
colorObj.NoDefault = true;
var colorObj = { NoDefault:true, Type:"", TextColor:0, PageColor:0, Cancel:false };
switch( ColorWellID )
{

View File

@ -376,7 +376,7 @@ function fillContextMenu(name)
dump("# of Nodes selected: " + select_list.length + "\n\n");
// perform intersection of commands over selected nodes
var cmdArray = new Array();
var cmdArray = [];
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
@ -389,7 +389,7 @@ function fillContextMenu(name)
var cmdEnum = db.GetAllCmds(rdfNode);
if (!cmdEnum) break;
var nextCmdArray = new Array();
var nextCmdArray = [];
while (cmdEnum.hasMoreElements())
{
var cmd = cmdEnum.getNext();

View File

@ -171,12 +171,11 @@ function GetColorAndUpdate(ColorWellID)
// Only allow selecting when in custom mode
if (!gDialog.CustomColorsRadio.selected) return;
var colorObj = new Object;
var colorWell = document.getElementById(ColorWellID);
if (!colorWell) return;
// Don't allow a blank color, i.e., using the "default"
colorObj.NoDefault = true;
var colorObj = { NoDefault:true, Type:"", TextColor:0, PageColor:0, Cancel:false };
switch( ColorWellID )
{

View File

@ -31,7 +31,7 @@ var imageEl;
var srcInputValue = null;
var marquee = null;
var frameDoc = null;
var buttonArray = new Array();
var buttonArray = [];
function Startup(){
if (!InitEditorShell())

View File

@ -29,7 +29,7 @@ var startY = null;
var endX = null;
var endY = null;
var downTool = false;
var currentElement = new Array();
var currentElement = [];
var currentTool = "pointer";
var currentRect = null;
var currentCir = null;
@ -43,7 +43,7 @@ var xlock = false;
var ylock = false;
var resize = false;
var currentZoom = 1;
var clipBoard = new Array();
var clipBoard = [];
function Rect(coords, href, target, alt, construct){
newRect = frameDoc.createElement("div");
@ -314,7 +314,7 @@ function selectElement(el, add){
}
}
currentElement = null;
currentElement = new Array();
currentElement = [];
currentElement[0] = el;
if (el != null){
if (currentElement[0].getAttribute("class") != "poly"){
@ -775,7 +775,7 @@ function zoom(direction, ratio){
function cutCopy(cut){
len = currentElement.length;
if (len >= 1){
clipBoard = new Array();
clipBoard = [];
for (i=0; i<len; i++){
el = currentElement[i];
if (el.className == 'rect'){

View File

@ -166,9 +166,8 @@ function onAccept()
}
// Detect when entire cells are selected:
// Get number of cells selected
var tagNameObj = new Object;
var countObj = new Object;
tagNameObj.value = "";
var tagNameObj = { value: "" };
var countObj = { value: 0 };
var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
var deletePlaceholder = false;

View File

@ -53,7 +53,7 @@ function Startup()
gDialog.ChangeSelectedRadio = document.getElementById("ChangeSelected");
// Try to get an existing list(s)
var mixedObj = new Object;
var mixedObj = { value: null };
gListType = editorShell.GetListState(mixedObj);
// We may have mixed list and non-list, or > 1 list type in selection
gMixedListSelection = mixedObj.value;

View File

@ -32,7 +32,7 @@ var gEditor; // the editor we're using
function initDialogObject()
{
// Create gReplaceDialog object and initialize.
gReplaceDialog = new Object();
gReplaceDialog = {};
gReplaceDialog.findInput = document.getElementById("dialog.findInput");
gReplaceDialog.replaceInput = document.getElementById("dialog.replaceInput");
gReplaceDialog.caseSensitive = document.getElementById("dialog.caseSensitive");

View File

@ -53,11 +53,13 @@ var curRowIndex;
var curColIndex;
var curColSpan;
var SelectedCellsType = 1;
var SELECT_CELL = 1;
var SELECT_ROW = 2;
var SELECT_COLUMN = 3;
var RESET_SELECTION = 0;
var cellData = new Object;
const SELECT_CELL = 1;
const SELECT_ROW = 2;
const SELECT_COLUMN = 3;
const RESET_SELECTION = 0;
var cellData = { cell:null, startRowIndex:0, startColIndex:0, rowSpan:0, colSpan:0,
actualRowSpan:0, actualColSpan:0, isSelected:false
};
var AdvancedEditUsed;
var alignWasChar = false;
@ -155,8 +157,8 @@ function Startup()
}
globalTableElement = TableElement.cloneNode(false);
var tagNameObj = new Object;
var countObj = new Object;
var tagNameObj = { value: "" };
var countObj = { value: 0 };
var tableOrCellElement = editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
gSelectedCellCount = countObj.value;
@ -383,15 +385,15 @@ function InitCellPanel()
function GetCellData(rowIndex, colIndex)
{
// Get actual rowspan and colspan
var startRowIndexObj = new Object;
var startColIndexObj = new Object;
var rowSpanObj = new Object;
var colSpanObj = new Object;
var actualRowSpanObj = new Object;
var actualColSpanObj = new Object;
var isSelectedObj = new Object;
var startRowIndexObj = { value: 0 };
var startColIndexObj = { value: 0 };
var rowSpanObj = { value: 0 };
var colSpanObj = { value: 0 };
var actualRowSpanObj = { value: 0 };
var actualColSpanObj = { value: 0 };
var isSelectedObj = { value: false };
if (!cellData)
cellData = new Object;
cellData = { cell: null };
try {
cellData.cell =
@ -429,7 +431,7 @@ function GetColorAndUpdate(ColorWellID)
var colorWell = document.getElementById(ColorWellID);
if (!colorWell) return;
var colorObj = new Object;
var colorObj = { Type:"", TableColor:0, CellColor:0, NoDefault:false, Cancel:false, BackgroundColor:0 };
switch( ColorWellID )
{
@ -442,8 +444,6 @@ function GetColorAndUpdate(ColorWellID)
colorObj.CellColor = CellColor;
break;
}
// Avoid the JS warning
colorObj.NoDefault = false;
window.openDialog("chrome://editor/content/EdColorPicker.xul", "_blank", "chrome,close,titlebar,modal", "", colorObj);
// User canceled the dialog
@ -707,9 +707,8 @@ function DoCellSelection()
break;
}
// Get number of cells selected
var tagNameObj = new Object;
var countObj = new Object;
tagNameObj.value = "";
var tagNameObj = { value: "" };
var countObj = { value: 0 };
var tableOrCellElement = editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
if (tagNameObj.value == "td")
gSelectedCellCount = countObj.value;