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 Renders an array of slices into the provided div, | 7 * @fileoverview Renders an array of slices into the provided div, |
8 * using a child canvas element. Uses a FastRectRenderer to draw only | 8 * using a child canvas element. Uses a FastRectRenderer to draw only |
9 * the visible slices. | 9 * the visible slices. |
10 */ | 10 */ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 decorate: function() { | 87 decorate: function() { |
88 this.className = 'timeline-thread-track'; | 88 this.className = 'timeline-thread-track'; |
89 }, | 89 }, |
90 | 90 |
91 set thread(thread) { | 91 set thread(thread) { |
92 this.thread_ = thread; | 92 this.thread_ = thread; |
93 this.updateChildTracks_(); | 93 this.updateChildTracks_(); |
94 }, | 94 }, |
95 | 95 |
| 96 /** |
| 97 * @return {string} A human-readable name for the track. |
| 98 */ |
| 99 get heading() { |
| 100 if (!this.thread_) |
| 101 return ''; |
| 102 var tname = this.thread_.name || this.thread_.tid; |
| 103 return this.thread_.parent.pid + ': ' + |
| 104 tname + ':'; |
| 105 }, |
| 106 |
| 107 set headingWidth(width) { |
| 108 for (var i = 0; i < this.tracks_.length; i++) |
| 109 this.tracks_[i].headingWidth = width; |
| 110 }, |
| 111 |
96 set viewport(v) { | 112 set viewport(v) { |
97 this.viewport_ = v; | 113 this.viewport_ = v; |
98 for (var i = 0; i < this.tracks_.length; i++) | 114 for (var i = 0; i < this.tracks_.length; i++) |
99 this.tracks_[i].viewport = v; | 115 this.tracks_[i].viewport = v; |
100 this.invalidate(); | 116 this.invalidate(); |
101 }, | 117 }, |
102 | 118 |
103 invalidate: function() { | 119 invalidate: function() { |
104 if (this.parentNode) | 120 if (this.parentNode) |
105 this.parentNode.invalidate(); | 121 this.parentNode.invalidate(); |
(...skipping 19 matching lines...) Expand all Loading... |
125 this.textContent = ''; | 141 this.textContent = ''; |
126 this.tracks_ = []; | 142 this.tracks_ = []; |
127 if (this.thread_) { | 143 if (this.thread_) { |
128 for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) { | 144 for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) { |
129 addTrack(this, this.thread_.nonNestedSubRows[srI]); | 145 addTrack(this, this.thread_.nonNestedSubRows[srI]); |
130 } | 146 } |
131 for (var srI = 0; srI < this.thread_.subRows.length; ++srI) { | 147 for (var srI = 0; srI < this.thread_.subRows.length; ++srI) { |
132 addTrack(this, this.thread_.subRows[srI]); | 148 addTrack(this, this.thread_.subRows[srI]); |
133 } | 149 } |
134 if (this.tracks_.length > 0) { | 150 if (this.tracks_.length > 0) { |
135 var tname = this.thread_.name || this.thread_.tid; | 151 this.tracks_[0].heading = this.heading; |
136 this.tracks_[0].heading = this.thread_.parent.pid + ': ' + | |
137 tname + ':'; | |
138 this.tracks_[0].tooltip = 'pid: ' + this.thread_.parent.pid + | 152 this.tracks_[0].tooltip = 'pid: ' + this.thread_.parent.pid + |
139 ', tid: ' + this.thread_.tid + | 153 ', tid: ' + this.thread_.tid + |
140 (this.thread_.name ? ', name: ' + this.thread_.name : ''); | 154 (this.thread_.name ? ', name: ' + this.thread_.name : ''); |
141 } | 155 } |
142 } | 156 } |
143 }, | 157 }, |
144 | 158 |
145 /** | 159 /** |
146 * Picks a slice, if any, at a given location. | 160 * Picks a slice, if any, at a given location. |
147 * @param {number} wX X location to search at, in worldspace. | 161 * @param {number} wX X location to search at, in worldspace. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 this.canvasContainer_ = document.createElement('div'); | 219 this.canvasContainer_ = document.createElement('div'); |
206 this.canvasContainer_.className = 'timeline-slice-track-canvas-container'; | 220 this.canvasContainer_.className = 'timeline-slice-track-canvas-container'; |
207 this.appendChild(this.canvasContainer_); | 221 this.appendChild(this.canvasContainer_); |
208 this.canvas_ = document.createElement('canvas'); | 222 this.canvas_ = document.createElement('canvas'); |
209 this.canvas_.className = 'timeline-slice-track-canvas'; | 223 this.canvas_.className = 'timeline-slice-track-canvas'; |
210 this.canvasContainer_.appendChild(this.canvas_); | 224 this.canvasContainer_.appendChild(this.canvas_); |
211 | 225 |
212 this.ctx_ = this.canvas_.getContext('2d'); | 226 this.ctx_ = this.canvas_.getContext('2d'); |
213 }, | 227 }, |
214 | 228 |
| 229 set headingWidth(width) { |
| 230 this.headingDiv_.style.width = width; |
| 231 }, |
| 232 |
| 233 get heading() { |
| 234 return this.headingDiv_.textContent; |
| 235 }, |
| 236 |
215 set heading(text) { | 237 set heading(text) { |
216 this.headingDiv_.textContent = text; | 238 this.headingDiv_.textContent = text; |
217 }, | 239 }, |
218 | 240 |
219 set tooltip(text) { | 241 set tooltip(text) { |
220 this.headingDiv_.title = text; | 242 this.headingDiv_.title = text; |
221 }, | 243 }, |
222 | 244 |
223 set slices(slices) { | 245 set slices(slices) { |
224 this.slices_ = slices; | 246 this.slices_ = slices; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 var index = this.indexOfSlice_(slice); | 458 var index = this.indexOfSlice_(slice); |
437 if (index != undefined) { | 459 if (index != undefined) { |
438 if (index < this.slices_.length - 1) | 460 if (index < this.slices_.length - 1) |
439 index++; | 461 index++; |
440 else | 462 else |
441 index = undefined; | 463 index = undefined; |
442 } | 464 } |
443 return index != undefined ? this.slices_[index] : undefined; | 465 return index != undefined ? this.slices_[index] : undefined; |
444 }, | 466 }, |
445 | 467 |
446 /** | 468 /** |
447 * Return the previous slice, if any, before the given slice. | 469 * Return the previous slice, if any, before the given slice. |
448 * @param {slice} A slice. | 470 * @param {slice} A slice. |
449 * @return {slice} The previous slice, or undefined. | 471 * @return {slice} The previous slice, or undefined. |
450 */ | 472 */ |
451 pickPrevious: function(slice) { | 473 pickPrevious: function(slice) { |
452 var index = this.indexOfSlice_(slice); | 474 var index = this.indexOfSlice_(slice); |
453 if (index == 0) | 475 if (index == 0) |
454 return undefined; | 476 return undefined; |
455 else if ((index != undefined) && (index > 0)) | 477 else if ((index != undefined) && (index > 0)) |
456 index--; | 478 index--; |
457 return index != undefined ? this.slices_[index] : undefined; | 479 return index != undefined ? this.slices_[index] : undefined; |
458 }, | 480 } |
459 | 481 |
460 }; | 482 }; |
461 | 483 |
462 return { | 484 return { |
463 TimelineSliceTrack: TimelineSliceTrack, | 485 TimelineSliceTrack: TimelineSliceTrack, |
464 TimelineThreadTrack: TimelineThreadTrack | 486 TimelineThreadTrack: TimelineThreadTrack |
465 }; | 487 }; |
466 }); | 488 }); |
OLD | NEW |