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