| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 offsets.push(time); | 90 offsets.push(time); |
| 91 } | 91 } |
| 92 | 92 |
| 93 return {offsets: offsets, precision: Math.max(0, -Math.floor(Math.log(gridSl
iceTime * 1.01) / Math.LN10))}; | 93 return {offsets: offsets, precision: Math.max(0, -Math.floor(Math.log(gridSl
iceTime * 1.01) / Math.LN10))}; |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * @param {!CanvasRenderingContext2D} context | 97 * @param {!CanvasRenderingContext2D} context |
| 98 * @param {!UI.TimelineGrid.Calculator} calculator | 98 * @param {!UI.TimelineGrid.Calculator} calculator |
| 99 * @param {number} paddingTop | 99 * @param {number} paddingTop |
| 100 * @param {number} headerHeight | 100 * @param {number=} headerHeight |
| 101 * @param {number=} freeZoneAtLeft | 101 * @param {number=} freeZoneAtLeft |
| 102 */ | 102 */ |
| 103 static drawCanvasGrid(context, calculator, paddingTop, headerHeight, freeZoneA
tLeft) { | 103 static drawCanvasGrid(context, calculator, paddingTop, headerHeight, freeZoneA
tLeft) { |
| 104 context.save(); | 104 context.save(); |
| 105 var ratio = window.devicePixelRatio; | 105 var ratio = window.devicePixelRatio; |
| 106 context.scale(ratio, ratio); | 106 context.scale(ratio, ratio); |
| 107 var width = context.canvas.width / window.devicePixelRatio; | 107 var width = context.canvas.width / window.devicePixelRatio; |
| 108 var height = context.canvas.height / window.devicePixelRatio; | 108 var height = context.canvas.height / window.devicePixelRatio; |
| 109 var dividersData = UI.TimelineGrid.calculateDividerOffsets(calculator); | 109 var dividersData = UI.TimelineGrid.calculateDividerOffsets(calculator); |
| 110 var dividerOffsets = dividersData.offsets; | 110 var dividerOffsets = dividersData.offsets; |
| 111 var precision = dividersData.precision; | 111 var precision = dividersData.precision; |
| 112 | 112 |
| 113 context.fillStyle = UI.themeSupport.patchColor('rgba(255, 255, 255, 0.5)', U
I.ThemeSupport.ColorUsage.Background); | 113 if (headerHeight) { |
| 114 context.fillRect(0, 0, width, headerHeight); | 114 context.fillStyle = UI.themeSupport.patchColor('rgba(255, 255, 255, 0.5)',
UI.ThemeSupport.ColorUsage.Background); |
| 115 context.fillRect(0, 0, width, headerHeight); |
| 116 } |
| 115 | 117 |
| 116 context.fillStyle = UI.themeSupport.patchColor('#333', UI.ThemeSupport.Color
Usage.Foreground); | 118 context.fillStyle = UI.themeSupport.patchColor('#333', UI.ThemeSupport.Color
Usage.Foreground); |
| 117 context.strokeStyle = UI.themeSupport.patchColor('rgba(0, 0, 0, 0.1)', UI.Th
emeSupport.ColorUsage.Foreground); | 119 context.strokeStyle = UI.themeSupport.patchColor('rgba(0, 0, 0, 0.1)', UI.Th
emeSupport.ColorUsage.Foreground); |
| 118 context.textBaseline = 'hanging'; | 120 context.textBaseline = 'hanging'; |
| 119 context.font = '11px ' + Host.fontFamily(); | 121 context.font = '11px ' + Host.fontFamily(); |
| 120 context.lineWidth = 1; | 122 context.lineWidth = 1; |
| 121 | 123 |
| 122 context.translate(0.5, 0.5); | 124 context.translate(0.5, 0.5); |
| 123 const paddingRight = 4; | 125 const paddingRight = 4; |
| 124 for (var i = 0; i < dividerOffsets.length; ++i) { | 126 for (var i = 0; i < dividerOffsets.length; ++i) { |
| 125 var time = dividerOffsets[i]; | 127 var time = dividerOffsets[i]; |
| 126 var position = calculator.computePosition(time); | 128 var position = calculator.computePosition(time); |
| 129 context.moveTo(position, 0); |
| 130 context.lineTo(position, height); |
| 131 if (!headerHeight) |
| 132 continue; |
| 127 var text = calculator.formatValue(time, precision); | 133 var text = calculator.formatValue(time, precision); |
| 128 var textWidth = context.measureText(text).width; | 134 var textWidth = context.measureText(text).width; |
| 129 var textPosition = position - textWidth - paddingRight; | 135 var textPosition = position - textWidth - paddingRight; |
| 130 if (!freeZoneAtLeft || freeZoneAtLeft < textPosition) | 136 if (!freeZoneAtLeft || freeZoneAtLeft < textPosition) |
| 131 context.fillText(text, textPosition, paddingTop); | 137 context.fillText(text, textPosition, paddingTop); |
| 132 context.moveTo(position, 0); | |
| 133 context.lineTo(position, height); | |
| 134 } | 138 } |
| 135 context.stroke(); | 139 context.stroke(); |
| 136 context.restore(); | 140 context.restore(); |
| 137 } | 141 } |
| 138 | 142 |
| 139 get dividersElement() { | 143 get dividersElement() { |
| 140 return this._dividersElement; | 144 return this._dividersElement; |
| 141 } | 145 } |
| 142 | 146 |
| 143 get dividersLabelBarElement() { | 147 get dividersLabelBarElement() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 286 |
| 283 /** @return {number} */ | 287 /** @return {number} */ |
| 284 zeroTime() {}, | 288 zeroTime() {}, |
| 285 | 289 |
| 286 /** @return {number} */ | 290 /** @return {number} */ |
| 287 maximumBoundary() {}, | 291 maximumBoundary() {}, |
| 288 | 292 |
| 289 /** @return {number} */ | 293 /** @return {number} */ |
| 290 boundarySpan() {} | 294 boundarySpan() {} |
| 291 }; | 295 }; |
| OLD | NEW |