From 396ab0d57e537c6b8a9919869a5e486673c55e83 Mon Sep 17 00:00:00 2001 From: Jorg K Date: Tue, 15 Jan 2019 10:42:53 +0100 Subject: [PATCH] Bug 1518823 - Port bug 1482389: Remove acces via .treeBoxObject and .boxObject. rs=bustage-fix --- editor/ui/dialogs/content/EdSelectProps.js | 68 +++++++------- .../ui/dialogs/content/EditorSaveAsCharset.js | 2 +- mail/base/content/SearchDialog.js | 1 - mail/base/content/folderDisplay.js | 92 +++++++++---------- mail/base/content/folderPane.js | 7 +- mail/base/content/foldersummary.js | 9 +- mail/base/content/mailCommands.js | 3 +- mail/base/content/mailContextMenus.js | 6 +- mail/base/content/mailTabs.js | 3 +- mail/base/content/mailWidgets.xml | 45 +++++---- mail/base/content/messageWindow.js | 4 +- mail/base/content/msgMail3PaneWindow.js | 26 ++---- mail/base/content/threadPane.js | 23 ++--- mail/components/addrbook/content/abCommon.js | 2 +- .../addrbook/content/abContactsPanel.js | 2 +- .../test/browser/browser_ext_menus.js | 2 +- mail/components/im/content/chat-messenger.js | 4 +- mail/components/preferences/cookies.js | 26 +++--- mail/components/preferences/permissions.js | 8 +- .../test-right-click-middle-click-messages.js | 26 +++--- .../test-folder-display-helpers.js | 31 +++---- mailnews/addrbook/content/abResultsPane.js | 7 +- .../base/content/msgSelectOfflineFolders.js | 9 +- mailnews/base/content/msgSynchronize.js | 18 ++-- mailnews/base/content/subscribe.js | 35 ++++--- .../base/content/virtualFolderListEdit.js | 9 +- mailnews/base/prefs/content/AccountManager.js | 4 +- mailnews/base/util/jsTreeSelection.js | 62 ++++++------- .../extensions/newsblog/content/FeedUtils.jsm | 2 +- .../newsblog/content/feed-subscriptions.js | 38 ++++---- .../newsblog/content/newsblogOverlay.js | 2 +- 31 files changed, 268 insertions(+), 308 deletions(-) diff --git a/editor/ui/dialogs/content/EdSelectProps.js b/editor/ui/dialogs/content/EdSelectProps.js index 24657959f4..ca58eced8e 100644 --- a/editor/ui/dialogs/content/EdSelectProps.js +++ b/editor/ui/dialogs/content/EdSelectProps.js @@ -8,7 +8,7 @@ var hasValue; var oldValue; var insertNew; var itemArray; -var treeBoxObject; +var theTree; var treeSelection; var selectElement; var currentItem = null; @@ -94,14 +94,14 @@ optionObject.prototype.cycleCell = function cycleCell(index) else if (selectedOption) { selectedOption.removeAttribute("selected"); - var column = treeBoxObject.columns["SelectSelCol"]; - treeBoxObject.invalidateColumn(column); + var column = theTree.columns["SelectSelCol"]; + theTree.invalidateColumn(column); selectedOption = null; } this.element.setAttribute("selected", ""); selectedOption = this.element; - var column = treeBoxObject.columns["SelectSelCol"]; - treeBoxObject.invalidateCell(index, column); + var column = theTree.columns["SelectSelCol"]; + theTree.invalidateCell(index, column); } if (currentItem == this) // Also update the deck @@ -178,10 +178,10 @@ optionObject.prototype.moveUp = function moveUp() if (itemArray[index].level < itemArray[index - 1].level + itemArray[index - 1].container) { // we need to repaint the tree's lines - treeBoxObject.invalidateRange(getParentIndex(index), index); + theTree.invalidateRange(getParentIndex(index), index); // a) option is just after an optgroup, so it becomes the last child itemArray[index].level = 2; - treeBoxObject.view.selectionChanged(); + theTree.view.selectionChanged(); } else { @@ -206,10 +206,10 @@ optionObject.prototype.moveDown = function moveDown() if (index + 1 == itemArray.length || itemArray[index].level > itemArray[index + 1].level) { // we need to repaint the tree's lines - treeBoxObject.invalidateRange(getParentIndex(index), index); + theTree.invalidateRange(getParentIndex(index), index); // a) option is last child of an optgroup, so it moves just after itemArray[index].level = 1; - treeBoxObject.view.selectionChanged(); + theTree.view.selectionChanged(); } else { @@ -292,7 +292,7 @@ optgroupObject.prototype.moveUp = function moveUp() var endItems = itemArray.splice(index); itemArray = itemArray.concat(movedItems).concat(endItems); // Repaint the lot - treeBoxObject.invalidateRange(index, j); + theTree.invalidateRange(index, j); selectTreeIndex(index, true); } @@ -312,7 +312,7 @@ optgroupObject.prototype.moveDown = function moveDown() var endItems = itemArray.splice(index); itemArray = itemArray.concat(movedItems).concat(endItems); // Repaint the lot - treeBoxObject.invalidateRange(index, j); + theTree.invalidateRange(index, j); index += j - i; selectTreeIndex(index, true); } @@ -321,11 +321,11 @@ optgroupObject.prototype.appendOption = function appendOption(child, parent) { var index = gDialog.nextChild(parent); // XXX need to repaint the lines, tree won't do this - var primaryCol = treeBoxObject.columns.getPrimaryColumn(); - treeBoxObject.invalidateCell(index - 1, primaryCol); + var primaryCol = theTree.columns.getPrimaryColumn(); + theTree.invalidateCell(index - 1, primaryCol); // insert the wrapped object as the last child itemArray.splice(index, 0, new optionObject(child, 2)); - treeBoxObject.rowCountChanged(index, 1); + theTree.rowCountChanged(index, 1); selectTreeIndex(index, false); }; @@ -432,10 +432,10 @@ function Startup() { var index = itemArray.length; // XXX need to repaint the lines, tree won't do this - treeBoxObject.invalidateRange(this.lastChild(), index); + theTree.invalidateRange(this.lastChild(), index); // append the wrapped object itemArray.push(new optionObject(child, 1)); - treeBoxObject.rowCountChanged(index, 1); + theTree.rowCountChanged(index, 1); selectTreeIndex(index, false); }, canDestroy: function canDestroy(prompt) @@ -481,8 +481,8 @@ function Startup() UpdateSelectMultiple(); // Define a custom view for the tree - treeBoxObject = gDialog.tree.treeBoxObject; - treeBoxObject.view = { + theTree = gDialog.tree; + theTree.view = { QueryInterface: ChromeUtils.generateQI(["nsITreeView", "nsISupportsWeakReference"]), // useful for debugging @@ -628,10 +628,10 @@ function AddOptGroup() var optgroupElement = GetCurrentEditor().createElementWithDefaults("optgroup"); var index = itemArray.length; // XXX need to repaint the lines, tree won't do this - treeBoxObject.invalidateRange(gDialog.lastChild(), index); + theTree.invalidateRange(gDialog.lastChild(), index); // append the wrapped object itemArray.push(new optgroupObject(optgroupElement)); - treeBoxObject.rowCountChanged(index, 1); + theTree.rowCountChanged(index, 1); selectTreeIndex(index, false); SetTextboxFocus(gDialog.optgroupLabel); } @@ -651,10 +651,10 @@ function RemoveElement() if (level == 1) { var last = gDialog.lastChild(); if (index > last) - treeBoxObject.invalidateRange(last, index); + theTree.invalidateRange(last, index); } selectTreeIndex(index, true); - treeBoxObject.rowCountChanged(++index, -1); + theTree.rowCountChanged(++index, -1); } } @@ -672,16 +672,16 @@ function onNameInput() gDialog.accept.disabled = disabled; gDialog.element.setAttribute("name", gDialog.selectName.value); // repaint the tree - var primaryCol = treeBoxObject.columns.getPrimaryColumn(); - treeBoxObject.invalidateCell(treeSelection.currentIndex, primaryCol); + var primaryCol = theTree.columns.getPrimaryColumn(); + theTree.invalidateCell(treeSelection.currentIndex, primaryCol); } function onLabelInput() { currentItem.element.setAttribute("label", gDialog.optgroupLabel.value); // repaint the tree - var primaryCol = treeBoxObject.columns.getPrimaryColumn(); - treeBoxObject.invalidateCell(treeSelection.currentIndex, primaryCol); + var primaryCol = theTree.columns.getPrimaryColumn(); + theTree.invalidateCell(treeSelection.currentIndex, primaryCol); } function onTextInput() @@ -689,13 +689,13 @@ function onTextInput() currentItem.element.text = gDialog.optionText.value; // repaint the tree if (hasValue) { - var primaryCol = treeBoxObject.columns.getPrimaryColumn(); - treeBoxObject.invalidateCell(treeSelection.currentIndex, primaryCol); + var primaryCol = theTree.columns.getPrimaryColumn(); + theTree.invalidateCell(treeSelection.currentIndex, primaryCol); } else { gDialog.optionValue.value = gDialog.optionText.value; - treeBoxObject.invalidateRow(treeSelection.currentIndex); + theTree.invalidateRow(treeSelection.currentIndex); } } @@ -705,8 +705,8 @@ function onValueInput() oldValue = gDialog.optionValue.value; currentItem.element.setAttribute("value", oldValue); // repaint the tree - var column = treeBoxObject.columns["SelectValCol"]; - treeBoxObject.invalidateCell(treeSelection.currentIndex, column); + var column = theTree.columns["SelectValCol"]; + theTree.invalidateCell(treeSelection.currentIndex, column); } function onHasValueClick() @@ -724,8 +724,8 @@ function onHasValueClick() currentItem.element.removeAttribute("value"); } // repaint the tree - var column = treeBoxObject.columns["SelectValCol"]; - treeBoxObject.invalidateCell(treeSelection.currentIndex, column); + var column = theTree.columns["SelectValCol"]; + theTree.invalidateCell(treeSelection.currentIndex, column); } function onSelectMultipleClick() @@ -738,7 +738,7 @@ function onSelectMultipleClick() function selectTreeIndex(index, focus) { treeSelection.select(index); - treeBoxObject.ensureRowIsVisible(index); + theTree.ensureRowIsVisible(index); if (focus) gDialog.tree.focus(); } diff --git a/editor/ui/dialogs/content/EditorSaveAsCharset.js b/editor/ui/dialogs/content/EditorSaveAsCharset.js index 948eeeea85..ae740e3af4 100644 --- a/editor/ui/dialogs/content/EditorSaveAsCharset.js +++ b/editor/ui/dialogs/content/EditorSaveAsCharset.js @@ -104,7 +104,7 @@ function InitDialog() var index = gCharsetInfo.map(info => info.value).indexOf(gCharset); if (index >= 0) { tree.view.selection.select(index); - tree.treeBoxObject.ensureRowIsVisible(index); + tree.ensureRowIsVisible(index); } } diff --git a/mail/base/content/SearchDialog.js b/mail/base/content/SearchDialog.js index 64ef786882..ebdcc7c58b 100644 --- a/mail/base/content/SearchDialog.js +++ b/mail/base/content/SearchDialog.js @@ -233,7 +233,6 @@ function searchOnLoad() { gFolderDisplay.messenger = messenger; gFolderDisplay.msgWindow = msgWindow; gFolderDisplay.tree = document.getElementById("threadTree"); - gFolderDisplay.treeBox = gFolderDisplay.tree.boxObject; gFolderDisplay.view.openSearchView(); gFolderDisplay.makeActive(); diff --git a/mail/base/content/folderDisplay.js b/mail/base/content/folderDisplay.js index e0daf1be87..90e08fb1f2 100644 --- a/mail/base/content/folderDisplay.js +++ b/mail/base/content/folderDisplay.js @@ -111,12 +111,6 @@ function FolderDisplayWidget(aTabInfo, aMessageDisplayWidget) { * responsible for setting this. */ this.tree = null; - /** - * The nsITreeBoxObject on the XUL tree node, accessible from this.tree as - * this.tree.boxObject and QueryInterfaced as such. The caller is - * responsible for setting this. - */ - this.treeBox = null; /** * The nsIMsgWindow corresponding to the window that holds us. There is only @@ -177,19 +171,19 @@ function FolderDisplayWidget(aTabInfo, aMessageDisplayWidget) { }); /** - * Create a fake tree box object for if/when this folder is in the background. + * Create a fake tree object for if/when this folder is in the background. * We need to give it a DOM object to send events to, including the onselect * event we care about and for which we added a handler above, and all the * other events we don't care about. */ - this._fakeTreeBox = new FakeTreeBoxObject(domNode); + this._fakeTree = new FakeTree(domNode); /** * Create a fake tree selection for cases where we have opened a background * tab. We'll get rid of this as soon as we've switched to the tab for the * first time, and have a real tree selection. */ - this._fakeTreeSelection = new JSTreeSelection(this._fakeTreeBox); + this._fakeTreeSelection = new JSTreeSelection(this._fakeTree); this._mostRecentSelectionCounts = []; this._mostRecentCurrentIndices = []; @@ -832,7 +826,7 @@ FolderDisplayWidget.prototype = { this.view.close(); this.messenger.setWindow(null, null); this.messenger = null; - this._fakeTreeBox = null; + this._fakeTree = null; this._fakeTreeSelection = null; }, // @} @@ -944,8 +938,8 @@ FolderDisplayWidget.prototype = { this._updateThreadDisplay(); // this creates a new selection object for the view. - if (this.treeBox) - this.treeBox.view = this.view.dbView; + if (this.tree) + this.tree.view = this.view.dbView; FolderDisplayListenerManager._fireListeners("onActiveCreatedView", [this]); @@ -1636,9 +1630,9 @@ FolderDisplayWidget.prototype = { // some things only need to happen if we are transitioning from inactive // to active if (wasInactive) { - if (this.treeBox) { + if (this.tree) { // We might have assigned our JS tree selection to - // this.view.dbView.selection back in _hookUpFakeTreeBox. If we've + // this.view.dbView.selection back in _hookUpFakeTree. If we've // done so, null the selection out so that the line after this // causes a real selection to be created. // If we haven't done so, we're fine as selection would be null here @@ -1652,11 +1646,11 @@ FolderDisplayWidget.prototype = { // out its view so that it won't try and clean up any views or their // selections. (The actual actions happen in // nsTreeBodyFrame::SetView) - // - this.view.dbView.selection.tree = this.treeBox - // - this.view.dbView.setTree(this.treeBox) - // - this.treeBox.view = this.view.dbView (in + // - this.view.dbView.selection.tree = this.tree + // - this.view.dbView.setTree(this.tree) + // - this.tree.view = this.view.dbView (in // nsTreeBodyObject::SetView) - this.treeBox.view = this.view.dbView; + this.tree.view = this.view.dbView; if (fakeTreeSelection) { fakeTreeSelection.duplicateSelection(this.view.dbView.selection); @@ -1665,7 +1659,7 @@ FolderDisplayWidget.prototype = { dontReloadMessage = true; } if (this._savedFirstVisibleRow != null) - this.treeBox.scrollToRow(this._savedFirstVisibleRow); + this.tree.scrollToRow(this._savedFirstVisibleRow); } } @@ -1738,14 +1732,14 @@ FolderDisplayWidget.prototype = { !document.getElementById("folderPaneBox").collapsed; if (this.view.dbView) { - if (this.treeBox) - this._savedFirstVisibleRow = this.treeBox.getFirstVisibleRow(); + if (this.tree) + this._savedFirstVisibleRow = this.tree.getFirstVisibleRow(); // save the message pane's state only when it is potentially visible this.messagePaneCollapsed = document.getElementById("messagepaneboxwrapper").collapsed; - this.hookUpFakeTreeBox(true); + this.hookUpFakeTree(true); } this.messageDisplay.makeInactive(); @@ -1762,7 +1756,7 @@ FolderDisplayWidget.prototype = { * tab, for example. * @private */ - hookUpFakeTreeBox(aNullRealTreeBoxView) { + hookUpFakeTree(aNullRealTreeBoxView) { // save off the tree selection object. the nsTreeBodyFrame will make the // view forget about it when our view is removed, so it's up to us to // save it. @@ -1772,15 +1766,15 @@ FolderDisplayWidget.prototype = { // if we want to, make the tree forget about the view right now so we can // tell the db view about its selection object so it can try and keep it // up-to-date even while hidden in the background - if (aNullRealTreeBoxView && this.treeBox) - this.treeBox.view = null; + if (aNullRealTreeBoxView && this.tree) + this.tree.view = null; // (and tell the db view about its selection again...) this.view.dbView.selection = treeSelection; // hook the dbview up to the fake tree box - this._fakeTreeBox.view = this.view.dbView; - this.view.dbView.setTree(this._fakeTreeBox); - treeSelection.tree = this._fakeTreeBox; + this._fakeTree.view = this.view.dbView; + this.view.dbView.setTree(this._fakeTree); + treeSelection.tree = this._fakeTree; }, /** @@ -2405,7 +2399,7 @@ FolderDisplayWidget.prototype = { // If we can get the height of the folder pane, treat the values as // percentages of that. - if (this.treeBox) { + if (this.tree) { let topPercentPadding = Services.prefs.getIntPref( "mail.threadpane.padding.top_percent"); let bottomPercentPadding = Services.prefs.getIntPref( @@ -2413,7 +2407,7 @@ FolderDisplayWidget.prototype = { // Assume the bottom row is half-visible and should generally be ignored. // (We could actually do the legwork to see if there is a partial one...) - let paneHeight = this.treeBox.getPageLength() - 1; + let paneHeight = this.tree.getPageLength() - 1; // Convert from percentages to absolute row counts. topPadding = Math.ceil((topPercentPadding / 100) * paneHeight); @@ -2461,21 +2455,21 @@ FolderDisplayWidget.prototype = { }, 0); } - let treeBox = this.treeBox; - if (!treeBox || !treeBox.view) + let tree = this.tree; + if (!tree || !tree.view) return; // try and trigger a reflow... - treeBox.height; + tree.height; - let maxIndex = treeBox.view.rowCount - 1; + let maxIndex = tree.view.rowCount - 1; - let first = treeBox.getFirstVisibleRow(); + let first = tree.getFirstVisibleRow(); // Assume the bottom row is half-visible and should generally be ignored. // (We could actually do the legwork to see if there is a partial one...) const halfVisible = 1; - let last = treeBox.getLastVisibleRow() - halfVisible; - let span = treeBox.getPageLength() - halfVisible; + let last = tree.getLastVisibleRow() - halfVisible; + let span = tree.getPageLength() - halfVisible; let [topPadding, bottomPadding] = this.visibleRowPadding; let target; @@ -2490,7 +2484,7 @@ FolderDisplayWidget.prototype = { return; // this sets the first visible row - treeBox.scrollToRow(target); + tree.scrollToRow(target); }, /** @@ -2517,13 +2511,13 @@ FolderDisplayWidget.prototype = { }, 0); } - let treeBox = this.treeBox; - if (!treeBox) + let tree = this.tree; + if (!tree) return; - let first = treeBox.getFirstVisibleRow(); + let first = tree.getFirstVisibleRow(); const halfVisible = 1; - let last = treeBox.getLastVisibleRow() - halfVisible; - let span = treeBox.getPageLength() - halfVisible; + let last = tree.getLastVisibleRow() - halfVisible; + let span = tree.getPageLength() - halfVisible; let [topPadding, bottomPadding] = this.visibleRowPadding; // bail if the range is already visible with padding constraints handled @@ -2543,7 +2537,7 @@ FolderDisplayWidget.prototype = { let halfSpare = Math.floor((span - rowSpan - topPadding - bottomPadding) / 2); target = aMinRow - halfSpare - topPadding; } - treeBox.scrollToRow(target); + tree.scrollToRow(target); }, /** @@ -2585,11 +2579,11 @@ FolderDisplayWidget.prototype = { * an event listener for onselect already attached), and pass its boxObject in * whenever nsTreeSelection QIs us to nsIBoxObject. */ -function FakeTreeBoxObject(aDOMNode) { +function FakeTree(aDOMNode) { this.domNode = aDOMNode; this.view = null; } -FakeTreeBoxObject.prototype = { +FakeTree.prototype = { view: null, ensureRowIsVisible() { // NOP @@ -2660,7 +2654,7 @@ FakeTreeBoxObject.prototype = { return this.domNode.boxObject.removeProperty(propertyName); }, QueryInterface: ChromeUtils.generateQI(["nsIBoxObject", - "nsITreeBoxObject"]), + "XULTreeElement"]), }; /* * Provide attribute and function implementations that complain very loudly if @@ -2697,7 +2691,7 @@ function FTBO_stubOutMethods(aObj, aMethodNames) { }; } } -FTBO_stubOutAttributes(FakeTreeBoxObject.prototype, [ +FTBO_stubOutAttributes(FakeTree.prototype, [ "columns", "focused", "treeBody", @@ -2706,7 +2700,7 @@ FTBO_stubOutAttributes(FakeTreeBoxObject.prototype, [ "horizontalPosition", "selectionRegion", ]); -FTBO_stubOutMethods(FakeTreeBoxObject.prototype, [ +FTBO_stubOutMethods(FakeTree.prototype, [ "getFirstVisibleRow", "getLastVisibleRow", "getPageLength", diff --git a/mail/base/content/folderPane.js b/mail/base/content/folderPane.js index 688923a5ac..85790a236b 100644 --- a/mail/base/content/folderPane.js +++ b/mail/base/content/folderPane.js @@ -267,8 +267,7 @@ var gFolderTreeView = { aEvent.originalTarget.localName == "scrollbarbutton") return; - let row = gFolderTreeView._treeElement.treeBoxObject.getRowAt(aEvent.clientX, - aEvent.clientY); + let row = gFolderTreeView._treeElement.getRowAt(aEvent.clientX, aEvent.clientY); let folderItem = gFolderTreeView._rowMap[row]; if (folderItem) folderItem.command(); @@ -278,7 +277,7 @@ var gFolderTreeView = { }, getFolderAtCoords(aX, aY) { - let row = gFolderTreeView._treeElement.treeBoxObject.getRowAt(aX, aY); + let row = gFolderTreeView._treeElement.getRowAt(aX, aY); if (row in gFolderTreeView._rowMap) return gFolderTreeView._rowMap[row]._folder; return null; @@ -574,7 +573,7 @@ var gFolderTreeView = { } this.selection.select(folderIndex); - this._treeElement.treeBoxObject.ensureRowIsVisible(folderIndex); + this._treeElement.ensureRowIsVisible(folderIndex); return true; }, diff --git a/mail/base/content/foldersummary.js b/mail/base/content/foldersummary.js index dc4e7dd69d..b7986f7e4e 100644 --- a/mail/base/content/foldersummary.js +++ b/mail/base/content/foldersummary.js @@ -206,16 +206,15 @@ class MozFolderTooltip extends MozFolderSummary { return true; } - let row = {}, col = {}; - gFolderTreeView._tree.getCellAt(event.clientX, event.clientY, row, col, {}); - if (col.value.id == "folderNameCol") { - let cropped = gFolderTreeView._tree.isCellCropped(row.value, col.value); + let treeCellInfo = gFolderTreeView._tree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.col.id == "folderNameCol") { + let cropped = gFolderTreeView._tree.isCellCropped(treeCellInfo.row, treeCellInfo.col); if (this._addLocationInfo(msgFolder, cropped, tooltipnode)) { return true; } } - let counts = gFolderTreeView.getSummarizedCounts(row.value, col.value.id); + let counts = gFolderTreeView.getSummarizedCounts(treeCellInfo.row, treeCellInfo.col.id); return this._addSummarizeExplain(counts, tooltipnode); } diff --git a/mail/base/content/mailCommands.js b/mail/base/content/mailCommands.js index 71f9d7d72d..d3e5b98f47 100644 --- a/mail/base/content/mailCommands.js +++ b/mail/base/content/mailCommands.js @@ -306,8 +306,7 @@ function ComposeMessage(type, format, folder, messageArray) { function NewMessageToSelectedAddresses(type, format, identity) { var abSidebarPanel = document.commandDispatcher.focusedWindow; var abResultsTree = abSidebarPanel.document.getElementById("abResultsTree"); - var abResultsBoxObject = abResultsTree.treeBoxObject; - var abView = abResultsBoxObject.view; + var abView = abResultsTree.view; abView = abView.QueryInterface(Ci.nsIAbView); var addresses = abView.selectedAddresses; var params = Cc["@mozilla.org/messengercompose/composeparams;1"].createInstance(Ci.nsIMsgComposeParams); diff --git a/mail/base/content/mailContextMenus.js b/mail/base/content/mailContextMenus.js index da78e9eef3..6c047114c2 100644 --- a/mail/base/content/mailContextMenus.js +++ b/mail/base/content/mailContextMenus.js @@ -34,7 +34,7 @@ function RestoreSelectionWithoutContentLoad(tree) { gRightMouseButtonSavedSelection = null; if (tree) - tree.treeBoxObject.invalidate(); + tree.invalidate(); UpdateMailToolbar("RestoreSelectionWithoutContentLoad"); } @@ -66,7 +66,7 @@ function fillMailContextMenu(event) { // No menu on grouped header row currently, any command would be an implied // multiselect. if (gFolderDisplay.tree) { - let row = gFolderDisplay.treeBox.getRowAt(event.clientX, event.clientY); + let row = gFolderDisplay.tree.getRowAt(event.clientX, event.clientY); if (gFolderDisplay.view.isGroupedByHeaderAtIndex(row)) { RestoreSelectionWithoutContentLoad(gFolderDisplay.tree); return false; @@ -228,7 +228,7 @@ function OpenMessageByHeader(messageHeader, openInNewWindow) { } if (tree && tree.currentIndex != -1) - tree.treeBoxObject.ensureRowIsVisible(tree.currentIndex); + tree.ensureRowIsVisible(tree.currentIndex); } } diff --git a/mail/base/content/mailTabs.js b/mail/base/content/mailTabs.js index bb0e0f8504..a96abcce03 100644 --- a/mail/base/content/mailTabs.js +++ b/mail/base/content/mailTabs.js @@ -358,7 +358,7 @@ var mailTabType = { } else { // We don't want to null out the real tree box view, as that // corresponds to the _current_ tab, not the new one - aTab.folderDisplay.hookUpFakeTreeBox(false); + aTab.folderDisplay.hookUpFakeTree(false); } }, persistTab(aTab) { @@ -499,7 +499,6 @@ var mailTabType = { aTab.folderDisplay = new FolderDisplayWidget(aTab, aTab.messageDisplay); aTab.folderDisplay.msgWindow = msgWindow; aTab.folderDisplay.tree = document.getElementById("threadTree"); - aTab.folderDisplay.treeBox = aTab.folderDisplay.tree.boxObject; aTab.folderDisplay.folderPaneVisible = aFolderPaneVisible; if (aIsFirstTab) { diff --git a/mail/base/content/mailWidgets.xml b/mail/base/content/mailWidgets.xml index 4f632ff169..93cd02c6bf 100644 --- a/mail/base/content/mailWidgets.xml +++ b/mail/base/content/mailWidgets.xml @@ -1835,10 +1835,9 @@ 0 && !event.ctrlKey && !event.metaKey) { @@ -1937,9 +1935,9 @@ } return; } - box.view.selection.select(index); + this.tree.view.selection.select(index); if (this.parentNode.hasAttribute("open")) - box.ensureRowIsVisible(index); + this.tree.ensureRowIsVisible(index); else this.self.fire(); }, @@ -1996,14 +1994,13 @@ = 0) - setTimeout(function() { box.ensureRowIsVisible(index); }, 0); + setTimeout(function() { this.tree.ensureRowIsVisible(index); }, 0); ]]> diff --git a/mail/base/content/messageWindow.js b/mail/base/content/messageWindow.js index 4d685dd825..54f8278c4d 100644 --- a/mail/base/content/messageWindow.js +++ b/mail/base/content/messageWindow.js @@ -91,7 +91,7 @@ StandaloneFolderDisplayWidget.prototype = { * the fake tree box so it will actually do something in NoteChange. */ onCreatedView() { - this._fakeTreeBox.view = this.view.dbView; + this._fakeTree.view = this.view.dbView; // Need to clear out this reference later. this._magicTreeSelection.view = this.view.dbView; @@ -102,7 +102,7 @@ StandaloneFolderDisplayWidget.prototype = { // showing an .eml file to go to a real message, at least in terms of // having the selection object properly associated with the tree. if (!this.messageDisplay.isDummy) { - this.view.dbView.setTree(this._fakeTreeBox); + this.view.dbView.setTree(this._fakeTree); this.view.dbView.selection = this._magicTreeSelection; // This lets the dbView know we don't really have a tree, so it can // avoid operating on messages in collapsed threads. diff --git a/mail/base/content/msgMail3PaneWindow.js b/mail/base/content/msgMail3PaneWindow.js index a00f2810ce..a309304956 100644 --- a/mail/base/content/msgMail3PaneWindow.js +++ b/mail/base/content/msgMail3PaneWindow.js @@ -397,7 +397,7 @@ var MailPrefObserver = { ++currentDisplayNameVersion); // refresh the thread pane - threadTree.treeBoxObject.invalidate(); + threadTree.invalidate(); } } }, @@ -1075,15 +1075,10 @@ function ClearMessagePane() { * aSingleSelect then we create a transient single-row selection. */ function ChangeSelectionWithoutContentLoad(event, tree, aSingleSelect) { - var treeBoxObj = tree.treeBoxObject; - if (!treeBoxObj) { - event.stopPropagation(); - return; - } - var treeSelection = treeBoxObj.view.selection; + var treeSelection = tree.view.selection; - var row = treeBoxObj.getRowAt(event.clientX, event.clientY); + var row = tree.getRowAt(event.clientX, event.clientY); // Only do something if: // - the row is valid // - it's not already selected (or we want a single selection) @@ -1100,12 +1095,12 @@ function ChangeSelectionWithoutContentLoad(event, tree, aSingleSelect) { } } - let transientSelection = new JSTreeSelection(treeBoxObj); + let transientSelection = new JSTreeSelection(tree); transientSelection.logAdjustSelectionForReplay(); gRightMouseButtonSavedSelection = { // Need to clear out this reference later. - view: treeBoxObj.view, + view: tree.view, realSelection: treeSelection, transientSelection, }; @@ -1114,14 +1109,14 @@ function ChangeSelectionWithoutContentLoad(event, tree, aSingleSelect) { // tell it to log calls to adjustSelection // attach it to the view - treeBoxObj.view.selection = transientSelection; + tree.view.selection = transientSelection; // Don't generate any selection events! (we never set this to false, because // that would generate an event, and we never need one of those from this // selection object. transientSelection.selectEventsSuppressed = true; transientSelection.select(row); transientSelection.currentIndex = saveCurrentIndex; - treeBoxObj.ensureRowIsVisible(row); + tree.ensureRowIsVisible(row); } event.stopPropagation(); } @@ -1154,11 +1149,8 @@ function FolderPaneOnClick(event) { FolderPaneContextMenuNewTab(event); RestoreSelectionWithoutContentLoad(folderTree); } else if (event.button == 0) { - var row = {}; - var col = {}; - var elt = {}; - folderTree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, elt); - if (row.value == -1) { + var treeCellInfo = folderTree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.row == -1) { if (event.originalTarget.localName == "treecol") { // clicking on the name column in the folder pane should not sort event.stopPropagation(); diff --git a/mail/base/content/threadPane.js b/mail/base/content/threadPane.js index b5fc6aa706..876e67d3f7 100644 --- a/mail/base/content/threadPane.js +++ b/mail/base/content/threadPane.js @@ -32,28 +32,25 @@ function ThreadPaneOnClick(event) { if (t.localName != "treechildren") return; - let row = {}; - let col = {}; - let elt = {}; let tree = GetThreadTree(); // Figure out what cell the click was in. - tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, elt); - if (row.value == -1) + let treeCellInfo = tree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.row == -1) return; // Grouped By Sort dummy header row non cycler column doubleclick toggles the // thread's open/close state; tree.xml handles it. Cyclers are not currently // implemented in group header rows, a click/doubleclick there should // select/toggle thread state. - if (gFolderDisplay.view.isGroupedByHeaderAtIndex(row.value)) { - if (!col.value.cycler) + if (gFolderDisplay.view.isGroupedByHeaderAtIndex(treeCellInfo.row)) { + if (!treeCellInfo.col.cycler) return; if (event.detail == 1) - gFolderDisplay.selectViewIndex(row.value); + gFolderDisplay.selectViewIndex(treeCellInfo.row); if (event.detail == 2) - gFolderDisplay.view.dbView.toggleOpenState(row.value); + gFolderDisplay.view.dbView.toggleOpenState(treeCellInfo.row); event.stopPropagation(); return; @@ -61,16 +58,16 @@ function ThreadPaneOnClick(event) { // If the cell is in a cycler column or if the user doubleclicked on the // twisty, don't open the message in a new window. - if (event.detail == 2 && !col.value.cycler && elt.value != "twisty") { + if (event.detail == 2 && !treeCellInfo.col.cycler && treeCellInfo.childElt != "twisty") { ThreadPaneDoubleClick(); // Doubleclicking should not toggle the open/close state of the thread. // This will happen if we don't prevent the event from bubbling to the // default handler in tree.xml. event.stopPropagation(); - } else if (col.value.id == "junkStatusCol") { + } else if (treeCellInfo.col.id == "junkStatusCol") { MsgJunkMailInfo(true); - } else if (col.value.id == "threadCol" && !event.shiftKey && (event.ctrlKey || event.metaKey)) { - gDBView.ExpandAndSelectThreadByIndex(row.value, true); + } else if (treeCellInfo.col.id == "threadCol" && !event.shiftKey && (event.ctrlKey || event.metaKey)) { + gDBView.ExpandAndSelectThreadByIndex(treeCellInfo.row, true); event.stopPropagation(); } } diff --git a/mail/components/addrbook/content/abCommon.js b/mail/components/addrbook/content/abCommon.js index e366401b04..42bb05d144 100644 --- a/mail/components/addrbook/content/abCommon.js +++ b/mail/components/addrbook/content/abCommon.js @@ -631,7 +631,7 @@ function DirPaneDoubleClick(event) { return; // Ignore double clicking on invalid rows. - let row = gDirTree.treeBoxObject.getRowAt(event.clientX, event.clientY); + let row = gDirTree.getRowAt(event.clientX, event.clientY); if (row == -1 || row > gDirTree.view.rowCount - 1) return; diff --git a/mail/components/addrbook/content/abContactsPanel.js b/mail/components/addrbook/content/abContactsPanel.js index 09d0e988bc..d92fe4c543 100644 --- a/mail/components/addrbook/content/abContactsPanel.js +++ b/mail/components/addrbook/content/abContactsPanel.js @@ -75,7 +75,7 @@ function contactsListOnClick(aEvent) { } // Any click on gAbResultsTree view (rows or blank space). if (target.localName == "treechildren") { - let row = gAbResultsTree.treeBoxObject.getRowAt(aEvent.clientX, aEvent.clientY); + let row = gAbResultsTree.getRowAt(aEvent.clientX, aEvent.clientY); if (row < 0 || row >= gAbResultsTree.view.rowCount) { // Any click on results tree whitespace. if ((aEvent.detail == 1 && aEvent.button == 0) || aEvent.button == 2) { diff --git a/mail/components/extensions/test/browser/browser_ext_menus.js b/mail/components/extensions/test/browser/browser_ext_menus.js index 14cbf8b351..1e1042bdbc 100644 --- a/mail/components/extensions/test/browser/browser_ext_menus.js +++ b/mail/components/extensions/test/browser/browser_ext_menus.js @@ -5,7 +5,7 @@ let gAccount, gFolders; function treeClick(tree, row, column, event) { - let coords = tree.treeBoxObject.getCoordsForCellItem(row, tree.columns[column], "cell"); + let coords = tree.getCoordsForCellItem(row, tree.columns[column], "cell"); let treeChildren = tree.lastElementChild; EventUtils.synthesizeMouse( treeChildren, diff --git a/mail/components/im/content/chat-messenger.js b/mail/components/im/content/chat-messenger.js index 327feb20a0..26af33bbf8 100644 --- a/mail/components/im/content/chat-messenger.js +++ b/mail/components/im/content/chat-messenger.js @@ -482,7 +482,7 @@ var chatHandler = { if (!treeView.isContainer(index) && treeView._rowMap[index].log.time == logTime) { logTree.view.selection.select(index); - logTree.treeBoxObject.ensureRowIsVisible(index); + logTree.ensureRowIsVisible(index); return true; } if (!treeView._rowMap[index].children.some(i => i.log.time == logTime)) @@ -494,7 +494,7 @@ var chatHandler = { ++index; if (treeView._rowMap[index].log.time == logTime) { logTree.view.selection.select(index); - logTree.treeBoxObject.ensureRowIsVisible(index); + logTree.ensureRowIsVisible(index); } return true; } diff --git a/mail/components/preferences/cookies.js b/mail/components/preferences/cookies.js index e87df27268..f7c8aa09c1 100644 --- a/mail/components/preferences/cookies.js +++ b/mail/components/preferences/cookies.js @@ -37,7 +37,7 @@ var gCookiesWindow = { _populateList(aInitialLoad) { this._loadCookies(); - this._tree.treeBoxObject.view = this._view; + this._tree.view = this._view; if (aInitialLoad) this.sort("rawHost"); if (this._view.rowCount > 0) @@ -79,7 +79,7 @@ var gCookiesWindow = { var oldRowCount = this._view._rowCount; this._view._rowCount = 0; - this._tree.treeBoxObject.rowCountChanged(0, -oldRowCount); + this._tree.rowCountChanged(0, -oldRowCount); this._view.selection.clearSelection(); } else if (aData == "reload") { // first, clear any existing entries @@ -137,7 +137,7 @@ var gCookiesWindow = { } // Make sure the tree display is up to date... - this._tree.treeBoxObject.invalidateRow(rowIndex); + this._tree.invalidateRow(rowIndex); // ... and if the cookie is selected, update the displayed metadata too if (cookieItem != null && this._view.selection.currentIndex == rowIndex) this._updateCookieData(cookieItem); @@ -166,7 +166,7 @@ var gCookiesWindow = { // if any to get the position correct.) var oldRowCount = this._rowCount; this._view._rowCount += rowCountImpact; - this._tree.treeBoxObject.rowCountChanged(oldRowCount - 1, rowCountImpact); + this._tree.rowCountChanged(oldRowCount - 1, rowCountImpact); document.getElementById("removeAllCookies").disabled = this._view._filtered; }, @@ -403,8 +403,8 @@ var gCookiesWindow = { var delta = multiplier * item.cookies.length; this._rowCount += delta; item.open = !item.open; - gCookiesWindow._tree.treeBoxObject.rowCountChanged(aIndex + 1, delta); - gCookiesWindow._tree.treeBoxObject.invalidateRow(aIndex); + gCookiesWindow._tree.rowCountChanged(aIndex + 1, delta); + gCookiesWindow._tree.invalidateRow(aIndex); } }, cycleHeader(aColumn) {}, @@ -608,7 +608,7 @@ var gCookiesWindow = { // Before SelectedIndex: 1 Before RowCount: 4 // After SelectedIndex: 1 After RowCount: 3 var seln = this._view.selection; - var tbo = this._tree.treeBoxObject; + var tbo = this._tree; if (seln.count < 1) return; @@ -730,8 +730,8 @@ var gCookiesWindow = { this._view._invalidateCache(0); this._view.selection.clearSelection(); this._view.selection.select(0); - this._tree.treeBoxObject.invalidate(); - this._tree.treeBoxObject.ensureRowIsVisible(0); + this._tree.invalidate(); + this._tree.ensureRowIsVisible(0); this._lastSortAscending = ascending; this._lastSortProperty = aProperty; @@ -744,12 +744,12 @@ var gCookiesWindow = { // Clear the Tree Display this._view._filtered = false; this._view._rowCount = 0; - this._tree.treeBoxObject.rowCountChanged(0, -this._view._filterSet.length); + this._tree.rowCountChanged(0, -this._view._filterSet.length); this._view._filterSet = []; // Just reload the list to make sure deletions are respected this._loadCookies(); - this._tree.treeBoxObject.view = this._view; + this._tree.view = this._view; // Restore sort order var sortby = this._lastSortProperty; @@ -840,10 +840,10 @@ var gCookiesWindow = { // Clear the display var oldCount = view._rowCount; view._rowCount = 0; - gCookiesWindow._tree.treeBoxObject.rowCountChanged(0, -oldCount); + gCookiesWindow._tree.rowCountChanged(0, -oldCount); // Set up the filtered display view._rowCount = view._filterSet.length; - gCookiesWindow._tree.treeBoxObject.rowCountChanged(0, view.rowCount); + gCookiesWindow._tree.rowCountChanged(0, view.rowCount); // if the view is not empty then select the first item if (view.rowCount > 0) diff --git a/mail/components/preferences/permissions.js b/mail/components/preferences/permissions.js index 71d770f15a..4fc00d58cf 100644 --- a/mail/components/preferences/permissions.js +++ b/mail/components/preferences/permissions.js @@ -175,13 +175,13 @@ var gPermissionManager = { if (this._lastPermissionSortColumn == "statusCol") { this._resortPermissions(); } - this._tree.treeBoxObject.invalidate(); + this._tree.invalidate(); }, _addPermission(aPermission) { this._addPermissionToList(aPermission); ++this._view._rowCount; - this._tree.treeBoxObject.rowCountChanged(this._view.rowCount - 1, 1); + this._tree.rowCountChanged(this._view.rowCount - 1, 1); // Re-do the sort, since we inserted this new item at the end. this._resortPermissions(); }, @@ -418,8 +418,8 @@ var gPermissionManager = { if (this._permissions[i].principal.origin == aPrincipal.origin) { this._permissions.splice(i, 1); this._view._rowCount--; - this._tree.treeBoxObject.rowCountChanged(this._view.rowCount - 1, -1); - this._tree.treeBoxObject.invalidate(); + this._tree.rowCountChanged(this._view.rowCount - 1, -1); + this._tree.invalidate(); break; } } diff --git a/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js b/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js index 9c6f112c64..32cc2286a3 100644 --- a/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js +++ b/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js @@ -320,12 +320,12 @@ function _middle_click_on_collapsed_thread_root_helper(aBackground) { let folderTab = mc.tabmail.currentTabInfo; - let treeBox = mc.threadTree.treeBoxObject; + let tree = mc.threadTree; // Scroll to the top, then to the bottom - treeBox.ensureRowIsVisible(0); - treeBox.scrollByLines(mc.folderDisplay.view.dbView.rowCount); + tree.ensureRowIsVisible(0); + tree.scrollByLines(mc.folderDisplay.view.dbView.rowCount); // Note the first visible row - let preFirstRow = treeBox.getFirstVisibleRow(); + let preFirstRow = tree.getFirstVisibleRow(); // Since reflowing a tree (eg when switching tabs) ensures that the current // index is brought into view, we need to set the current index so that we @@ -344,9 +344,9 @@ function _middle_click_on_collapsed_thread_root_helper(aBackground) { } // Make sure the first visible row is still the same - if (treeBox.getFirstVisibleRow() != preFirstRow) + if (tree.getFirstVisibleRow() != preFirstRow) throw new Error("The first visible row should have been " + preFirstRow + - ", but is actually " + treeBox.getFirstVisibleRow() + "."); + ", but is actually " + tree.getFirstVisibleRow() + "."); close_tab(tabMessage); } @@ -362,13 +362,13 @@ function _middle_click_on_expanded_thread_root_helper(aBackground) { let folderTab = mc.tabmail.currentTabInfo; - let treeBox = mc.threadTree.treeBoxObject; + let tree = mc.threadTree; // Scroll to the top, then to near (but not exactly) the bottom - treeBox.ensureRowIsVisible(0); - treeBox.scrollToRow(mc.folderDisplay.view.dbView.rowCount - - treeBox.getPageLength() - (NUM_MESSAGES_IN_THREAD / 2)); + tree.ensureRowIsVisible(0); + tree.scrollToRow(mc.folderDisplay.view.dbView.rowCount - + tree.getPageLength() - (NUM_MESSAGES_IN_THREAD / 2)); // Note the first visible row - let preFirstRow = treeBox.getFirstVisibleRow(); + let preFirstRow = tree.getFirstVisibleRow(); // Since reflowing a tree (eg when switching tabs) ensures that the current // index is brought into view, we need to set the current index so that we @@ -387,9 +387,9 @@ function _middle_click_on_expanded_thread_root_helper(aBackground) { } // Make sure the first visible row is still the same - if (treeBox.getFirstVisibleRow() != preFirstRow) + if (tree.getFirstVisibleRow() != preFirstRow) throw new Error("The first visible row should have been " + preFirstRow + - ", but is actually " + treeBox.getFirstVisibleRow() + "."); + ", but is actually " + tree.getFirstVisibleRow() + "."); close_tab(tabMessage); } diff --git a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js index 80dfebf234..58c4d9bb01 100644 --- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js +++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js @@ -961,11 +961,11 @@ function click_tree_row(aTree, aRowIndex, aController) { let selection = aTree.view.selection; selection.select(aRowIndex); - aTree.treeBoxObject.ensureRowIsVisible(aRowIndex); + aTree.ensureRowIsVisible(aRowIndex); // get cell coordinates let column = aTree.columns[0]; - let coords = aTree.treeBoxObject.getCoordsForCellItem(aRowIndex, column, "text"); + let coords = aTree.getCoordsForCellItem(aRowIndex, column, "text"); aController.sleep(0); EventUtils.synthesizeMouse(aTree.body, coords.x + 4, coords.y + 4, @@ -1098,9 +1098,8 @@ function select_shift_click_row(aViewIndex, aController, aDoNotRequireLoad) { function _row_click_helper(aController, aTree, aViewIndex, aButton, aExtra) { // Force-focus the tree aTree.focus(); - let treeBox = aTree.treeBoxObject; // very important, gotta be able to see the row - treeBox.ensureRowIsVisible(aViewIndex); + aTree.ensureRowIsVisible(aViewIndex); // coordinates of the upper left of the entire tree widget (headers included) let tx = aTree.boxObject.x, ty = aTree.boxObject.y; // coordinates of the row display region of the tree (below the headers) @@ -1118,12 +1117,12 @@ function _row_click_helper(aController, aTree, aViewIndex, aButton, aExtra) { if (aExtra !== "toggle") rowX += 32; } - let rowY = treeBox.rowHeight * (aViewIndex - treeBox.getFirstVisibleRow()) + - treeBox.rowHeight / 2; - if (treeBox.getRowAt(x + rowX, y + rowY) != aViewIndex) { + let rowY = aTree.rowHeight * (aViewIndex - aTree.getFirstVisibleRow()) + + aTree.rowHeight / 2; + if (aTree.getRowAt(x + rowX, y + rowY) != aViewIndex) { throw new Error("Thought we would find row " + aViewIndex + " at " + rowX + "," + rowY + " but we found " + - treeBox.getRowAt(rowX, rowY)); + aTree.getRowAt(rowX, rowY)); } // Generate a mouse-down for all click types; the transient selection // logic happens on mousedown which our tests assume is happening. (If you @@ -1189,10 +1188,10 @@ function middle_click_on_row(aViewIndex) { * Assert that the given row index is currently visible in the thread pane view. */ function assert_row_visible(aViewIndex) { - let treeBox = mc.threadTree.treeBoxObject; + let tree = mc.threadTree; - if (treeBox.getFirstVisibleRow() > aViewIndex || - treeBox.getLastVisibleRow() < aViewIndex) + if (tree.getFirstVisibleRow() > aViewIndex || + tree.getLastVisibleRow() < aViewIndex) throw new Error("Row " + aViewIndex + " should currently be visible in " + "the thread pane, but isn't."); } @@ -2227,12 +2226,12 @@ function assert_visible(aViewIndexOrMessage) { viewIndex = _normalize_view_index(aViewIndexOrMessage); else viewIndex = mc.dbView.findIndexOfMsgHdr(aViewIndexOrMessage, false); - let treeBox = mc.threadTree.boxObject; - if (viewIndex < treeBox.getFirstVisibleRow() || - viewIndex > treeBox.getLastVisibleRow()) + let tree = mc.threadTree; + if (viewIndex < tree.getFirstVisibleRow() || + viewIndex > tree.getLastVisibleRow()) throw new Error("View index " + viewIndex + " is not visible! (" + - treeBox.getFirstVisibleRow() + "-" + - treeBox.getLastVisibleRow() + " are visible)"); + tree.getFirstVisibleRow() + "-" + + tree.getLastVisibleRow() + " are visible)"); } /** diff --git a/mailnews/addrbook/content/abResultsPane.js b/mailnews/addrbook/content/abResultsPane.js index e8849ac2db..d739d6fead 100644 --- a/mailnews/addrbook/content/abResultsPane.js +++ b/mailnews/addrbook/content/abResultsPane.js @@ -76,7 +76,7 @@ function SetAbView(aURI) var actualSortColumn = gAbView.setView(directory, GetAbViewListener(), sortColumn, sortDirection); - gAbResultsTree.treeBoxObject.view = + gAbResultsTree.view = gAbView.QueryInterface(Ci.nsITreeView); UpdateSortIndicators(actualSortColumn, sortDirection); @@ -289,8 +289,7 @@ function AbResultsPaneOnClick(event) } else if (t.localName == "treechildren") { // figure out what row the click was in - var row = gAbResultsTree.treeBoxObject.getRowAt(event.clientX, - event.clientY); + var row = gAbResultsTree.getRowAt(event.clientX, event.clientY); if (row == -1) return; @@ -354,7 +353,7 @@ function UpdateSortIndicators(colID, sortDirection) function InvalidateResultsPane() { if (gAbResultsTree) - gAbResultsTree.treeBoxObject.invalidate(); + gAbResultsTree.invalidate(); } // Controller object for Results Pane diff --git a/mailnews/base/content/msgSelectOfflineFolders.js b/mailnews/base/content/msgSelectOfflineFolders.js index 2db6e0ccc7..ca294baf7d 100644 --- a/mailnews/base/content/msgSelectOfflineFolders.js +++ b/mailnews/base/content/msgSelectOfflineFolders.js @@ -68,15 +68,12 @@ var gSelectOffline = { if (aEvent.button != 0) return; - let row = {}; - let col = {}; - this._treeElement.treeBoxObject - .getCellAt(aEvent.clientX, aEvent.clientY, row, col, {}); + let treeCellInfo = this._treeElement.getCellAt(aEvent.clientX); - if (row.value == -1 || col.value.id != "syncCol") + if (treeCellInfo.row == -1 || treeCellInfo.col.id != "syncCol") return; - this._toggle(row.value); + this._toggle(treeCellInfo.row); }, _toggle: function(aRow) { diff --git a/mailnews/base/content/msgSynchronize.js b/mailnews/base/content/msgSynchronize.js index 6d6d9657bf..d366ccd3ac 100644 --- a/mailnews/base/content/msgSynchronize.js +++ b/mailnews/base/content/msgSynchronize.js @@ -128,19 +128,15 @@ function onSynchronizeClick(event) if (event.button != 0) return; - var row = {} - var col = {} - var elt = {} - - gSynchronizeTree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, elt); - if (row.value == -1) + let treeCellInfo = gSynchronizeTree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.row == -1) return; - if (elt.value == "twisty") { - var folderResource = GetFolderResource(gSynchronizeTree, row.value); + if (treeCellInfo.childElt == "twisty") { + var folderResource = GetFolderResource(gSynchronizeTree, treeCellInfo.row); var folder = folderResource.QueryInterface(Ci.nsIMsgFolder); - if (!(gSynchronizeTree.treeBoxObject.view.isContainerOpen(row.value))) { + if (!(gSynchronizeTree.view.isContainerOpen(treeCellInfo.row))) { var serverType = folder.server.type; // imap is the only server type that does folder discovery if (serverType != "imap") return; @@ -158,8 +154,8 @@ function onSynchronizeClick(event) } } else { - if (col.value.id == "syncCol") { - UpdateNode(GetFolderResource(gSynchronizeTree, row.value), row.value); + if (treeCellInfo.col.id == "syncCol") { + UpdateNode(GetFolderResource(gSynchronizeTree, treeCellInfo.row), treeCellInfo.row); } } } diff --git a/mailnews/base/content/subscribe.js b/mailnews/base/content/subscribe.js index 6a84214360..6e0ecb1d21 100644 --- a/mailnews/base/content/subscribe.js +++ b/mailnews/base/content/subscribe.js @@ -7,7 +7,6 @@ ChromeUtils.import("resource:///modules/iteratorUtils.jsm"); var gSubscribeTree = null; var gSubscribeBody = null; -var gSearchTree; var okCallback = null; var gChangeTable = {}; var gServerURI = null; @@ -17,7 +16,7 @@ var gNameFieldLabel = null; var gStatusFeedback; var gSubscribeDeck = null; var gSearchView = null; -var gSearchTreeBoxObject = null; +var gSearchTree = null; var gSubscribeBundle; function Stop() @@ -148,7 +147,7 @@ function SubscribeOnLoad() gSubscribeTree = document.getElementById("subscribeTree"); gSubscribeBody = document.getElementById("subscribeTreeBody"); gSearchTree = document.getElementById("searchTree"); - gSearchTreeBoxObject = document.getElementById("searchTree").treeBoxObject; + gSearchTree = document.getElementById("searchTree"); gNameField = document.getElementById("namefield"); gNameFieldLabel = document.getElementById("namefieldlabel"); @@ -270,25 +269,24 @@ function SearchOnClick(event) // we only care about button 0 (left click) events if (event.button != 0 || event.originalTarget.localName != "treechildren") return; - var row = {}, col = {}, childElt = {}; - gSearchTreeBoxObject.getCellAt(event.clientX, event.clientY, row, col, childElt); - if (row.value == -1 || row.value > gSearchView.rowCount-1) + let treeCellInfo = gSearchTree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.row == -1 || treeCellInfo.row > gSearchView.rowCount-1) return; - if (col.value.id == "subscribedColumn2") { + if (treeCellInfo.col.id == "subscribedColumn2") { if (event.detail != 2) { // single clicked on the check box // (in the "subscribedColumn2" column) reverse state // if double click, do nothing - ReverseStateFromRow(row.value); + ReverseStateFromRow(treeCellInfo.row); } } else if (event.detail == 2) { // double clicked on a row, reverse state - ReverseStateFromRow(row.value); + ReverseStateFromRow(treeCellInfo.row); } // invalidate the row - InvalidateSearchTreeRow(row.value); + InvalidateSearchTreeRow(treeCellInfo.row); } function ReverseStateFromRow(aRow) @@ -356,16 +354,15 @@ function SubscribeOnClick(event) if (event.button != 0 || event.originalTarget.localName != "treechildren") return; - var row = {}, col = {}, obj = {}; - gSubscribeTree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj); - if (row.value == -1 || row.value > (gSubscribeTree.view.rowCount - 1)) + let treeCellInfo = gSubscribeTree.getCellAt(event.clientX, event.clientY); + if (treeCellInfo.row == -1 || treeCellInfo.row > (gSubscribeTree.view.rowCount - 1)) return; if (event.detail == 2) { // only toggle subscribed state when double clicking something // that isn't a container - if (!gSubscribeTree.view.isContainer(row.value)) { - ReverseStateFromNode(row.value); + if (!gSubscribeTree.view.isContainer(treeCellInfo.row)) { + ReverseStateFromNode(treeCellInfo.row); return; } } @@ -373,7 +370,7 @@ function SubscribeOnClick(event) { // if the user single clicks on the subscribe check box, we handle it here if (col.value.id == "subscribedColumn") - ReverseStateFromNode(row.value); + ReverseStateFromNode(treeCellInfo.row); } } @@ -412,12 +409,12 @@ function ShowNewGroupsList() function InvalidateSearchTreeRow(row) { - gSearchTreeBoxObject.invalidateRow(row); + gSearchTree.invalidateRow(row); } function InvalidateSearchTree() { - gSearchTreeBoxObject.invalidate(); + gSearchTree.invalidate(); } function SwitchToNormalView() @@ -442,7 +439,7 @@ function Search() if (!gSearchView && gSubscribableServer) { gSearchView = gSubscribableServer.QueryInterface(Ci.nsITreeView); gSearchView.selection = null; - gSearchTreeBoxObject.view = gSearchView; + gSearchTree.view = gSearchView; } } else { diff --git a/mailnews/base/content/virtualFolderListEdit.js b/mailnews/base/content/virtualFolderListEdit.js index 2f582ee933..58f55ee8df 100644 --- a/mailnews/base/content/virtualFolderListEdit.js +++ b/mailnews/base/content/virtualFolderListEdit.js @@ -73,14 +73,11 @@ var gSelectVirtual = { if (aEvent.button != 0) return; - let row = {}; - let col = {}; - this._treeElement.treeBoxObject - .getCellAt(aEvent.clientX, aEvent.clientY, row, col, {}); - if (row.value == -1 || col.value.id != "selectedCol") + let treeCellInfo = this._treeElement.getCellAt(aEvent.clientX, aEvent.clientY); + if (treeCellInfo.row == -1 || treeCellInfo.col.id != "selectedCol") return; - this._toggle(row.value); + this._toggle(treeCellInfo.row); }, _toggle: function(aRow) { diff --git a/mailnews/base/prefs/content/AccountManager.js b/mailnews/base/prefs/content/AccountManager.js index 668380599f..a5f165424f 100644 --- a/mailnews/base/prefs/content/AccountManager.js +++ b/mailnews/base/prefs/content/AccountManager.js @@ -197,13 +197,13 @@ function selectServer(server, selectPageId) let accountTree = document.getElementById("accounttree"); let index = accountTree.view.getIndexOfItem(pageToSelect); accountTree.view.selection.select(index); - accountTree.treeBoxObject.ensureRowIsVisible(index); + accountTree.ensureRowIsVisible(index); let lastItem = accountNode.lastChild.lastChild; if (lastItem.localName == "treeitem") index = accountTree.view.getIndexOfItem(lastItem); - accountTree.treeBoxObject.ensureRowIsVisible(index); + accountTree.ensureRowIsVisible(index); } function replaceWithDefaultSmtpServer(deletedSmtpServerKey) diff --git a/mailnews/base/util/jsTreeSelection.js b/mailnews/base/util/jsTreeSelection.js index 999ef81a51..3186d4337e 100644 --- a/mailnews/base/util/jsTreeSelection.js +++ b/mailnews/base/util/jsTreeSelection.js @@ -37,8 +37,8 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); * * Unit test is in mailnews/base/util/test_jsTreeSelection.js */ -function JSTreeSelection(aTreeBoxObject) { - this._treeBoxObject = aTreeBoxObject; +function JSTreeSelection(aTree) { + this._tree = aTree; this._currentIndex = null; this._shiftSelectPivot = null; @@ -49,9 +49,9 @@ function JSTreeSelection(aTreeBoxObject) { } JSTreeSelection.prototype = { /** - * The current nsITreeBoxObject, appropriately QueryInterfaced. May be null. + * The current XULTreeElement, appropriately QueryInterfaced. May be null. */ - _treeBoxObject: null, + _tree: null, /** * Where the focus rectangle (that little dotted thing) shows up. Just @@ -83,10 +83,10 @@ JSTreeSelection.prototype = { _view: null, get tree() { - return this._treeBoxObject; + return this._tree; }, - set tree(aTreeBoxObject) { - this._treeBoxObject = aTreeBoxObject; + set tree(aTree) { + this._tree = aTree; }, set view(aView) { @@ -138,8 +138,8 @@ JSTreeSelection.prototype = { this._count = 1; this._ranges = [[aViewIndex, aViewIndex]]; - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); }, @@ -206,8 +206,8 @@ JSTreeSelection.prototype = { // otherwise we need to keep going } - if (this._treeBoxObject) - this._treeBoxObject.invalidateRow(aIndex); + if (this._tree) + this._tree.invalidateRow(aIndex); this._fireSelectionChanged(); }, @@ -242,8 +242,8 @@ JSTreeSelection.prototype = { if (!aAugment) { this._count = aRangeEnd - aRangeStart + 1; this._ranges = [[aRangeStart, aRangeEnd]]; - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); return; } @@ -292,8 +292,8 @@ JSTreeSelection.prototype = { this._ranges.splice(insertionPoint, 0, [aRangeStart, aRangeEnd]); this._updateCount(); - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); }, @@ -348,8 +348,8 @@ JSTreeSelection.prototype = { this._ranges.splice.apply(this._ranges, args); this._updateCount(); - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); // note! nsTreeSelection doesn't fire a selection changed event, so neither // do we, but it seems like we should }, @@ -362,8 +362,8 @@ JSTreeSelection.prototype = { this._shiftSelectPivot = null; this._count = 0; this._ranges = []; - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); }, @@ -391,8 +391,8 @@ JSTreeSelection.prototype = { this._count = rowCount; this._ranges = [[0, rowCount - 1]]; - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); }, @@ -407,8 +407,8 @@ JSTreeSelection.prototype = { }, invalidateSelection: function JSTreeSelection_invalidateSelection() { - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); }, /** @@ -523,8 +523,8 @@ JSTreeSelection.prototype = { this._ranges[iTrans] = [low + aCount, high + aCount]; } // invalidate and fire selection change notice - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this._fireSelectionChanged(); return; } @@ -553,8 +553,8 @@ JSTreeSelection.prototype = { this._ranges.splice(iTrans, 1); } - if (this._treeBoxObject) - this._treeBoxObject.invalidate(); + if (this._tree) + this._tree.invalidate(); this.selectEventsSuppressed = saveSuppress; }, @@ -582,8 +582,8 @@ JSTreeSelection.prototype = { if (this.selectEventsSuppressed) return; let view; - if (this._treeBoxObject && this._treeBoxObject.view) - view = this._treeBoxObject.view; + if (this._tree && this._tree.view) + view = this._tree.view; else view = this._view; @@ -609,8 +609,8 @@ JSTreeSelection.prototype = { return; this._currentIndex = (aIndex != -1) ? aIndex : null; - if (this._treeBoxObject) - this._treeBoxObject.invalidateRow(aIndex); + if (this._tree) + this._tree.invalidateRow(aIndex); }, currentColumn: null, diff --git a/mailnews/extensions/newsblog/content/FeedUtils.jsm b/mailnews/extensions/newsblog/content/FeedUtils.jsm index eca419a84e..c5c63b051d 100644 --- a/mailnews/extensions/newsblog/content/FeedUtils.jsm +++ b/mailnews/extensions/newsblog/content/FeedUtils.jsm @@ -868,7 +868,7 @@ var FeedUtils = { win = Services.wm.getMostRecentWindow("Mail:News-BlogSubscriptions"); if (win) { - win.FeedSubscriptions.mView.treeBox.invalidate(); + win.FeedSubscriptions.mView.tree.invalidate(); } }, diff --git a/mailnews/extensions/newsblog/content/feed-subscriptions.js b/mailnews/extensions/newsblog/content/feed-subscriptions.js index f70ec5a2e4..bf042c9675 100644 --- a/mailnews/extensions/newsblog/content/feed-subscriptions.js +++ b/mailnews/extensions/newsblog/content/feed-subscriptions.js @@ -109,7 +109,7 @@ var FeedSubscriptions = { } } - this.mView.treeBox.ensureRowIsVisible(this.mView.selection.currentIndex); + this.mView.tree.ensureRowIsVisible(this.mView.selection.currentIndex); this.clearStatusInfo(); }, @@ -130,7 +130,7 @@ var FeedSubscriptions = { /* nsITreeView */ /* eslint-disable no-multi-spaces */ - treeBox: null, + tree: null, mRowCount: 0, get rowCount() { return this.mRowCount; }, @@ -139,7 +139,7 @@ var FeedSubscriptions = { get selection() { return this._selection; }, set selection(val) { return this._selection = val; }, - setTree(aTreebox) { this.treeBox = aTreebox; }, + setTree(aTree) { this.tree = aTree; }, isSeparator(aRow) { return false; }, isSorted() { return false; }, isEditable(aRow, aColumn) { return false; }, @@ -274,7 +274,7 @@ var FeedSubscriptions = { // Now invalidate the correct tree rows. this.mRowCount--; - this.treeBox.rowCountChanged(aRow, -1); + this.tree.rowCountChanged(aRow, -1); // Now update the selection position, unless noSelect (selection is // done later or not at all). If the item is the last child, select the @@ -575,7 +575,7 @@ var FeedSubscriptions = { // Suppress the select event caused by rowCountChanged. this.selection.selectEventsSuppressed = true; // Add or remove the children from our view. - this.treeBox.rowCountChanged(aRow, delta); + this.tree.rowCountChanged(aRow, delta); return delta; }, }, @@ -724,8 +724,8 @@ var FeedSubscriptions = { let found = false; let firstVisRow, curFirstVisRow, curLastVisRow; - if (this.mView.treeBox) { - firstVisRow = this.mView.treeBox.getFirstVisibleRow(); + if (this.mView.tree) { + firstVisRow = this.mView.tree.getFirstVisibleRow(); } if (parentIndex != null) { @@ -859,13 +859,13 @@ var FeedSubscriptions = { } // Ensure tree position does not jump unnecessarily. - curFirstVisRow = this.mView.treeBox.getFirstVisibleRow(); - curLastVisRow = this.mView.treeBox.getLastVisibleRow(); + curFirstVisRow = this.mView.tree.getFirstVisibleRow(); + curLastVisRow = this.mView.tree.getLastVisibleRow(); if (firstVisRow >= 0 && this.mView.rowCount - curLastVisRow > firstVisRow - curFirstVisRow) { - this.mView.treeBox.scrollToRow(firstVisRow); + this.mView.tree.scrollToRow(firstVisRow); } else { - this.mView.treeBox.ensureRowIsVisible(this.mView.rowCount - 1); + this.mView.tree.ensureRowIsVisible(this.mView.rowCount - 1); } FeedUtils.log.debug("selectFolder: curIndex:firstVisRow:" + @@ -905,7 +905,7 @@ var FeedSubscriptions = { for (let i = seln.currentIndex + 1; i < this.mView.rowCount; i++) { if (this.mView.getItemAtIndex(i).url == aFeed.url) { this.mView.selection.select(i); - this.mView.treeBox.ensureRowIsVisible(i); + this.mView.tree.ensureRowIsVisible(i); found = true; break; } @@ -1988,7 +1988,7 @@ var FeedSubscriptions = { let feedWindow = this.feedWindow; let curSelItem = this.currentSelectedItem; - let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow(); + let firstVisRow = feedWindow.mView.tree.getFirstVisibleRow(); let indexInView = feedWindow.mView.getItemInViewIndex(parentFolder); let open = indexInView != null; @@ -2001,7 +2001,7 @@ var FeedSubscriptions = { feedWindow.mFeedContainers.push(feedWindow.makeFolderObject(parentFolder, 0)); feedWindow.mView.mRowCount++; feedWindow.mTree.view = feedWindow.mView; - feedWindow.mView.treeBox.scrollToRow(firstVisRow); + feedWindow.mView.tree.scrollToRow(firstVisRow); return; } } @@ -2028,7 +2028,7 @@ var FeedSubscriptions = { feedWindow.mView.toggleOpenState(parentIndex); } - feedWindow.mView.treeBox.scrollToRow(firstVisRow); + feedWindow.mView.tree.scrollToRow(firstVisRow); if (curSelItem.container) { feedWindow.selectFolder(curSelItem.folder, { open: curSelItem.open }); @@ -2083,7 +2083,7 @@ var FeedSubscriptions = { let feedWindow = this.feedWindow; let curSelIndex = this.currentSelectedIndex; let curSelItem = this.currentSelectedItem; - let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow(); + let firstVisRow = feedWindow.mView.tree.getFirstVisibleRow(); let indexInView = feedWindow.mView.getItemInViewIndex(aOrigFolder); let open = indexInView != null; @@ -2109,7 +2109,7 @@ var FeedSubscriptions = { feedWindow.mView.toggle(parentIndex); feedWindow.mView.toggleOpenState(parentIndex); - feedWindow.mView.treeBox.scrollToRow(firstVisRow); + feedWindow.mView.tree.scrollToRow(firstVisRow); if (curSelItem.container) { if (curSelItem.folder == aOrigFolder) { @@ -2139,7 +2139,7 @@ var FeedSubscriptions = { let feedWindow = this.feedWindow; let curSelIndex = this.currentSelectedIndex; let curSelItem = this.currentSelectedItem; - let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow(); + let firstVisRow = feedWindow.mView.tree.getFirstVisibleRow(); let indexInView = feedWindow.mView.getItemInViewIndex(aSrcFolder); let destIndexInView = feedWindow.mView.getItemInViewIndex(aDestFolder); let open = indexInView != null || destIndexInView != null; @@ -2169,7 +2169,7 @@ var FeedSubscriptions = { feedWindow.mView.toggle(parentIndex); feedWindow.mView.toggleOpenState(parentIndex); - feedWindow.mView.treeBox.scrollToRow(firstVisRow); + feedWindow.mView.tree.scrollToRow(firstVisRow); if (curSelItem.container) { if (curSelItem.folder == aSrcFolder || select) { diff --git a/mailnews/extensions/newsblog/content/newsblogOverlay.js b/mailnews/extensions/newsblog/content/newsblogOverlay.js index 2717ea6e6c..f32866db02 100755 --- a/mailnews/extensions/newsblog/content/newsblogOverlay.js +++ b/mailnews/extensions/newsblog/content/newsblogOverlay.js @@ -277,7 +277,7 @@ function openSubscriptionsDialog(aFolder) { if (subscriptionsWindow) { if (aFolder) { subscriptionsWindow.FeedSubscriptions.selectFolder(aFolder); - subscriptionsWindow.FeedSubscriptions.mView.treeBox.ensureRowIsVisible( + subscriptionsWindow.FeedSubscriptions.mView.tree.ensureRowIsVisible( subscriptionsWindow.FeedSubscriptions.mView.selection.currentIndex); }