mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877149 - use skipArrange param to the richgrid mutators where possibe to reduce the number of arrangeItems calls. r=mbrubeck
This commit is contained in:
parent
3bee7f9189
commit
6059c95212
@ -54,7 +54,7 @@
|
||||
box.showContextMenu(this, event, true);
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
|
||||
<handler event="keypress" phase="capturing" keycode="VK_RETURN">
|
||||
<![CDATA[
|
||||
event.preventDefault();
|
||||
@ -268,7 +268,7 @@
|
||||
for (let i = 0; i < iterCount; i++) {
|
||||
if (i > lastMatch) {
|
||||
let lastItem = this._results.itemCount - 1;
|
||||
this._results.removeItemAt(lastItem);
|
||||
this._results.removeItemAt(lastItem, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@
|
||||
|
||||
let item = this._results.getItemAtIndex(i);
|
||||
if (item == null) {
|
||||
item = this._results.appendItem(label, value);
|
||||
item = this._results.appendItem(label, value, true);
|
||||
item.setAttribute("autocomplete", "true");
|
||||
} else {
|
||||
item.setAttribute("label", label);
|
||||
@ -308,10 +308,10 @@
|
||||
this._engines = Services.search.getVisibleEngines();
|
||||
|
||||
while (this._searches.itemCount > 0)
|
||||
this._searches.removeItemAt(0);
|
||||
this._searches.removeItemAt(0, true);
|
||||
|
||||
this._engines.forEach(function (anEngine) {
|
||||
let item = this._searches.appendItem(anEngine.name, anEngine.name);
|
||||
let item = this._searches.appendItem(anEngine.name, anEngine.name, true);
|
||||
item.setAttribute("autocomplete", "true");
|
||||
item.setAttribute("search", "true");
|
||||
|
||||
@ -336,9 +336,8 @@
|
||||
for (let i = 0, len = this._searches.itemCount; i < len; i++) {
|
||||
let item = this._searches.getItemAtIndex(i);
|
||||
item.setAttribute("label", label);
|
||||
item.refresh && item.refresh();
|
||||
}
|
||||
|
||||
this._searches.arrangeItems();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -30,7 +30,7 @@ var Bookmarks = {
|
||||
aURI,
|
||||
bookmarkService.DEFAULT_INDEX,
|
||||
bookmarkTitle);
|
||||
|
||||
|
||||
// XXX Used for browser-chrome tests
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("BookmarkCreated", true, false);
|
||||
@ -69,7 +69,7 @@ var Bookmarks = {
|
||||
/**
|
||||
* Wraps a list/grid control implementing nsIDOMXULSelectControlElement and
|
||||
* fills it with the user's bookmarks.
|
||||
*
|
||||
*
|
||||
* @param aSet Control implementing nsIDOMXULSelectControlElement.
|
||||
* @param {Number} aLimit Maximum number of items to show in the view.
|
||||
* @param aRoot Bookmark root to show in the view.
|
||||
@ -77,6 +77,7 @@ var Bookmarks = {
|
||||
function BookmarksView(aSet, aLimit, aRoot, aFilterUnpinned) {
|
||||
this._set = aSet;
|
||||
this._set.controller = this;
|
||||
this._inBatch = false; // batch up grid updates to avoid redundant arrangeItems calls
|
||||
|
||||
this._limit = aLimit;
|
||||
this._filterUnpinned = aFilterUnpinned;
|
||||
@ -152,6 +153,8 @@ BookmarksView.prototype = {
|
||||
rootNode.containerOpen = true;
|
||||
let childCount = rootNode.childCount;
|
||||
|
||||
this._inBatch = true; // batch up grid updates to avoid redundant arrangeItems calls
|
||||
|
||||
for (let i = 0, addedCount = 0; i < childCount && addedCount < limit; i++) {
|
||||
let node = rootNode.getChild(i);
|
||||
|
||||
@ -188,9 +191,10 @@ BookmarksView.prototype = {
|
||||
// This can happen when undoing a delete.
|
||||
if (aRefresh) {
|
||||
while (this._set.itemCount > limit)
|
||||
this._set.removeItemAt(this._set.itemCount - 1);
|
||||
this._set.removeItemAt(this._set.itemCount - 1, true);
|
||||
}
|
||||
|
||||
this._set.arrangeItems();
|
||||
this._inBatch = false;
|
||||
rootNode.containerOpen = false;
|
||||
},
|
||||
|
||||
@ -203,14 +207,15 @@ BookmarksView.prototype = {
|
||||
|
||||
clearBookmarks: function bv_clearBookmarks() {
|
||||
while (this._set.itemCount > 0)
|
||||
this._set.removeItemAt(0);
|
||||
this._set.removeItemAt(0, true);
|
||||
this._set.arrangeItems();
|
||||
},
|
||||
|
||||
addBookmark: function bv_addBookmark(aBookmarkId, aPos) {
|
||||
let index = this._bookmarkService.getItemIndex(aBookmarkId);
|
||||
let uri = this._bookmarkService.getBookmarkURI(aBookmarkId);
|
||||
let title = this._bookmarkService.getItemTitle(aBookmarkId) || uri.spec;
|
||||
let item = this._set.insertItemAt(aPos || index, title, uri.spec);
|
||||
let item = this._set.insertItemAt(aPos || index, title, uri.spec, this._inBatch);
|
||||
item.setAttribute("bookmarkId", aBookmarkId);
|
||||
this._setContextActions(item);
|
||||
this._updateFavicon(aBookmarkId, item, uri);
|
||||
@ -252,7 +257,7 @@ BookmarksView.prototype = {
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
|
||||
let oldIndex = this._set.getIndexOfItem(item);
|
||||
let index = this._bookmarkService.getItemIndex(aBookmarkId);
|
||||
|
||||
@ -274,7 +279,7 @@ BookmarksView.prototype = {
|
||||
removeBookmark: function bv_removeBookmark(aBookmarkId) {
|
||||
let item = this._getItemForBookmarkId(aBookmarkId);
|
||||
let index = this._set.getIndexOfItem(item);
|
||||
this._set.removeItemAt(index);
|
||||
this._set.removeItemAt(index, this._inBatch);
|
||||
},
|
||||
|
||||
destruct: function bv_destruct() {
|
||||
@ -426,7 +431,7 @@ BookmarkChangeListener.prototype = {
|
||||
let itemIndex = PlacesUtils.bookmarks.getItemIndex(aItemId);
|
||||
if (!this._view.inCurrentView(aParentId, aItemId))
|
||||
return;
|
||||
|
||||
|
||||
this._view.updateBookmark(aItemId);
|
||||
},
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
function HistoryView(aSet, aLimit, aFilterUnpinned) {
|
||||
this._set = aSet;
|
||||
this._set.controller = this;
|
||||
this._inBatch = false;
|
||||
this._inBatch = 0;
|
||||
|
||||
this._limit = aLimit;
|
||||
this._filterUnpinned = aFilterUnpinned;
|
||||
@ -30,6 +30,7 @@ HistoryView.prototype = {
|
||||
},
|
||||
|
||||
populateGrid: function populateGrid(aRefresh) {
|
||||
this._inBatch++; // always batch up grid updates to avoid redundant arrangeItems calls
|
||||
let query = this._navHistoryService.getNewQuery();
|
||||
let options = this._navHistoryService.getNewQueryOptions();
|
||||
options.excludeQueries = true;
|
||||
@ -83,6 +84,9 @@ HistoryView.prototype = {
|
||||
}
|
||||
|
||||
rootNode.containerOpen = false;
|
||||
this._set.arrangeItems();
|
||||
if (this._inBatch > 0)
|
||||
this._inBatch--;
|
||||
},
|
||||
|
||||
destruct: function destruct() {
|
||||
@ -113,7 +117,9 @@ HistoryView.prototype = {
|
||||
removeHistory: function (aUri) {
|
||||
let items = this._set.getItemsByUrl(aUri);
|
||||
for (let item of items)
|
||||
this._set.removeItem(item, this._inBatch);
|
||||
this._set.removeItem(item, true);
|
||||
if (!this._inBatch)
|
||||
this._set.arrangeItems();
|
||||
},
|
||||
|
||||
doActionOnSelectedTiles: function bv_doActionOnSelectedTiles(aActionName, aEvent) {
|
||||
@ -207,12 +213,15 @@ HistoryView.prototype = {
|
||||
|
||||
onBeginUpdateBatch: function() {
|
||||
// Avoid heavy grid redraws while a batch is in process
|
||||
this._inBatch = true;
|
||||
this._inBatch++;
|
||||
},
|
||||
|
||||
onEndUpdateBatch: function() {
|
||||
this._inBatch = false;
|
||||
this.populateGrid(true);
|
||||
if (this._inBatch > 0) {
|
||||
this._inBatch--;
|
||||
this._set.arrangeItems();
|
||||
}
|
||||
},
|
||||
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID,
|
||||
|
Loading…
Reference in New Issue
Block a user