Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1301)

Unified Diff: chrome/browser/resources/shared/js/cr/ui/list.js

Issue 10824328: Reduce number of expensive calls to List.redraw() during load of settings page. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed all comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/options2/content_settings_exceptions_area.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/cr/ui/list.js
diff --git a/chrome/browser/resources/shared/js/cr/ui/list.js b/chrome/browser/resources/shared/js/cr/ui/list.js
index 49facce0aa02551924e7952ba8539072c0c094b2..09e6e4a2c18d2b4022404bfab9aac5b980ebbb4a 100644
--- a/chrome/browser/resources/shared/js/cr/ui/list.js
+++ b/chrome/browser/resources/shared/js/cr/ui/list.js
@@ -948,33 +948,34 @@ cr.define('cr.ui', function() {
/**
* Merges list items currently existing in the list with items in the range
* [firstIndex, lastIndex). Removes or adds items if needed.
- * Doesn't delete {@code this.pinnedItem_} if it presents (instead hides if
- * it's out of the range). Also adds the items to {@code newCachedItems}.
+ * Doesn't delete {@code this.pinnedItem_} if it is present (instead hides
+ * it if it is out of the range). Adds items to {@code newCachedItems}.
* @param {number} firstIndex The index of first item, inclusively.
* @param {number} lastIndex The index of last item, exclusively.
* @param {Object.<string, ListItem>} cachedItems Old items cache.
* @param {Object.<string, ListItem>} newCachedItems New items cache.
*/
mergeItems: function(firstIndex, lastIndex, cachedItems, newCachedItems) {
+ var self = this;
var dataModel = this.dataModel;
+ var currentIndex = firstIndex;
- function insert(to) {
+ function insert() {
var dataItem = dataModel.item(currentIndex);
- var newItem = cachedItems[currentIndex] || to.createItem(dataItem);
+ var newItem = cachedItems[currentIndex] || self.createItem(dataItem);
newItem.listIndex = currentIndex;
newCachedItems[currentIndex] = newItem;
- to.insertBefore(newItem, item);
+ self.insertBefore(newItem, item);
currentIndex++;
}
- function remove(from) {
+ function remove() {
var next = item.nextSibling;
- if (item != from.pinnedItem_)
- from.removeChild(item);
+ if (item != self.pinnedItem_)
+ self.removeChild(item);
item = next;
}
- var currentIndex = firstIndex;
for (var item = this.beforeFiller_.nextSibling;
item != this.afterFiller_ && currentIndex < lastIndex;) {
if (!this.isItem(item)) {
@@ -984,19 +985,19 @@ cr.define('cr.ui', function() {
var index = item.listIndex;
if (cachedItems[index] != item || index < currentIndex) {
- remove(this);
+ remove();
} else if (index == currentIndex) {
newCachedItems[currentIndex] = item;
item = item.nextSibling;
currentIndex++;
} else { // index > currentIndex
- insert(this);
+ insert();
}
}
while (item != this.afterFiller_) {
if (this.isItem(item))
- remove(this);
+ remove();
else
item = item.nextSibling;
}
@@ -1010,7 +1011,7 @@ cr.define('cr.ui', function() {
}
while (currentIndex < lastIndex)
- insert(this);
+ insert();
},
/**
@@ -1087,7 +1088,7 @@ cr.define('cr.ui', function() {
return;
var dataModel = this.dataModel;
- if (!dataModel) {
+ if (!dataModel || !this.autoExpands_ && this.clientHeight == 0) {
this.cachedItems_ = {};
this.firstIndex_ = 0;
this.lastIndex_ = 0;
« no previous file with comments | « chrome/browser/resources/options2/content_settings_exceptions_area.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698