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

Side by Side Diff: Source/devtools/front_end/TimelineOverviewPane.js

Issue 20066005: DevTools: [Timeline] Reset Memory Overview pane when clear button is clicked (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove redundant _clear Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 WebInspector.TimelineOverviewBase.call(this, model); 456 WebInspector.TimelineOverviewBase.call(this, model);
457 this.element.id = "timeline-overview-memory"; 457 this.element.id = "timeline-overview-memory";
458 458
459 this._maxHeapSizeLabel = this.element.createChild("div", "max memory-graph-l abel"); 459 this._maxHeapSizeLabel = this.element.createChild("div", "max memory-graph-l abel");
460 this._minHeapSizeLabel = this.element.createChild("div", "min memory-graph-l abel"); 460 this._minHeapSizeLabel = this.element.createChild("div", "min memory-graph-l abel");
461 } 461 }
462 462
463 WebInspector.TimelineMemoryOverview.prototype = { 463 WebInspector.TimelineMemoryOverview.prototype = {
464 update: function() 464 update: function()
465 { 465 {
466 this._resetCanvas();
467
466 var records = this._model.records; 468 var records = this._model.records;
467 if (!records.length) 469 if (!records.length)
468 return; 470 return;
469 471
470 this._resetCanvas();
471
472 const lowerOffset = 3; 472 const lowerOffset = 3;
473 var maxUsedHeapSize = 0; 473 var maxUsedHeapSize = 0;
474 var minUsedHeapSize = 100000000000; 474 var minUsedHeapSize = 100000000000;
475 var minTime = this._model.minimumRecordTime(); 475 var minTime = this._model.minimumRecordTime();
476 var maxTime = this._model.maximumRecordTime(); 476 var maxTime = this._model.maximumRecordTime();
477 WebInspector.TimelinePresentationModel.forAllRecords(records, function(r ) { 477 WebInspector.TimelinePresentationModel.forAllRecords(records, function(r ) {
478 maxUsedHeapSize = Math.max(maxUsedHeapSize, r.usedHeapSize || maxUse dHeapSize); 478 maxUsedHeapSize = Math.max(maxUsedHeapSize, r.usedHeapSize || maxUse dHeapSize);
479 minUsedHeapSize = Math.min(minUsedHeapSize, r.usedHeapSize || minUse dHeapSize); 479 minUsedHeapSize = Math.min(minUsedHeapSize, r.usedHeapSize || minUse dHeapSize);
480 }); 480 });
481 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize); 481 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize);
482 482
483 var width = this._canvas.width; 483 var width = this._canvas.width;
484 var height = this._canvas.height - lowerOffset; 484 var height = this._canvas.height - lowerOffset;
485 var xFactor = width / (maxTime - minTime); 485 var xFactor = width / (maxTime - minTime);
486 var yFactor = height / Math.max(maxUsedHeapSize - minUsedHeapSize, 1); 486 var yFactor = height / Math.max(maxUsedHeapSize - minUsedHeapSize, 1);
487 487
488 var histogram = new Array(width); 488 var histogram = new Array(width);
489 WebInspector.TimelinePresentationModel.forAllRecords(records, function(r ) { 489 WebInspector.TimelinePresentationModel.forAllRecords(records, function(r ) {
490 if (!r.usedHeapSize) 490 if (!r.usedHeapSize)
491 return; 491 return;
492 var x = Math.round((WebInspector.TimelineModel.endTimeInSeconds(r) - minTime) * xFactor); 492 var x = Math.round((WebInspector.TimelineModel.endTimeInSeconds(r) - minTime) * xFactor);
493 var y = Math.round((r.usedHeapSize - minUsedHeapSize) * yFactor); 493 var y = Math.round((r.usedHeapSize - minUsedHeapSize) * yFactor);
494 histogram[x] = Math.max(histogram[x] || 0, y); 494 histogram[x] = Math.max(histogram[x] || 0, y);
495 }); 495 });
496 496
497 var ctx = this._context;
498 this._clear(ctx);
499
500 height++; // +1 so that the border always fit into the canvas area. 497 height++; // +1 so that the border always fit into the canvas area.
501 498
502 var y = 0; 499 var y = 0;
503 var isFirstPoint = true; 500 var isFirstPoint = true;
501 var ctx = this._context;
504 ctx.beginPath(); 502 ctx.beginPath();
505 ctx.moveTo(0, this._canvas.height); 503 ctx.moveTo(0, this._canvas.height);
506 for (var x = 0; x < histogram.length; x++) { 504 for (var x = 0; x < histogram.length; x++) {
507 if (typeof histogram[x] === "undefined") 505 if (typeof histogram[x] === "undefined")
508 continue; 506 continue;
509 if (isFirstPoint) { 507 if (isFirstPoint) {
510 isFirstPoint = false; 508 isFirstPoint = false;
511 y = histogram[x]; 509 y = histogram[x];
512 ctx.lineTo(0, height - y); 510 ctx.lineTo(0, height - y);
513 } 511 }
(...skipping 10 matching lines...) Expand all
524 ctx.strokeStyle = "rgba(20,0,0,0.8)"; 522 ctx.strokeStyle = "rgba(20,0,0,0.8)";
525 ctx.stroke(); 523 ctx.stroke();
526 524
527 ctx.fillStyle = "rgba(214,225,254, 0.8);"; 525 ctx.fillStyle = "rgba(214,225,254, 0.8);";
528 ctx.fill(); 526 ctx.fill();
529 527
530 this._maxHeapSizeLabel.textContent = Number.bytesToString(maxUsedHeapSiz e); 528 this._maxHeapSizeLabel.textContent = Number.bytesToString(maxUsedHeapSiz e);
531 this._minHeapSizeLabel.textContent = Number.bytesToString(minUsedHeapSiz e); 529 this._minHeapSizeLabel.textContent = Number.bytesToString(minUsedHeapSiz e);
532 }, 530 },
533 531
534 _clear: function(ctx)
535 {
536 ctx.fillStyle = "rgba(255,255,255,0.8)";
537 ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);
538 },
539
540 __proto__: WebInspector.TimelineOverviewBase.prototype 532 __proto__: WebInspector.TimelineOverviewBase.prototype
541 } 533 }
542 534
543 /** 535 /**
544 * @constructor 536 * @constructor
545 * @extends {WebInspector.TimelineOverviewBase} 537 * @extends {WebInspector.TimelineOverviewBase}
546 * @param {WebInspector.TimelineModel} model 538 * @param {WebInspector.TimelineModel} model
547 */ 539 */
548 WebInspector.TimelineEventOverview = function(model) 540 WebInspector.TimelineEventOverview = function(model)
549 { 541 {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 WebInspector.TimelineWindowFilter.prototype = { 955 WebInspector.TimelineWindowFilter.prototype = {
964 /** 956 /**
965 * @param {!WebInspector.TimelinePresentationModel.Record} record 957 * @param {!WebInspector.TimelinePresentationModel.Record} record
966 * @return {boolean} 958 * @return {boolean}
967 */ 959 */
968 accept: function(record) 960 accept: function(record)
969 { 961 {
970 return record.lastChildEndTime >= this._pane._windowStartTime && record. startTime <= this._pane._windowEndTime; 962 return record.lastChildEndTime >= this._pane._windowStartTime && record. startTime <= this._pane._windowEndTime;
971 } 963 }
972 } 964 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698