| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   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 {!WebInspector.TimelineGrid.Calculator} calculator |   98    * @param {!WebInspector.TimelineGrid.Calculator} calculator | 
|   99    * @param {number} paddingTop |   99    * @param {number} paddingTop | 
|  100    * @param {number=} freeZoneAtLeft |  100    * @param {number=} freeZoneAtLeft | 
 |  101    * @param {number=} freeZoneAtRight | 
 |  102    * @param {string=} fontSize | 
|  101    */ |  103    */ | 
|  102   static drawCanvasGrid(context, calculator, paddingTop, freeZoneAtLeft) { |  104   static drawCanvasGrid(context, calculator, paddingTop, freeZoneAtLeft, freeZon
     eAtRight, fontSize) { | 
|  103     context.save(); |  105     context.save(); | 
|  104     var ratio = window.devicePixelRatio; |  106     var ratio = window.devicePixelRatio; | 
|  105     context.scale(ratio, ratio); |  107     context.scale(ratio, ratio); | 
|  106     var width = context.canvas.width / window.devicePixelRatio; |  108     var width = context.canvas.width / window.devicePixelRatio; | 
|  107     var height = context.canvas.height / window.devicePixelRatio; |  109     var height = context.canvas.height / window.devicePixelRatio; | 
|  108     var dividersData = WebInspector.TimelineGrid.calculateDividerOffsets(calcula
     tor); |  110     var dividersData = WebInspector.TimelineGrid.calculateDividerOffsets(calcula
     tor); | 
|  109     var dividerOffsets = dividersData.offsets; |  111     var dividerOffsets = dividersData.offsets; | 
|  110     var precision = dividersData.precision; |  112     var precision = dividersData.precision; | 
|  111  |  113  | 
|  112     context.fillStyle = 'rgba(255, 255, 255, 0.5)'; |  114     context.fillStyle = 'rgba(255, 255, 255, 0.5)'; | 
|  113     context.fillRect(0, 0, width, 15); |  115     context.fillRect(0, 0, width, 15); | 
|  114  |  116  | 
|  115     context.fillStyle = '#333'; |  117     context.fillStyle = '#333'; | 
|  116     context.strokeStyle = 'rgba(0, 0, 0, 0.1)'; |  118     context.strokeStyle = 'rgba(0, 0, 0, 0.1)'; | 
|  117     context.textBaseline = 'hanging'; |  119     context.textBaseline = 'hanging'; | 
|  118     context.font = '11px ' + WebInspector.fontFamily(); |  120     if (!fontSize) | 
 |  121       fontSize = '11px'; | 
 |  122     context.font = fontSize + ' ' + WebInspector.fontFamily(); | 
|  119     context.lineWidth = 1; |  123     context.lineWidth = 1; | 
|  120  |  124  | 
|  121     context.translate(0.5, 0.5); |  125     context.translate(0.5, 0.5); | 
|  122     const paddingRight = 4; |  126     const paddingRight = 4; | 
|  123     freeZoneAtLeft = freeZoneAtLeft || 0; |  127     freeZoneAtLeft = freeZoneAtLeft || 0; | 
 |  128     freeZoneAtRight = freeZoneAtRight || 0; | 
|  124     for (var i = 0; i < dividerOffsets.length; ++i) { |  129     for (var i = 0; i < dividerOffsets.length; ++i) { | 
|  125       var time = dividerOffsets[i]; |  130       var time = dividerOffsets[i]; | 
|  126       var position = calculator.computePosition(time); |  131       var position = calculator.computePosition(time); | 
|  127       var text = calculator.formatValue(time, precision); |  132       var text = calculator.formatValue(time, precision); | 
|  128       var textWidth = context.measureText(text).width; |  133       var textWidth = context.measureText(text).width; | 
|  129       var textPosition = position - textWidth - paddingRight; |  134       var textPosition = position - textWidth - paddingRight; | 
|  130       if (freeZoneAtLeft < textPosition) |  135       if (freeZoneAtLeft < textPosition && width - freeZoneAtRight > textPositio
     n + textWidth) | 
|  131         context.fillText(text, textPosition, paddingTop); |  136         context.fillText(text, textPosition, paddingTop); | 
|  132       context.moveTo(position, 0); |  137       context.moveTo(position, 0); | 
|  133       context.lineTo(position, height); |  138       context.lineTo(position, height); | 
|  134     } |  139     } | 
|  135     context.stroke(); |  140     context.stroke(); | 
|  136     context.restore(); |  141     context.restore(); | 
|  137   } |  142   } | 
|  138  |  143  | 
|  139   get dividersElement() { |  144   get dividersElement() { | 
|  140     return this._dividersElement; |  145     return this._dividersElement; | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  282  |  287  | 
|  283   /** @return {number} */ |  288   /** @return {number} */ | 
|  284   zeroTime: function() {}, |  289   zeroTime: function() {}, | 
|  285  |  290  | 
|  286   /** @return {number} */ |  291   /** @return {number} */ | 
|  287   maximumBoundary: function() {}, |  292   maximumBoundary: function() {}, | 
|  288  |  293  | 
|  289   /** @return {number} */ |  294   /** @return {number} */ | 
|  290   boundarySpan: function() {} |  295   boundarySpan: function() {} | 
|  291 }; |  296 }; | 
| OLD | NEW |