OLD | NEW |
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 /** | 5 /** |
6 * @fileoverview Interactive visualizaiton of TimelineModel objects | 6 * @fileoverview Interactive visualizaiton of TimelineModel objects |
7 * based loosely on gantt charts. Each thread in the TimelineModel is given a | 7 * based loosely on gantt charts. Each thread in the TimelineModel is given a |
8 * set of TimelineTracks, one per subrow in the thread. The Timeline class | 8 * set of TimelineTracks, one per subrow in the thread. The Timeline class |
9 * acts as a controller, creating the individual tracks, while TimelineTracks | 9 * acts as a controller, creating the individual tracks, while TimelineTracks |
10 * do actual drawing. | 10 * do actual drawing. |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // Get a sorted list of threads. | 389 // Get a sorted list of threads. |
390 var threads = []; | 390 var threads = []; |
391 for (var tid in process.threads) | 391 for (var tid in process.threads) |
392 threads.push(process.threads[tid]); | 392 threads.push(process.threads[tid]); |
393 threads.sort(tracing.TimelineThread.compare); | 393 threads.sort(tracing.TimelineThread.compare); |
394 | 394 |
395 // Create the threads. | 395 // Create the threads. |
396 threads.forEach(function(thread) { | 396 threads.forEach(function(thread) { |
397 var track = new tracing.TimelineThreadTrack(); | 397 var track = new tracing.TimelineThreadTrack(); |
398 track.heading = thread.userFriendlyName + ':'; | 398 track.heading = thread.userFriendlyName + ':'; |
399 track.tooltip = thread.userFriendlyDetials; | 399 track.tooltip = thread.userFriendlyDetails; |
400 track.headingWidth = maxHeadingWidth; | 400 track.headingWidth = maxHeadingWidth; |
401 track.viewport = this.viewport_; | 401 track.viewport = this.viewport_; |
402 track.thread = thread; | 402 track.thread = thread; |
403 this.tracks_.appendChild(track); | 403 this.tracks_.appendChild(track); |
404 }.bind(this)); | 404 }.bind(this)); |
405 }.bind(this)); | 405 }.bind(this)); |
406 | 406 |
407 // Set up a reasonable viewport. | 407 // Set up a reasonable viewport. |
408 this.viewport_.setWhenPossible(function() { | 408 this.viewport_.setWhenPossible(function() { |
409 var rangeTimestamp = this.model_.maxTimestamp - | 409 var rangeTimestamp = this.model_.maxTimestamp - |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 654 |
655 // Shift the timebase left until its just left of minTimestamp. | 655 // Shift the timebase left until its just left of minTimestamp. |
656 var numInterfvalsSinceStart = Math.ceil((tb - this.model_.minTimestamp) / | 656 var numInterfvalsSinceStart = Math.ceil((tb - this.model_.minTimestamp) / |
657 this.viewport_.gridStep_); | 657 this.viewport_.gridStep_); |
658 this.viewport_.gridTimebase = tb - | 658 this.viewport_.gridTimebase = tb - |
659 (numInterfvalsSinceStart + 1) * this.viewport_.gridStep_; | 659 (numInterfvalsSinceStart + 1) * this.viewport_.gridStep_; |
660 this.viewport_.gridEnabled = true; | 660 this.viewport_.gridEnabled = true; |
661 }, | 661 }, |
662 | 662 |
663 onMouseDown_: function(e) { | 663 onMouseDown_: function(e) { |
664 rect = this.tracks_.getClientRects()[0]; | 664 var canv = this.firstCanvas; |
| 665 var rect = this.tracks_.getClientRects()[0]; |
665 var inside = rect && | 666 var inside = rect && |
666 e.clientX >= rect.left && | 667 e.clientX >= rect.left && |
667 e.clientX < rect.right && | 668 e.clientX < rect.right && |
668 e.clientY >= rect.top && | 669 e.clientY >= rect.top && |
669 e.clientY < rect.bottom; | 670 e.clientY < rect.bottom && |
| 671 e.x >= canv.offsetLeft; |
670 if (!inside) | 672 if (!inside) |
671 return; | 673 return; |
672 | 674 |
673 var canv = this.firstCanvas; | |
674 var pos = { | 675 var pos = { |
675 x: e.clientX - canv.offsetLeft, | 676 x: e.clientX - canv.offsetLeft, |
676 y: e.clientY - canv.offsetTop | 677 y: e.clientY - canv.offsetTop |
677 }; | 678 }; |
678 | 679 |
679 var wX = this.viewport_.xViewToWorld(pos.x); | 680 var wX = this.viewport_.xViewToWorld(pos.x); |
680 | 681 |
681 this.dragBeginEvent_ = e; | 682 this.dragBeginEvent_ = e; |
682 e.preventDefault(); | 683 e.preventDefault(); |
683 if (this.focusElement.tabIndex >= 0) | 684 if (this.focusElement.tabIndex >= 0) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 if (a <= b) { | 737 if (a <= b) { |
737 track.pickRange(loWX, hiWX, loY, hiY, addHit); | 738 track.pickRange(loWX, hiWX, loY, hiY, addHit); |
738 } | 739 } |
739 } | 740 } |
740 // Activate the new selection. | 741 // Activate the new selection. |
741 this.selection = selection; | 742 this.selection = selection; |
742 } | 743 } |
743 }, | 744 }, |
744 | 745 |
745 onDblClick_: function(e) { | 746 onDblClick_: function(e) { |
| 747 var canv = this.firstCanvas; |
| 748 if (e.x < canv.offsetLeft) |
| 749 return; |
| 750 |
746 var scale = 4; | 751 var scale = 4; |
747 if (e.shiftKey) | 752 if (e.shiftKey) |
748 scale = 1 / scale; | 753 scale = 1 / scale; |
749 this.zoomBy_(scale); | 754 this.zoomBy_(scale); |
750 e.preventDefault(); | 755 e.preventDefault(); |
751 } | 756 } |
752 }; | 757 }; |
753 | 758 |
754 /** | 759 /** |
755 * The TimelineModel being viewed by the timeline | 760 * The TimelineModel being viewed by the timeline |
756 * @type {TimelineModel} | 761 * @type {TimelineModel} |
757 */ | 762 */ |
758 cr.defineProperty(Timeline, 'model', cr.PropertyKind.JS); | 763 cr.defineProperty(Timeline, 'model', cr.PropertyKind.JS); |
759 | 764 |
760 return { | 765 return { |
761 Timeline: Timeline, | 766 Timeline: Timeline, |
762 TimelineViewport: TimelineViewport | 767 TimelineViewport: TimelineViewport |
763 }; | 768 }; |
764 }); | 769 }); |
OLD | NEW |