summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 03:16:21 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-12 03:16:21 +0000
commit493675cb47dc7d7f297e2ec5e5b80510af087ce7 (patch)
tree550828d5dfe666fc9952996f3b72c3b325e9bdac
parent73aba521e02972d94782502092fd226906dc2b97 (diff)
downloadchromium_src-493675cb47dc7d7f297e2ec5e5b80510af087ce7.zip
chromium_src-493675cb47dc7d7f297e2ec5e5b80510af087ce7.tar.gz
chromium_src-493675cb47dc7d7f297e2ec5e5b80510af087ce7.tar.bz2
Drastically reduce the number of redraws when editing content settings.
Using the debugger, I can verify that previously we were redrawing the entire list once per row (e.g. 10 times if you delete a row in a list that has 10 rows). Now it only redraws once for the delete. BUG=69086 TEST=see above Review URL: http://codereview.chromium.org/6099016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71140 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options/content_settings.js13
-rw-r--r--chrome/browser/resources/options/content_settings_exceptions_area.js21
2 files changed, 15 insertions, 19 deletions
diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js
index a9a80bb..2b40cbf 100644
--- a/chrome/browser/resources/options/content_settings.js
+++ b/chrome/browser/resources/options/content_settings.js
@@ -98,11 +98,7 @@ cr.define('options', function() {
document.querySelector('div[contentType=' + type + ']' +
' list[mode=normal]');
- exceptionsList.reset();
- for (var i = 0; i < list.length; i++) {
- exceptionsList.addException(list[i]);
- }
- exceptionsList.redraw();
+ exceptionsList.setExceptions(list);
};
ContentSettings.setOTRExceptions = function(type, list) {
@@ -111,12 +107,7 @@ cr.define('options', function() {
' list[mode=otr]');
exceptionsList.parentNode.classList.remove('hidden');
-
- exceptionsList.reset();
- for (var i = 0; i < list.length; i++) {
- exceptionsList.addException(list[i]);
- }
- exceptionsList.redraw();
+ exceptionsList.setExceptions(list);
};
/**
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js
index 5a0e788..b75709c 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.js
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.js
@@ -424,7 +424,7 @@ cr.define('options.contentSettings', function() {
window.setTimeout(function() {
var activeElement = doc.activeElement;
if (!exceptionList.contains(activeElement))
- exceptionList.selectionModel.clear();
+ exceptionList.selectionModel.unselectAll();
}, 50);
}
@@ -458,16 +458,21 @@ cr.define('options.contentSettings', function() {
},
/**
- * Adds an exception to the js model.
- * @param {Object} entry A dictionary of values for the exception.
+ * Sets the exceptions in the js model.
+ * @param {Object} entries A list of dictionaries of values, each dictionary
+ * represents an exception.
*/
- addException: function(entry) {
+ setExceptions: function(entries) {
+ var deleteCount = this.dataModel.length;
+
if (this.isEditable()) {
- // We have to add it before the Add New Exception row.
- this.dataModel.splice(this.dataModel.length - 1, 0, entry);
- } else {
- this.dataModel.push(entry);
+ // We don't want to remove the Add New Exception row.
+ deleteCount = deleteCount - 1;
}
+
+ var args = [0, deleteCount];
+ args.push.apply(args, entries);
+ this.dataModel.splice.apply(this.dataModel, args);
},
/**