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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js

Issue 2242023002: DevTools: Timeline warning colors should scale with severity. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 /* 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 */ 382 */
383 update: function() 383 update: function()
384 { 384 {
385 WebInspector.TimelineEventOverview.prototype.update.call(this); 385 WebInspector.TimelineEventOverview.prototype.update.call(this);
386 var height = this._canvas.height; 386 var height = this._canvas.height;
387 var timeOffset = this._model.minimumRecordTime(); 387 var timeOffset = this._model.minimumRecordTime();
388 var timeSpan = this._model.maximumRecordTime() - timeOffset; 388 var timeSpan = this._model.maximumRecordTime() - timeOffset;
389 var scale = this._canvas.width / timeSpan; 389 var scale = this._canvas.width / timeSpan;
390 var frames = this._frameModel.frames(); 390 var frames = this._frameModel.frames();
391 var ctx = this._context; 391 var ctx = this._context;
392 var fillPath = new Path2D(); 392
393 var markersPath = new Path2D();
394 for (var i = 0; i < frames.length; ++i) { 393 for (var i = 0; i < frames.length; ++i) {
395 var frame = frames[i]; 394 var frame = frames[i];
396 if (!frame.hasWarnings()) 395 if (!frame.hasWarnings())
397 continue; 396 continue;
398 paintWarningDecoration(frame.startTime, frame.duration); 397 paintWarningDecoration(frame.startTime, frame.duration);
399 } 398 }
400 399
401 var events = this._model.mainThreadEvents(); 400 var events = this._model.mainThreadEvents();
402 for (var i = 0; i < events.length; ++i) { 401 for (var i = 0; i < events.length; ++i) {
403 if (!events[i].warning) 402 if (!events[i].warning)
404 continue; 403 continue;
405 paintWarningDecoration(events[i].startTime, events[i].duration); 404 paintWarningDecoration(events[i].startTime, events[i].duration);
406 } 405 }
407 406
408 ctx.fillStyle = "hsl(0, 80%, 90%)";
409 ctx.strokeStyle = "red";
410 ctx.lineWidth = 2 * window.devicePixelRatio;
411 ctx.fill(fillPath);
412 ctx.stroke(markersPath);
413 407
414 /** 408 /**
415 * @param {number} time 409 * @param {number} time
416 * @param {number} duration 410 * @param {number} duration
417 */ 411 */
418 function paintWarningDecoration(time, duration) 412 function paintWarningDecoration(time, duration)
419 { 413 {
420 var x = Math.round(scale * (time - timeOffset)); 414 var x = Math.round(scale * (time - timeOffset));
421 var w = Math.round(scale * duration); 415 var w = Math.round(scale * duration);
422 fillPath.rect(x, 0, w, height); 416 var markersPath = new Path2D();
423 markersPath.moveTo(x + w, 0); 417
424 markersPath.lineTo(x + w, height); 418 var overage = duration - 16;
caseq 2016/08/16 18:37:16 should we do it just for frames perhaps? how does
419 var intensity = Number.constrain(overage / (30 + overage), 0, 1).toF ixed(3);
420 ctx.fillStyle = `hsla(0, 80%, 85%, ${intensity})`;
421 ctx.fillRect(x, 0, w, height);
422
423 markersPath.moveTo(x, 0);
424 markersPath.lineTo(x + w, 0);
425 ctx.strokeStyle = `hsla(0, 80%, 45%, ${intensity})`;
426 ctx.lineWidth = 2 * window.devicePixelRatio;
427 ctx.stroke(markersPath);
425 } 428 }
426 }, 429 },
427 430
428 __proto__: WebInspector.TimelineEventOverview.prototype 431 __proto__: WebInspector.TimelineEventOverview.prototype
429 } 432 }
430 433
431 /** 434 /**
432 * @constructor 435 * @constructor
433 * @extends {WebInspector.TimelineEventOverview} 436 * @extends {WebInspector.TimelineEventOverview}
434 * @param {!WebInspector.TimelineModel} model 437 * @param {!WebInspector.TimelineModel} model
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 counters[group] = this._quantDuration; 815 counters[group] = this._quantDuration;
813 this._callback(counters); 816 this._callback(counters);
814 interval -= this._quantDuration; 817 interval -= this._quantDuration;
815 } 818 }
816 this._counters = []; 819 this._counters = [];
817 this._counters[group] = interval; 820 this._counters[group] = interval;
818 this._lastTime = time; 821 this._lastTime = time;
819 this._remainder = this._quantDuration - interval; 822 this._remainder = this._quantDuration - interval;
820 } 823 }
821 } 824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698