| Index: chrome_linux/resources/inspector/ProfilesPanel.js
|
| ===================================================================
|
| --- chrome_linux/resources/inspector/ProfilesPanel.js (revision 229864)
|
| +++ chrome_linux/resources/inspector/ProfilesPanel.js (working copy)
|
| @@ -53,7 +53,7 @@
|
| WebInspector.ProfilesPanel=function(name,type)
|
| {var singleProfileMode=typeof name!=="undefined";name=name||"profiles";WebInspector.Panel.call(this,name);this.registerRequiredCSS("panelEnablerView.css");this.registerRequiredCSS("heapProfiler.css");this.registerRequiredCSS("profilesPanel.css");this.createSidebarViewWithTree();this.profilesItemTreeElement=new WebInspector.ProfilesSidebarTreeElement(this);this.sidebarTree.appendChild(this.profilesItemTreeElement);this._singleProfileMode=singleProfileMode;this._profileTypesByIdMap={};this.profileViews=document.createElement("div");this.profileViews.id="profile-views";this.splitView.mainElement.appendChild(this.profileViews);this._statusBarButtons=[];this.recordButton=new WebInspector.StatusBarButton("","record-profile-status-bar-item");this.recordButton.addEventListener("click",this.toggleRecordButton,this);this._statusBarButtons.push(this.recordButton);this.clearResultsButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear all profiles."),"clear-status-bar-item");this.clearResultsButton.addEventListener("click",this._clearProfiles,this);this._statusBarButtons.push(this.clearResultsButton);this._profileTypeStatusBarItemsContainer=document.createElement("div");this._profileTypeStatusBarItemsContainer.className="status-bar-items";this._profileViewStatusBarItemsContainer=document.createElement("div");this._profileViewStatusBarItemsContainer.className="status-bar-items";if(singleProfileMode){this._launcherView=this._createLauncherView();this._registerProfileType((type));this._selectedProfileType=type;this._updateProfileTypeSpecificUI();}else{this._launcherView=new WebInspector.MultiProfileLauncherView(this);this._launcherView.addEventListener(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,this._onProfileTypeSelected,this);this._registerProfileType(new WebInspector.CPUProfileType());this._registerProfileType(new WebInspector.HeapSnapshotProfileType());this._registerProfileType(new WebInspector.TrackingHeapSnapshotProfileType(this));if(!WebInspector.WorkerManager.isWorkerFrontend()&&WebInspector.experimentsSettings.canvasInspection.isEnabled())
|
| this._registerProfileType(new WebInspector.CanvasProfileType());}
|
| -this._profilesWereRequested=false;this._reset();this._createFileSelectorElement();this.element.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._registerShortcuts();WebInspector.ContextMenu.registerProvider(this);this._configureCpuProfilerSamplingInterval();WebInspector.settings.highResolutionCpuProfiling.addChangeListener(this._configureCpuProfilerSamplingInterval,this);}
|
| +this._profilesWereRequested=false;this._reset();this._createFileSelectorElement();this.element.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._registerShortcuts();WebInspector.ContextMenu.registerProvider(this);}
|
| WebInspector.ProfilesPanel.prototype={_createFileSelectorElement:function()
|
| {if(this._fileSelectorElement)
|
| this.element.removeChild(this._fileSelectorElement);this._fileSelectorElement=WebInspector.createFileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this._fileSelectorElement);},_createLauncherView:function()
|
| @@ -62,10 +62,7 @@
|
| continue;if(fileName.endsWith(type.fileExtension()))
|
| return type;}
|
| return null;},_registerShortcuts:function()
|
| -{this.registerShortcuts(WebInspector.ProfilesPanelDescriptor.ShortcutKeys.StartStopRecording,this.toggleRecordButton.bind(this));},_configureCpuProfilerSamplingInterval:function()
|
| -{var intervalUs=WebInspector.settings.highResolutionCpuProfiling.get()?100:1000;ProfilerAgent.setSamplingInterval(intervalUs,didChangeInterval.bind(this));function didChangeInterval(error)
|
| -{if(error)
|
| -WebInspector.showErrorMessage(error)}},_loadFromFile:function(file)
|
| +{this.registerShortcuts(WebInspector.ProfilesPanelDescriptor.ShortcutKeys.StartStopRecording,this.toggleRecordButton.bind(this));},_loadFromFile:function(file)
|
| {this._createFileSelectorElement();var profileType=this._findProfileTypeByExtension(file.name);if(!profileType){var extensions=[];for(var id in this._profileTypesByIdMap){var extension=this._profileTypesByIdMap[id].fileExtension();if(!extension)
|
| continue;extensions.push(extension);}
|
| WebInspector.log(WebInspector.UIString("Can't load file. Only files with extensions '%s' can be loaded.",extensions.join("', '")));return;}
|
| @@ -97,9 +94,8 @@
|
| {var element=event.srcElement;while(element&&!element.treeElement&&element!==this.element)
|
| element=element.parentElement;if(!element)
|
| return;if(element.treeElement&&element.treeElement.handleContextMenuEvent){element.treeElement.handleContextMenuEvent(event,this);return;}
|
| -var contextMenu=new WebInspector.ContextMenu(event);if(this.visibleView instanceof WebInspector.HeapSnapshotView){this.visibleView.populateContextMenu(contextMenu,event);}
|
| -if(element!==this.element||event.srcElement===this.sidebarElement){contextMenu.appendItem(WebInspector.UIString("Load\u2026"),this._fileSelectorElement.click.bind(this._fileSelectorElement));}
|
| -contextMenu.show();},_makeTitleKey:function(text,profileTypeId)
|
| +if(element!==this.element||event.srcElement===this.sidebarElement){var contextMenu=new WebInspector.ContextMenu(event);if(this.visibleView instanceof WebInspector.HeapSnapshotView)
|
| +this.visibleView.populateContextMenu(contextMenu,event);contextMenu.appendItem(WebInspector.UIString("Load\u2026"),this._fileSelectorElement.click.bind(this._fileSelectorElement));contextMenu.show();}},_makeTitleKey:function(text,profileTypeId)
|
| {return escape(text)+'/'+escape(profileTypeId);},_addProfileHeader:function(profile)
|
| {var profileType=profile.profileType();var typeId=profileType.id;var sidebarParent=profileType.treeElement;sidebarParent.hidden=false;var small=false;var alternateTitle;if(!WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(profile.title)&&!profile.isTemporary){var profileTitleKey=this._makeTitleKey(profile.title,typeId);if(!(profileTitleKey in this._profileGroups))
|
| this._profileGroups[profileTitleKey]=[];var group=this._profileGroups[profileTitleKey];group.push(profile);if(group.length===2){group._profilesTreeElement=new WebInspector.ProfileGroupSidebarTreeElement(this,profile.title);var index=sidebarParent.children.indexOf(group[0]._profilesTreeElement);sidebarParent.insertChild(group._profilesTreeElement,index);var selected=group[0]._profilesTreeElement.selected;sidebarParent.removeChild(group[0]._profilesTreeElement);group._profilesTreeElement.appendChild(group[0]._profilesTreeElement);if(selected)
|
| @@ -340,7 +336,8 @@
|
| {if(error)
|
| return;if(!profile.head){return;}
|
| this._processProfileData(profile);},_processProfileData:function(profile)
|
| -{this.profileHead=profile.head;this.samples=profile.samples;this._calculateTimes(profile);this._assignParentsInProfile();if(this.samples)
|
| +{this.profileHead=profile.head;this.samples=profile.samples;this._calculateTimes(profile);if(profile.idleTime)
|
| +this._injectIdleTimeNode(profile);this._assignParentsInProfile();if(this.samples)
|
| this._buildIdToNodeMap();this._changeView();this._updatePercentButton();if(this._flameChart)
|
| this._flameChart.update();},get statusBarItems()
|
| {return[this.viewSelectComboBox.element,this._statusBarButtonsElement];},_getBottomUpProfileDataGridTree:function()
|
| @@ -404,7 +401,7 @@
|
| return;var script=WebInspector.debuggerModel.scriptForId(node.scriptId)
|
| if(!script)
|
| return;var uiLocation=script.rawLocationToUILocation(node.lineNumber);if(!uiLocation)
|
| -return;WebInspector.showPanel("scripts").showUILocation(uiLocation);},_changeView:function()
|
| +return;WebInspector.showPanel("scripts").showUISourceCode(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber);},_changeView:function()
|
| {if(!this.profile)
|
| return;switch(this.viewSelectComboBox.selectedOption().value){case WebInspector.CPUProfileView._TypeFlame:this._ensureFlameChartCreated();this.dataGrid.detach();this._flameChart.show(this.element);this._viewType.set(WebInspector.CPUProfileView._TypeFlame);this._statusBarButtonsElement.enableStyleClass("hidden",true);return;case WebInspector.CPUProfileView._TypeTree:this.profileDataGridTree=this._getTopDownProfileDataGridTree();this._sortProfile();this._viewType.set(WebInspector.CPUProfileView._TypeTree);break;case WebInspector.CPUProfileView._TypeHeavy:this.profileDataGridTree=this._getBottomUpProfileDataGridTree();this._sortProfile();this._viewType.set(WebInspector.CPUProfileView._TypeHeavy);break;}
|
| this._statusBarButtonsElement.enableStyleClass("hidden",false);if(this._flameChart)
|
| @@ -436,7 +433,10 @@
|
| nodesToTraverse.push({parent:children[i],children:children[i].children});}}},_buildIdToNodeMap:function()
|
| {var idToNode=this._idToNode={};var stack=[this.profileHead];while(stack.length){var node=stack.pop();idToNode[node.id]=node;for(var i=0;i<node.children.length;i++)
|
| stack.push(node.children[i]);}
|
| -var topLevelNodes=this.profileHead.children;for(var i=0;i<topLevelNodes.length;i++){var node=topLevelNodes[i];if(node.functionName=="(garbage collector)"){this._gcNode=node;break;}}},__proto__:WebInspector.View.prototype}
|
| +var topLevelNodes=this.profileHead.children;for(var i=0;i<topLevelNodes.length;i++){var node=topLevelNodes[i];if(node.functionName=="(garbage collector)"){this._gcNode=node;break;}}},_injectIdleTimeNode:function(profile)
|
| +{var idleTime=profile.idleTime;var nodes=profile.head.children;var programNode={selfTime:0};for(var i=nodes.length-1;i>=0;--i){if(nodes[i].functionName==="(program)"){programNode=nodes[i];break;}}
|
| +var programTime=programNode.selfTime;if(idleTime>programTime)
|
| +idleTime=programTime;programTime=programTime-idleTime;programNode.selfTime=programTime;programNode.totalTime=programTime;var idleNode={functionName:"(idle)",url:null,lineNumber:0,totalTime:idleTime,selfTime:idleTime,callUID:0,children:[]};nodes.push(idleNode);},__proto__:WebInspector.View.prototype}
|
| WebInspector.CPUProfileType=function()
|
| {WebInspector.ProfileType.call(this,WebInspector.CPUProfileType.TypeId,WebInspector.UIString("Collect JavaScript CPU Profile"));InspectorBackend.registerProfilerDispatcher(this);this._recording=false;WebInspector.CPUProfileType.instance=this;}
|
| WebInspector.CPUProfileType.TypeId="CPU";WebInspector.CPUProfileType.prototype={fileExtension:function()
|
| @@ -478,7 +478,7 @@
|
| {ProfilerAgent.getCPUProfile(this.uid,getCPUProfileCallback.bind(this));}
|
| this._fileName=this._fileName||"CPU-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
|
| {this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;var fileReader=new WebInspector.ChunkedFileReader(file,10000000,this);fileReader.start(this);},__proto__:WebInspector.ProfileHeader.prototype};WebInspector.FlameChart=function(cpuProfileView)
|
| -{WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.className="fill";this.element.id="cpu-flame-chart";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("flame-chart");this._overviewCanvas=this._overviewContainer.createChild("canvas","flame-chart-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.FlameChart.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._chartContainer=this.element.createChild("div","chart-container");this._timelineGrid=new WebInspector.TimelineGrid();this._chartContainer.appendChild(this._timelineGrid.element);this._calculator=new WebInspector.FlameChart.Calculator();this._canvas=this._chartContainer.createChild("canvas");this._canvas.addEventListener("mousemove",this._onMouseMove.bind(this));WebInspector.installDragHandle(this._canvas,this._startCanvasDragging.bind(this),this._canvasDragging.bind(this),this._endCanvasDragging.bind(this),"col-resize");this._cpuProfileView=cpuProfileView;this._windowLeft=0.0;this._windowRight=1.0;this._barHeight=15;this._minWidth=2;this._paddingLeft=15;this._canvas.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this._canvas.addEventListener("click",this._onClick.bind(this),false);this._linkifier=new WebInspector.Linkifier();this._highlightedEntryIndex=-1;if(!WebInspector.FlameChart._colorGenerator)
|
| +{WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.className="fill";this.element.id="cpu-flame-chart";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("flame-chart");this._overviewCanvas=this._overviewContainer.createChild("canvas","flame-chart-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.FlameChart.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._chartContainer=this.element.createChild("div","chart-container");this._timelineGrid=new WebInspector.TimelineGrid();this._chartContainer.appendChild(this._timelineGrid.element);this._calculator=new WebInspector.FlameChart.Calculator();this._canvas=this._chartContainer.createChild("canvas");this._canvas.addEventListener("mousemove",this._onMouseMove.bind(this));WebInspector.installDragHandle(this._canvas,this._startCanvasDragging.bind(this),this._canvasDragging.bind(this),this._endCanvasDragging.bind(this),"col-resize");this._cpuProfileView=cpuProfileView;this._windowLeft=0.0;this._windowRight=1.0;this._barHeight=15;this._minWidth=2;this._paddingLeft=15;this._canvas.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this.element.addEventListener("click",this._onClick.bind(this),false);this._linkifier=new WebInspector.Linkifier();this._highlightedEntryIndex=-1;if(!WebInspector.FlameChart._colorGenerator)
|
| WebInspector.FlameChart._colorGenerator=new WebInspector.FlameChart.ColorGenerator();}
|
| WebInspector.FlameChart.Calculator=function()
|
| {}
|
| @@ -514,10 +514,10 @@
|
| {this._overviewGrid.setWindow(timeLeft/this._totalTime,timeRight/this._totalTime);},_onWindowChanged:function(event)
|
| {this._scheduleUpdate();},_startCanvasDragging:function(event)
|
| {if(!this._timelineData)
|
| -return false;this._isDragging=true;this._wasDragged=false;this._dragStartPoint=event.pageX;this._dragStartWindowLeft=this._windowLeft;this._dragStartWindowRight=this._windowRight;return true;},_canvasDragging:function(event)
|
| +return false;this._isDragging=true;this._dragStartPoint=event.pageX;this._dragStartWindowLeft=this._windowLeft;this._dragStartWindowRight=this._windowRight;return true;},_canvasDragging:function(event)
|
| {var pixelShift=this._dragStartPoint-event.pageX;var windowShift=pixelShift/this._totalPixels;var windowLeft=Math.max(0,this._dragStartWindowLeft+windowShift);if(windowLeft===this._windowLeft)
|
| return;windowShift=windowLeft-this._dragStartWindowLeft;var windowRight=Math.min(1,this._dragStartWindowRight+windowShift);if(windowRight===this._windowRight)
|
| -return;windowShift=windowRight-this._dragStartWindowRight;this._overviewGrid.setWindow(this._dragStartWindowLeft+windowShift,this._dragStartWindowRight+windowShift);this._wasDragged=true;},_endCanvasDragging:function()
|
| +return;windowShift=windowRight-this._dragStartWindowRight;this._overviewGrid.setWindow(this._dragStartWindowLeft+windowShift,this._dragStartWindowRight+windowShift);},_endCanvasDragging:function()
|
| {this._isDragging=false;},_calculateTimelineData:function()
|
| {if(this._cpuProfileView.samples)
|
| return this._calculateTimelineDataForSamples();if(this._timelineData)
|
| @@ -553,8 +553,7 @@
|
| pushEntryInfoRow(WebInspector.UIString("Name"),node.functionName);if(this._cpuProfileView.samples){pushEntryInfoRow(WebInspector.UIString("Self time"),Number.secondsToString(entry.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Total time"),Number.secondsToString(entry.duration/1000,true));}
|
| if(node.url)
|
| pushEntryInfoRow(WebInspector.UIString("URL"),node.url+":"+node.lineNumber);pushEntryInfoRow(WebInspector.UIString("Aggregated self time"),Number.secondsToString(node.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Aggregated total time"),Number.secondsToString(node.totalTime/1000,true));return entryInfo;},_onClick:function(e)
|
| -{if(this._wasDragged)
|
| -return;if(this._highlightedEntryIndex===-1)
|
| +{if(this._highlightedEntryIndex===-1)
|
| return;var node=this._timelineData.entries[this._highlightedEntryIndex].node;this.dispatchEventToListeners(WebInspector.FlameChart.Events.SelectedNode,node);},_onMouseWheel:function(e)
|
| {if(e.wheelDeltaY){const zoomFactor=1.1;const mouseWheelZoomSpeed=1/120;var zoom=Math.pow(zoomFactor,-e.wheelDeltaY*mouseWheelZoomSpeed);var overviewReference=(this._pixelWindowLeft+e.offsetX-this._paddingLeft)/this._totalPixels;this._overviewGrid.zoom(zoom,overviewReference);}else{var shift=Number.constrain(-1*this._windowWidth/4*e.wheelDeltaX/120,-this._windowLeft,1-this._windowRight);this._overviewGrid.setWindow(this._windowLeft+shift,this._windowRight+shift);}},_coordinatesToEntryIndex:function(x,y)
|
| {var timelineData=this._timelineData;if(!timelineData)
|
| @@ -571,16 +570,12 @@
|
| {anchorBox.x=Math.floor(entry.startTime*this._timeToPixel)-this._pixelWindowLeft+this._paddingLeft;anchorBox.y=this._canvas.height/window.devicePixelRatio-(entry.depth+1)*this._barHeight;anchorBox.width=Math.max(Math.ceil(entry.duration*this._timeToPixel),this._minWidth);anchorBox.height=this._barHeight;if(anchorBox.x<0){anchorBox.width+=anchorBox.x;anchorBox.x=0;}
|
| anchorBox.width=Number.constrain(anchorBox.width,0,this._canvas.width-anchorBox.x);},draw:function(width,height)
|
| {var timelineData=this._calculateTimelineData();if(!timelineData)
|
| -return;var timelineEntries=timelineData.entries;var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._canvas.width=canvasWidth;this._canvas.height=canvasHeight;this._canvas.style.width=width+"px";this._canvas.style.height=height+"px";var barHeight=this._barHeight;var context=this._canvas.getContext("2d");context.scale(ratio,ratio);var visibleTimeLeft=this._timeWindowLeft-this._paddingLeftTime;var timeWindowRight=this._timeWindowRight;function forEachEntry(flameChart,callback)
|
| -{var anchorBox=new AnchorBox();for(var i=0;i<timelineEntries.length;++i){var entry=timelineEntries[i];var startTime=entry.startTime;if(startTime>timeWindowRight)
|
| +return;var timelineEntries=timelineData.entries;var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._canvas.width=canvasWidth;this._canvas.height=canvasHeight;this._canvas.style.width=width+"px";this._canvas.style.height=height+"px";var barHeight=this._barHeight;var context=this._canvas.getContext("2d");var textPaddingLeft=2;context.scale(ratio,ratio);context.font=(barHeight-4)+"px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.textBaseline="alphabetic";this._dotsWidth=context.measureText("\u2026").width;var visibleTimeLeft=this._timeWindowLeft-this._paddingLeftTime;var anchorBox=new AnchorBox();for(var i=0;i<timelineEntries.length;++i){var entry=timelineEntries[i];var startTime=entry.startTime;if(startTime>this._timeWindowRight)
|
| break;if((startTime+entry.duration)<visibleTimeLeft)
|
| -continue;flameChart._entryToAnchorBox(entry,anchorBox);callback(flameChart,context,entry,anchorBox,flameChart._highlightedEntryIndex===i);}}
|
| -function drawBar(flameChart,context,entry,anchorBox,highlighted)
|
| -{context.beginPath();context.rect(anchorBox.x,anchorBox.y,anchorBox.width-1,anchorBox.height-1);var colorPair=entry.colorPair;context.fillStyle=highlighted?colorPair.highlighted:colorPair.normal;context.fill();}
|
| -forEachEntry(this,drawBar);context.font=(barHeight-4)+"px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.textBaseline="alphabetic";context.fillStyle="#333";this._dotsWidth=context.measureText("\u2026").width;var textPaddingLeft=2;function drawText(flameChart,context,entry,anchorBox,highlighted)
|
| -{var xText=Math.max(0,anchorBox.x);var widthText=anchorBox.width-textPaddingLeft+anchorBox.x-xText;var title=flameChart._prepareText(context,entry.node.functionName,widthText);if(title)
|
| -context.fillText(title,xText+textPaddingLeft,anchorBox.y+barHeight-4);}
|
| -forEachEntry(this,drawText);var entryInfo=this._prepareHighlightedEntryInfo();if(entryInfo)
|
| +continue;this._entryToAnchorBox(entry,anchorBox);var colorPair=entry.colorPair;var color;if(this._highlightedEntryIndex===i)
|
| +color=colorPair.highlighted;else
|
| +color=colorPair.normal;context.beginPath();context.rect(anchorBox.x,anchorBox.y,anchorBox.width-1,anchorBox.height-1);context.fillStyle=color;context.fill();var xText=Math.max(0,anchorBox.x);var widthText=anchorBox.width-textPaddingLeft+anchorBox.x-xText;var title=this._prepareText(context,entry.node.functionName,widthText);if(title){context.fillStyle="#333";context.fillText(title,xText+textPaddingLeft,anchorBox.y+barHeight-4);}}
|
| +var entryInfo=this._prepareHighlightedEntryInfo();if(entryInfo)
|
| this._printEntryInfo(context,entryInfo,0,25,width);},_printEntryInfo:function(context,entryInfo,x,y,width)
|
| {const lineHeight=18;const paddingLeft=10;const paddingTop=5;var maxTitleWidth=0;var basicFont="100% "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.font="bold "+basicFont;context.textBaseline="top";for(var i=0;i<entryInfo.length;++i)
|
| maxTitleWidth=Math.max(maxTitleWidth,context.measureText(entryInfo[i].title).width);var maxTextWidth=0;for(var i=0;i<entryInfo.length;++i)
|
| @@ -682,22 +677,15 @@
|
| {this.node.nodeIndex=newIndex;},item:function()
|
| {return this.node;},next:function()
|
| {this.node.nodeIndex=this.node._nextNodeIndex();}}
|
| -WebInspector.HeapSnapshotProgress=function(dispatcher)
|
| -{this._dispatcher=dispatcher;}
|
| -WebInspector.HeapSnapshotProgress.Event={Update:"ProgressUpdate"};WebInspector.HeapSnapshotProgress.prototype={updateStatus:function(status)
|
| -{this._sendUpdateEvent(WebInspector.UIString(status));},updateProgress:function(title,value,total)
|
| -{var percentValue=((total?(value/total):0)*100).toFixed(0);this._sendUpdateEvent(WebInspector.UIString(title,percentValue));},_sendUpdateEvent:function(text)
|
| -{if(this._dispatcher)
|
| -this._dispatcher.sendEvent(WebInspector.HeapSnapshotProgress.Event.Update,text);}}
|
| -WebInspector.HeapSnapshot=function(profile,progress)
|
| -{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._progress=progress;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
|
| +WebInspector.HeapSnapshot=function(profile)
|
| +{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
|
| this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._init();}
|
| function HeapSnapshotMetainfo()
|
| {this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.type_strings={};this.fields=[];this.types=[];}
|
| function HeapSnapshotHeader()
|
| {this.title="";this.uid=0;this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;}
|
| WebInspector.HeapSnapshot.prototype={_init:function()
|
| -{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Marking invisible edges\u2026");this._markInvisibleEdges();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function()
|
| +{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._buildEdgeIndexes();this._markInvisibleEdges();this._buildRetainers();this._calculateFlags();this._calculateDistances();var result=this._buildPostOrderIndex();this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._buildDominatedNodes();},_buildEdgeIndexes:function()
|
| {var nodes=this._nodes;var nodeCount=this.nodeCount;var firstEdgeIndexes=this._firstEdgeIndexes=new Uint32Array(nodeCount+1);var nodeFieldCount=this._nodeFieldCount;var edgeFieldsCount=this._edgeFieldsCount;var nodeEdgeCountOffset=this._nodeEdgeCountOffset;firstEdgeIndexes[nodeCount]=this._containmentEdges.length;for(var nodeOrdinal=0,edgeIndex=0;nodeOrdinal<nodeCount;++nodeOrdinal){firstEdgeIndexes[nodeOrdinal]=edgeIndex;edgeIndex+=nodes[nodeOrdinal*nodeFieldCount+nodeEdgeCountOffset]*edgeFieldsCount;}},_buildRetainers:function()
|
| {var retainingNodes=this._retainingNodes=new Uint32Array(this._edgeCount);var retainingEdges=this._retainingEdges=new Uint32Array(this._edgeCount);var firstRetainerIndex=this._firstRetainerIndex=new Uint32Array(this.nodeCount+1);var containmentEdges=this._containmentEdges;var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var edgeToNodeOffset=this._edgeToNodeOffset;var nodes=this._nodes;var firstEdgeIndexes=this._firstEdgeIndexes;var nodeCount=this.nodeCount;for(var toNodeFieldIndex=edgeToNodeOffset,l=containmentEdges.length;toNodeFieldIndex<l;toNodeFieldIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[toNodeFieldIndex];if(toNodeIndex%nodeFieldCount)
|
| throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];}
|
| @@ -885,12 +873,11 @@
|
| {this.removeEventListener("sorting complete",this._sortingComplete,this);this._populatedAndSorted=true;this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,this);},willHide:function()
|
| {this._clearCurrentHighlight();},populateContextMenu:function(profilesPanel,contextMenu,event)
|
| {var td=event.target.enclosingNodeOrSelfWithNodeName("td");if(!td)
|
| -return;var node=td.heapSnapshotNode;function revealInDominatorsView()
|
| +return;var node=td.heapSnapshotNode;if(node instanceof WebInspector.HeapSnapshotInstanceNode||node instanceof WebInspector.HeapSnapshotObjectNode){function revealInDominatorsView()
|
| {profilesPanel.showObject(node.snapshotNodeId,"Dominators");}
|
| -function revealInSummaryView()
|
| +contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}else if(node instanceof WebInspector.HeapSnapshotDominatorObjectNode){function revealInSummaryView()
|
| {profilesPanel.showObject(node.snapshotNodeId,"Summary");}
|
| -if(node&&node.showRetainingEdges){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}
|
| -else if(node instanceof WebInspector.HeapSnapshotInstanceNode||node instanceof WebInspector.HeapSnapshotObjectNode){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}else if(node instanceof WebInspector.HeapSnapshotDominatorObjectNode){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));}},resetSortingCache:function()
|
| +contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));}},resetSortingCache:function()
|
| {delete this._lastSortColumnIdentifier;delete this._lastSortAscending;},topLevelNodes:function()
|
| {return this.rootNode().children;},highlightObjectByHeapSnapshotId:function(heapSnapshotObjectId)
|
| {},highlightNode:function(node)
|
| @@ -1213,14 +1200,14 @@
|
| {return node.id;},_childHashForNode:function(childNode)
|
| {return childNode.snapshotNodeId;},comparator:function()
|
| {var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"retainedSize",false],shallowSize:["selfSize",sortAscending,"id",true],retainedSize:["retainedSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator(sortFields);},_emptyData:function()
|
| -{return{};},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype};WebInspector.HeapSnapshotLoader=function(dispatcher)
|
| -{this._reset();this._progress=new WebInspector.HeapSnapshotProgress(dispatcher);}
|
| +{return{};},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype};WebInspector.HeapSnapshotLoader=function()
|
| +{this._reset();}
|
| WebInspector.HeapSnapshotLoader.prototype={dispose:function()
|
| {this._reset();},_reset:function()
|
| {this._json="";this._state="find-snapshot-info";this._snapshot={};},close:function()
|
| {if(this._json)
|
| this._parseStringsArray();},buildSnapshot:function(constructorName)
|
| -{this._progress.updateStatus("Processing snapshot\u2026");var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot,this._progress);this._reset();return result;},_parseUintArray:function()
|
| +{var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot);this._reset();return result;},_parseUintArray:function()
|
| {var index=0;var char0="0".charCodeAt(0),char9="9".charCodeAt(0),closingBracket="]".charCodeAt(0);var length=this._json.length;while(true){while(index<length){var code=this._json.charCodeAt(index);if(char0<=code&&code<=char9)
|
| break;else if(code===closingBracket){this._json=this._json.slice(index+1);return false;}
|
| ++index;}
|
| @@ -1229,22 +1216,22 @@
|
| break;nextNumber*=10;nextNumber+=(code-char0);++index;}
|
| if(index===length){this._json=this._json.slice(startIndex);return true;}
|
| this._array[this._arrayIndex++]=nextNumber;}},_parseStringsArray:function()
|
| -{this._progress.updateStatus("Parsing strings\u2026");var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
|
| +{var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
|
| throw new Error("Incomplete JSON");this._json=this._json.slice(0,closingBracketIndex+1);this._snapshot.strings=JSON.parse(this._json);},write:function(chunk)
|
| {this._json+=chunk;switch(this._state){case"find-snapshot-info":{var snapshotToken="\"snapshot\"";var snapshotTokenIndex=this._json.indexOf(snapshotToken);if(snapshotTokenIndex===-1)
|
| -throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";this._progress.updateStatus("Loading snapshot info\u2026");}
|
| +throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";}
|
| case"parse-snapshot-info":{var closingBracketIndex=WebInspector.findBalancedCurlyBrackets(this._json);if(closingBracketIndex===-1)
|
| return;this._snapshot.snapshot=(JSON.parse(this._json.slice(0,closingBracketIndex)));this._json=this._json.slice(closingBracketIndex);this._state="find-nodes";}
|
| case"find-nodes":{var nodesToken="\"nodes\"";var nodesTokenIndex=this._json.indexOf(nodesToken);if(nodesTokenIndex===-1)
|
| return;var bracketIndex=this._json.indexOf("[",nodesTokenIndex);if(bracketIndex===-1)
|
| return;this._json=this._json.slice(bracketIndex+1);var node_fields_count=this._snapshot.snapshot.meta.node_fields.length;var nodes_length=this._snapshot.snapshot.node_count*node_fields_count;this._array=new Uint32Array(nodes_length);this._arrayIndex=0;this._state="parse-nodes";}
|
| -case"parse-nodes":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading nodes\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
|
| +case"parse-nodes":{if(this._parseUintArray())
|
| return;this._snapshot.nodes=this._array;this._state="find-edges";this._array=null;}
|
| case"find-edges":{var edgesToken="\"edges\"";var edgesTokenIndex=this._json.indexOf(edgesToken);if(edgesTokenIndex===-1)
|
| return;var bracketIndex=this._json.indexOf("[",edgesTokenIndex);if(bracketIndex===-1)
|
| return;this._json=this._json.slice(bracketIndex+1);var edge_fields_count=this._snapshot.snapshot.meta.edge_fields.length;var edges_length=this._snapshot.snapshot.edge_count*edge_fields_count;this._array=new Uint32Array(edges_length);this._arrayIndex=0;this._state="parse-edges";}
|
| -case"parse-edges":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading edges\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
|
| -return;this._snapshot.edges=this._array;this._array=null;this._state="find-strings";this._progress.updateStatus("Loading strings\u2026");}
|
| +case"parse-edges":{if(this._parseUintArray())
|
| +return;this._snapshot.edges=this._array;this._array=null;this._state="find-strings";}
|
| case"find-strings":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
|
| return;var bracketIndex=this._json.indexOf("[",stringsTokenIndex);if(bracketIndex===-1)
|
| return;this._json=this._json.slice(bracketIndex);this._state="accumulate-strings";break;}
|
| @@ -1256,7 +1243,10 @@
|
| WebInspector.HeapSnapshotRealWorker=function()
|
| {this._worker=new Worker("HeapSnapshotWorker.js");this._worker.addEventListener("message",this._messageReceived.bind(this),false);}
|
| WebInspector.HeapSnapshotRealWorker.prototype={_messageReceived:function(event)
|
| -{var message=event.data;this.dispatchEventToListeners("message",message);},postMessage:function(message)
|
| +{var message=event.data;if("callId"in message)
|
| +this.dispatchEventToListeners("message",message);else{if(message.object!=="console"){console.log(WebInspector.UIString("Worker asks to call a method '%s' on an unsupported object '%s'.",message.method,message.object));return;}
|
| +if(message.method!=="log"&&message.method!=="info"&&message.method!=="error"){console.log(WebInspector.UIString("Worker asks to call an unsupported method '%s' on the console object.",message.method));return;}
|
| +console[message.method].apply(window[message.object],message.arguments);}},postMessage:function(message)
|
| {this._worker.postMessage(message);},terminate:function()
|
| {this._worker.terminate();},__proto__:WebInspector.HeapSnapshotWorkerWrapper.prototype}
|
| WebInspector.AsyncTaskQueue=function()
|
| @@ -1277,9 +1267,9 @@
|
| {function send()
|
| {this.dispatchEventToListeners("message",message);}
|
| this._asyncTaskQueue.addTask(send.bind(this));},__proto__:WebInspector.HeapSnapshotWorkerWrapper.prototype}
|
| -WebInspector.HeapSnapshotWorkerProxy=function(eventHandler)
|
| -{this._eventHandler=eventHandler;this._nextObjectId=1;this._nextCallId=1;this._callbacks=[];this._previousCallbacks=[];this._worker=typeof InspectorTest==="undefined"?new WebInspector.HeapSnapshotRealWorker():new WebInspector.HeapSnapshotFakeWorker();this._worker.addEventListener("message",this._messageReceived,this);}
|
| -WebInspector.HeapSnapshotWorkerProxy.prototype={createLoader:function(snapshotConstructorName,proxyConstructor)
|
| +WebInspector.HeapSnapshotWorker=function()
|
| +{this._nextObjectId=1;this._nextCallId=1;this._callbacks=[];this._previousCallbacks=[];this._worker=typeof InspectorTest==="undefined"?new WebInspector.HeapSnapshotRealWorker():new WebInspector.HeapSnapshotFakeWorker();this._worker.addEventListener("message",this._messageReceived,this);}
|
| +WebInspector.HeapSnapshotWorker.prototype={createLoader:function(snapshotConstructorName,proxyConstructor)
|
| {var objectId=this._nextObjectId++;var proxy=new WebInspector.HeapSnapshotLoaderProxy(this,objectId,snapshotConstructorName,proxyConstructor);this._postMessage({callId:this._nextCallId++,disposition:"create",objectId:objectId,methodName:"WebInspector.HeapSnapshotLoader"});return proxy;},dispose:function()
|
| {this._worker.terminate();if(this._interval)
|
| clearInterval(this._interval);},disposeObject:function(objectId)
|
| @@ -1299,10 +1289,8 @@
|
| this._previousCallbacks[callId]=true;},_findFunction:function(name)
|
| {var path=name.split(".");var result=window;for(var i=0;i<path.length;++i)
|
| result=result[path[i]];return result;},_messageReceived:function(event)
|
| -{var data=event.data;if(data.eventName){if(this._eventHandler)
|
| -this._eventHandler(data.eventName,data.data);return;}
|
| -if(data.error){if(data.errorMethodName)
|
| -WebInspector.log(WebInspector.UIString("An error happened when a call for method '%s' was requested",data.errorMethodName));WebInspector.log(data.errorCallStack);delete this._callbacks[data.callId];return;}
|
| +{var data=event.data;if(event.data.error){if(event.data.errorMethodName)
|
| +WebInspector.log(WebInspector.UIString("An error happened when a call for method '%s' was requested",event.data.errorMethodName));WebInspector.log(event.data.errorCallStack);delete this._callbacks[data.callId];return;}
|
| if(!this._callbacks[data.callId])
|
| return;var callback=this._callbacks[data.callId];delete this._callbacks[data.callId];callback(data.result);},_postMessage:function(message)
|
| {this._worker.postMessage(message);},__proto__:WebInspector.Object.prototype}
|
| @@ -1318,10 +1306,9 @@
|
| {WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);this._snapshotConstructorName=snapshotConstructorName;this._proxyConstructor=proxyConstructor;this._pendingSnapshotConsumers=[];}
|
| WebInspector.HeapSnapshotLoaderProxy.prototype={addConsumer:function(callback)
|
| {this._pendingSnapshotConsumers.push(callback);},write:function(chunk,callback)
|
| -{this.callMethod(callback,"write",chunk);},close:function(callback)
|
| +{this.callMethod(callback,"write",chunk);},close:function()
|
| {function buildSnapshot()
|
| -{if(callback)
|
| -callback();this.callFactoryMethod(updateStaticData.bind(this),"buildSnapshot",this._proxyConstructor,this._snapshotConstructorName);}
|
| +{this.callFactoryMethod(updateStaticData.bind(this),"buildSnapshot",this._proxyConstructor,this._snapshotConstructorName);}
|
| function updateStaticData(snapshotProxy)
|
| {this.dispose();snapshotProxy.updateStaticData(notifyPendingConsumers.bind(this));}
|
| function notifyPendingConsumers(snapshotProxy)
|
| @@ -1351,6 +1338,10 @@
|
| this.callMethod(dataReceived.bind(this),"updateStaticData");},get totalSize()
|
| {return this._staticData.totalSize;},get uid()
|
| {return this._staticData.uid;},__proto__:WebInspector.HeapSnapshotProxyObject.prototype}
|
| +WebInspector.NativeHeapSnapshotProxy=function(worker,objectId)
|
| +{WebInspector.HeapSnapshotProxy.call(this,worker,objectId);}
|
| +WebInspector.NativeHeapSnapshotProxy.prototype={images:function(callback)
|
| +{this.callMethod(callback,"images");},__proto__:WebInspector.HeapSnapshotProxy.prototype}
|
| WebInspector.HeapSnapshotProviderProxy=function(worker,objectId)
|
| {WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);}
|
| WebInspector.HeapSnapshotProviderProxy.prototype={nodePosition:function(snapshotObjectId,callback)
|
| @@ -1361,7 +1352,7 @@
|
| {WebInspector.View.call(this);this.element.addStyleClass("heap-snapshot-view");this.parent=parent;this.parent.addEventListener("profile added",this._onProfileHeaderAdded,this);if(profile._profileType.id===WebInspector.TrackingHeapSnapshotProfileType.TypeId){this._trackingOverviewGrid=new WebInspector.HeapTrackingOverviewGrid(profile);this._trackingOverviewGrid.addEventListener(WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged,this._onIdsRangeChanged.bind(this));this._trackingOverviewGrid.show(this.element);}
|
| this.viewsContainer=document.createElement("div");this.viewsContainer.addStyleClass("views-container");this.element.appendChild(this.viewsContainer);this.containmentView=new WebInspector.View();this.containmentView.element.addStyleClass("view");this.containmentDataGrid=new WebInspector.HeapSnapshotContainmentDataGrid();this.containmentDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.containmentDataGrid.show(this.containmentView.element);this.containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.constructorsView=new WebInspector.View();this.constructorsView.element.addStyleClass("view");this.constructorsView.element.appendChild(this._createToolbarWithClassNameFilter());this.constructorsDataGrid=new WebInspector.HeapSnapshotConstructorsDataGrid();this.constructorsDataGrid.element.addStyleClass("class-view-grid");this.constructorsDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.constructorsDataGrid.show(this.constructorsView.element);this.constructorsDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dataGrid=(this.constructorsDataGrid);this.currentView=this.constructorsView;this.currentView.show(this.viewsContainer);this.diffView=new WebInspector.View();this.diffView.element.addStyleClass("view");this.diffView.element.appendChild(this._createToolbarWithClassNameFilter());this.diffDataGrid=new WebInspector.HeapSnapshotDiffDataGrid();this.diffDataGrid.element.addStyleClass("class-view-grid");this.diffDataGrid.show(this.diffView.element);this.diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dominatorView=new WebInspector.View();this.dominatorView.element.addStyleClass("view");this.dominatorDataGrid=new WebInspector.HeapSnapshotDominatorsDataGrid();this.dominatorDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.dominatorDataGrid.show(this.dominatorView.element);this.dominatorDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.retainmentViewHeader=document.createElement("div");this.retainmentViewHeader.addStyleClass("retainers-view-header");WebInspector.installDragHandle(this.retainmentViewHeader,this._startRetainersHeaderDragging.bind(this),this._retainersHeaderDragging.bind(this),this._endRetainersHeaderDragging.bind(this),"row-resize");var retainingPathsTitleDiv=document.createElement("div");retainingPathsTitleDiv.className="title";var retainingPathsTitle=document.createElement("span");retainingPathsTitle.textContent=WebInspector.UIString("Object's retaining tree");retainingPathsTitleDiv.appendChild(retainingPathsTitle);this.retainmentViewHeader.appendChild(retainingPathsTitleDiv);this.element.appendChild(this.retainmentViewHeader);this.retainmentView=new WebInspector.View();this.retainmentView.element.addStyleClass("view");this.retainmentView.element.addStyleClass("retaining-paths-view");this.retainmentDataGrid=new WebInspector.HeapSnapshotRetainmentDataGrid();this.retainmentDataGrid.show(this.retainmentView.element);this.retainmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._inspectedObjectChanged,this);this.retainmentView.show(this.element);this.retainmentDataGrid.reset();this.viewSelect=new WebInspector.StatusBarComboBox(this._onSelectedViewChanged.bind(this));this.views=[{title:"Summary",view:this.constructorsView,grid:this.constructorsDataGrid},{title:"Comparison",view:this.diffView,grid:this.diffDataGrid},{title:"Containment",view:this.containmentView,grid:this.containmentDataGrid}];if(WebInspector.settings.showAdvancedHeapSnapshotProperties.get())
|
| this.views.push({title:"Dominators",view:this.dominatorView,grid:this.dominatorDataGrid});this.views.current=0;for(var i=0;i<this.views.length;++i)
|
| -this.viewSelect.createOption(WebInspector.UIString(this.views[i].title));this._profileUid=profile.uid;this._profileTypeId=profile.profileType().id;this.baseSelect=new WebInspector.StatusBarComboBox(this._changeBase.bind(this));this.baseSelect.element.addStyleClass("hidden");this._updateBaseOptions();this.filterSelect=new WebInspector.StatusBarComboBox(this._changeFilter.bind(this));this._updateFilterOptions();this.selectedSizeText=new WebInspector.StatusBarText("");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._getHoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),undefined,true);this.profile.load(profileCallback.bind(this));function profileCallback(heapSnapshotProxy)
|
| +this.viewSelect.createOption(WebInspector.UIString(this.views[i].title));this._profileUid=profile.uid;this._profileTypeId=profile.profileType().id;this.baseSelect=new WebInspector.StatusBarComboBox(this._changeBase.bind(this));this.baseSelect.element.addStyleClass("hidden");this._updateBaseOptions();this.filterSelect=new WebInspector.StatusBarComboBox(this._changeFilter.bind(this));this._updateFilterOptions();this.helpButton=new WebInspector.StatusBarButton("","heap-snapshot-help-status-bar-item status-bar-item");this.helpButton.addEventListener("click",this._helpClicked,this);this.selectedSizeText=new WebInspector.StatusBarText("");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._getHoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),undefined,true);this.profile.load(profileCallback.bind(this));function profileCallback(heapSnapshotProxy)
|
| {var list=this._profiles();var profileIndex;for(var i=0;i<list.length;++i){if(list[i].uid===this._profileUid){profileIndex=i;break;}}
|
| if(profileIndex>0)
|
| this.baseSelect.setSelectedIndex(profileIndex-1);else
|
| @@ -1371,7 +1362,7 @@
|
| this.constructorsDataGrid.setSelectionRange(minId,maxId);},dispose:function()
|
| {this.parent.removeEventListener("profile added",this._onProfileHeaderAdded,this);this.profile.dispose();if(this.baseProfile)
|
| this.baseProfile.dispose();this.containmentDataGrid.dispose();this.constructorsDataGrid.dispose();this.diffDataGrid.dispose();this.dominatorDataGrid.dispose();this.retainmentDataGrid.dispose();},get statusBarItems()
|
| -{return[this.viewSelect.element,this.baseSelect.element,this.filterSelect.element,this.selectedSizeText.element];},get profile()
|
| +{return[this.viewSelect.element,this.baseSelect.element,this.filterSelect.element,this.helpButton.element,this.selectedSizeText.element];},get profile()
|
| {return this.parent.getProfile(this._profileTypeId,this._profileUid);},get baseProfile()
|
| {return this.parent.getProfile(this._profileTypeId,this._baseProfileUid);},wasShown:function()
|
| {this.profile.load(profileCallback.bind(this));function profileCallback(){this.profile._wasShown();if(this.baseProfile)
|
| @@ -1454,7 +1445,16 @@
|
| return;var row=target.enclosingNodeOrSelfWithNodeName("tr");if(!row)
|
| return;span.node=row._dataGridNode;return span;},_resolveObjectForPopover:function(element,showCallback,objectGroupName)
|
| {if(this.profile.fromFile())
|
| -return;element.node.queryObjectContent(showCallback,objectGroupName);},_startRetainersHeaderDragging:function(event)
|
| +return;element.node.queryObjectContent(showCallback,objectGroupName);},_helpClicked:function(event)
|
| +{if(!this._helpPopoverContentElement){var refTypes=["a:","console-formatted-name",WebInspector.UIString("property"),"0:","console-formatted-name",WebInspector.UIString("element"),"a:","console-formatted-number",WebInspector.UIString("context var"),"a:","console-formatted-null",WebInspector.UIString("system prop")];var objTypes=[" a ","console-formatted-object","Object","\"a\"","console-formatted-string","String","/a/","console-formatted-string","RegExp","a()","console-formatted-function","Function","a[]","console-formatted-object","Array","num","console-formatted-number","Number"," a ","console-formatted-null","System"];var contentElement=document.createElement("table");contentElement.className="heap-snapshot-help";var headerRow=document.createElement("tr");var propsHeader=document.createElement("th");propsHeader.textContent=WebInspector.UIString("Property types:");headerRow.appendChild(propsHeader);var objsHeader=document.createElement("th");objsHeader.textContent=WebInspector.UIString("Object types:");headerRow.appendChild(objsHeader);contentElement.appendChild(headerRow);function appendHelp(help,index,cell)
|
| +{var div=document.createElement("div");div.className="source-code event-properties";var name=document.createElement("span");name.textContent=help[index];name.className=help[index+1];div.appendChild(name);var desc=document.createElement("span");desc.textContent=" "+help[index+2];div.appendChild(desc);cell.appendChild(div);}
|
| +var len=Math.max(refTypes.length,objTypes.length);for(var i=0;i<len;i+=3){var row=document.createElement("tr");var refCell=document.createElement("td");if(refTypes[i])
|
| +appendHelp(refTypes,i,refCell);row.appendChild(refCell);var objCell=document.createElement("td");if(objTypes[i])
|
| +appendHelp(objTypes,i,objCell);row.appendChild(objCell);contentElement.appendChild(row);}
|
| +this._helpPopoverContentElement=contentElement;this.helpPopover=new WebInspector.Popover();}
|
| +if(this.helpPopover.isShowing())
|
| +this.helpPopover.hide();else
|
| +this.helpPopover.show(this._helpPopoverContentElement,this.helpButton.element);},_startRetainersHeaderDragging:function(event)
|
| {if(!this.isShowing())
|
| return false;this._previousDragPosition=event.pageY;return true;},_retainersHeaderDragging:function(event)
|
| {var height=this.retainmentView.element.clientHeight;height+=this._previousDragPosition-event.pageY;this._previousDragPosition=event.pageY;this._updateRetainmentViewHeight(height);event.consume(true);},_endRetainersHeaderDragging:function(event)
|
| @@ -1542,62 +1542,49 @@
|
| {title=title||WebInspector.UIString("Recording\u2026");return new WebInspector.HeapProfileHeader(this,title);},_requestProfilesFromBackend:function(populateCallback)
|
| {},__proto__:WebInspector.HeapSnapshotProfileType.prototype}
|
| WebInspector.HeapProfileHeader=function(type,title,uid,maxJSObjectId)
|
| -{WebInspector.ProfileHeader.call(this,type,title,uid);this.maxJSObjectId=maxJSObjectId;this._receiver=null;this._snapshotProxy=null;this._totalNumberOfChunks=0;this._transferHandler=null;}
|
| +{WebInspector.ProfileHeader.call(this,type,title,uid);this.maxJSObjectId=maxJSObjectId;this._receiver=null;this._snapshotProxy=null;this._totalNumberOfChunks=0;}
|
| WebInspector.HeapProfileHeader.prototype={createSidebarTreeElement:function()
|
| {return new WebInspector.ProfileSidebarTreeElement(this,WebInspector.UIString("Snapshot %d"),"heap-snapshot-sidebar-tree-item");},createView:function(profilesPanel)
|
| {return new WebInspector.HeapSnapshotView(profilesPanel,this);},load:function(callback)
|
| {if(this.uid===-1)
|
| return;if(this._snapshotProxy){callback(this._snapshotProxy);return;}
|
| -this._numberOfChunks=0;if(!this._receiver){this._setupWorker();this._transferHandler=new WebInspector.BackendSnapshotLoader(this);this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this.startSnapshotTransfer();}
|
| +this._numberOfChunks=0;this._savedChunks=0;this._savingToFile=false;if(!this._receiver){this._setupWorker();this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this.startSnapshotTransfer();}
|
| var loaderProxy=(this._receiver);loaderProxy.addConsumer(callback);},startSnapshotTransfer:function()
|
| {HeapProfilerAgent.getHeapSnapshot(this.uid);},snapshotConstructorName:function()
|
| {return"JSHeapSnapshot";},snapshotProxyConstructor:function()
|
| {return WebInspector.HeapSnapshotProxy;},_setupWorker:function()
|
| {function setProfileWait(event)
|
| {this.sidebarElement.wait=event.data;}
|
| -var worker=new WebInspector.HeapSnapshotWorkerProxy(this._handleWorkerEvent.bind(this));worker.addEventListener("wait",setProfileWait,this);var loaderProxy=worker.createLoader(this.snapshotConstructorName(),this.snapshotProxyConstructor());loaderProxy.addConsumer(this._snapshotReceived.bind(this));this._receiver=loaderProxy;},_handleWorkerEvent:function(eventName,data)
|
| -{if(WebInspector.HeapSnapshotProgress.Event.Update!==eventName)
|
| -return;this._updateSubtitle(data);},dispose:function()
|
| +var worker=new WebInspector.HeapSnapshotWorker();worker.addEventListener("wait",setProfileWait,this);var loaderProxy=worker.createLoader(this.snapshotConstructorName(),this.snapshotProxyConstructor());loaderProxy.addConsumer(this._snapshotReceived.bind(this));this._receiver=loaderProxy;},dispose:function()
|
| {if(this._receiver)
|
| this._receiver.close();else if(this._snapshotProxy)
|
| -this._snapshotProxy.dispose();if(this._view){var view=this._view;this._view=null;view.dispose();}},_updateSubtitle:function(value)
|
| -{this.sidebarElement.subtitle=value;},_didCompleteSnapshotTransfer:function()
|
| +this._snapshotProxy.dispose();if(this._view){var view=this._view;this._view=null;view.dispose();}},_updateTransferProgress:function(value,maxValue)
|
| +{var percentValue=((maxValue?(value/maxValue):0)*100).toFixed(0);if(this._savingToFile)
|
| +this.sidebarElement.subtitle=WebInspector.UIString("Saving\u2026 %d\%",percentValue);else
|
| +this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026 %d\%",percentValue);},_updateSnapshotStatus:function()
|
| {this.sidebarElement.subtitle=Number.bytesToString(this._snapshotProxy.totalSize);this.sidebarElement.wait=false;},transferChunk:function(chunk)
|
| -{this._transferHandler.transferChunk(chunk);},_snapshotReceived:function(snapshotProxy)
|
| +{++this._numberOfChunks;this._receiver.write(chunk,callback.bind(this));function callback()
|
| +{this._updateTransferProgress(++this._savedChunks,this._totalNumberOfChunks);if(this._totalNumberOfChunks===this._savedChunks){if(this._savingToFile)
|
| +this._updateSnapshotStatus();else
|
| +this.sidebarElement.subtitle=WebInspector.UIString("Parsing\u2026");this._receiver.close();}}},_snapshotReceived:function(snapshotProxy)
|
| {this._receiver=null;if(snapshotProxy)
|
| -this._snapshotProxy=snapshotProxy;this._didCompleteSnapshotTransfer();var worker=(this._snapshotProxy.worker);this.isTemporary=false;worker.startCheckingForLongRunningCalls();this.notifySnapshotReceived();},notifySnapshotReceived:function()
|
| +this._snapshotProxy=snapshotProxy;this._updateSnapshotStatus();var worker=(this._snapshotProxy.worker);this.isTemporary=false;worker.startCheckingForLongRunningCalls();this.notifySnapshotReceived();},notifySnapshotReceived:function()
|
| {this._profileType._snapshotReceived(this);},finishHeapSnapshot:function()
|
| -{if(this._transferHandler){this._transferHandler.finishTransfer();this._totalNumberOfChunks=this._transferHandler._totalNumberOfChunks;}},_wasShown:function()
|
| +{this._totalNumberOfChunks=this._numberOfChunks;},_wasShown:function()
|
| {},canSaveToFile:function()
|
| {return!this.fromFile()&&!!this._snapshotProxy&&!this._receiver;},saveToFile:function()
|
| -{var fileOutputStream=new WebInspector.FileOutputStream();function onOpen()
|
| -{this._receiver=fileOutputStream;this._transferHandler=new WebInspector.SaveSnapshotHandler(this);HeapProfilerAgent.getHeapSnapshot(this.uid);}
|
| -this._fileName=this._fileName||"Heap-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
|
| -{this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this._setupWorker();var delegate=new WebInspector.HeapSnapshotLoadFromFileDelegate(this);var fileReader=this._createFileReader(file,delegate);fileReader.start(this._receiver);},_createFileReader:function(file,delegate)
|
| +{this._numberOfChunks=0;var fileOutputStream=new WebInspector.FileOutputStream();function onOpen()
|
| +{this._receiver=fileOutputStream;this._savedChunks=0;this._updateTransferProgress(0,this._totalNumberOfChunks);HeapProfilerAgent.getHeapSnapshot(this.uid);}
|
| +this._savingToFile=true;this._fileName=this._fileName||"Heap-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
|
| +{this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this._setupWorker();this._numberOfChunks=0;this._savingToFile=false;var delegate=new WebInspector.HeapSnapshotLoadFromFileDelegate(this);var fileReader=this._createFileReader(file,delegate);fileReader.start(this._receiver);},_createFileReader:function(file,delegate)
|
| {return new WebInspector.ChunkedFileReader(file,10000000,delegate);},__proto__:WebInspector.ProfileHeader.prototype}
|
| -WebInspector.SnapshotTransferHandler=function(header,title)
|
| -{this._numberOfChunks=0;this._savedChunks=0;this._header=header;this._totalNumberOfChunks=0;this._title=title;}
|
| -WebInspector.SnapshotTransferHandler.prototype={transferChunk:function(chunk)
|
| -{++this._numberOfChunks;this._header._receiver.write(chunk,this._didTransferChunk.bind(this));},finishTransfer:function()
|
| -{},_didTransferChunk:function()
|
| -{this._updateProgress(++this._savedChunks,this._totalNumberOfChunks);},_updateProgress:function(value,total)
|
| -{}}
|
| -WebInspector.SaveSnapshotHandler=function(header)
|
| -{WebInspector.SnapshotTransferHandler.call(this,header,"Saving\u2026 %d\%");this._totalNumberOfChunks=header._totalNumberOfChunks;this._updateProgress(0,this._totalNumberOfChunks);}
|
| -WebInspector.SaveSnapshotHandler.prototype={_updateProgress:function(value,total)
|
| -{var percentValue=((total?(value/total):0)*100).toFixed(0);this._header._updateSubtitle(WebInspector.UIString(this._title,percentValue));if(value===total){this._header._receiver.close();this._header._didCompleteSnapshotTransfer();}},__proto__:WebInspector.SnapshotTransferHandler.prototype}
|
| -WebInspector.BackendSnapshotLoader=function(header)
|
| -{WebInspector.SnapshotTransferHandler.call(this,header,"Loading\u2026 %d\%");}
|
| -WebInspector.BackendSnapshotLoader.prototype={finishTransfer:function()
|
| -{this._header._receiver.close(this._didFinishTransfer.bind(this));this._totalNumberOfChunks=this._numberOfChunks;},_didFinishTransfer:function()
|
| -{console.assert(this._totalNumberOfChunks===this._savedChunks,"Not all chunks were transfered.");},__proto__:WebInspector.SnapshotTransferHandler.prototype}
|
| WebInspector.HeapSnapshotLoadFromFileDelegate=function(snapshotHeader)
|
| {this._snapshotHeader=snapshotHeader;}
|
| WebInspector.HeapSnapshotLoadFromFileDelegate.prototype={onTransferStarted:function()
|
| {},onChunkTransferred:function(reader)
|
| -{},onTransferFinished:function()
|
| -{},onError:function(reader,e)
|
| -{switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' not found.",reader.fileName()));break;case e.target.error.NOT_READABLE_ERR:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' is not readable",reader.fileName()));break;case e.target.error.ABORT_ERR:break;default:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code));}}}
|
| +{this._snapshotHeader._updateTransferProgress(reader.loadedSize(),reader.fileSize());},onTransferFinished:function()
|
| +{this._snapshotHeader.finishHeapSnapshot();},onError:function(reader,e)
|
| +{switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' not found.",reader.fileName());break;case e.target.error.NOT_READABLE_ERR:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' is not readable",reader.fileName());break;case e.target.error.ABORT_ERR:break;default:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code);}}}
|
| WebInspector.HeapTrackingOverviewGrid=function(heapProfileHeader)
|
| {WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.id="heap-recording-view";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("heap-recording");this._overviewCanvas=this._overviewContainer.createChild("canvas","heap-recording-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.HeapTrackingOverviewGrid.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._profileSamples=heapProfileHeader._profileSamples||heapProfileHeader._profileType._profileSamples;if(heapProfileHeader.isTemporary){this._profileType=heapProfileHeader._profileType;this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);}
|
| var timestamps=this._profileSamples.timestamps;var totalTime=this._profileSamples.totalTime;this._windowLeft=0.0;this._windowRight=totalTime&×tamps.length?(timestamps[timestamps.length-1]-timestamps[0])/totalTime:1.0;this._overviewGrid.setWindow(this._windowLeft,this._windowRight);this._yScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();this._xScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();}
|
| @@ -1647,17 +1634,16 @@
|
| {this._objects=[];this._global=globalObject;this._postMessage=postMessage;}
|
| WebInspector.HeapSnapshotWorkerDispatcher.prototype={_findFunction:function(name)
|
| {var path=name.split(".");var result=this._global;for(var i=0;i<path.length;++i)
|
| -result=result[path[i]];return result;},sendEvent:function(name,data)
|
| -{this._postMessage({eventName:name,data:data});},dispatchMessage:function(event)
|
| -{var data=event.data;var response={callId:data.callId};try{switch(data.disposition){case"create":{var constructorFunction=this._findFunction(data.methodName);this._objects[data.objectId]=new constructorFunction(this);break;}
|
| +result=result[path[i]];return result;},dispatchMessage:function(event)
|
| +{var data=event.data;var response={callId:data.callId};try{switch(data.disposition){case"create":{var constructorFunction=this._findFunction(data.methodName);this._objects[data.objectId]=new constructorFunction();break;}
|
| case"dispose":{delete this._objects[data.objectId];break;}
|
| case"getter":{var object=this._objects[data.objectId];var result=object[data.methodName];response.result=result;break;}
|
| case"factory":{var object=this._objects[data.objectId];var result=object[data.methodName].apply(object,data.methodArguments);if(result)
|
| this._objects[data.newObjectId]=result;response.result=!!result;break;}
|
| case"method":{var object=this._objects[data.objectId];response.result=object[data.methodName].apply(object,data.methodArguments);break;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName)
|
| response.errorMethodName=data.methodName;}
|
| -this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress)
|
| -{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};WebInspector.HeapSnapshot.call(this,profile,progress);}
|
| +this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile)
|
| +{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};WebInspector.HeapSnapshot.call(this,profile);}
|
| WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex)
|
| {return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edges,edgeIndex)
|
| {return new WebInspector.JSHeapSnapshotEdge(this,edges,edgeIndex);},createRetainingEdge:function(retainedNodeIndex,retainerIndex)
|
| @@ -1801,24 +1787,19 @@
|
| this.sort(this.lastComparator,true);},restore:function()
|
| {if(!this._savedChildren)
|
| return;this.children[0].restorePosition();WebInspector.ProfileDataGridTree.prototype.restore.call(this);},_merge:WebInspector.TopDownProfileDataGridNode.prototype._merge,_sharedPopulate:WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate,__proto__:WebInspector.ProfileDataGridTree.prototype};WebInspector.CanvasProfileView=function(profile)
|
| -{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this.element.addStyleClass("canvas-profile-view");this._profile=profile;this._traceLogId=profile.traceLogId();this._traceLogPlayer=profile.traceLogPlayer();this._linkifier=new WebInspector.Linkifier();const defaultReplayLogWidthPercent=0.34;this._replayInfoSplitView=new WebInspector.SplitView(true,"canvasProfileViewReplaySplitLocation",defaultReplayLogWidthPercent);this._replayInfoSplitView.setMainElementConstraints(defaultReplayLogWidthPercent,defaultReplayLogWidthPercent);this._replayInfoSplitView.show(this.element);this._imageSplitView=new WebInspector.SplitView(false,"canvasProfileViewSplitLocation",300);this._imageSplitView.show(this._replayInfoSplitView.firstElement());var replayImageContainer=this._imageSplitView.firstElement();replayImageContainer.id="canvas-replay-image-container";this._replayImageElement=replayImageContainer.createChild("image","canvas-replay-image");this._debugInfoElement=replayImageContainer.createChild("div","canvas-debug-info hidden");this._spinnerIcon=replayImageContainer.createChild("img","canvas-spinner-icon hidden");var replayLogContainer=this._imageSplitView.secondElement();var controlsContainer=replayLogContainer.createChild("div","status-bar");var logGridContainer=replayLogContainer.createChild("div","canvas-replay-log");this._createControlButton(controlsContainer,"canvas-replay-first-step",WebInspector.UIString("First call."),this._onReplayFirstStepClick.bind(this));this._createControlButton(controlsContainer,"canvas-replay-prev-step",WebInspector.UIString("Previous call."),this._onReplayStepClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-step",WebInspector.UIString("Next call."),this._onReplayStepClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-prev-draw",WebInspector.UIString("Previous drawing call."),this._onReplayDrawingCallClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-draw",WebInspector.UIString("Next drawing call."),this._onReplayDrawingCallClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-last-step",WebInspector.UIString("Last call."),this._onReplayLastStepClick.bind(this));this._replayContextSelector=new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this));this._replayContextSelector.createOption(WebInspector.UIString("<screenshot auto>"),WebInspector.UIString("Show screenshot of the last replayed resource."),"");controlsContainer.appendChild(this._replayContextSelector.element);this._installReplayInfoSidebarWidgets(controlsContainer);this._replayStateView=new WebInspector.CanvasReplayStateView(this._traceLogPlayer);this._replayStateView.show(this._replayInfoSplitView.secondElement());this._replayContexts={};var columns=[{title:"#",sortable:false,width:"5%"},{title:WebInspector.UIString("Call"),sortable:false,width:"75%",disclosure:true},{title:WebInspector.UIString("Location"),sortable:false,width:"20%"}];this._logGrid=new WebInspector.DataGrid(columns);this._logGrid.element.addStyleClass("fill");this._logGrid.show(logGridContainer);this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._replayTraceLog,this);this.element.addEventListener("mousedown",this._onMouseClick.bind(this),true);this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._popoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this._popoverHelper.setRemoteObjectFormatter(this._hexNumbersFormatter.bind(this));this._requestTraceLog(0);}
|
| +{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this._profile=profile;this._traceLogId=profile.traceLogId();this.element.addStyleClass("canvas-profile-view");this._linkifier=new WebInspector.Linkifier();this._splitView=new WebInspector.SplitView(false,"canvasProfileViewSplitLocation",300);var replayImageContainer=this._splitView.firstElement();replayImageContainer.id="canvas-replay-image-container";this._replayImageElement=replayImageContainer.createChild("image","canvas-replay-image");this._debugInfoElement=replayImageContainer.createChild("div","canvas-debug-info hidden");this._spinnerIcon=replayImageContainer.createChild("img","canvas-spinner-icon hidden");var replayInfoContainer=this._splitView.secondElement();var controlsContainer=replayInfoContainer.createChild("div","status-bar");var logGridContainer=replayInfoContainer.createChild("div","canvas-replay-log");this._createControlButton(controlsContainer,"canvas-replay-first-step",WebInspector.UIString("First call."),this._onReplayFirstStepClick.bind(this));this._createControlButton(controlsContainer,"canvas-replay-prev-step",WebInspector.UIString("Previous call."),this._onReplayStepClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-step",WebInspector.UIString("Next call."),this._onReplayStepClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-prev-draw",WebInspector.UIString("Previous drawing call."),this._onReplayDrawingCallClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-draw",WebInspector.UIString("Next drawing call."),this._onReplayDrawingCallClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-last-step",WebInspector.UIString("Last call."),this._onReplayLastStepClick.bind(this));this._replayContextSelector=new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this));this._replayContextSelector.createOption("<screenshot auto>",WebInspector.UIString("Show screenshot of the last replayed resource."),"");controlsContainer.appendChild(this._replayContextSelector.element);this._replayContexts={};this._currentResourceStates={};var columns=[{title:"#",sortable:true,width:"5%"},{title:WebInspector.UIString("Call"),sortable:true,width:"75%",disclosure:true},{title:WebInspector.UIString("Location"),sortable:true,width:"20%"}];this._logGrid=new WebInspector.DataGrid(columns);this._logGrid.element.addStyleClass("fill");this._logGrid.show(logGridContainer);this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._replayTraceLog.bind(this));this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._popoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this._splitView.show(this.element);this._requestTraceLog(0);}
|
| WebInspector.CanvasProfileView.TraceLogPollingInterval=500;WebInspector.CanvasProfileView.prototype={dispose:function()
|
| {this._linkifier.reset();},get statusBarItems()
|
| {return[];},get profile()
|
| {return this._profile;},elementsToRestoreScrollPositionsFor:function()
|
| -{return[this._logGrid.scrollContainer];},_installReplayInfoSidebarWidgets:function(controlsContainer)
|
| -{this._replayInfoResizeWidgetElement=controlsContainer.createChild("div","resizer-widget");this._replayInfoSplitView.installResizer(this._replayInfoResizeWidgetElement);this._toggleReplayStateSidebarButton=new WebInspector.StatusBarButton("","right-sidebar-show-hide-button canvas-sidebar-show-hide-button",3);this._toggleReplayStateSidebarButton.addEventListener("click",clickHandler,this);controlsContainer.appendChild(this._toggleReplayStateSidebarButton.element);this._enableReplayInfoSidebar(false);function clickHandler()
|
| -{this._enableReplayInfoSidebar(this._toggleReplayStateSidebarButton.state==="left");}},_enableReplayInfoSidebar:function(show)
|
| -{if(show){this._toggleReplayStateSidebarButton.state="right";this._toggleReplayStateSidebarButton.title=WebInspector.UIString("Hide sidebar.");this._replayInfoSplitView.showBoth();}else{this._toggleReplayStateSidebarButton.state="left";this._toggleReplayStateSidebarButton.title=WebInspector.UIString("Show sidebar.");this._replayInfoSplitView.showOnlyFirst();}
|
| -this._replayInfoResizeWidgetElement.enableStyleClass("hidden",!show);},_onMouseClick:function(event)
|
| -{var resourceLinkElement=event.target.enclosingNodeOrSelfWithClass("canvas-formatted-resource");if(resourceLinkElement){this._enableReplayInfoSidebar(true);this._replayStateView.selectResource(resourceLinkElement.__resourceId);event.consume(true);return;}
|
| -if(event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link"))
|
| -event.consume(false);},_createControlButton:function(parent,className,title,clickCallback)
|
| -{var button=new WebInspector.StatusBarButton(title,className+" canvas-replay-button");parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);},_onReplayContextChanged:function()
|
| -{var selectedContextId=this._replayContextSelector.selectedOption().value;function didReceiveResourceState(resourceState)
|
| -{this._enableWaitIcon(false);if(selectedContextId!==this._replayContextSelector.selectedOption().value)
|
| -return;var imageURL=(resourceState&&resourceState.imageURL)||"";this._replayImageElement.src=imageURL;this._replayImageElement.style.visibility=imageURL?"":"hidden";}
|
| -this._enableWaitIcon(true);this._traceLogPlayer.getResourceState(selectedContextId,didReceiveResourceState.bind(this));},_onReplayStepClick:function(forward)
|
| +{return[this._logGrid.scrollContainer];},_createControlButton:function(parent,className,title,clickCallback)
|
| +{var button=new WebInspector.StatusBarButton(title,className);parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);},_onReplayContextChanged:function()
|
| +{function didReceiveResourceState(error,resourceState)
|
| +{const emptyTransparentImageURL="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";this._enableWaitIcon(false);if(error)
|
| +return;this._currentResourceStates[resourceState.id]=resourceState;var selectedContextId=this._replayContextSelector.selectedOption().value;if(selectedContextId===resourceState.id)
|
| +this._replayImageElement.src=resourceState.imageURL||emptyTransparentImageURL;}
|
| +var selectedContextId=this._replayContextSelector.selectedOption().value||"auto";var resourceState=this._currentResourceStates[selectedContextId];if(resourceState)
|
| +this._replayImageElement.src=resourceState.imageURL;else{this._enableWaitIcon(true);CanvasAgent.getResourceState(this._traceLogId,selectedContextId,didReceiveResourceState.bind(this));}},_onReplayStepClick:function(forward)
|
| {var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
|
| return;var nextNode=selectedNode;do{nextNode=forward?nextNode.traverseNextNode(false):nextNode.traversePreviousNode(false);}while(nextNode&&typeof nextNode.index!=="number");(nextNode||selectedNode).revealAndSelect();},_onReplayDrawingCallClick:function(forward)
|
| {var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
|
| @@ -1837,19 +1818,19 @@
|
| {this._spinnerIcon.enableStyleClass("hidden",!enable);this._debugInfoElement.enableStyleClass("hidden",enable);},_replayTraceLog:function()
|
| {if(this._pendingReplayTraceLogEvent)
|
| return;var index=this._selectedCallIndex();if(index===-1||index===this._lastReplayCallIndex)
|
| -return;this._lastReplayCallIndex=index;this._pendingReplayTraceLogEvent=true;function didReplayTraceLog(resourceState,replayTime)
|
| -{delete this._pendingReplayTraceLogEvent;this._enableWaitIcon(false);this._debugInfoElement.textContent="Replay time: "+Number.secondsToString(replayTime/1000,true);this._onReplayContextChanged();if(index!==this._selectedCallIndex())
|
| +return;this._lastReplayCallIndex=index;this._pendingReplayTraceLogEvent=true;function didReplayTraceLog(error,resourceState,replayTime)
|
| +{delete this._pendingReplayTraceLogEvent;this._enableWaitIcon(false);if(!error){this._currentResourceStates={};this._currentResourceStates["auto"]=resourceState;this._currentResourceStates[resourceState.id]=resourceState;this._debugInfoElement.textContent="Replay time: "+Number(replayTime).toFixed()+"ms";this._onReplayContextChanged();}
|
| +if(index!==this._selectedCallIndex())
|
| this._replayTraceLog();}
|
| -this._enableWaitIcon(true);this._traceLogPlayer.replayTraceLog(index,didReplayTraceLog.bind(this));},_requestTraceLog:function(offset)
|
| -{function didReceiveTraceLog(traceLog)
|
| -{this._enableWaitIcon(false);if(!traceLog)
|
| +this._enableWaitIcon(true);CanvasAgent.replayTraceLog(this._traceLogId,index,didReplayTraceLog.bind(this));},_didReceiveTraceLog:function(error,traceLog)
|
| +{this._enableWaitIcon(false);if(error||!traceLog)
|
| return;var callNodes=[];var calls=traceLog.calls;var index=traceLog.startOffset;for(var i=0,n=calls.length;i<n;++i)
|
| callNodes.push(this._createCallNode(index++,calls[i]));var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i){var contextId=contexts[i].resourceId||"";var description=contexts[i].description||"";if(this._replayContexts[contextId])
|
| continue;this._replayContexts[contextId]=true;this._replayContextSelector.createOption(description,WebInspector.UIString("Show screenshot of this context's canvas."),contextId);}
|
| this._appendCallNodes(callNodes);if(traceLog.alive)
|
| setTimeout(this._requestTraceLog.bind(this,index),WebInspector.CanvasProfileView.TraceLogPollingInterval);else
|
| -this._flattenSingleFrameNode();this._profile._updateCapturingStatus(traceLog);this._onReplayLastStepClick();}
|
| -this._enableWaitIcon(true);this._traceLogPlayer.getTraceLog(offset,undefined,didReceiveTraceLog.bind(this));},_selectedCallIndex:function()
|
| +this._flattenSingleFrameNode();this._profile._updateCapturingStatus(traceLog);this._onReplayLastStepClick();},_requestTraceLog:function(offset)
|
| +{this._enableWaitIcon(true);CanvasAgent.getTraceLog(this._traceLogId,offset,undefined,this._didReceiveTraceLog.bind(this));},_selectedCallIndex:function()
|
| {var node=this._logGrid.selectedNode;return node?this._peekLastRecursively(node).index:-1;},_peekLastRecursively:function(node)
|
| {var lastChild;while((lastChild=node.children.peekLast()))
|
| node=lastChild;return node;},_appendCallNodes:function(callNodes)
|
| @@ -1869,23 +1850,24 @@
|
| drawCallGroup=splitDrawCallGroup(drawCallGroup);else
|
| groupHasDrawCall=true;}}},_createCallNode:function(index,call)
|
| {var callViewElement=document.createElement("div");var data={};data[0]=index+1;data[1]=callViewElement;data[2]="";if(call.sourceURL){var lineNumber=Math.max(0,call.lineNumber-1)||0;var columnNumber=Math.max(0,call.columnNumber-1)||0;data[2]=this._linkifier.linkifyLocation(call.sourceURL,lineNumber,columnNumber);}
|
| -callViewElement.createChild("span","canvas-function-name").textContent=call.functionName||"context."+call.property;if(call.arguments){callViewElement.createTextChild("(");for(var i=0,n=call.arguments.length;i<n;++i){var argument=(call.arguments[i]);if(i)
|
| -callViewElement.createTextChild(", ");var element=WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(argument);element.__argumentIndex=i;callViewElement.appendChild(element);}
|
| -callViewElement.createTextChild(")");}else if(call.value){callViewElement.createTextChild(" = ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.value));}
|
| -if(call.result){callViewElement.createTextChild(" => ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.result));}
|
| -var node=new WebInspector.DataGridNode(data);node.index=index;node.selectable=true;node.call=call;return node;},_popoverAnchor:function(element,event)
|
| -{var argumentElement=element.enclosingNodeOrSelfWithClass("canvas-call-argument");if(!argumentElement||argumentElement.__suppressPopover)
|
| +callViewElement.createChild("span","canvas-function-name").textContent=call.functionName||"context."+call.property;if(call.arguments){callViewElement.createTextChild("(");for(var i=0,n=call.arguments.length;i<n;++i){var argument=call.arguments[i];if(i)
|
| +callViewElement.createTextChild(", ");this._createCallArgumentChild(callViewElement,argument)._argumentIndex=i;}
|
| +callViewElement.createTextChild(")");}else if(typeof call.value!=="undefined"){callViewElement.createTextChild(" = ");this._createCallArgumentChild(callViewElement,call.value);}
|
| +if(typeof call.result!=="undefined"){callViewElement.createTextChild(" => ");this._createCallArgumentChild(callViewElement,call.result);}
|
| +var node=new WebInspector.DataGridNode(data);node.index=index;node.selectable=true;node.call=call;return node;},_createCallArgumentChild:function(parentElement,callArgument)
|
| +{var element=parentElement.createChild("span","canvas-call-argument");element._argumentIndex=-1;if(callArgument.type==="string"){const maxStringLength=150;element.createTextChild("\"");element.createChild("span","canvas-formatted-string").textContent=callArgument.description.trimMiddle(maxStringLength);element.createTextChild("\"");element._suppressPopover=(callArgument.description.length<=maxStringLength&&!/[\r\n]/.test(callArgument.description));}else{var type=callArgument.subtype||callArgument.type;if(type){element.addStyleClass("canvas-formatted-"+type);switch(type){case"null":case"undefined":case"boolean":element._suppressPopover=true;break;case"number":element._suppressPopover=!isNaN(callArgument.description);break;}}
|
| +element.textContent=callArgument.description;}
|
| +if(callArgument.resourceId){element.addStyleClass("canvas-formatted-resource");element.resourceId=callArgument.resourceId;}
|
| +return element;},_popoverAnchor:function(element,event)
|
| +{var argumentElement=element.enclosingNodeOrSelfWithClass("canvas-call-argument");if(!argumentElement||argumentElement._suppressPopover)
|
| return null;return argumentElement;},_resolveObjectForPopover:function(argumentElement,showCallback,objectGroupName)
|
| -{function showObjectPopover(error,result,resourceState)
|
| +{var dataGridNode=this._logGrid.dataGridNodeFromNode(argumentElement);if(!dataGridNode){this._popoverHelper.hidePopover();return;}
|
| +var callIndex=dataGridNode.index;var argumentIndex=argumentElement._argumentIndex;function showObjectPopover(error,result,resourceState)
|
| {if(error)
|
| return;if(!result)
|
| -return;this._popoverAnchorElement=argumentElement.cloneNode(true);this._popoverAnchorElement.addStyleClass("canvas-popover-anchor");this._popoverAnchorElement.addStyleClass("source-frame-eval-expression");argumentElement.parentElement.appendChild(this._popoverAnchorElement);var diffLeft=this._popoverAnchorElement.boxInWindow().x-argumentElement.boxInWindow().x;this._popoverAnchorElement.style.left=this._popoverAnchorElement.offsetLeft-diffLeft+"px";showCallback(WebInspector.RemoteObject.fromPayload(result),false,this._popoverAnchorElement);}
|
| -var evalResult=argumentElement.__evalResult;if(evalResult)
|
| -showObjectPopover.call(this,null,evalResult);else{var dataGridNode=this._logGrid.dataGridNodeFromNode(argumentElement);if(!dataGridNode||typeof dataGridNode.index!=="number"){this._popoverHelper.hidePopover();return;}
|
| -var callIndex=dataGridNode.index;var argumentIndex=argumentElement.__argumentIndex;if(typeof argumentIndex!=="number")
|
| -argumentIndex=-1;CanvasAgent.evaluateTraceLogCallArgument(this._traceLogId,callIndex,argumentIndex,objectGroupName,showObjectPopover.bind(this));}},_hexNumbersFormatter:function(object)
|
| -{if(object.type==="number"){var str="0000"+Number(object.description).toString(16).toUpperCase();str=str.replace(/^0+(.{4,})$/,"$1");return"0x"+str;}
|
| -return object.description||"";},_onHidePopover:function()
|
| +return;if(result&&result.type==="number"){var str="0000"+Number(result.description).toString(16).toUpperCase();str=str.replace(/^0+(.{4,})$/,"$1");result.description="0x"+str;}
|
| +this._popoverAnchorElement=argumentElement.cloneNode(true);this._popoverAnchorElement.addStyleClass("canvas-popover-anchor");this._popoverAnchorElement.addStyleClass("source-frame-eval-expression");argumentElement.parentElement.appendChild(this._popoverAnchorElement);var diffLeft=this._popoverAnchorElement.boxInWindow().x-argumentElement.boxInWindow().x;this._popoverAnchorElement.style.left=this._popoverAnchorElement.offsetLeft-diffLeft+"px";showCallback(WebInspector.RemoteObject.fromPayload(result),false,this._popoverAnchorElement);}
|
| +CanvasAgent.evaluateTraceLogCallArgument(this._traceLogId,callIndex,argumentIndex,objectGroupName,showObjectPopover.bind(this));},_onHidePopover:function()
|
| {if(this._popoverAnchorElement){this._popoverAnchorElement.remove()
|
| delete this._popoverAnchorElement;}},_flattenSingleFrameNode:function()
|
| {var rootNode=this._logGrid.rootNode();if(rootNode.children.length!==1)
|
| @@ -1952,124 +1934,17 @@
|
| {this._profileType._contextCreated(frameId);},traceLogsRemoved:function(frameId,traceLogId)
|
| {this._profileType._traceLogsRemoved(frameId,traceLogId);}}
|
| WebInspector.CanvasProfileHeader=function(type,title,uid,traceLogId,frameId)
|
| -{WebInspector.ProfileHeader.call(this,type,title,uid);this._traceLogId=traceLogId||"";this._frameId=frameId;this._alive=true;this._traceLogSize=0;this._traceLogPlayer=traceLogId?new WebInspector.CanvasTraceLogPlayerProxy(traceLogId):null;}
|
| +{WebInspector.ProfileHeader.call(this,type,title,uid);this._traceLogId=traceLogId||"";this._frameId=frameId;this._alive=true;this._traceLogSize=0;}
|
| WebInspector.CanvasProfileHeader.prototype={traceLogId:function()
|
| -{return this._traceLogId;},traceLogPlayer:function()
|
| -{return this._traceLogPlayer;},frameId:function()
|
| +{return this._traceLogId;},frameId:function()
|
| {return this._frameId;},createSidebarTreeElement:function()
|
| {return new WebInspector.ProfileSidebarTreeElement(this,WebInspector.UIString("Trace Log %d"),"profile-sidebar-tree-item");},createView:function(profilesPanel)
|
| {return new WebInspector.CanvasProfileView(this);},dispose:function()
|
| -{if(this._traceLogPlayer)
|
| -this._traceLogPlayer.dispose();clearTimeout(this._requestStatusTimer);this._alive=false;},_updateCapturingStatus:function(traceLog)
|
| +{if(this._traceLogId){CanvasAgent.dropTraceLog(this._traceLogId);clearTimeout(this._requestStatusTimer);this._alive=false;}},_updateCapturingStatus:function(traceLog)
|
| {if(!this.sidebarElement||!this._traceLogId)
|
| return;if(traceLog){this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;}
|
| this.sidebarElement.subtitle=this._alive?WebInspector.UIString("Capturing\u2026 %d calls",this._traceLogSize):WebInspector.UIString("Captured %d calls",this._traceLogSize);this.sidebarElement.wait=this._alive;if(this._alive){clearTimeout(this._requestStatusTimer);this._requestStatusTimer=setTimeout(this._requestCapturingStatus.bind(this),WebInspector.CanvasProfileView.TraceLogPollingInterval);}},_requestCapturingStatus:function()
|
| -{function didReceiveTraceLog(traceLog)
|
| -{if(!traceLog)
|
| +{function didReceiveTraceLog(error,traceLog)
|
| +{if(error)
|
| return;this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;this._updateCapturingStatus();}
|
| -this._traceLogPlayer.getTraceLog(0,0,didReceiveTraceLog.bind(this));},__proto__:WebInspector.ProfileHeader.prototype}
|
| -WebInspector.CanvasProfileDataGridHelper={createCallArgumentElement:function(callArgument)
|
| -{if(callArgument.enumName)
|
| -return WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(callArgument.enumName,+callArgument.description);var element=document.createElement("span");element.className="canvas-call-argument";var description=callArgument.description;if(callArgument.type==="string"){const maxStringLength=150;element.createTextChild("\"");element.createChild("span","canvas-formatted-string").textContent=description.trimMiddle(maxStringLength);element.createTextChild("\"");element.__suppressPopover=(description.length<=maxStringLength&&!/[\r\n]/.test(description));if(!element.__suppressPopover)
|
| -element.__evalResult=WebInspector.RemoteObject.fromPrimitiveValue(description);}else{var type=callArgument.subtype||callArgument.type;if(type){element.addStyleClass("canvas-formatted-"+type);if(["null","undefined","boolean","number"].indexOf(type)>=0)
|
| -element.__suppressPopover=true;}
|
| -element.textContent=description;if(callArgument.remoteObject)
|
| -element.__evalResult=WebInspector.RemoteObject.fromPayload(callArgument.remoteObject);}
|
| -if(callArgument.resourceId){element.addStyleClass("canvas-formatted-resource");element.__resourceId=callArgument.resourceId;}
|
| -return element;},createEnumValueElement:function(enumName,enumValue)
|
| -{var element=document.createElement("span");element.className="canvas-call-argument canvas-formatted-number";element.textContent=enumName;element.__evalResult=WebInspector.RemoteObject.fromPrimitiveValue(enumValue);return element;}}
|
| -WebInspector.CanvasTraceLogPlayerProxy=function(traceLogId)
|
| -{this._traceLogId=traceLogId;this._currentResourceStates={};this._defaultResourceId=null;}
|
| -WebInspector.CanvasTraceLogPlayerProxy.Events={CanvasTraceLogReceived:"CanvasTraceLogReceived",CanvasReplayStateChanged:"CanvasReplayStateChanged",CanvasResourceStateReceived:"CanvasResourceStateReceived",}
|
| -WebInspector.CanvasTraceLogPlayerProxy.prototype={getTraceLog:function(startOffset,maxLength,userCallback)
|
| -{function callback(error,traceLog)
|
| -{if(error||!traceLog){userCallback(null);return;}
|
| -userCallback(traceLog);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,traceLog);}
|
| -CanvasAgent.getTraceLog(this._traceLogId,startOffset,maxLength,callback.bind(this));},dispose:function()
|
| -{this._currentResourceStates={};CanvasAgent.dropTraceLog(this._traceLogId);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},getResourceState:function(resourceId,userCallback)
|
| -{resourceId=resourceId||this._defaultResourceId;if(!resourceId){userCallback(null);return;}
|
| -if(this._currentResourceStates[resourceId]){userCallback(this._currentResourceStates[resourceId]);return;}
|
| -function callback(error,resourceState)
|
| -{if(error||!resourceState){userCallback(null);return;}
|
| -this._currentResourceStates[resourceId]=resourceState;userCallback(resourceState);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
|
| -CanvasAgent.getResourceState(this._traceLogId,resourceId,callback.bind(this));},replayTraceLog:function(index,userCallback)
|
| -{function callback(error,resourceState,replayTime)
|
| -{this._currentResourceStates={};if(error||!resourceState){resourceState=null;userCallback(null,replayTime);}else{this._defaultResourceId=resourceState.id;this._currentResourceStates[resourceState.id]=resourceState;userCallback(resourceState,replayTime);}
|
| -this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);if(resourceState)
|
| -this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
|
| -CanvasAgent.replayTraceLog(this._traceLogId,index,callback.bind(this));},clearResourceStates:function()
|
| -{this._currentResourceStates={};this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},__proto__:WebInspector.Object.prototype};WebInspector.CanvasReplayStateView=function(traceLogPlayer)
|
| -{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this.element.addStyleClass("canvas-replay-state-view");this._traceLogPlayer=traceLogPlayer;var controlsContainer=this.element.createChild("div","status-bar");this._prevButton=this._createControlButton(controlsContainer,"canvas-replay-state-prev",WebInspector.UIString("Previous resource."),this._onResourceNavigationClick.bind(this,false));this._nextButton=this._createControlButton(controlsContainer,"canvas-replay-state-next",WebInspector.UIString("Next resource."),this._onResourceNavigationClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-state-refresh",WebInspector.UIString("Refresh."),this._onStateRefreshClick.bind(this));this._resourceSelector=new WebInspector.StatusBarComboBox(this._onReplayResourceChanged.bind(this));this._currentOption=this._resourceSelector.createOption(WebInspector.UIString("<auto>"),WebInspector.UIString("Show state of the last replayed resource."),"");controlsContainer.appendChild(this._resourceSelector.element);this._resourceIdToDescription={};this._gridNodesExpandedState={};this._gridScrollPositions={};this._currentResourceId=null;this._prevOptionsStack=[];this._nextOptionsStack=[];this._highlightedGridNodes=[];var columns=[{title:WebInspector.UIString("Name"),sortable:false,width:"50%",disclosure:true},{title:WebInspector.UIString("Value"),sortable:false,width:"50%"}];this._stateGrid=new WebInspector.DataGrid(columns);this._stateGrid.element.addStyleClass("fill");this._stateGrid.show(this.element);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged,this._onReplayResourceChanged,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,this._onCanvasTraceLogReceived,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,this._onCanvasResourceStateReceived,this);this._updateButtonsEnabledState();}
|
| -WebInspector.CanvasReplayStateView.prototype={selectResource:function(resourceId)
|
| -{if(resourceId===this._resourceSelector.selectedOption().value)
|
| -return;var option=this._resourceSelector.selectElement().firstChild;for(var index=0;option;++index,option=option.nextSibling){if(resourceId===option.value){this._resourceSelector.setSelectedIndex(index);this._onReplayResourceChanged();break;}}},_createControlButton:function(parent,className,title,clickCallback)
|
| -{var button=new WebInspector.StatusBarButton(title,className+" canvas-replay-button");parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);return button;},_onResourceNavigationClick:function(forward)
|
| -{var newOption=forward?this._nextOptionsStack.pop():this._prevOptionsStack.pop();if(!newOption)
|
| -return;(forward?this._prevOptionsStack:this._nextOptionsStack).push(this._currentOption);this._isNavigationButton=true;this.selectResource(newOption.value);delete this._isNavigationButton;this._updateButtonsEnabledState();},_onStateRefreshClick:function()
|
| -{this._traceLogPlayer.clearResourceStates();},_updateButtonsEnabledState:function()
|
| -{this._prevButton.setEnabled(this._prevOptionsStack.length>0);this._nextButton.setEnabled(this._nextOptionsStack.length>0);},_updateCurrentOption:function()
|
| -{const maxStackSize=256;var selectedOption=this._resourceSelector.selectedOption();if(this._currentOption===selectedOption)
|
| -return;if(!this._isNavigationButton){this._prevOptionsStack.push(this._currentOption);this._nextOptionsStack=[];if(this._prevOptionsStack.length>maxStackSize)
|
| -this._prevOptionsStack.shift();this._updateButtonsEnabledState();}
|
| -this._currentOption=selectedOption;},_collectResourcesFromTraceLog:function(traceLog)
|
| -{var collectedResources=[];var calls=traceLog.calls;for(var i=0,n=calls.length;i<n;++i){var call=calls[i];var args=call.arguments||[];for(var j=0;j<args.length;++j)
|
| -this._collectResourceFromCallArgument(args[j],collectedResources);this._collectResourceFromCallArgument(call.result,collectedResources);this._collectResourceFromCallArgument(call.value,collectedResources);}
|
| -var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i)
|
| -this._collectResourceFromCallArgument(contexts[i],collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourcesFromResourceState:function(resourceState)
|
| -{var collectedResources=[];this._collectResourceFromResourceStateDescriptors(resourceState.descriptors,collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourceFromResourceStateDescriptors:function(descriptors,output)
|
| -{if(!descriptors)
|
| -return;for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];this._collectResourceFromCallArgument(descriptor.value,output);this._collectResourceFromResourceStateDescriptors(descriptor.values,output);}},_collectResourceFromCallArgument:function(argument,output)
|
| -{if(!argument)
|
| -return;var resourceId=argument.resourceId;if(!resourceId||this._resourceIdToDescription[resourceId])
|
| -return;this._resourceIdToDescription[resourceId]=argument.description;output.push(argument);},_addCollectedResourcesToSelector:function(collectedResources)
|
| -{if(!collectedResources.length)
|
| -return;function comparator(arg1,arg2)
|
| -{var a=arg1.description;var b=arg2.description;return String.naturalOrderComparator(a,b);}
|
| -collectedResources.sort(comparator);var selectElement=this._resourceSelector.selectElement();var currentOption=selectElement.firstChild;currentOption=currentOption.nextSibling;for(var i=0,n=collectedResources.length;i<n;++i){var argument=collectedResources[i];while(currentOption&&String.naturalOrderComparator(currentOption.text,argument.description)<0)
|
| -currentOption=currentOption.nextSibling;var option=this._resourceSelector.createOption(argument.description,WebInspector.UIString("Show state of this resource."),argument.resourceId);if(currentOption)
|
| -selectElement.insertBefore(option,currentOption);}},_onReplayResourceChanged:function()
|
| -{this._updateCurrentOption();var selectedResourceId=this._resourceSelector.selectedOption().value;function didReceiveResourceState(resourceState)
|
| -{if(selectedResourceId!==this._resourceSelector.selectedOption().value)
|
| -return;this._showResourceState(resourceState);}
|
| -this._traceLogPlayer.getResourceState(selectedResourceId,didReceiveResourceState.bind(this));},_onCanvasTraceLogReceived:function(event)
|
| -{var traceLog=(event.data);if(traceLog)
|
| -this._collectResourcesFromTraceLog(traceLog);},_onCanvasResourceStateReceived:function(event)
|
| -{var resourceState=(event.data);if(resourceState)
|
| -this._collectResourcesFromResourceState(resourceState);},_showResourceState:function(resourceState)
|
| -{this._saveExpandedState();this._saveScrollState();var rootNode=this._stateGrid.rootNode();if(!resourceState){this._currentResourceId=null;this._updateDataGridHighlights([]);rootNode.removeChildren();return;}
|
| -var nodesToHighlight=[];var nameToOldGridNodes={};function populateNameToNodesMap(map,node)
|
| -{if(!node)
|
| -return;for(var i=0,child;child=node.children[i];++i){var item={node:child,children:{}};map[child.name]=item;populateNameToNodesMap(item.children,child);}}
|
| -populateNameToNodesMap(nameToOldGridNodes,rootNode);rootNode.removeChildren();function comparator(d1,d2)
|
| -{var hasChildren1=!!d1.values;var hasChildren2=!!d2.values;if(hasChildren1!==hasChildren2)
|
| -return hasChildren1?1:-1;return String.naturalOrderComparator(d1.name,d2.name);}
|
| -function appendResourceStateDescriptors(descriptors,parent,nameToOldChildren)
|
| -{descriptors=descriptors||[];descriptors.sort(comparator);var oldChildren=nameToOldChildren||{};for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];var childNode=this._createDataGridNode(descriptor);parent.appendChild(childNode);var oldChildrenItem=oldChildren[childNode.name]||{};var oldChildNode=oldChildrenItem.node;if(!oldChildNode||oldChildNode.element.textContent!==childNode.element.textContent)
|
| -nodesToHighlight.push(childNode);appendResourceStateDescriptors.call(this,descriptor.values,childNode,oldChildrenItem.children);}}
|
| -appendResourceStateDescriptors.call(this,resourceState.descriptors,rootNode,nameToOldGridNodes);var shouldHighlightChanges=(this._resourceKindId(this._currentResourceId)===this._resourceKindId(resourceState.id));this._currentResourceId=resourceState.id;this._restoreExpandedState();this._updateDataGridHighlights(shouldHighlightChanges?nodesToHighlight:[]);this._restoreScrollState();},_updateDataGridHighlights:function(nodes)
|
| -{for(var i=0,n=this._highlightedGridNodes.length;i<n;++i){var node=this._highlightedGridNodes[i];node.element.removeStyleClass("canvas-grid-node-highlighted");}
|
| -this._highlightedGridNodes=nodes;for(var i=0,n=this._highlightedGridNodes.length;i<n;++i){var node=this._highlightedGridNodes[i];node.element.addStyleClass("canvas-grid-node-highlighted");node.reveal();}},_resourceKindId:function(resourceId)
|
| -{var description=(resourceId&&this._resourceIdToDescription[resourceId])||"";return description.replace(/\d+/g,"");},_forEachGridNode:function(callback)
|
| -{function processRecursively(node,key)
|
| -{for(var i=0,child;child=node.children[i];++i){var childKey=key+"#"+child.name;callback(child,childKey);processRecursively(child,childKey);}}
|
| -processRecursively(this._stateGrid.rootNode(),"");},_saveExpandedState:function()
|
| -{if(!this._currentResourceId)
|
| -return;var expandedState={};var key=this._resourceKindId(this._currentResourceId);this._gridNodesExpandedState[key]=expandedState;function callback(node,key)
|
| -{if(node.expanded)
|
| -expandedState[key]=true;}
|
| -this._forEachGridNode(callback);},_restoreExpandedState:function()
|
| -{if(!this._currentResourceId)
|
| -return;var key=this._resourceKindId(this._currentResourceId);var expandedState=this._gridNodesExpandedState[key];if(!expandedState)
|
| -return;function callback(node,key)
|
| -{if(expandedState[key])
|
| -node.expand();}
|
| -this._forEachGridNode(callback);},_saveScrollState:function()
|
| -{if(!this._currentResourceId)
|
| -return;var key=this._resourceKindId(this._currentResourceId);this._gridScrollPositions[key]={scrollTop:this._stateGrid.scrollContainer.scrollTop,scrollLeft:this._stateGrid.scrollContainer.scrollLeft};},_restoreScrollState:function()
|
| -{if(!this._currentResourceId)
|
| -return;var key=this._resourceKindId(this._currentResourceId);var scrollState=this._gridScrollPositions[key];if(!scrollState)
|
| -return;this._stateGrid.scrollContainer.scrollTop=scrollState.scrollTop;this._stateGrid.scrollContainer.scrollLeft=scrollState.scrollLeft;},_createDataGridNode:function(descriptor)
|
| -{var name=descriptor.name;var callArgument=descriptor.value;var valueElement=callArgument?WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(callArgument):"";var nameElement=name;if(typeof descriptor.enumValueForName!=="undefined")
|
| -nameElement=WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(name,+descriptor.enumValueForName);if(descriptor.isArray&&descriptor.values){if(typeof nameElement==="string")
|
| -nameElement+="["+descriptor.values.length+"]";else{var element=document.createElement("span");element.appendChild(nameElement);element.createTextChild("["+descriptor.values.length+"]");nameElement=element;}}
|
| -var data={};data[0]=nameElement;data[1]=valueElement;var node=new WebInspector.DataGridNode(data);node.selectable=false;node.name=name;return node;},__proto__:WebInspector.View.prototype};
|
| +CanvasAgent.getTraceLog(this._traceLogId,0,0,didReceiveTraceLog.bind(this));},__proto__:WebInspector.ProfileHeader.prototype};
|
|
|