| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> |
| 4 * Copyright (C) 2009 Google Inc. All rights reserved. | 4 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 this.element = createElement("div"); | 36 this.element = createElement("div"); |
| 37 WebInspector.appendStyle(this.element, "ui_lazy/timelineGrid.css"); | 37 WebInspector.appendStyle(this.element, "ui_lazy/timelineGrid.css"); |
| 38 | 38 |
| 39 this._dividersElement = this.element.createChild("div", "resources-dividers"
); | 39 this._dividersElement = this.element.createChild("div", "resources-dividers"
); |
| 40 | 40 |
| 41 this._gridHeaderElement = createElement("div"); | 41 this._gridHeaderElement = createElement("div"); |
| 42 this._gridHeaderElement.classList.add("timeline-grid-header"); | 42 this._gridHeaderElement.classList.add("timeline-grid-header"); |
| 43 this._eventDividersElement = this._gridHeaderElement.createChild("div", "res
ources-event-dividers"); | 43 this._eventDividersElement = this._gridHeaderElement.createChild("div", "res
ources-event-dividers"); |
| 44 this._dividersLabelBarElement = this._gridHeaderElement.createChild("div", "
resources-dividers-label-bar"); | 44 this._dividersLabelBarElement = this._gridHeaderElement.createChild("div", "
resources-dividers-label-bar"); |
| 45 this.element.appendChild(this._gridHeaderElement); | 45 this.element.appendChild(this._gridHeaderElement); |
| 46 } | 46 }; |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * @param {!WebInspector.TimelineGrid.Calculator} calculator | 49 * @param {!WebInspector.TimelineGrid.Calculator} calculator |
| 50 * @param {number=} freeZoneAtLeft | 50 * @param {number=} freeZoneAtLeft |
| 51 * @return {!{offsets: !Array.<number>, precision: number}} | 51 * @return {!{offsets: !Array.<number>, precision: number}} |
| 52 */ | 52 */ |
| 53 WebInspector.TimelineGrid.calculateDividerOffsets = function(calculator, freeZon
eAtLeft) | 53 WebInspector.TimelineGrid.calculateDividerOffsets = function(calculator, freeZon
eAtLeft) |
| 54 { | 54 { |
| 55 // TODO(allada) Remove this code out when timeline canvas experiment is over
. | 55 // TODO(allada) Remove this code out when timeline canvas experiment is over
. |
| 56 /** @const */ var minGridSlicePx = 64; // minimal distance between grid line
s. | 56 /** @const */ var minGridSlicePx = 64; // minimal distance between grid line
s. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 | 85 |
| 86 var offsets = []; | 86 var offsets = []; |
| 87 for (var i = 0; i < dividersCount; ++i) { | 87 for (var i = 0; i < dividersCount; ++i) { |
| 88 var time = firstDividerTime + gridSliceTime * i; | 88 var time = firstDividerTime + gridSliceTime * i; |
| 89 if (calculator.computePosition(time) < freeZoneAtLeft) | 89 if (calculator.computePosition(time) < freeZoneAtLeft) |
| 90 continue; | 90 continue; |
| 91 offsets.push(time); | 91 offsets.push(time); |
| 92 } | 92 } |
| 93 | 93 |
| 94 return {offsets: offsets, precision: Math.max(0, -Math.floor(Math.log(gridSl
iceTime * 1.01) / Math.LN10))}; | 94 return {offsets: offsets, precision: Math.max(0, -Math.floor(Math.log(gridSl
iceTime * 1.01) / Math.LN10))}; |
| 95 } | 95 }; |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * @param {!HTMLCanvasElement} canvas | 98 * @param {!HTMLCanvasElement} canvas |
| 99 * @param {!WebInspector.TimelineGrid.Calculator} calculator | 99 * @param {!WebInspector.TimelineGrid.Calculator} calculator |
| 100 */ | 100 */ |
| 101 WebInspector.TimelineGrid.drawCanvasGrid = function(canvas, calculator) | 101 WebInspector.TimelineGrid.drawCanvasGrid = function(canvas, calculator) |
| 102 { | 102 { |
| 103 var context = canvas.getContext("2d"); | 103 var context = canvas.getContext("2d"); |
| 104 context.save(); | 104 context.save(); |
| 105 var ratio = window.devicePixelRatio; | 105 var ratio = window.devicePixelRatio; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 127 var position = calculator.computePosition(time); | 127 var position = calculator.computePosition(time); |
| 128 var text = calculator.formatValue(time, precision); | 128 var text = calculator.formatValue(time, precision); |
| 129 var textWidth = context.measureText(text).width; | 129 var textWidth = context.measureText(text).width; |
| 130 var textPosition = position - textWidth - paddingRight; | 130 var textPosition = position - textWidth - paddingRight; |
| 131 context.fillText(text, textPosition, paddingTop); | 131 context.fillText(text, textPosition, paddingTop); |
| 132 context.moveTo(position, 0); | 132 context.moveTo(position, 0); |
| 133 context.lineTo(position, height); | 133 context.lineTo(position, height); |
| 134 } | 134 } |
| 135 context.stroke(); | 135 context.stroke(); |
| 136 context.restore(); | 136 context.restore(); |
| 137 } | 137 }; |
| 138 | 138 |
| 139 WebInspector.TimelineGrid.prototype = { | 139 WebInspector.TimelineGrid.prototype = { |
| 140 get dividersElement() | 140 get dividersElement() |
| 141 { | 141 { |
| 142 return this._dividersElement; | 142 return this._dividersElement; |
| 143 }, | 143 }, |
| 144 | 144 |
| 145 get dividersLabelBarElement() | 145 get dividersLabelBarElement() |
| 146 { | 146 { |
| 147 return this._dividersLabelBarElement; | 147 return this._dividersLabelBarElement; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 }, | 256 }, |
| 257 | 257 |
| 258 /** | 258 /** |
| 259 * @param {number} scrollTop | 259 * @param {number} scrollTop |
| 260 */ | 260 */ |
| 261 setScrollTop: function(scrollTop) | 261 setScrollTop: function(scrollTop) |
| 262 { | 262 { |
| 263 this._dividersLabelBarElement.style.top = scrollTop + "px"; | 263 this._dividersLabelBarElement.style.top = scrollTop + "px"; |
| 264 this._eventDividersElement.style.top = scrollTop + "px"; | 264 this._eventDividersElement.style.top = scrollTop + "px"; |
| 265 } | 265 } |
| 266 } | 266 }; |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * @interface | 269 * @interface |
| 270 */ | 270 */ |
| 271 WebInspector.TimelineGrid.Calculator = function() { } | 271 WebInspector.TimelineGrid.Calculator = function() { }; |
| 272 | 272 |
| 273 WebInspector.TimelineGrid.Calculator.prototype = { | 273 WebInspector.TimelineGrid.Calculator.prototype = { |
| 274 /** | 274 /** |
| 275 * @return {number} | 275 * @return {number} |
| 276 */ | 276 */ |
| 277 paddingLeft: function() { }, | 277 paddingLeft: function() { }, |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * @param {number} time | 280 * @param {number} time |
| 281 * @return {number} | 281 * @return {number} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 293 minimumBoundary: function() { }, | 293 minimumBoundary: function() { }, |
| 294 | 294 |
| 295 /** @return {number} */ | 295 /** @return {number} */ |
| 296 zeroTime: function() { }, | 296 zeroTime: function() { }, |
| 297 | 297 |
| 298 /** @return {number} */ | 298 /** @return {number} */ |
| 299 maximumBoundary: function() { }, | 299 maximumBoundary: function() { }, |
| 300 | 300 |
| 301 /** @return {number} */ | 301 /** @return {number} */ |
| 302 boundarySpan: function() { } | 302 boundarySpan: function() { } |
| 303 } | 303 }; |
| OLD | NEW |