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

Unified Diff: chrome/browser/resources/task_manager/main.js

Issue 9570028: Fix for "removing tasks can change row selection" bug. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/task_manager/main.js
diff --git a/chrome/browser/resources/task_manager/main.js b/chrome/browser/resources/task_manager/main.js
index 9bc0d285d2e3478f64481fbb377b71870657e812..4d07cdd96cd2254c3b38b75436a504e5fb7b90af 100644
--- a/chrome/browser/resources/task_manager/main.js
+++ b/chrome/browser/resources/task_manager/main.js
@@ -542,18 +542,30 @@ TaskManager.prototype = {
var length = task.length;
var tasks = task.tasks;
- // We have to store the selected indexes and restore them after
+ // We have to store the selected pids and restore them after
// splice(), because it might replace some items but the replaced
// items would lose the selection.
var oldSelectedIndexes = sm.selectedIndexes;
+ // Create map of selected PIDs.
+ var oldSelectedPids = {};
flackr 2012/03/01 21:45:06 You can probably just call this selectedPids since
Kevin Greer 2012/03/01 22:13:44 Done.
+ for (var i = 0; i < oldSelectedIndexes.length; i++) {
+ var item = dm.item(oldSelectedIndexes[i]);
+ if (item) oldSelectedPids[item['processId'][0]] = true;
+ }
+
var args = tasks.slice();
args.unshift(start, dm.length);
dm.splice.apply(dm, args);
- sm.selectedIndexes = oldSelectedIndexes.filter(function(index) {
- return index < dm.length;
- });
+ // Create new array of selected indices from map of old PIDs.
flackr 2012/03/01 21:45:06 nit: s/indices/indexes since that's the property n
Kevin Greer 2012/03/01 22:13:44 Done.
+ var newSelectedIndexes = [];
+ for (var i = 0; i < dm.length; i++) {
+ if (oldSelectedPids[dm.item(i)['processId'][0]])
+ newSelectedIndexes.push(i);
+ }
+
+ sm.selectedIndexes = newSelectedIndexes;
var pids = [];
for (var i = 0; i < dm.length; i++) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698