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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @constructor */ 5 /** @constructor */
6 function TaskManager() { } 6 function TaskManager() { }
7 7
8 cr.addSingletonGetter(TaskManager); 8 cr.addSingletonGetter(TaskManager);
9 9
10 var localStrings = new LocalStrings(); 10 var localStrings = new LocalStrings();
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 if (!dm || !sm) return; 535 if (!dm || !sm) return;
536 536
537 this.table_.list.startBatchUpdates(); 537 this.table_.list.startBatchUpdates();
538 sm.beginChange(); 538 sm.beginChange();
539 539
540 var type = task.type; 540 var type = task.type;
541 var start = task.start; 541 var start = task.start;
542 var length = task.length; 542 var length = task.length;
543 var tasks = task.tasks; 543 var tasks = task.tasks;
544 544
545 // We have to store the selected indexes and restore them after 545 // We have to store the selected pids and restore them after
546 // splice(), because it might replace some items but the replaced 546 // splice(), because it might replace some items but the replaced
547 // items would lose the selection. 547 // items would lose the selection.
548 var oldSelectedIndexes = sm.selectedIndexes; 548 var oldSelectedIndexes = sm.selectedIndexes;
549 549
550 // Create map of selected PIDs.
551 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.
552 for (var i = 0; i < oldSelectedIndexes.length; i++) {
553 var item = dm.item(oldSelectedIndexes[i]);
554 if (item) oldSelectedPids[item['processId'][0]] = true;
555 }
556
550 var args = tasks.slice(); 557 var args = tasks.slice();
551 args.unshift(start, dm.length); 558 args.unshift(start, dm.length);
552 dm.splice.apply(dm, args); 559 dm.splice.apply(dm, args);
553 560
554 sm.selectedIndexes = oldSelectedIndexes.filter(function(index) { 561 // 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.
555 return index < dm.length; 562 var newSelectedIndexes = [];
556 }); 563 for (var i = 0; i < dm.length; i++) {
564 if (oldSelectedPids[dm.item(i)['processId'][0]])
565 newSelectedIndexes.push(i);
566 }
567
568 sm.selectedIndexes = newSelectedIndexes;
557 569
558 var pids = []; 570 var pids = [];
559 for (var i = 0; i < dm.length; i++) { 571 for (var i = 0; i < dm.length; i++) {
560 pids.push(dm.item(i)['processId'][0]); 572 pids.push(dm.item(i)['processId'][0]);
561 } 573 }
562 574
563 // Sweeps unused caches, which elements no longer exist on the list. 575 // Sweeps unused caches, which elements no longer exist on the list.
564 for (var pid in this.elementsCache_) { 576 for (var pid in this.elementsCache_) {
565 if (pids.indexOf(pid) == -1) 577 if (pids.indexOf(pid) == -1)
566 delete this.elementsCache_[pid]; 578 delete this.elementsCache_[pid];
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 var params = parseQueryParams(window.location); 697 var params = parseQueryParams(window.location);
686 var opt = {}; 698 var opt = {};
687 opt['isShowTitle'] = params.showtitle; 699 opt['isShowTitle'] = params.showtitle;
688 opt['isBackgroundMode'] = params.background; 700 opt['isBackgroundMode'] = params.background;
689 opt['isShowCloseButton'] = params.showclose; 701 opt['isShowCloseButton'] = params.showclose;
690 taskmanager.initialize(document.body, opt); 702 taskmanager.initialize(document.body, opt);
691 } 703 }
692 704
693 document.addEventListener('DOMContentLoaded', init); 705 document.addEventListener('DOMContentLoaded', init);
694 document.addEventListener('Close', taskmanager.onClose.bind(taskmanager)); 706 document.addEventListener('Close', taskmanager.onClose.bind(taskmanager));
OLDNEW
« 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