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

Side by Side Diff: tools/turbolizer/selection.js

Issue 2230083004: [turbolizer] Use locations rather than ranges everywhere (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove stray change Created 4 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 unified diff | Download patch
« no previous file with comments | « tools/turbolizer/schedule-view.js ('k') | tools/turbolizer/selection-broker.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project 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 var Selection = function(handler) { 5 var Selection = function(handler) {
6 this.handler = handler; 6 this.handler = handler;
7 this.selectionBase = null; 7 this.selectionBase = null;
8 this.lastSelection = null; 8 this.lastSelection = null;
9 this.selection = new Set(); 9 this.selection = new Set();
10 } 10 }
(...skipping 22 matching lines...) Expand all
33 if (isSelected) { 33 if (isSelected) {
34 let first = true; 34 let first = true;
35 for (let i of s) { 35 for (let i of s) {
36 if (first) { 36 if (first) {
37 this.selectionBase = i; 37 this.selectionBase = i;
38 this.lastSelection = i; 38 this.lastSelection = i;
39 first = false; 39 first = false;
40 } 40 }
41 this.selection.add(i); 41 this.selection.add(i);
42 } 42 }
43 handler.select(this.selection, true);
43 } else { 44 } else {
44 let unselectSet = new Set(); 45 let unselectSet = new Set();
45 for (let i of s) { 46 for (let i of s) {
46 if (this.selection.has(i)) { 47 if (this.selection.has(i)) {
47 unselectSet.add(i); 48 unselectSet.add(i);
48 this.selection.delete(i); 49 this.selection.delete(i);
49 } 50 }
50 } 51 }
52 handler.select(unselectSet, false);
51 } 53 }
52 handler.select(this.selection, isSelected);
53 } 54 }
54 55
55 56
56 Selection.prototype.extendTo = function(pos) { 57 Selection.prototype.extendTo = function(pos) {
57 if (pos == this.lastSelection || this.lastSelection === null) return; 58 if (pos == this.lastSelection || this.lastSelection === null) return;
58 59
59 var handler = this.handler; 60 var handler = this.handler;
60 var pos_diff = handler.selectionDifference(pos, true, this.lastSelection, fals e); 61 var pos_diff = handler.selectionDifference(pos, true, this.lastSelection, fals e);
61 var unselect_diff = []; 62 var unselect_diff = [];
62 if (pos_diff.length == 0) { 63 if (pos_diff.length == 0) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 100
100 Selection.prototype.detachSelection = function() { 101 Selection.prototype.detachSelection = function() {
101 var result = new Set(); 102 var result = new Set();
102 for (var i of this.selection) { 103 for (var i of this.selection) {
103 result.add(i); 104 result.add(i);
104 } 105 }
105 this.clear(); 106 this.clear();
106 return result; 107 return result;
107 } 108 }
OLDNEW
« no previous file with comments | « tools/turbolizer/schedule-view.js ('k') | tools/turbolizer/selection-broker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698