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

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

Powered by Google App Engine
This is Rietveld 408576698