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

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

Issue 184823002: DevTools: do not cache details node, remove linkifier from presentation record. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review comments addressed. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 WebInspector.TimelineUIUtils.generatePopupContentForFrameStatistics = function(s tatistics) 370 WebInspector.TimelineUIUtils.generatePopupContentForFrameStatistics = function(s tatistics)
371 { 371 {
372 /** 372 /**
373 * @param {number} time 373 * @param {number} time
374 */ 374 */
375 function formatTimeAndFPS(time) 375 function formatTimeAndFPS(time)
376 { 376 {
377 return WebInspector.UIString("%s (%.0f FPS)", Number.millisToString(time , true), 1 / time); 377 return WebInspector.UIString("%s (%.0f FPS)", Number.millisToString(time , true), 1 / time);
378 } 378 }
379 379
380 var contentHelper = new WebInspector.TimelineDetailsContentHelper(false); 380 var contentHelper = new WebInspector.TimelineDetailsContentHelper(new WebIns pector.Linkifier(), false);
381 contentHelper.appendTextRow(WebInspector.UIString("Minimum Time"), formatTim eAndFPS(statistics.minDuration)); 381 contentHelper.appendTextRow(WebInspector.UIString("Minimum Time"), formatTim eAndFPS(statistics.minDuration));
382 contentHelper.appendTextRow(WebInspector.UIString("Average Time"), formatTim eAndFPS(statistics.average)); 382 contentHelper.appendTextRow(WebInspector.UIString("Average Time"), formatTim eAndFPS(statistics.average));
383 contentHelper.appendTextRow(WebInspector.UIString("Maximum Time"), formatTim eAndFPS(statistics.maxDuration)); 383 contentHelper.appendTextRow(WebInspector.UIString("Maximum Time"), formatTim eAndFPS(statistics.maxDuration));
384 contentHelper.appendTextRow(WebInspector.UIString("Standard Deviation"), Num ber.millisToString(statistics.stddev, true)); 384 contentHelper.appendTextRow(WebInspector.UIString("Standard Deviation"), Num ber.millisToString(statistics.stddev, true));
385 385
386 return contentHelper.element; 386 return contentHelper.element;
387 } 387 }
388 388
389 /** 389 /**
390 * @param {!CanvasRenderingContext2D} context 390 * @param {!CanvasRenderingContext2D} context
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 appendTextRow: function(title, content) 520 appendTextRow: function(title, content)
521 { 521 {
522 var row = document.createElement("tr"); 522 var row = document.createElement("tr");
523 row.appendChild(this._createCell(title, "timeline-details-row-title")); 523 row.appendChild(this._createCell(title, "timeline-details-row-title"));
524 row.appendChild(this._createCell(content, "timeline-details-row-data")); 524 row.appendChild(this._createCell(content, "timeline-details-row-data"));
525 this._contentTable.appendChild(row); 525 this._contentTable.appendChild(row);
526 }, 526 },
527 527
528 /** 528 /**
529 * @param {string} title 529 * @param {string} title
530 * @param {!Element|string} content 530 * @param {!Node|string} content
531 */ 531 */
532 appendElementRow: function(title, content) 532 appendElementRow: function(title, content)
533 { 533 {
534 var row = document.createElement("tr"); 534 var row = document.createElement("tr");
535 var titleCell = this._createCell(title, "timeline-details-row-title"); 535 var titleCell = this._createCell(title, "timeline-details-row-title");
536 row.appendChild(titleCell); 536 row.appendChild(titleCell);
537 var cell = document.createElement("td"); 537 var cell = document.createElement("td");
538 cell.className = "details"; 538 cell.className = "details";
539 if (content instanceof Node) 539 if (content instanceof Node)
540 cell.appendChild(content); 540 cell.appendChild(content);
541 else 541 else
542 cell.createTextChild(content || ""); 542 cell.createTextChild(content || "");
543 row.appendChild(cell); 543 row.appendChild(cell);
544 this._contentTable.appendChild(row); 544 this._contentTable.appendChild(row);
545 } 545 }
546 } 546 }
547 547
548 /** 548 /**
549 * @constructor 549 * @constructor
550 * @param {!WebInspector.Linkifier} linkifier
550 * @param {boolean} monospaceValues 551 * @param {boolean} monospaceValues
551 */ 552 */
552 WebInspector.TimelineDetailsContentHelper = function(monospaceValues) 553 WebInspector.TimelineDetailsContentHelper = function(linkifier, monospaceValues)
553 { 554 {
555 this._linkifier = linkifier;
554 this.element = document.createElement("div"); 556 this.element = document.createElement("div");
555 this.element.className = "timeline-details-view-block"; 557 this.element.className = "timeline-details-view-block";
556 this._monospaceValues = monospaceValues; 558 this._monospaceValues = monospaceValues;
557 } 559 }
558 560
559 WebInspector.TimelineDetailsContentHelper.prototype = { 561 WebInspector.TimelineDetailsContentHelper.prototype = {
560 /** 562 /**
561 * @param {string} title 563 * @param {string} title
562 * @param {string|number|boolean} value 564 * @param {string|number|boolean} value
563 */ 565 */
564 appendTextRow: function(title, value) 566 appendTextRow: function(title, value)
565 { 567 {
566 var rowElement = this.element.createChild("div", "timeline-details-view- row"); 568 var rowElement = this.element.createChild("div", "timeline-details-view- row");
567 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title); 569 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title);
568 rowElement.createChild("span", "timeline-details-view-row-value" + (this ._monospaceValues ? " monospace" : "")).textContent = value; 570 rowElement.createChild("span", "timeline-details-view-row-value" + (this ._monospaceValues ? " monospace" : "")).textContent = value;
569 }, 571 },
570 572
571 /** 573 /**
572 * @param {string} title 574 * @param {string} title
573 * @param {!Element|string} content 575 * @param {!Node|string} content
574 */ 576 */
575 appendElementRow: function(title, content) 577 appendElementRow: function(title, content)
576 { 578 {
577 var rowElement = this.element.createChild("div", "timeline-details-view- row"); 579 var rowElement = this.element.createChild("div", "timeline-details-view- row");
578 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title); 580 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title);
579 var valueElement = rowElement.createChild("span", "timeline-details-view -row-details" + (this._monospaceValues ? " monospace" : "")); 581 var valueElement = rowElement.createChild("span", "timeline-details-view -row-details" + (this._monospaceValues ? " monospace" : ""));
580 if (content instanceof Node) 582 if (content instanceof Node)
581 valueElement.appendChild(content); 583 valueElement.appendChild(content);
582 else 584 else
583 valueElement.createTextChild(content || ""); 585 valueElement.createTextChild(content || "");
584 }, 586 },
585 587
586 /** 588 /**
587 * @param {string} title 589 * @param {string} title
590 * @param {string} url
591 * @param {number} line
592 */
593 appendLocationRow: function(title, url, line)
594 {
595 this.appendElementRow(title, this._linkifier.linkifyLocation(url, line - 1) || "");
596 },
597
598 /**
599 * @param {string} title
588 * @param {!Array.<!ConsoleAgent.CallFrame>} stackTrace 600 * @param {!Array.<!ConsoleAgent.CallFrame>} stackTrace
589 * @param {function(!ConsoleAgent.CallFrame)} callFrameLinkifier
590 */ 601 */
591 appendStackTrace: function(title, stackTrace, callFrameLinkifier) 602 appendStackTrace: function(title, stackTrace)
592 { 603 {
593 var rowElement = this.element.createChild("div", "timeline-details-view- row"); 604 var rowElement = this.element.createChild("div", "timeline-details-view- row");
594 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title); 605 rowElement.createChild("span", "timeline-details-view-row-title").textCo ntent = WebInspector.UIString("%s: ", title);
595 var stackTraceElement = rowElement.createChild("div", "timeline-details- view-row-stack-trace monospace"); 606 var stackTraceElement = rowElement.createChild("div", "timeline-details- view-row-stack-trace monospace");
596 607
597 for (var i = 0; i < stackTrace.length; ++i) { 608 for (var i = 0; i < stackTrace.length; ++i) {
598 var stackFrame = stackTrace[i]; 609 var stackFrame = stackTrace[i];
599 var row = stackTraceElement.createChild("div"); 610 var row = stackTraceElement.createChild("div");
600 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)")); 611 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)"));
601 row.createTextChild(" @ "); 612 row.createTextChild(" @ ");
602 var urlElement = callFrameLinkifier(stackFrame); 613 var urlElement = this._linkifier.linkifyLocation(stackFrame.url, sta ckFrame.lineNumber - 1);
603 row.appendChild(urlElement); 614 row.appendChild(urlElement);
604 } 615 }
605 } 616 }
606 } 617 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/TimelinePresentationModel.js ('k') | Source/devtools/front_end/TimelineView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698