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

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

Issue 2169023002: [turbolizer] Fix a latent bug when dragging a node under another node. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | 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 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 nodeMouseUp(d3node, d) { 463 nodeMouseUp(d3node, d) {
464 var graph = this, 464 var graph = this,
465 state = graph.state, 465 state = graph.state,
466 consts = graph.consts; 466 consts = graph.consts;
467 467
468 var mouseDownNode = state.mouseDownNode; 468 var mouseDownNode = state.mouseDownNode;
469 469
470 if (!mouseDownNode) return; 470 if (!mouseDownNode) return;
471 471
472 if (mouseDownNode !== d){ 472 if (state.justDragged) {
473 // we're in a different node: create new edge for mousedown edge and add t o graph 473 // dragged, not clicked
474 var newEdge = {source: mouseDownNode, target: d}; 474 state.justDragged = false;
475 var filtRes = graph.visibleEdges.filter(function(d){ 475 } else{
476 if (d.source === newEdge.target && d.target === newEdge.source){ 476 // clicked, not dragged
477 graph.edges.splice(graph.edges.indexOf(d), 1); 477 var extend = d3.event.shiftKey;
478 } 478 var selection = graph.state.selection;
479 return d.source === newEdge.source && d.target === newEdge.target; 479 if (!extend) {
480 }); 480 selection.clear();
481 if (!filtRes[0].length){
482 graph.edges.push(newEdge);
483 graph.updateGraphVisibility();
484 } 481 }
485 } else{ 482 selection.select(d3node[0][0], true);
486 // we're in the same node
487 if (state.justDragged) {
488 // dragged, not clicked
489 state.justDragged = false;
490 } else{
491 // clicked, not dragged
492 var extend = d3.event.shiftKey;
493 var selection = graph.state.selection;
494 if (!extend) {
495 selection.clear();
496 }
497 selection.select(d3node[0][0], true);
498 }
499 } 483 }
500 } 484 }
501 485
502 selectSourcePositions(start, end, selected) { 486 selectSourcePositions(start, end, selected) {
503 var graph = this; 487 var graph = this;
504 var map = []; 488 var map = [];
505 var sel = graph.nodes.filter(function(n) { 489 var sel = graph.nodes.filter(function(n) {
506 var pos = (n.pos === undefined) 490 var pos = (n.pos === undefined)
507 ? -1 491 ? -1
508 : n.getFunctionRelativeSourcePosition(graph); 492 : n.getFunctionRelativeSourcePosition(graph);
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 962 }
979 963
980 viewWholeGraph() { 964 viewWholeGraph() {
981 var graph = this; 965 var graph = this;
982 var minScale = graph.minScale(); 966 var minScale = graph.minScale();
983 var translation = [0, 0]; 967 var translation = [0, 0];
984 translation = graph.getVisibleTranslation(translation, minScale); 968 translation = graph.getVisibleTranslation(translation, minScale);
985 graph.translateClipped(translation, minScale); 969 graph.translateClipped(translation, minScale);
986 } 970 }
987 } 971 }
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