| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 6 /** |
| 7 * @fileoverview TimelineView visualizes TRACE_EVENT events using the | 7 * @fileoverview TimelineView visualizes TRACE_EVENT events using the |
| 8 * tracing.Timeline component. | 8 * tracing.Timeline component. |
| 9 */ | 9 */ |
| 10 cr.define('tracing', function() { | 10 cr.define('tracing', function() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 this.summaryEl_.className = 'summary'; | 57 this.summaryEl_.className = 'summary'; |
| 58 | 58 |
| 59 summaryContainer_.appendChild(this.summaryEl_); | 59 summaryContainer_.appendChild(this.summaryEl_); |
| 60 this.appendChild(this.timelineContainer_); | 60 this.appendChild(this.timelineContainer_); |
| 61 this.appendChild(summaryContainer_); | 61 this.appendChild(summaryContainer_); |
| 62 | 62 |
| 63 this.onSelectionChangedBoundToThis_ = this.onSelectionChanged_.bind(this); | 63 this.onSelectionChangedBoundToThis_ = this.onSelectionChanged_.bind(this); |
| 64 }, | 64 }, |
| 65 | 65 |
| 66 set traceEvents(traceEvents) { | 66 set traceEvents(traceEvents) { |
| 67 console.log('TimelineView.refresh'); | |
| 68 this.timelineModel_ = new tracing.TimelineModel(traceEvents); | 67 this.timelineModel_ = new tracing.TimelineModel(traceEvents); |
| 69 | 68 |
| 70 // remove old timeline | 69 // remove old timeline |
| 71 this.timelineContainer_.textContent = ''; | 70 this.timelineContainer_.textContent = ''; |
| 72 | 71 |
| 73 // create new timeline if needed | 72 // create new timeline if needed |
| 74 if (traceEvents.length) { | 73 if (traceEvents.length) { |
| 74 if (this.timeline_) |
| 75 this.timeline_.detach(); |
| 75 this.timeline_ = new tracing.Timeline(); | 76 this.timeline_ = new tracing.Timeline(); |
| 76 this.timeline_.model = this.timelineModel_; | 77 this.timeline_.model = this.timelineModel_; |
| 77 this.timelineContainer_.appendChild(this.timeline_); | 78 this.timelineContainer_.appendChild(this.timeline_); |
| 78 this.timeline_.onResize(); | |
| 79 this.timeline_.addEventListener('selectionChange', | 79 this.timeline_.addEventListener('selectionChange', |
| 80 this.onSelectionChangedBoundToThis_); | 80 this.onSelectionChangedBoundToThis_); |
| 81 this.onSelectionChanged_(); | 81 this.onSelectionChanged_(); |
| 82 } else { | 82 } else { |
| 83 this.timeline_ = null; | 83 this.timeline_ = null; |
| 84 } | 84 } |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 onSelectionChanged_: function(e) { | 87 onSelectionChanged_: function(e) { |
| 88 console.log('selection changed'); | |
| 89 var timeline = this.timeline_; | 88 var timeline = this.timeline_; |
| 90 var selection = timeline.selection; | 89 var selection = timeline.selection; |
| 91 if (!selection.length) { | 90 if (!selection.length) { |
| 92 var oldScrollTop = this.timelineContainer_.scrollTop; | 91 var oldScrollTop = this.timelineContainer_.scrollTop; |
| 93 this.summaryEl_.textContent = timeline.keyHelp; | 92 this.summaryEl_.textContent = timeline.keyHelp; |
| 94 this.timelineContainer_.scrollTop = oldScrollTop; | 93 this.timelineContainer_.scrollTop = oldScrollTop; |
| 95 return; | 94 return; |
| 96 } | 95 } |
| 97 | 96 |
| 98 var text = ''; | 97 var text = ''; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 var oldScrollTop = this.timelineContainer_.scrollTop; | 172 var oldScrollTop = this.timelineContainer_.scrollTop; |
| 174 this.summaryEl_.textContent = text; | 173 this.summaryEl_.textContent = text; |
| 175 this.timelineContainer_.scrollTop = oldScrollTop; | 174 this.timelineContainer_.scrollTop = oldScrollTop; |
| 176 } | 175 } |
| 177 }; | 176 }; |
| 178 | 177 |
| 179 return { | 178 return { |
| 180 TimelineView: TimelineView | 179 TimelineView: TimelineView |
| 181 }; | 180 }; |
| 182 }); | 181 }); |
| OLD | NEW |