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

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

Issue 465223002: [ Do not submit ] Prototype for invalidation analysis Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Unify the three invalidation trace event categories Created 6 years, 3 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.TimelineUIUtils} 7 * @extends {WebInspector.TimelineUIUtils}
8 */ 8 */
9 WebInspector.TracingTimelineUIUtils = function() 9 WebInspector.TracingTimelineUIUtils = function()
10 { 10 {
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 /** 478 /**
479 * @param {!WebInspector.TracingModel.Event} event 479 * @param {!WebInspector.TracingModel.Event} event
480 * @param {!WebInspector.TracingTimelineModel} model 480 * @param {!WebInspector.TracingTimelineModel} model
481 * @param {!WebInspector.Linkifier} linkifier 481 * @param {!WebInspector.Linkifier} linkifier
482 * @param {function(!DocumentFragment)} callback 482 * @param {function(!DocumentFragment)} callback
483 */ 483 */
484 WebInspector.TracingTimelineUIUtils.buildTraceEventDetails = function(event, mod el, linkifier, callback) 484 WebInspector.TracingTimelineUIUtils.buildTraceEventDetails = function(event, mod el, linkifier, callback)
485 { 485 {
486 var target = event.thread.target(); 486 var target = event.thread.target();
487 var relatedNode = null; 487 var relatedNode = null;
488 var invalidationBackendNodeIds = [];
489 var invalidationEvent = event;
488 var barrier = new CallbackBarrier(); 490 var barrier = new CallbackBarrier();
489 if (!event.previewElement && target) { 491 if (!event.previewElement && target) {
490 if (event.imageURL) 492 if (event.imageURL)
491 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage)); 493 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage));
492 else if (event.picture) 494 else if (event.picture)
493 WebInspector.TracingTimelineUIUtils.buildPicturePreviewContent(targe t, event.picture, barrier.createCallback(saveImage)); 495 WebInspector.TracingTimelineUIUtils.buildPicturePreviewContent(targe t, event.picture, barrier.createCallback(saveImage));
494 } 496 }
497
498 if (target) {
499 var invalidationNodeIdMap = {};
500
501 if (event.nodeId)
502 invalidationNodeIdMap[event.nodeId] = true;
503 if (event.styleInvalidationTrackingEvents && event.styleInvalidationTrac kingEvents.length) {
504 event.styleInvalidationTrackingEvents.forEach(function(invalidationE vent) {
505 if (invalidationEvent.nodeId)
506 invalidationNodeIdMap[invalidationEvent.nodeId] = true;
507 });
508 }
509 if (event.layoutInvalidationTrackingEvents && event.layoutInvalidationTr ackingEvents.length) {
510 event.layoutInvalidationTrackingEvents.forEach(function(invalidation Event) {
511 if (invalidationEvent.nodeId)
512 invalidationNodeIdMap[invalidationEvent.nodeId] = true;
513 });
514 }
515
516 var keys = Object.keys(invalidationNodeIdMap);
517 for (var i = 0; i < keys.length; i++)
518 invalidationBackendNodeIds.push(parseInt(keys[i]));
519 target.domModel.pushNodesByBackendIdsToFrontend(invalidationBackendNodeI ds, barrier.createCallback(updateInvalidationNodeIds));
520 }
521
495 if (event.backendNodeId && target) 522 if (event.backendNodeId && target)
496 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode)); 523 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode));
524
497 barrier.callWhenDone(callbackWrapper); 525 barrier.callWhenDone(callbackWrapper);
498 526
499 /** 527 /**
500 * @param {!Element=} element 528 * @param {!Element=} element
501 */ 529 */
502 function saveImage(element) 530 function saveImage(element)
503 { 531 {
504 event.previewElement = element || null; 532 event.previewElement = element || null;
505 } 533 }
506 534
507 /** 535 /**
508 * @param {?Array.<!DOMAgent.NodeId>} nodeIds 536 * @param {?Array.<!DOMAgent.NodeId>} nodeIds
509 */ 537 */
510 function setRelatedNode(nodeIds) 538 function setRelatedNode(nodeIds)
511 { 539 {
512 if (nodeIds) 540 if (nodeIds)
513 relatedNode = target.domModel.nodeForId(nodeIds[0]); 541 relatedNode = target.domModel.nodeForId(nodeIds[0]);
514 } 542 }
515 543
544 function updateInvalidationNodeIds(frontendNodeIds)
545 {
546 if (!frontendNodeIds)
547 return;
548 if (frontendNodeIds.length != invalidationBackendNodeIds.length) {
549 console.error('Did not resolve the correct number of frontend node i ds.');
550 return;
551 }
552
553 // FIXME: Use a map here instead of an O(n^2) loop.
554 invalidationBackendNodeIds.forEach(function(backendNodeId, index) {
555 if (invalidationEvent.nodeId == backendNodeId)
556 invalidationEvent.frontendNodeId = frontendNodeIds[index];
557 if (invalidationEvent.styleInvalidationTrackingEvents && invalidatio nEvent.styleInvalidationTrackingEvents.length) {
558 invalidationEvent.styleInvalidationTrackingEvents.forEach(functi on(invalidationEvent) {
559 if (invalidationEvent.nodeId == backendNodeId)
560 invalidationEvent.frontendNodeId = frontendNodeIds[index ];
561 });
562 }
563 if (invalidationEvent.layoutInvalidationTrackingEvents && invalidati onEvent.layoutInvalidationTrackingEvents.length) {
564 invalidationEvent.layoutInvalidationTrackingEvents.forEach(funct ion(invalidationEvent) {
565 if (invalidationEvent.nodeId == backendNodeId)
566 invalidationEvent.frontendNodeId = frontendNodeIds[index ];
567 });
568 }
569 });
570 }
571
516 function callbackWrapper() 572 function callbackWrapper()
517 { 573 {
518 callback(WebInspector.TracingTimelineUIUtils._buildTraceEventDetailsSync hronously(event, model, linkifier, relatedNode)); 574 callback(WebInspector.TracingTimelineUIUtils._buildTraceEventDetailsSync hronously(event, model, linkifier, relatedNode));
519 } 575 }
520 } 576 }
521 577
522 /** 578 /**
523 * @param {!WebInspector.TracingModel.Event} event 579 * @param {!WebInspector.TracingModel.Event} event
524 * @param {!WebInspector.TracingTimelineModel} model 580 * @param {!WebInspector.TracingTimelineModel} model
525 * @param {!WebInspector.Linkifier} linkifier 581 * @param {!WebInspector.Linkifier} linkifier
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 case recordTypes.DecodeImage: 669 case recordTypes.DecodeImage:
614 case recordTypes.ResizeImage: 670 case recordTypes.ResizeImage:
615 case recordTypes.DrawLazyPixelRef: 671 case recordTypes.DrawLazyPixelRef:
616 relatedNodeLabel = WebInspector.UIString("Image element"); 672 relatedNodeLabel = WebInspector.UIString("Image element");
617 if (event.imageURL) 673 if (event.imageURL)
618 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), W ebInspector.linkifyResourceAsNode(event.imageURL)); 674 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), W ebInspector.linkifyResourceAsNode(event.imageURL));
619 break; 675 break;
620 case recordTypes.RecalculateStyles: // We don't want to see default details. 676 case recordTypes.RecalculateStyles: // We don't want to see default details.
621 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), event.args["elementCount"]); 677 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), event.args["elementCount"]);
622 callStackLabel = WebInspector.UIString("Styles recalculation forced"); 678 callStackLabel = WebInspector.UIString("Styles recalculation forced");
679 // FIXME: Show invalidation tracking for updating style.
623 break; 680 break;
624 case recordTypes.Layout: 681 case recordTypes.Layout:
625 var beginData = event.args["beginData"]; 682 var beginData = event.args["beginData"];
626 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layou t"), beginData["dirtyObjects"]); 683 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layou t"), beginData["dirtyObjects"]);
627 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), b eginData["totalObjects"]); 684 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), b eginData["totalObjects"]);
628 contentHelper.appendTextRow(WebInspector.UIString("Layout scope"), 685 contentHelper.appendTextRow(WebInspector.UIString("Layout scope"),
629 beginData["partialLayout"] ? WebInspector.UI String("Partial") : WebInspector.UIString("Whole document")); 686 beginData["partialLayout"] ? WebInspector.UI String("Partial") : WebInspector.UIString("Whole document"));
630 callSiteStackTraceLabel = WebInspector.UIString("Layout invalidated"); 687 callSiteStackTraceLabel = WebInspector.UIString("Layout invalidated");
631 callStackLabel = WebInspector.UIString("Layout forced"); 688 callStackLabel = WebInspector.UIString("Layout forced");
632 relatedNodeLabel = WebInspector.UIString("Layout root"); 689 relatedNodeLabel = WebInspector.UIString("Layout root");
690 // FIXME: Show invalidation tracking for updating layout.
691 break;
692 case recordTypes.UpdateLayerTree:
693 // FIXME: Show invalidation tracking for updating the layer tree.
633 break; 694 break;
634 case recordTypes.ConsoleTime: 695 case recordTypes.ConsoleTime:
635 contentHelper.appendTextRow(WebInspector.UIString("Message"), event.name ); 696 contentHelper.appendTextRow(WebInspector.UIString("Message"), event.name );
636 break; 697 break;
637 case recordTypes.WebSocketCreate: 698 case recordTypes.WebSocketCreate:
638 case recordTypes.WebSocketSendHandshakeRequest: 699 case recordTypes.WebSocketSendHandshakeRequest:
639 case recordTypes.WebSocketReceiveHandshakeResponse: 700 case recordTypes.WebSocketReceiveHandshakeResponse:
640 case recordTypes.WebSocketDestroy: 701 case recordTypes.WebSocketDestroy:
641 var initiatorData = initiator ? initiator.args["data"] : eventData; 702 var initiatorData = initiator ? initiator.args["data"] : eventData;
642 if (typeof initiatorData["webSocketURL"] !== "undefined") 703 if (typeof initiatorData["webSocketURL"] !== "undefined")
(...skipping 29 matching lines...) Expand all
672 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIString(" Call Stack"), eventStackTrace); 733 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIString(" Call Stack"), eventStackTrace);
673 734
674 var warning = event.warning; 735 var warning = event.warning;
675 if (warning) { 736 if (warning) {
676 var div = document.createElement("div"); 737 var div = document.createElement("div");
677 div.textContent = warning; 738 div.textContent = warning;
678 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div); 739 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div);
679 } 740 }
680 if (event.previewElement) 741 if (event.previewElement)
681 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement); 742 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement);
743
744 // Show invalidation tracking.
745 if (event.styleInvalidationTrackingEvents && event.styleInvalidationTracking Events.length) {
746 contentHelper.element.appendChild(
747 this._buildInvalidationDetailsNode(WebInspector.UIString("Style inva lidations"),
748 linkifier, event, event.styleInvalidationTrackingEvents));
749 }
750 if (event.layoutInvalidationTrackingEvents && event.layoutInvalidationTracki ngEvents.length) {
751 contentHelper.element.appendChild(
752 this._buildInvalidationDetailsNode(WebInspector.UIString("Layout inv alidations"),
753 linkifier, event, event.layoutInvalidationTrackingEvents));
754 }
755
682 fragment.appendChild(contentHelper.element); 756 fragment.appendChild(contentHelper.element);
683 return fragment; 757 return fragment;
684 } 758 }
685 759
686 /** 760 /**
687 * @param {!Object} total 761 * @param {!Object} total
688 * @param {!WebInspector.TracingTimelineModel} model 762 * @param {!WebInspector.TracingTimelineModel} model
689 * @param {!WebInspector.TracingModel.Event} event 763 * @param {!WebInspector.TracingModel.Event} event
690 * @return {boolean} 764 * @return {boolean}
691 */ 765 */
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 else if (recordType === recordTypes.BeginFrame) 858 else if (recordType === recordTypes.BeginFrame)
785 eventDivider.className += " timeline-frame-divider"; 859 eventDivider.className += " timeline-frame-divider";
786 860
787 if (title) 861 if (title)
788 eventDivider.title = title; 862 eventDivider.title = title;
789 863
790 return eventDivider; 864 return eventDivider;
791 } 865 }
792 866
793 /** 867 /**
868 * TODO: write me
869 */
870 WebInspector.TracingTimelineUIUtils._buildInvalidationDetailsNode = function(tit le, linkifier, event, invalidationEvents)
871 {
872 var detailsNode = document.createElement("div");
873 detailsNode.className = "timeline-details-view-row";
874 var titleElement = document.createElement("span");
875 titleElement.className = "timeline-details-view-row-title";
876 titleElement.textContent = WebInspector.UIString("%s: ", title);
877 detailsNode.appendChild(titleElement);
878 var eventsList = document.createElement("ol");
879 detailsNode.appendChild(eventsList);
880
881 invalidationEvents.forEach(function(invalidationEvent, idx) {
882 var row = document.createElement("li");
883 eventsList.appendChild(row);
884
885 var nodeRow = document.createElement("div");
886 row.appendChild(nodeRow);
887 var target = event.thread.target();
888 var node = target.domModel.nodeForId(invalidationEvent.frontendNodeId);
889 if (node)
890 nodeRow.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeRef erence(node));
891 else if (invalidationEvent.nodeName)
892 nodeRow.textContent = '[' + invalidationEvent.nodeName + ']';
893 else
894 nodeRow.textContent = '[ unknown node ]';
895
896 var callstack = invalidationEvent.callstack ? JSON.parse(invalidationEve nt.callstack) : [];
897 if (callstack.length > 0) {
898 var callstackRow = document.createElement("div");
899 row.appendChild(callstackRow);
900 callstack.forEach(function(stackFrame) {
901 var frameRow = document.createElement("div");
902 frameRow.className = "timeline-details-view-row monospace";
903 callstackRow.appendChild(frameRow);
904 frameRow.textContent = stackFrame.functionName || WebInspector.U IString("(anonymous function)");
905 frameRow.textContent += " @ ";
906 var urlElement = linkifier.linkifyScriptLocation(target, stackFr ame.scriptId, stackFrame.url, stackFrame.lineNumber - 1, stackFrame.columnNumber - 1);
907 frameRow.appendChild(urlElement);
908 });
909 }
910 });
911 return detailsNode;
912 }
913
914 /**
794 * @return {!Array.<string>} 915 * @return {!Array.<string>}
795 */ 916 */
796 WebInspector.TracingTimelineUIUtils._visibleTypes = function() 917 WebInspector.TracingTimelineUIUtils._visibleTypes = function()
797 { 918 {
798 var eventStyles = WebInspector.TracingTimelineUIUtils._initEventStyles(); 919 var eventStyles = WebInspector.TracingTimelineUIUtils._initEventStyles();
799 var result = []; 920 var result = [];
800 for (var name in eventStyles) { 921 for (var name in eventStyles) {
801 if (!eventStyles[name].hidden) 922 if (!eventStyles[name].hidden)
802 result.push(name); 923 result.push(name);
803 } 924 }
804 return result; 925 return result;
805 } 926 }
806 927
807 /** 928 /**
808 * @return {!WebInspector.TracingTimelineModel.Filter} 929 * @return {!WebInspector.TracingTimelineModel.Filter}
809 */ 930 */
810 WebInspector.TracingTimelineUIUtils.hiddenEventsFilter = function() 931 WebInspector.TracingTimelineUIUtils.hiddenEventsFilter = function()
811 { 932 {
812 return new WebInspector.TracingTimelineModel.InclusiveEventNameFilter(WebIns pector.TracingTimelineUIUtils._visibleTypes()); 933 return new WebInspector.TracingTimelineModel.InclusiveEventNameFilter(WebIns pector.TracingTimelineUIUtils._visibleTypes());
813 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698