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

Side by Side Diff: tools/turbolizer/graph-view.js

Issue 2050233002: [turbolizer] Add 2 buttons; add middle-click on input; add comment in UI. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@mywork
Patch Set: Created 4 years, 6 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 | « no previous file | tools/turbolizer/index.html » ('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 "use strict"; 5 "use strict";
6 6
7 class GraphView extends View { 7 class GraphView extends View {
8 constructor (d3, id, nodes, edges, broker) { 8 constructor (d3, id, nodes, edges, broker) {
9 super(id, broker); 9 super(id, broker);
10 var graph = this; 10 var graph = this;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 }); 162 });
163 163
164 d3.select("#zoom-selection").on("click", function() { 164 d3.select("#zoom-selection").on("click", function() {
165 graph.viewSelection(); 165 graph.viewSelection();
166 }); 166 });
167 167
168 d3.select("#toggle-types").on("click", function() { 168 d3.select("#toggle-types").on("click", function() {
169 graph.toggleTypes(); 169 graph.toggleTypes();
170 }); 170 });
171 171
172 d3.select("#show-effects").on("click", function() {
173 graph.showEffects();
174 });
175
176 d3.select("#hide-control").on("click", function() {
177 graph.hideControl();
178 });
179
172 d3.select("#search-input").on("keydown", function() { 180 d3.select("#search-input").on("keydown", function() {
173 if (d3.event.keyCode == 13) { 181 if (d3.event.keyCode == 13) {
174 graph.state.selection.clear(); 182 graph.state.selection.clear();
175 var reg = new RegExp(this.value); 183 var reg = new RegExp(this.value);
176 var selected = graph.visibleNodes.each(function(n) { 184 var selected = graph.visibleNodes.each(function(n) {
177 if (reg.exec(n.getDisplayLabel()) != null || 185 if (reg.exec(n.getDisplayLabel()) != null ||
178 (graph.state.showTypes && reg.exec(n.getDisplayType())) || 186 (graph.state.showTypes && reg.exec(n.getDisplayType())) ||
179 reg.exec(n.opcode) != null) { 187 reg.exec(n.opcode) != null) {
180 graph.state.selection.select(this, true); 188 graph.state.selection.select(this, true);
181 } 189 }
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 return !d.inputs[i].isVisible(); 613 return !d.inputs[i].isVisible();
606 } ) 614 } )
607 .attr("id", "ib," + d.inputs[i].stringID()) 615 .attr("id", "ib," + d.inputs[i].stringID())
608 .attr("r", DEFAULT_NODE_BUBBLE_RADIUS) 616 .attr("r", DEFAULT_NODE_BUBBLE_RADIUS)
609 .attr("transform", function(d) { 617 .attr("transform", function(d) {
610 return "translate(" + x + "," + y + ")"; 618 return "translate(" + x + "," + y + ")";
611 }) 619 })
612 .on("mousedown", function(d){ 620 .on("mousedown", function(d){
613 var components = this.id.split(','); 621 var components = this.id.split(',');
614 var node = graph.nodeMap[components[3]]; 622 var node = graph.nodeMap[components[3]];
615 var edge = node.inputs[components[2]]; 623 var edgeIndex = components[2];
616 var visible = !edge.isVisible(); 624 var edge = node.inputs[edgeIndex];
617 node.setInputVisibility(components[2], visible); 625 if (d3.event.button == 0) {
618 d3.event.stopPropagation(); 626 // Left mouse button click: show the edge and the node it leads
627 // to.
628 var visible = !edge.isVisible();
629 node.setInputVisibility(components[2], visible);
630 d3.event.stopPropagation();
631 } else {
632 // Alternate mouse button click: as above, but more: if we
633 // clicked the nth input bubble, expand all nth input bubbles of
634 // nodes that have the same opcode. If in this process we make
635 // more nodes visible that have the same opcode, also expand
636 // their nth input bubbles, until we stabilize.
637 filterActionUntilStabilize(graph.nodes,
638 // filter
639 function(otherNode) {
640 return (node.opcode === otherNode.opcode) &&
641 (otherNode.visible) &&
642 (otherNode.inputs.length >= edgeIndex) &&
643 (!otherNode.inputs[edgeIndex].visible);
644 },
645 // action
646 function(otherNode) {
647 otherNode.setInputVisibility(edgeIndex, true);
648 });
649 }
650
619 graph.updateGraphVisibility(); 651 graph.updateGraphVisibility();
620 }); 652 });
621 } 653 }
622 if (d.outputs.length != 0) { 654 if (d.outputs.length != 0) {
623 var x = d.getOutputX(); 655 var x = d.getOutputX();
624 var y = graph.getNodeHeight() + DEFAULT_NODE_BUBBLE_RADIUS / 2 + 4; 656 var y = graph.getNodeHeight() + DEFAULT_NODE_BUBBLE_RADIUS / 2 + 4;
625 var s = g.append('circle') 657 var s = g.append('circle')
626 .classed("filledBubbleStyle", function(c) { 658 .classed("filledBubbleStyle", function(c) {
627 return d.areAnyOutputsVisible() == 2; 659 return d.areAnyOutputsVisible() == 2;
628 } ) 660 } )
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 graph.state.showTypes = !graph.state.showTypes; 840 graph.state.showTypes = !graph.state.showTypes;
809 var element = document.getElementById('toggle-types'); 841 var element = document.getElementById('toggle-types');
810 if (graph.state.showTypes) { 842 if (graph.state.showTypes) {
811 element.classList.add('button-input-toggled'); 843 element.classList.add('button-input-toggled');
812 } else { 844 } else {
813 element.classList.remove('button-input-toggled'); 845 element.classList.remove('button-input-toggled');
814 } 846 }
815 graph.updateGraphVisibility(); 847 graph.updateGraphVisibility();
816 } 848 }
817 849
850 showEffects() {
851 var graph = this;
852
853 // Loop over all the nodes to find nodes which are visible. All effect
854 // edges to a visible node should become visible, as well as the source
855 // node of such edges. As long as more nodes become visible, repeat the
856 // process.
857
858 filterActionUntilStabilize(graph.nodes,
859 // filter
860 function(node) {
861 return node.visible;
862 },
863 // action
864 function(node) {
865 node.inputs.forEach(function(inputEdge) {
866 if (node !== inputEdge.target) {
867 window.alert("Error: target of an input edge should be the node itse lf");
868 }
869 if (!inputEdge.visible && inputEdge.type == "effect") {
870 node.setInputVisibility(inputEdge.index, true);
871 }
872 });
873 }
874 );
875
876 graph.updateGraphVisibility();
877 }
878
879 hideControl() {
880 var graph = this;
881
882 graph.edges.forEach(function(edge) {
883 if (edge.type == "control") {
884 edge.visible = false;
885 }
886 });
887
888 graph.updateGraphVisibility();
889 }
890
818 viewSelection() { 891 viewSelection() {
819 var graph = this; 892 var graph = this;
820 var minX, maxX, minY, maxY; 893 var minX, maxX, minY, maxY;
821 var hasSelection = false; 894 var hasSelection = false;
822 graph.visibleNodes.each(function(n) { 895 graph.visibleNodes.each(function(n) {
823 if (this.classList.contains("selected")) { 896 if (this.classList.contains("selected")) {
824 hasSelection = true; 897 hasSelection = true;
825 minX = minX ? Math.min(minX, n.x) : n.x; 898 minX = minX ? Math.min(minX, n.x) : n.x;
826 maxX = maxX ? Math.max(maxX, n.x + n.getTotalNodeWidth()) : 899 maxX = maxX ? Math.max(maxX, n.x + n.getTotalNodeWidth()) :
827 n.x + n.getTotalNodeWidth(); 900 n.x + n.getTotalNodeWidth();
(...skipping 23 matching lines...) Expand all
851 } 924 }
852 925
853 viewWholeGraph() { 926 viewWholeGraph() {
854 var graph = this; 927 var graph = this;
855 var minScale = graph.minScale(); 928 var minScale = graph.minScale();
856 var translation = [0, 0]; 929 var translation = [0, 0];
857 translation = graph.getVisibleTranslation(translation, minScale); 930 translation = graph.getVisibleTranslation(translation, minScale);
858 graph.translateClipped(translation, minScale); 931 graph.translateClipped(translation, minScale);
859 } 932 }
860 } 933 }
OLDNEW
« no previous file with comments | « no previous file | tools/turbolizer/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698