Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkTimelineColumn.js

Issue 2418623002: [Devtools] Added divider timing to network timeline expirement (Closed)
Patch Set: [Devtools] Added divider timeing to network timeline expirement Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @param {!WebInspector.NetworkLogView} networkLogView 8 * @param {!WebInspector.NetworkLogView} networkLogView
9 * @param {!WebInspector.SortableDataGrid} dataGrid 9 * @param {!WebInspector.SortableDataGrid} dataGrid
10 */ 10 */
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 var ranges = WebInspector.RequestTimingView.calculateRequestTimeRang es(request, 0); 242 var ranges = WebInspector.RequestTimingView.calculateRequestTimeRang es(request, 0);
243 for (var range of ranges) { 243 for (var range of ranges) {
244 if (range.name === WebInspector.RequestTimeRangeNames.Total || 244 if (range.name === WebInspector.RequestTimeRangeNames.Total ||
245 range.name === WebInspector.RequestTimeRangeNames.Sending || 245 range.name === WebInspector.RequestTimeRangeNames.Sending ||
246 range.end - range.start === 0) 246 range.end - range.start === 0)
247 continue; 247 continue;
248 this._drawBar(context, range, rowOffset - scrollTop); 248 this._drawBar(context, range, rowOffset - scrollTop);
249 } 249 }
250 } 250 }
251 context.restore(); 251 context.restore();
252 this._drawDividers(context);
253 },
254
255 _drawDividers: function(context)
allada 2016/10/12 21:02:56 This function is to replace: https://cs.chromium.o
256 {
257 context.save();
258 /** @const */
259 var minGridSlicePx = 64; // minimal distance between grid lines.
260 /** @const */
261 var fontSize = 10;
262
263 var drawableWidth = this._offsetWidth - this._leftPadding - this._rightP adding;
264 var timelineDuration = this._timelineDuration();
265 var dividersCount = drawableWidth / minGridSlicePx;
266 var gridSliceTime = timelineDuration / dividersCount;
267 var pixelsPerTime = drawableWidth / timelineDuration;
268
269 // Align gridSliceTime to a nearest round value.
270 // We allow spans that fit into the formula: span = (1|2|5)x10^n,
271 // e.g.: ... .1 .2 .5 1 2 5 10 20 50 ...
272 // After a span has been chosen make grid lines at multiples of the span .
273
274 var logGridSliceTime = Math.ceil(Math.log(gridSliceTime) / Math.LN10);
275 gridSliceTime = Math.pow(10, logGridSliceTime);
276 if (gridSliceTime * pixelsPerTime >= 5 * minGridSlicePx)
277 gridSliceTime = gridSliceTime / 5;
278 if (gridSliceTime * pixelsPerTime >= 2 * minGridSlicePx)
279 gridSliceTime = gridSliceTime / 2;
280
281 context.lineWidth = 1;
282 context.strokeStyle = "rgba(0, 0, 0, .1)";
283 context.font = fontSize + "px sans-serif";
284 context.fillStyle = "#444"
285 gridSliceTime = gridSliceTime;
286 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi dth; position += gridSliceTime * pixelsPerTime) {
287 // Added .5 because canvas drawing points are between pixels.
288 var drawPosition = Math.floor(position) + this._leftPadding + .5;
289 context.beginPath();
290 context.moveTo(drawPosition, 0);
291 context.lineTo(drawPosition, this._offsetHeight);
292 context.stroke();
293 if (position <= gridSliceTime * pixelsPerTime)
294 continue;
295 var textData = Number.secondsToString(position / pixelsPerTime);
296 context.fillText(textData, drawPosition - context.measureText(textDa ta).width - 2, Math.floor(this._networkLogView.headerHeight() - fontSize / 2));
297 }
298 context.restore();
252 }, 299 },
253 300
254 /** 301 /**
255 * @return {number} 302 * @return {number}
256 */ 303 */
257 _timelineDuration: function() 304 _timelineDuration: function()
258 { 305 {
259 return this._networkLogView.calculator().maximumBoundary() - this._netwo rkLogView.calculator().minimumBoundary(); 306 return this._networkLogView.calculator().maximumBoundary() - this._netwo rkLogView.calculator().minimumBoundary();
260 }, 307 },
261 308
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 color = this._rowHoverColor; 378 color = this._rowHoverColor;
332 379
333 context.fillStyle = color; 380 context.fillStyle = color;
334 context.rect(0, y, this._offsetWidth, rowHeight); 381 context.rect(0, y, this._offsetWidth, rowHeight);
335 context.fill(); 382 context.fill();
336 context.restore(); 383 context.restore();
337 }, 384 },
338 385
339 __proto__: WebInspector.VBox.prototype 386 __proto__: WebInspector.VBox.prototype
340 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698