| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.TimelineOverviewBase} | 33 * @extends {WebInspector.TimelineOverviewBase} |
| 34 * @param {!WebInspector.TimelineModel} model | 34 * @param {!WebInspector.TimelineModel} model |
| 35 * @param {!WebInspector.TimelineFrameModelBase} frameModel | 35 * @param {!WebInspector.TimelineFrameModelBase} frameModel |
| 36 */ | 36 */ |
| 37 WebInspector.TimelineFrameOverview = function(model, frameModel) | 37 WebInspector.TimelineFrameOverview = function(model, frameModel) |
| 38 { | 38 { |
| 39 WebInspector.TimelineOverviewBase.call(this, model); | 39 WebInspector.TimelineOverviewBase.call(this); |
| 40 this.element.id = "timeline-overview-frames"; | 40 this.element.id = "timeline-overview-frames"; |
| 41 this._model = model; |
| 41 this._frameModel = frameModel; | 42 this._frameModel = frameModel; |
| 42 this.reset(); | 43 this.reset(); |
| 43 | 44 |
| 44 this._outerPadding = 4 * window.devicePixelRatio; | 45 this._outerPadding = 4 * window.devicePixelRatio; |
| 45 this._maxInnerBarWidth = 10 * window.devicePixelRatio; | 46 this._maxInnerBarWidth = 10 * window.devicePixelRatio; |
| 46 this._topPadding = 6 * window.devicePixelRatio; | 47 this._topPadding = 6 * window.devicePixelRatio; |
| 47 | 48 |
| 48 // The below two are really computed by update() -- but let's have something
so that windowTimes() is happy. | 49 // The below two are really computed by update() -- but let's have something
so that windowTimes() is happy. |
| 49 this._actualPadding = 5 * window.devicePixelRatio; | 50 this._actualPadding = 5 * window.devicePixelRatio; |
| 50 this._actualOuterBarWidth = this._maxInnerBarWidth + this._actualPadding; | 51 this._actualOuterBarWidth = this._maxInnerBarWidth + this._actualPadding; |
| 51 | 52 |
| 52 this._fillStyles = {}; | 53 this._fillStyles = {}; |
| 53 var categories = WebInspector.TimelineUIUtils.categories(); | 54 var categories = WebInspector.TimelineUIUtils.categories(); |
| 54 for (var category in categories) | 55 for (var category in categories) |
| 55 this._fillStyles[category] = WebInspector.TimelineUIUtils.createFillStyl
eForCategory(this._context, this._maxInnerBarWidth, 0, categories[category]); | 56 this._fillStyles[category] = WebInspector.TimelineUIUtils.createFillStyl
eForCategory(this._context, this._maxInnerBarWidth, 0, categories[category]); |
| 56 | 57 |
| 57 this._frameTopShadeGradient = this._context.createLinearGradient(0, 0, 0, th
is._topPadding); | 58 this._frameTopShadeGradient = this._context.createLinearGradient(0, 0, 0, th
is._topPadding); |
| 58 this._frameTopShadeGradient.addColorStop(0, "rgba(255, 255, 255, 0.9)"); | 59 this._frameTopShadeGradient.addColorStop(0, "rgba(255, 255, 255, 0.9)"); |
| 59 this._frameTopShadeGradient.addColorStop(1, "rgba(255, 255, 255, 0.2)"); | 60 this._frameTopShadeGradient.addColorStop(1, "rgba(255, 255, 255, 0.2)"); |
| 60 | 61 |
| 61 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), fal
se); | 62 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), fal
se); |
| 62 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false
); | 63 this.element.addEventListener("mouseout", this._onMouseOut.bind(this), false
); |
| 63 } | 64 } |
| 64 | 65 |
| 66 WebInspector.TimelineFrameOverview.Events = { |
| 67 SelectionChanged: "SelectionChanged" |
| 68 } |
| 69 |
| 65 WebInspector.TimelineFrameOverview.prototype = { | 70 WebInspector.TimelineFrameOverview.prototype = { |
| 66 /** | 71 /** |
| 67 * @override | 72 * @override |
| 68 */ | 73 */ |
| 69 reset: function() | 74 reset: function() |
| 70 { | 75 { |
| 71 /** @type {!Array<!{startTime:number, endTime:number}>} */ | 76 /** @type {!Array<!{startTime:number, endTime:number}>} */ |
| 72 this._barTimes = []; | 77 this._barTimes = []; |
| 73 /** @type {!Array<!WebInspector.TimelineFrame>} */ | 78 /** @type {!Array<!WebInspector.TimelineFrame>} */ |
| 74 this._visibleFrames = []; | 79 this._visibleFrames = []; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 this._context.save(); | 101 this._context.save(); |
| 97 for (var i = this._visibleFrames.length - 1; i >= 0; --i) | 102 for (var i = this._visibleFrames.length - 1; i >= 0; --i) |
| 98 this._drawBar(i); | 103 this._drawBar(i); |
| 99 this._drawTopShadeGradient(); | 104 this._drawTopShadeGradient(); |
| 100 this._drawFPSMarks(); | 105 this._drawFPSMarks(); |
| 101 this._drawSelection(); | 106 this._drawSelection(); |
| 102 this._context.restore(); | 107 this._context.restore(); |
| 103 }, | 108 }, |
| 104 | 109 |
| 105 /** | 110 /** |
| 106 * @override | |
| 107 * @param {?WebInspector.TimelineSelection} selection | 111 * @param {?WebInspector.TimelineSelection} selection |
| 108 */ | 112 */ |
| 109 select: function(selection) | 113 select: function(selection) |
| 110 { | 114 { |
| 111 var oldSelectionIndex = this._selectedBarIndex; | 115 var oldSelectionIndex = this._selectedBarIndex; |
| 112 var frame = selection && selection.type() === WebInspector.TimelineSelec
tion.Type.Frame ? /** @type {!WebInspector.TimelineFrame} */ (selection.object()
) : null; | 116 var frame = selection && selection.type() === WebInspector.TimelineSelec
tion.Type.Frame ? /** @type {!WebInspector.TimelineFrame} */ (selection.object()
) : null; |
| 113 var index = frame ? this._visibleFrames.indexOf(frame) : -1; | 117 var index = frame ? this._visibleFrames.indexOf(frame) : -1; |
| 114 this._selectedBarIndex = index >= 0 ? index : null; | 118 this._selectedBarIndex = index >= 0 ? index : null; |
| 115 if (this._selectedBarIndex === oldSelectionIndex) | 119 if (this._selectedBarIndex === oldSelectionIndex) |
| 116 return; | 120 return; |
| 117 if (typeof oldSelectionIndex === "number") | 121 if (typeof oldSelectionIndex === "number") |
| 118 this._redrawBar(oldSelectionIndex); | 122 this._redrawBar(oldSelectionIndex); |
| 119 this._drawSelection(); | 123 this._drawSelection(); |
| 120 }, | 124 }, |
| 121 | 125 |
| 122 /** | 126 /** |
| 123 * @override | 127 * @override |
| 124 * @param {!Event} event | 128 * @param {!Event} event |
| 125 * @return {?WebInspector.TimelineSelection|undefined} | 129 * @return {boolean} |
| 126 */ | 130 */ |
| 127 selectionFromEvent: function(event) | 131 onClick: function(event) |
| 128 { | 132 { |
| 129 var barIndex = this._screenPositionToBarIndex(event.clientX); | 133 var barIndex = this._screenPositionToBarIndex(event.clientX); |
| 130 if (barIndex < 0 || barIndex >= this._visibleFrames.length) | 134 if (barIndex < 0 || barIndex >= this._visibleFrames.length) |
| 131 return null; | 135 return false; |
| 132 return WebInspector.TimelineSelection.fromFrame(this._visibleFrames[barI
ndex]); | 136 var selection = WebInspector.TimelineSelection.fromFrame(this._visibleFr
ames[barIndex]); |
| 137 this.dispatchEventToListeners(WebInspector.TimelineFrameOverview.Events.
SelectionChanged, selection); |
| 138 return true; |
| 133 }, | 139 }, |
| 134 | 140 |
| 135 /** | 141 /** |
| 136 * @param {!Event} event | 142 * @param {!Event} event |
| 137 */ | 143 */ |
| 138 _onMouseMove: function(event) | 144 _onMouseMove: function(event) |
| 139 { | 145 { |
| 140 var barIndex = this._screenPositionToBarIndex(event.clientX); | 146 var barIndex = this._screenPositionToBarIndex(event.clientX); |
| 141 if (barIndex < 0 || barIndex >= this._visibleFrames.length) | 147 if (barIndex < 0 || barIndex >= this._visibleFrames.length) |
| 142 barIndex = null; | 148 barIndex = null; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 * @param {number} time | 473 * @param {number} time |
| 468 * @param {function(number, {startTime:number, endTime:number}):number} comp
arator | 474 * @param {function(number, {startTime:number, endTime:number}):number} comp
arator |
| 469 */ | 475 */ |
| 470 _firstBarAfter: function(time, comparator) | 476 _firstBarAfter: function(time, comparator) |
| 471 { | 477 { |
| 472 return insertionIndexForObjectInListSortedByFunction(time, this._barTime
s, comparator); | 478 return insertionIndexForObjectInListSortedByFunction(time, this._barTime
s, comparator); |
| 473 }, | 479 }, |
| 474 | 480 |
| 475 __proto__: WebInspector.TimelineOverviewBase.prototype | 481 __proto__: WebInspector.TimelineOverviewBase.prototype |
| 476 } | 482 } |
| OLD | NEW |