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

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

Issue 717243002: Timeline: do not imply event.thread.target is the main target (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: avoid keep stale model in TimelineFrameModel Created 6 years, 1 month 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 * @param {!WebInspector.TracingModel.Event} event 257 * @param {!WebInspector.TracingModel.Event} event
258 * @return {boolean} 258 * @return {boolean}
259 */ 259 */
260 WebInspector.TimelineUIUtils.isTallMarkerEvent = function(event) 260 WebInspector.TimelineUIUtils.isTallMarkerEvent = function(event)
261 { 261 {
262 return event.name !== WebInspector.TimelineModel.RecordType.TimeStamp; 262 return event.name !== WebInspector.TimelineModel.RecordType.TimeStamp;
263 } 263 }
264 264
265 /** 265 /**
266 * @param {!WebInspector.TracingModel.Event} event 266 * @param {!WebInspector.TracingModel.Event} event
267 * @param {?WebInspector.Target} target
267 * @param {!WebInspector.Linkifier} linkifier 268 * @param {!WebInspector.Linkifier} linkifier
268 * @return {?Node} 269 * @return {?Node}
269 */ 270 */
270 WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, lin kifier) 271 WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar get, linkifier)
271 { 272 {
272 var recordType = WebInspector.TimelineModel.RecordType; 273 var recordType = WebInspector.TimelineModel.RecordType;
273 var target = event.thread.target();
274 var details; 274 var details;
275 var detailsText; 275 var detailsText;
276 var eventData = event.args["data"]; 276 var eventData = event.args["data"];
277 switch (event.name) { 277 switch (event.name) {
278 case recordType.GCEvent: 278 case recordType.GCEvent:
279 var delta = event.args["usedHeapSizeBefore"] - event.args["usedHeapSizeA fter"]; 279 var delta = event.args["usedHeapSizeBefore"] - event.args["usedHeapSizeA fter"];
280 detailsText = WebInspector.UIString("%s collected", Number.bytesToString (delta)); 280 detailsText = WebInspector.UIString("%s collected", Number.bytesToString (delta));
281 break; 281 break;
282 case recordType.TimerFire: 282 case recordType.TimerFire:
283 detailsText = eventData["timerId"]; 283 detailsText = eventData["timerId"];
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 397 }
398 398
399 /** 399 /**
400 * @param {!WebInspector.TracingModel.Event} event 400 * @param {!WebInspector.TracingModel.Event} event
401 * @param {!WebInspector.TimelineModel} model 401 * @param {!WebInspector.TimelineModel} model
402 * @param {!WebInspector.Linkifier} linkifier 402 * @param {!WebInspector.Linkifier} linkifier
403 * @param {function(!DocumentFragment)} callback 403 * @param {function(!DocumentFragment)} callback
404 */ 404 */
405 WebInspector.TimelineUIUtils.buildTraceEventDetails = function(event, model, lin kifier, callback) 405 WebInspector.TimelineUIUtils.buildTraceEventDetails = function(event, model, lin kifier, callback)
406 { 406 {
407 var target = event.thread.target(); 407 var target = model.target();
408 if (!target) {
409 callbackWrapper();
410 return;
411 }
408 var relatedNode = null; 412 var relatedNode = null;
409 var barrier = new CallbackBarrier(); 413 var barrier = new CallbackBarrier();
410 if (!event.previewElement) { 414 if (!event.previewElement) {
411 if (event.imageURL && target) 415 if (event.imageURL)
412 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage)); 416 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage));
413 else if (event.picture) 417 else if (event.picture)
414 WebInspector.TimelineUIUtils.buildPicturePreviewContent(event, barri er.createCallback(saveImage)); 418 WebInspector.TimelineUIUtils.buildPicturePreviewContent(event, targe t, barrier.createCallback(saveImage));
415 } 419 }
416 if (event.backendNodeId && target) 420 if (event.backendNodeId)
417 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode)); 421 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode));
418 if (event.invalidationTrackingEvents) 422 if (event.invalidationTrackingEvents)
419 WebInspector.TimelineUIUtils._pushInvalidationNodeIdsToFrontend(event, b arrier.createCallback(updateInvalidationNodeIds)); 423 WebInspector.TimelineUIUtils._pushInvalidationNodeIdsToFrontend(event, t arget, barrier.createCallback(updateInvalidationNodeIds));
420 barrier.callWhenDone(callbackWrapper); 424 barrier.callWhenDone(callbackWrapper);
421 425
422 /** 426 /**
423 * @param {!Element=} element 427 * @param {!Element=} element
424 */ 428 */
425 function saveImage(element) 429 function saveImage(element)
426 { 430 {
427 event.previewElement = element || null; 431 event.previewElement = element || null;
428 } 432 }
429 433
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 497
494 var pieChart = hasChildren ? 498 var pieChart = hasChildren ?
495 WebInspector.TimelineUIUtils.generatePieChart(stats, selfCategory, selfT ime) : 499 WebInspector.TimelineUIUtils.generatePieChart(stats, selfCategory, selfT ime) :
496 WebInspector.TimelineUIUtils.generatePieChart(stats); 500 WebInspector.TimelineUIUtils.generatePieChart(stats);
497 501
498 var recordTypes = WebInspector.TimelineModel.RecordType; 502 var recordTypes = WebInspector.TimelineModel.RecordType;
499 503
500 // This message may vary per event.name; 504 // This message may vary per event.name;
501 var relatedNodeLabel; 505 var relatedNodeLabel;
502 506
503 var contentHelper = new WebInspector.TimelineDetailsContentHelper(event.thre ad.target(), linkifier, true); 507 var contentHelper = new WebInspector.TimelineDetailsContentHelper(model.targ et(), linkifier, true);
504 contentHelper.appendTextRow(WebInspector.UIString("Type"), WebInspector.Time lineUIUtils.eventTitle(event, model)); 508 contentHelper.appendTextRow(WebInspector.UIString("Type"), WebInspector.Time lineUIUtils.eventTitle(event, model));
505 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.milli sToString(event.selfTime, true)); 509 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.milli sToString(event.selfTime, true));
506 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number.mill isToString((event.startTime - model.minimumRecordTime()))); 510 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number.mill isToString((event.startTime - model.minimumRecordTime())));
507 contentHelper.appendElementRow(WebInspector.UIString("Aggregated Time"), pie Chart); 511 contentHelper.appendElementRow(WebInspector.UIString("Aggregated Time"), pie Chart);
508 var eventData = event.args["data"]; 512 var eventData = event.args["data"];
509 var initiator = event.initiator; 513 var initiator = event.initiator;
510 514
511 switch (event.name) { 515 switch (event.name) {
512 case recordTypes.GCEvent: 516 case recordTypes.GCEvent:
513 var delta = event.args["usedHeapSizeBefore"] - event.args["usedHeapSizeA fter"]; 517 var delta = event.args["usedHeapSizeBefore"] - event.args["usedHeapSizeA fter"];
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 contentHelper.appendTextRow(WebInspector.UIString("URL"), initiatorD ata["webSocketURL"]); 604 contentHelper.appendTextRow(WebInspector.UIString("URL"), initiatorD ata["webSocketURL"]);
601 if (typeof initiatorData["webSocketProtocol"] !== "undefined") 605 if (typeof initiatorData["webSocketProtocol"] !== "undefined")
602 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protoco l"), initiatorData["webSocketProtocol"]); 606 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protoco l"), initiatorData["webSocketProtocol"]);
603 if (typeof eventData["message"] !== "undefined") 607 if (typeof eventData["message"] !== "undefined")
604 contentHelper.appendTextRow(WebInspector.UIString("Message"), eventD ata["message"]); 608 contentHelper.appendTextRow(WebInspector.UIString("Message"), eventD ata["message"]);
605 break; 609 break;
606 case recordTypes.EmbedderCallback: 610 case recordTypes.EmbedderCallback:
607 contentHelper.appendTextRow(WebInspector.UIString("Callback Function"), eventData["callbackName"]); 611 contentHelper.appendTextRow(WebInspector.UIString("Callback Function"), eventData["callbackName"]);
608 break; 612 break;
609 default: 613 default:
610 var detailsNode = WebInspector.TimelineUIUtils.buildDetailsNodeForTraceE vent(event, linkifier); 614 var detailsNode = WebInspector.TimelineUIUtils.buildDetailsNodeForTraceE vent(event, model.target(), linkifier);
611 if (detailsNode) 615 if (detailsNode)
612 contentHelper.appendElementRow(WebInspector.UIString("Details"), det ailsNode); 616 contentHelper.appendElementRow(WebInspector.UIString("Details"), det ailsNode);
613 break; 617 break;
614 } 618 }
615 619
616 if (relatedNode) 620 if (relatedNode)
617 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UIString ("Related node"), WebInspector.DOMPresentationUtils.linkifyNodeReference(related Node)); 621 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UIString ("Related node"), WebInspector.DOMPresentationUtils.linkifyNodeReference(related Node));
618 622
619 if (eventData && eventData["scriptName"] && event.name !== recordTypes.Funct ionCall) 623 if (eventData && eventData["scriptName"] && event.name !== recordTypes.Funct ionCall)
620 contentHelper.appendLocationRow(WebInspector.UIString("Function Call"), eventData["scriptName"], eventData["scriptLine"]); 624 contentHelper.appendLocationRow(WebInspector.UIString("Function Call"), eventData["scriptName"], eventData["scriptLine"]);
621 625
622 var warning = event.warning; 626 var warning = event.warning;
623 if (warning) { 627 if (warning) {
624 var div = createElement("div"); 628 var div = createElement("div");
625 div.textContent = warning; 629 div.textContent = warning;
626 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div); 630 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div);
627 } 631 }
628 if (event.previewElement) 632 if (event.previewElement)
629 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement); 633 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement);
630 634
631 if (event.stackTrace || (event.initiator && event.initiator.stackTrace) || e vent.invalidationTrackingEvents) 635 if (event.stackTrace || (event.initiator && event.initiator.stackTrace) || e vent.invalidationTrackingEvents)
632 WebInspector.TimelineUIUtils._generateCauses(event, contentHelper); 636 WebInspector.TimelineUIUtils._generateCauses(event, model.target(), cont entHelper);
633 637
634 fragment.appendChild(contentHelper.element); 638 fragment.appendChild(contentHelper.element);
635 639
636 return fragment; 640 return fragment;
637 } 641 }
638 642
639 /** 643 /**
640 * @param {!WebInspector.TracingModel.Event} event 644 * @param {!WebInspector.TracingModel.Event} event
645 * @param {?WebInspector.Target} target
641 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper 646 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper
642 */ 647 */
643 WebInspector.TimelineUIUtils._generateCauses = function(event, contentHelper) 648 WebInspector.TimelineUIUtils._generateCauses = function(event, target, contentHe lper)
644 { 649 {
645 var recordTypes = WebInspector.TimelineModel.RecordType; 650 var recordTypes = WebInspector.TimelineModel.RecordType;
646 651
647 var callSiteStackLabel; 652 var callSiteStackLabel;
648 var stackLabel; 653 var stackLabel;
649 var initiator = event.initiator; 654 var initiator = event.initiator;
650 655
651 switch (event.name) { 656 switch (event.name) {
652 case recordTypes.TimerFire: 657 case recordTypes.TimerFire:
653 callSiteStackLabel = WebInspector.UIString("Timer installed"); 658 callSiteStackLabel = WebInspector.UIString("Timer installed");
654 break; 659 break;
655 case recordTypes.FireAnimationFrame: 660 case recordTypes.FireAnimationFrame:
656 callSiteStackLabel = WebInspector.UIString("Animation frame requested"); 661 callSiteStackLabel = WebInspector.UIString("Animation frame requested");
657 break; 662 break;
658 case recordTypes.RecalculateStyles: 663 case recordTypes.RecalculateStyles:
659 stackLabel = WebInspector.UIString("Recalculation was forced"); 664 stackLabel = WebInspector.UIString("Recalculation was forced");
660 break; 665 break;
661 case recordTypes.Layout: 666 case recordTypes.Layout:
662 callSiteStackLabel = WebInspector.UIString("First layout invalidation"); 667 callSiteStackLabel = WebInspector.UIString("First layout invalidation");
663 stackLabel = WebInspector.UIString("Layout forced"); 668 stackLabel = WebInspector.UIString("Layout forced");
664 break; 669 break;
665 } 670 }
666 671
667 // Direct cause. 672 // Direct cause.
668 if (event.stackTrace) 673 if (event.stackTrace)
669 contentHelper.appendStackTrace(stackLabel || WebInspector.UIString("Stac k trace"), event.stackTrace); 674 contentHelper.appendStackTrace(stackLabel || WebInspector.UIString("Stac k trace"), event.stackTrace);
670 675
671 // Indirect causes. 676 // Indirect causes.
672 if (event.invalidationTrackingEvents) { // Full invalidation tracking (exper imental). 677 if (event.invalidationTrackingEvents) { // Full invalidation tracking (exper imental).
673 WebInspector.TimelineUIUtils._generateInvalidations(event, contentHelper ); 678 WebInspector.TimelineUIUtils._generateInvalidations(event, target, conte ntHelper);
674 } else if (initiator && initiator.stackTrace) { // Partial invalidation trac king. 679 } else if (initiator && initiator.stackTrace) { // Partial invalidation trac king.
675 contentHelper.appendStackTrace(callSiteStackLabel || WebInspector.UIStri ng("First invalidated"), initiator.stackTrace); 680 contentHelper.appendStackTrace(callSiteStackLabel || WebInspector.UIStri ng("First invalidated"), initiator.stackTrace);
676 } 681 }
677 } 682 }
678 683
679 /** 684 /**
680 * @param {!WebInspector.TracingModel.Event} event 685 * @param {!WebInspector.TracingModel.Event} event
686 * @param {?WebInspector.Target} target
681 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper 687 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper
682 */ 688 */
683 WebInspector.TimelineUIUtils._generateInvalidations = function(event, contentHel per) 689 WebInspector.TimelineUIUtils._generateInvalidations = function(event, target, co ntentHelper)
684 { 690 {
685 if (!event.invalidationTrackingEvents) 691 if (!event.invalidationTrackingEvents)
686 return; 692 return;
687 693
688 var target = event.thread.target();
689 var invalidations = {}; 694 var invalidations = {};
690 event.invalidationTrackingEvents.forEach(function(invalidation) { 695 event.invalidationTrackingEvents.forEach(function(invalidation) {
691 if (!invalidations[invalidation.type]) 696 if (!invalidations[invalidation.type])
692 invalidations[invalidation.type] = [invalidation]; 697 invalidations[invalidation.type] = [invalidation];
693 else 698 else
694 invalidations[invalidation.type].push(invalidation); 699 invalidations[invalidation.type].push(invalidation);
695 }); 700 });
696 701
697 Object.keys(invalidations).forEach(function(type) { 702 Object.keys(invalidations).forEach(function(type) {
698 WebInspector.TimelineUIUtils._generateInvalidationsForType( 703 WebInspector.TimelineUIUtils._generateInvalidationsForType(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 reasonRow.textContent = WebInspector.UIString("Reason: %s.", reason) ; 753 reasonRow.textContent = WebInspector.UIString("Reason: %s.", reason) ;
749 } 754 }
750 755
751 if (invalidation.stackTrace) 756 if (invalidation.stackTrace)
752 contentHelper.createChildStackTraceElement(row, invalidation.stackTr ace); 757 contentHelper.createChildStackTraceElement(row, invalidation.stackTr ace);
753 } 758 }
754 } 759 }
755 760
756 /** 761 /**
757 * @param {!WebInspector.TracingModel.Event} event 762 * @param {!WebInspector.TracingModel.Event} event
763 * @param {!WebInspector.Target} target
758 * @param {function(?Array.<number>, ?Array.<number>)} callback 764 * @param {function(?Array.<number>, ?Array.<number>)} callback
759 */ 765 */
760 WebInspector.TimelineUIUtils._pushInvalidationNodeIdsToFrontend = function(event , callback) 766 WebInspector.TimelineUIUtils._pushInvalidationNodeIdsToFrontend = function(event , target, callback)
761 { 767 {
762 var backendNodeIds = []; 768 var backendNodeIds = [];
769 var dedupedNodeIds = {};
763 770
764 var dedupedNodeIds = {};
765 if (event.nodeId) { 771 if (event.nodeId) {
766 backendNodeIds.push(event.nodeId); 772 backendNodeIds.push(event.nodeId);
767 dedupedNodeIds[event.nodeId] = true; 773 dedupedNodeIds[event.nodeId] = true;
768 } 774 }
769 event.invalidationTrackingEvents.forEach(function(invalidation) { 775 event.invalidationTrackingEvents.forEach(function(invalidation) {
770 if (invalidation.nodeId && !dedupedNodeIds[invalidation.nodeId]) { 776 if (invalidation.nodeId && !dedupedNodeIds[invalidation.nodeId]) {
771 backendNodeIds.push(invalidation.nodeId); 777 backendNodeIds.push(invalidation.nodeId);
772 dedupedNodeIds[invalidation.nodeId] = true; 778 dedupedNodeIds[invalidation.nodeId] = true;
773 } 779 }
774 }); 780 });
775 781
776 var target = event.thread.target();
777 target.domModel.pushNodesByBackendIdsToFrontend(backendNodeIds, function(fro ntendNodeIds) { 782 target.domModel.pushNodesByBackendIdsToFrontend(backendNodeIds, function(fro ntendNodeIds) {
778 callback(frontendNodeIds, backendNodeIds); 783 callback(frontendNodeIds, backendNodeIds);
779 }); 784 });
780 } 785 }
781 786
782 /** 787 /**
783 * @param {!Object} total 788 * @param {!Object} total
784 * @param {!WebInspector.TimelineModel.Record} record 789 * @param {!WebInspector.TimelineModel.Record} record
785 */ 790 */
786 WebInspector.TimelineUIUtils.aggregateTimeForRecord = function(total, record) 791 WebInspector.TimelineUIUtils.aggregateTimeForRecord = function(total, record)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 aggregatedTotal += total[categoryName]; 838 aggregatedTotal += total[categoryName];
834 total["idle"] = Math.max(0, event.endTime - event.startTime - aggreg atedTotal); 839 total["idle"] = Math.max(0, event.endTime - event.startTime - aggreg atedTotal);
835 } 840 }
836 return false; 841 return false;
837 } 842 }
838 return hasChildren; 843 return hasChildren;
839 } 844 }
840 845
841 /** 846 /**
842 * @param {!WebInspector.TracingModel.Event} event 847 * @param {!WebInspector.TracingModel.Event} event
848 * @param {!WebInspector.Target} target
843 * @param {function(!Element=)} callback 849 * @param {function(!Element=)} callback
844 */ 850 */
845 WebInspector.TimelineUIUtils.buildPicturePreviewContent = function(event, callba ck) 851 WebInspector.TimelineUIUtils.buildPicturePreviewContent = function(event, target , callback)
846 { 852 {
847 853
848 new WebInspector.LayerPaintEvent(event).loadPicture(onSnapshotLoaded); 854 new WebInspector.LayerPaintEvent(event, target).loadPicture(onSnapshotLoaded );
849 /** 855 /**
850 * @param {?Array.<number>} rect 856 * @param {?Array.<number>} rect
851 * @param {?WebInspector.PaintProfilerSnapshot} snapshot 857 * @param {?WebInspector.PaintProfilerSnapshot} snapshot
852 */ 858 */
853 function onSnapshotLoaded(rect, snapshot) 859 function onSnapshotLoaded(rect, snapshot)
854 { 860 {
855 if (!snapshot) { 861 if (!snapshot) {
856 callback(); 862 callback();
857 return; 863 return;
858 } 864 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 for (var i = 0; i < stackTrace.length; ++i) { 1332 for (var i = 0; i < stackTrace.length; ++i) {
1327 var stackFrame = stackTrace[i]; 1333 var stackFrame = stackTrace[i];
1328 var row = stackTraceElement.createChild("div"); 1334 var row = stackTraceElement.createChild("div");
1329 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)")); 1335 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)"));
1330 row.createTextChild(" @ "); 1336 row.createTextChild(" @ ");
1331 var urlElement = this._linkifier.linkifyScriptLocation(this._target, stackFrame.scriptId, stackFrame.url, stackFrame.lineNumber - 1, stackFrame.colu mnNumber - 1); 1337 var urlElement = this._linkifier.linkifyScriptLocation(this._target, stackFrame.scriptId, stackFrame.url, stackFrame.lineNumber - 1, stackFrame.colu mnNumber - 1);
1332 row.appendChild(urlElement); 1338 row.appendChild(urlElement);
1333 } 1339 }
1334 } 1340 }
1335 } 1341 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TimelinePanel.js ('k') | Source/devtools/front_end/timeline/TimelineView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698