OLD | NEW |
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 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(2, green, [
"wheel"]), | 1602 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(2, green, [
"wheel"]), |
1603 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["click", "mousedown", "mouseup"]), | 1603 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["click", "mousedown", "mouseup"]), |
1604 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["touchstart", "touchend", "touchmove", "touchcancel"]), | 1604 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["touchstart", "touchend", "touchmove", "touchcancel"]), |
1605 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["pointerdown", "pointerup", "pointercancel", "gotpointercapture", "lostpointerc
apture"]), | 1605 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, orange,
["pointerdown", "pointerup", "pointercancel", "gotpointercapture", "lostpointerc
apture"]), |
1606 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, purple,
["keydown", "keyup", "keypress"]) | 1606 new WebInspector.TimelineUIUtils.EventDispatchTypeDescriptor(3, purple,
["keydown", "keyup", "keypress"]) |
1607 ]; | 1607 ]; |
1608 return WebInspector.TimelineUIUtils._eventDispatchDesciptors; | 1608 return WebInspector.TimelineUIUtils._eventDispatchDesciptors; |
1609 } | 1609 } |
1610 | 1610 |
1611 /** | 1611 /** |
1612 * @param {!Array<!WebInspector.TracingModel.Event>} events | |
1613 * @param {number} startTime | |
1614 * @param {number} endTime | |
1615 * @param {!Array<!WebInspector.TraceEventFilter>} filters | |
1616 * @param {function(!WebInspector.TracingModel.Event):string} eventIdCallback | |
1617 * @return {!WebInspector.TimelineModel.ProfileTreeNode} | |
1618 */ | |
1619 WebInspector.TimelineUIUtils.buildTopDownTree = function(events, startTime, endT
ime, filters, eventIdCallback) | |
1620 { | |
1621 // Temporarily deposit a big enough value that exceeds the max recording tim
e. | |
1622 var /** @const */ initialTime = 1e7; | |
1623 var root = new WebInspector.TimelineModel.ProfileTreeNode(); | |
1624 root.totalTime = initialTime; | |
1625 root.selfTime = initialTime; | |
1626 root.name = WebInspector.UIString("Top-Down Chart"); | |
1627 var parent = root; | |
1628 | |
1629 /** | |
1630 * @param {!WebInspector.TracingModel.Event} e | |
1631 * @return {boolean} | |
1632 */ | |
1633 function filter(e) | |
1634 { | |
1635 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instant) | |
1636 return false; | |
1637 if (e.endTime <= startTime || e.startTime >= endTime) | |
1638 return false; | |
1639 if (WebInspector.TracingModel.isAsyncPhase(e.phase)) | |
1640 return false; | |
1641 for (var filter of filters) { | |
1642 if (!filter.accept(e)) | |
1643 return false; | |
1644 } | |
1645 return true; | |
1646 } | |
1647 | |
1648 /** | |
1649 * @param {!WebInspector.TracingModel.Event} e | |
1650 */ | |
1651 function onStartEvent(e) | |
1652 { | |
1653 if (!filter(e)) | |
1654 return; | |
1655 var time = Math.min(endTime, e.endTime) - Math.max(startTime, e.startTim
e); | |
1656 var id = eventIdCallback(e); | |
1657 if (!parent.children) | |
1658 parent.children = /** @type {!Map<string,!WebInspector.TimelineModel
.ProfileTreeNode>} */ (new Map()); | |
1659 var node = parent.children.get(id); | |
1660 if (node) { | |
1661 node.selfTime += time; | |
1662 node.totalTime += time; | |
1663 } else { | |
1664 node = new WebInspector.TimelineModel.ProfileTreeNode(); | |
1665 node.totalTime = time; | |
1666 node.selfTime = time; | |
1667 node.parent = parent; | |
1668 node.name = eventName(e); | |
1669 node.id = id; | |
1670 node.event = e; | |
1671 parent.children.set(id, node); | |
1672 } | |
1673 parent.selfTime -= time; | |
1674 if (parent.selfTime < 0) { | |
1675 console.log("Error: Negative self of " + parent.selfTime, e); | |
1676 parent.selfTime = 0; | |
1677 } | |
1678 parent = node; | |
1679 } | |
1680 | |
1681 /** | |
1682 * @param {!WebInspector.TracingModel.Event} e | |
1683 */ | |
1684 function onEndEvent(e) | |
1685 { | |
1686 if (!filter(e)) | |
1687 return; | |
1688 parent = parent.parent; | |
1689 } | |
1690 | |
1691 /** | |
1692 * @param {!WebInspector.TracingModel.Event} e | |
1693 * @return {string} | |
1694 */ | |
1695 function eventName(e) | |
1696 { | |
1697 if (e.name === "JSFrame") | |
1698 return WebInspector.beautifyFunctionName(e.args.data.functionName); | |
1699 if (e.name === "EventDispatch") | |
1700 return WebInspector.UIString("Event%s", e.args.data ? " (" + e.args.
data.type + ")" : ""); | |
1701 return e.name; | |
1702 } | |
1703 | |
1704 WebInspector.TimelineModel.forEachEvent(events, onStartEvent, onEndEvent); | |
1705 root.totalTime -= root.selfTime; | |
1706 root.selfTime = 0; | |
1707 return root; | |
1708 } | |
1709 | |
1710 /** | |
1711 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree | |
1712 * @param {function(!WebInspector.TimelineModel.ProfileTreeNode):?WebInspector.T
imelineModel.ProfileTreeNode=} groupingCallback | |
1713 * @return {!WebInspector.TimelineModel.ProfileTreeNode} | |
1714 */ | |
1715 WebInspector.TimelineUIUtils.buildBottomUpTree = function(topDownTree, groupingC
allback) | |
1716 { | |
1717 var buRoot = new WebInspector.TimelineModel.ProfileTreeNode(); | |
1718 buRoot.totalTime = 0; | |
1719 buRoot.name = WebInspector.UIString("Bottom-Up Chart"); | |
1720 /** @type {!Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */ | |
1721 buRoot.children = new Map(); | |
1722 processNode(topDownTree); | |
1723 | |
1724 /** | |
1725 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode | |
1726 */ | |
1727 function processNode(tdNode) | |
1728 { | |
1729 if (tdNode.selfTime > 0) { | |
1730 var buParent = groupingCallback && groupingCallback(tdNode) || buRoo
t; | |
1731 appendNode(tdNode, buParent); | |
1732 } | |
1733 if (tdNode.children) | |
1734 tdNode.children.forEach(processNode); | |
1735 } | |
1736 | |
1737 /** | |
1738 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode | |
1739 * @param {!WebInspector.TimelineModel.ProfileTreeNode} buParent | |
1740 */ | |
1741 function appendNode(tdNode, buParent) | |
1742 { | |
1743 var time = tdNode.selfTime; | |
1744 buParent.totalTime += time; | |
1745 while (tdNode.parent) { | |
1746 if (!buParent.children) | |
1747 buParent.children = /** @type {!Map<string,!WebInspector.Timelin
eModel.ProfileTreeNode>} */ (new Map()); | |
1748 var id = tdNode.id; | |
1749 var buNode = buParent.children.get(id); | |
1750 if (!buNode) { | |
1751 buNode = new WebInspector.TimelineModel.ProfileTreeNode(); | |
1752 buNode.totalTime = time; | |
1753 buNode.name = tdNode.name; | |
1754 buNode.event = tdNode.event; | |
1755 buNode.id = id; | |
1756 buParent.children.set(id, buNode); | |
1757 } else { | |
1758 buNode.totalTime += time; | |
1759 } | |
1760 tdNode = tdNode.parent; | |
1761 buParent = buNode; | |
1762 } | |
1763 } | |
1764 | |
1765 return buRoot; | |
1766 } | |
1767 | |
1768 /** | |
1769 * @constructor | 1612 * @constructor |
1770 * @extends {WebInspector.Object} | 1613 * @extends {WebInspector.Object} |
1771 * @param {string} name | 1614 * @param {string} name |
1772 * @param {string} title | 1615 * @param {string} title |
1773 * @param {boolean} visible | 1616 * @param {boolean} visible |
1774 * @param {string} borderColor | 1617 * @param {string} borderColor |
1775 * @param {string} backgroundColor | 1618 * @param {string} backgroundColor |
1776 * @param {string} fillColorStop0 | 1619 * @param {string} fillColorStop0 |
1777 * @param {string} fillColorStop1 | 1620 * @param {string} fillColorStop1 |
1778 */ | 1621 */ |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 return; | 1927 return; |
2085 | 1928 |
2086 var stackTraceElement = parentElement.createChild("div", "timeline-detai
ls-view-row-value timeline-details-view-row-stack-trace monospace"); | 1929 var stackTraceElement = parentElement.createChild("div", "timeline-detai
ls-view-row-value timeline-details-view-row-stack-trace monospace"); |
2087 | 1930 |
2088 var callFrameElem = WebInspector.DOMPresentationUtils.buildStackTracePre
viewContents(this._target, this._linkifier, stackTrace); | 1931 var callFrameElem = WebInspector.DOMPresentationUtils.buildStackTracePre
viewContents(this._target, this._linkifier, stackTrace); |
2089 | 1932 |
2090 stackTraceElement.appendChild(callFrameElem); | 1933 stackTraceElement.appendChild(callFrameElem); |
2091 } | 1934 } |
2092 | 1935 |
2093 } | 1936 } |
OLD | NEW |