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

Unified Diff: tools/turbolizer/selection.js

Issue 729913004: Add a html-based visualizer for TurboFan graphs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 4 years, 7 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 | « tools/turbolizer/search2.png ('k') | tools/turbolizer/selection-broker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/selection.js
diff --git a/tools/turbolizer/selection.js b/tools/turbolizer/selection.js
new file mode 100644
index 0000000000000000000000000000000000000000..eb7a0b094faa379cad31a1d149d4d9334c4b56f7
--- /dev/null
+++ b/tools/turbolizer/selection.js
@@ -0,0 +1,98 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var Selection = function(handler) {
+ this.handler = handler;
+ this.selectionBase = null;
+ this.lastSelection = null;
+ this.selection = new Set();
+}
+
+
+Selection.prototype.isEmpty = function() {
+ return this.selection.size == 0;
+}
+
+
+Selection.prototype.clear = function() {
+ var handler = this.handler;
+ this.selectionBase = null;
+ this.lastSelection = null;
+ handler.select(this.selection, false);
+ handler.clear();
+ this.selection = new Set();
+}
+
+
+count = 0;
+
+Selection.prototype.select = function(s, selected) {
+ var handler = this.handler;
+ if (this.selection.has(s) && !selected) {
+ handler.select([s], false);
+ this.selection.delete(s);
+ return;
+ }
+
+ if (selected) {
+ this.selection.add(s);
+ this.selectionBase = s;
+ this.lastSelection = s;
+ handler.select(this.selection, selected);
+ }
+}
+
+
+Selection.prototype.extendTo = function(pos) {
+ if (pos == this.lastSelection || this.lastSelection === null) return;
+
+ var handler = this.handler;
+ var pos_diff = handler.selectionDifference(pos, true, this.lastSelection, false);
+ var unselect_diff = [];
+ if (pos_diff.length == 0) {
+ pos_diff = handler.selectionDifference(this.selectionBase, false, pos, true);
+ if (pos_diff.length != 0) {
+ unselect_diff = handler.selectionDifference(this.lastSelection, true, this.selectionBase, false);
+ this.selection = new Set();
+ this.selection.add(this.selectionBase);
+ for (var d of pos_diff) {
+ this.selection.add(d);
+ }
+ } else {
+ unselect_diff = handler.selectionDifference(this.lastSelection, true, pos, false);
+ for (var d of unselect_diff) {
+ this.selection.delete(d);
+ }
+ }
+ } else {
+ unselect_diff = handler.selectionDifference(this.selectionBase, false, this.lastSelection, true);
+ if (unselect_diff != 0) {
+ pos_diff = handler.selectionDifference(pos, true, this.selectionBase, false);
+ if (pos_diff.length == 0) {
+ unselect_diff = handler.selectionDifference(pos, false, this.lastSelection, true);
+ }
+ for (var d of unselect_diff) {
+ this.selection.delete(d);
+ }
+ }
+ if (pos_diff.length != 0) {
+ for (var d of pos_diff) {
+ this.selection.add(d);
+ }
+ }
+ }
+ handler.select(unselect_diff, false);
+ handler.select(pos_diff, true);
+ this.lastSelection = pos;
+}
+
+
+Selection.prototype.detachSelection = function() {
+ var result = new Set();
+ for (var i of this.selection) {
+ result.add(i);
+ }
+ this.clear();
+ return result;
+}
« no previous file with comments | « tools/turbolizer/search2.png ('k') | tools/turbolizer/selection-broker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698