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

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: Addressed flackr's review. 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..62eb4a4efd8105b2ed7934b057fec487cc275cd8 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 selectedPids = {};
+ for (var i = 0; i < oldSelectedIndexes.length; i++) {
+ var item = dm.item(oldSelectedIndexes[i]);
+ if (item) selectedPids[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 indexes from map of old PIDs.
+ var newSelectedIndexes = [];
+ for (var i = 0; i < dm.length; i++) {
+ if (selectedPids[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