OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 entryLevels: [], | 169 entryLevels: [], |
170 entryTotalTimes: [], | 170 entryTotalTimes: [], |
171 entryOffsets: [], | 171 entryOffsets: [], |
172 }; | 172 }; |
173 | 173 |
174 /** @type {!Array.<string>} */ | 174 /** @type {!Array.<string>} */ |
175 this._entryTitles = []; | 175 this._entryTitles = []; |
176 | 176 |
177 /** @type {!Array.<string>} */ | 177 /** @type {!Array.<string>} */ |
178 this._entryColors = []; | 178 this._entryColors = []; |
179 | |
180 /** @type {!Array.<!WebInspector.TimelineModel.Record>} */ | |
181 this._entryRecords = []; | |
179 }, | 182 }, |
180 | 183 |
181 /** | 184 /** |
182 * @param {!WebInspector.TimelineModel.Record} record | 185 * @param {!WebInspector.TimelineModel.Record} record |
183 * @param {number} level | 186 * @param {number} level |
184 */ | 187 */ |
185 _appendRecord: function(record, level) | 188 _appendRecord: function(record, level) |
186 { | 189 { |
187 var timelineData = this.timelineData(); | 190 var timelineData = this.timelineData(); |
188 | 191 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 * @param {number} endTime | 231 * @param {number} endTime |
229 */ | 232 */ |
230 _pushRecord: function(record, level, color, startTime, endTime) | 233 _pushRecord: function(record, level, color, startTime, endTime) |
231 { | 234 { |
232 var index = this._entryTitles.length; | 235 var index = this._entryTitles.length; |
233 this._entryTitles[index] = record.type; | 236 this._entryTitles[index] = record.type; |
234 this._timelineData.entryOffsets[index] = startTime - this._zeroTime; | 237 this._timelineData.entryOffsets[index] = startTime - this._zeroTime; |
235 this._timelineData.entryLevels[index] = level; | 238 this._timelineData.entryLevels[index] = level; |
236 this._timelineData.entryTotalTimes[index] = endTime - startTime; | 239 this._timelineData.entryTotalTimes[index] = endTime - startTime; |
237 this._entryColors[index] = color; | 240 this._entryColors[index] = color; |
241 this._entryRecords[index] = record; | |
238 }, | 242 }, |
239 | 243 |
240 /** | 244 /** |
241 * @param {number} entryIndex | 245 * @param {number} entryIndex |
242 * @return {?Array.<!{title: string, text: string}>} | 246 * @return {?Array.<!{title: string, text: string}>} |
243 */ | 247 */ |
244 prepareHighlightedEntryInfo: function(entryIndex) | 248 prepareHighlightedEntryInfo: function(entryIndex) |
245 { | 249 { |
246 return null; | 250 return null; |
247 }, | 251 }, |
248 | 252 |
249 /** | 253 /** |
250 * @param {number} entryIndex | 254 * @param {number} entryIndex |
251 * @return {boolean} | 255 * @return {boolean} |
252 */ | 256 */ |
253 canJumpToEntry: function(entryIndex) | 257 canJumpToEntry: function(entryIndex) |
254 { | 258 { |
255 return false; | 259 return false; |
256 }, | 260 }, |
257 | 261 |
258 /** | 262 /** |
259 * @param {number} entryIndex | 263 * @param {number} entryIndex |
260 * @return {?Object} | 264 * @return {?Object} |
261 */ | 265 */ |
262 entryData: function(entryIndex) | 266 entryData: function(entryIndex) |
263 { | 267 { |
264 return null; | 268 return this._entryRecords[entryIndex]; |
pfeldman
2014/03/05 12:13:02
You should express selection in terms of entryInde
| |
265 }, | 269 }, |
266 | 270 |
267 /** | 271 /** |
268 * @param {number} entryIndex | 272 * @param {number} entryIndex |
269 * @return {!string} | 273 * @return {!string} |
270 */ | 274 */ |
271 entryColor: function(entryIndex) | 275 entryColor: function(entryIndex) |
272 { | 276 { |
273 return this._entryColors[entryIndex]; | 277 return this._entryColors[entryIndex]; |
278 }, | |
279 | |
280 /** | |
281 * @param {number} entryIndex | |
282 * @return {!{startTimeOffset: number, endTimeOffset: number}} | |
283 */ | |
284 highlightTimeRange: function(entryIndex) | |
pfeldman
2014/03/05 12:13:02
What is the semantics of this method?
loislo
2014/03/05 12:57:55
As I've told you we generates a few entries per si
| |
285 { | |
286 var record = this._entryRecords[entryIndex]; | |
287 return { | |
288 startTimeOffset: record.startTime - this._zeroTime, | |
289 endTimeOffset: (record.endTime || record.startTime) - this._zeroTime | |
290 }; | |
274 } | 291 } |
275 } | 292 } |
276 | 293 |
277 /** | 294 /** |
278 * @constructor | 295 * @constructor |
279 * @extends {WebInspector.View} | 296 * @extends {WebInspector.View} |
280 * @implements {WebInspector.TimelineModeView} | 297 * @implements {WebInspector.TimelineModeView} |
281 * @implements {WebInspector.TimeRangeController} | 298 * @implements {WebInspector.FlameChartDelegate} |
282 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 299 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
283 * @param {!WebInspector.TimelineModel} model | 300 * @param {!WebInspector.TimelineModel} model |
284 * @param {!WebInspector.TimelineFrameModel} frameModel | 301 * @param {!WebInspector.TimelineFrameModel} frameModel |
285 * @param {boolean} mainThread | 302 * @param {boolean} mainThread |
286 */ | 303 */ |
287 WebInspector.TimelineFlameChart = function(delegate, model, frameModel, mainThre ad) | 304 WebInspector.TimelineFlameChart = function(delegate, model, frameModel, mainThre ad) |
288 { | 305 { |
289 WebInspector.View.call(this); | 306 WebInspector.View.call(this); |
307 this.element.classList.add("timeline-flamechart"); | |
308 this.registerRequiredCSS("flameChart.css"); | |
290 this._delegate = delegate; | 309 this._delegate = delegate; |
291 this._model = model; | 310 this._model = model; |
292 this._dataProvider = new WebInspector.TimelineFlameChartDataProvider(model, frameModel, mainThread); | 311 this._dataProvider = new WebInspector.TimelineFlameChartDataProvider(model, frameModel, mainThread); |
293 this._mainView = new WebInspector.FlameChart.MainPane(this._dataProvider, th is, true, true); | 312 this._mainView = new WebInspector.FlameChart.MainPane(this._dataProvider, th is, true, true); |
294 this._mainView.show(this.element); | 313 this._mainView.show(this.element); |
295 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); | 314 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); |
315 this._mainView.addEventListener(WebInspector.FlameChart.Events.EntrySelected , this._onEntrySelected, this); | |
296 } | 316 } |
297 | 317 |
298 WebInspector.TimelineFlameChart.prototype = { | 318 WebInspector.TimelineFlameChart.prototype = { |
299 /** | 319 /** |
300 * @param {number} windowStartTime | 320 * @param {number} windowStartTime |
301 * @param {number} windowEndTime | 321 * @param {number} windowEndTime |
302 */ | 322 */ |
303 requestWindowTimes: function(windowStartTime, windowEndTime) | 323 requestWindowTimes: function(windowStartTime, windowEndTime) |
304 { | 324 { |
305 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); | 325 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 */ | 397 */ |
378 highlightSearchResult: function(record, regex, selectRecord) | 398 highlightSearchResult: function(record, regex, selectRecord) |
379 { | 399 { |
380 }, | 400 }, |
381 | 401 |
382 /** | 402 /** |
383 * @param {?WebInspector.TimelineModel.Record} record | 403 * @param {?WebInspector.TimelineModel.Record} record |
384 */ | 404 */ |
385 setSelectedRecord: function(record) | 405 setSelectedRecord: function(record) |
386 { | 406 { |
407 var entryRecords = this._dataProvider._entryRecords; | |
408 for (var entryIndex = 0; entryIndex < entryRecords.length; ++entryIndex) { | |
409 if (entryRecords[entryIndex] === record) { | |
410 this._mainView.setSelectedEntry(entryIndex); | |
411 return; | |
412 } | |
413 } | |
414 this._mainView.setSelectedEntry(-1); | |
415 if (this._selectedElement) { | |
416 this._selectedElement.remove(); | |
417 delete this._selectedElement; | |
418 } | |
419 }, | |
420 | |
421 /** | |
422 * @param {!WebInspector.Event} event | |
423 */ | |
424 _onEntrySelected: function(event) | |
425 { | |
426 var record = /** @type {!WebInspector.TimelineModel.Record} */(event.dat a); | |
427 this._delegate.selectRecord(record); | |
428 }, | |
429 | |
430 /** | |
431 * @param {number} entryIndex | |
432 * @param {number} x | |
433 * @param {number} y | |
434 * @param {number} width | |
435 * @param {number} height | |
436 */ | |
437 drawSelectedElement: function(entryIndex, x, y, width, height) | |
438 { | |
439 if (!this._selectedElement) | |
440 this._selectedElement = this.element.createChild("div", "timeline-fl amechart-selected-element"); | |
pfeldman
2014/03/05 12:13:02
This element must belong to the FlameChard and be
loislo
2014/03/05 12:57:55
Done.
| |
441 var style = this._selectedElement.style; | |
442 style.left = x + "px"; | |
443 style.top = y + "px"; | |
444 style.width = width + "px"; | |
445 style.height = height + "px"; | |
387 }, | 446 }, |
388 | 447 |
389 __proto__: WebInspector.View.prototype | 448 __proto__: WebInspector.View.prototype |
390 } | 449 } |
OLD | NEW |