Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / TimelinePanel.js
1 WebInspector.MemoryStatistics=function(timelineView,model)
2 {WebInspector.View.call(this);this._timelineView=timelineView;this.element.classList.add("fill");this._counters=[];model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onRecordAdded,this);model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._onRecordsCleared,this);this._memorySidebarView=new WebInspector.SidebarView(WebInspector.SidebarView.SidebarPosition.Start,undefined);this._memorySidebarView.element.id="memory-graphs-container";this._memorySidebarView.addEventListener(WebInspector.SidebarView.EventTypes.Resized,this._sidebarResized.bind(this));this._canvasContainer=this._memorySidebarView.mainElement();this._canvasContainer.id="memory-graphs-canvas-container";this._createCurrentValuesBar();this._canvas=this._canvasContainer.createChild("canvas","fill");this._canvas.id="memory-counters-graph";this._lastMarkerXPosition=0;this._canvas.addEventListener("mouseover",this._onMouseOver.bind(this),true);this._canvas.addEventListener("mousemove",this._onMouseMove.bind(this),true);this._canvas.addEventListener("mouseout",this._onMouseOut.bind(this),true);this._canvas.addEventListener("click",this._onClick.bind(this),true);this._timelineGrid=new WebInspector.TimelineGrid();this._canvasContainer.appendChild(this._timelineGrid.dividersElement);this._memorySidebarView.sidebarElement().createChild("div","sidebar-tree sidebar-tree-section").textContent=WebInspector.UIString("COUNTERS");this._counterUI=this._createCounterUIList();this._memorySidebarView.show(this.element);}
3 WebInspector.MemoryStatistics.Counter=function(time)
4 {this.time=time;}
5 WebInspector.SwatchCheckbox=function(title,color)
6 {this.element=document.createElement("div");this._swatch=this.element.createChild("div","swatch");this.element.createChild("span","title").textContent=title;this._color=color;this.checked=true;this.element.addEventListener("click",this._toggleCheckbox.bind(this),true);}
7 WebInspector.SwatchCheckbox.Events={Changed:"Changed"}
8 WebInspector.SwatchCheckbox.prototype={get checked()
9 {return this._checked;},set checked(v)
10 {this._checked=v;if(this._checked)
11 this._swatch.style.backgroundColor=this._color;else
12 this._swatch.style.backgroundColor="";},_toggleCheckbox:function(event)
13 {this.checked=!this.checked;this.dispatchEventToListeners(WebInspector.SwatchCheckbox.Events.Changed);},__proto__:WebInspector.Object.prototype}
14 WebInspector.CounterUIBase=function(memoryCountersPane,title,graphColor,valueGetter)
15 {this._memoryCountersPane=memoryCountersPane;this.valueGetter=valueGetter;var container=memoryCountersPane._memorySidebarView.sidebarElement().createChild("div","memory-counter-sidebar-info");var swatchColor=graphColor;this._swatch=new WebInspector.SwatchCheckbox(WebInspector.UIString(title),swatchColor);this._swatch.addEventListener(WebInspector.SwatchCheckbox.Events.Changed,this._toggleCounterGraph.bind(this));container.appendChild(this._swatch.element);this._value=null;this.graphColor=graphColor;this.strokeColor=graphColor;this.graphYValues=[];}
16 WebInspector.CounterUIBase.prototype={_toggleCounterGraph:function(event)
17 {if(this._swatch.checked)
18 this._value.classList.remove("hidden");else
19 this._value.classList.add("hidden");this._memoryCountersPane.refresh();},updateCurrentValue:function(countersEntry)
20 {this._value.textContent=Number.bytesToString(this.valueGetter(countersEntry));},clearCurrentValueAndMarker:function(ctx)
21 {this._value.textContent="";},get visible()
22 {return this._swatch.checked;},}
23 WebInspector.MemoryStatistics.prototype={_createCurrentValuesBar:function()
24 {throw new Error("Not implemented");},_createCounterUIList:function()
25 {throw new Error("Not implemented");},_onRecordsCleared:function()
26 {this._counters=[];},height:function()
27 {return this._memorySidebarView.element.offsetHeight;},setSidebarWidth:function(width)
28 {this._memorySidebarView.setSidebarWidth(width);},_sidebarResized:function(event)
29 {this.dispatchEventToListeners(WebInspector.TimelineView.Events.SidebarResized,(event.data));this.onResize();},_canvasHeight:function()
30 {throw new Error("Not implemented");},onResize:function()
31 {var width=this._canvasContainer.offsetWidth+1;this._canvas.style.width=width+"px";this._timelineGrid.dividersElement.style.width=width+"px";var parentElement=this._canvas.parentElement;this._canvas.width=width;this._canvas.height=parentElement.clientHeight-15;this.refresh();},_onRecordAdded:function(event)
32 {throw new Error("Not implemented");},draw:function()
33 {this._calculateVisibleIndexes();this._calculateXValues();this._clear();this._setVerticalClip(10,this._canvas.height-20);},_calculateVisibleIndexes:function()
34 {var calculator=this._timelineView.calculator;var start=calculator.minimumBoundary()*1000;var end=calculator.maximumBoundary()*1000;function comparator(value,sample)
35 {return value-sample.time;}
36 this._minimumIndex=Number.constrain(this._counters.upperBound(start,comparator)-1,0,this._counters.length-1);this._maximumIndex=Number.constrain(this._counters.lowerBound(end,comparator),0,this._counters.length-1);this._minTime=start;this._maxTime=end;},_onClick:function(event)
37 {var x=event.x-event.target.offsetParent.offsetLeft;var i=this._recordIndexAt(x);var counter=this._counters[i];if(counter)
38 this._timelineView.revealRecordAt(counter.time/1000);},_onMouseOut:function(event)
39 {delete this._markerXPosition;var ctx=this._canvas.getContext("2d");this._clearCurrentValueAndMarker(ctx);},_clearCurrentValueAndMarker:function(ctx)
40 {for(var i=0;i<this._counterUI.length;i++)
41 this._counterUI[i].clearCurrentValueAndMarker(ctx);},_onMouseOver:function(event)
42 {this._onMouseMove(event);},_onMouseMove:function(event)
43 {var x=event.x-event.target.offsetParent.offsetLeft
44 this._markerXPosition=x;this._refreshCurrentValues();},_refreshCurrentValues:function()
45 {if(!this._counters.length)
46 return;if(this._markerXPosition===undefined)
47 return;if(this._maximumIndex===-1)
48 return;var i=this._recordIndexAt(this._markerXPosition);this._updateCurrentValue(this._counters[i]);this._highlightCurrentPositionOnGraphs(this._markerXPosition,i);},_updateCurrentValue:function(counterEntry)
49 {for(var j=0;j<this._counterUI.length;j++)
50 this._counterUI[j].updateCurrentValue(counterEntry);},_recordIndexAt:function(x)
51 {var i;for(i=this._minimumIndex+1;i<=this._maximumIndex;i++){var statX=this._counters[i].x;if(x<statX)
52 break;}
53 i--;return i;},_highlightCurrentPositionOnGraphs:function(x,index)
54 {var ctx=this._canvas.getContext("2d");this._restoreImageUnderMarker(ctx);this._drawMarker(ctx,x,index);},_restoreImageUnderMarker:function(ctx)
55 {throw new Error("Not implemented");},_drawMarker:function(ctx,x,index)
56 {throw new Error("Not implemented");},refresh:function()
57 {this._timelineGrid.updateDividers(this._timelineView.calculator);this.draw();this._refreshCurrentValues();},_setVerticalClip:function(originY,height)
58 {this._originY=originY;this._clippedHeight=height;},_calculateXValues:function()
59 {if(!this._counters.length)
60 return;var width=this._canvas.width;var xFactor=width/(this._maxTime-this._minTime);this._counters[this._minimumIndex].x=0;for(var i=this._minimumIndex+1;i<this._maximumIndex;i++)
61 this._counters[i].x=xFactor*(this._counters[i].time-this._minTime);this._counters[this._maximumIndex].x=width;},_clear:function()
62 {var ctx=this._canvas.getContext("2d");ctx.clearRect(0,0,ctx.canvas.width,ctx.canvas.height);this._discardImageUnderMarker();},_discardImageUnderMarker:function()
63 {throw new Error("Not implemented");},__proto__:WebInspector.View.prototype};WebInspector.CountersGraph=function(timelineView,model)
64 {WebInspector.MemoryStatistics.call(this,timelineView,model);}
65 WebInspector.CounterUI=function(memoryCountersPane,title,currentValueLabel,color,valueGetter)
66 {WebInspector.CounterUIBase.call(this,memoryCountersPane,title,color,valueGetter)
67 this._range=this._swatch.element.createChild("span");this._value=memoryCountersPane._currentValuesBar.createChild("span","memory-counter-value");this._value.style.color=color;this._currentValueLabel=currentValueLabel;this.graphColor=color;this.graphYValues=[];}
68 WebInspector.CountersGraph.Counter=function(time,documentCount,nodeCount,listenerCount,usedGPUMemoryKBytes)
69 {WebInspector.MemoryStatistics.Counter.call(this,time);this.documentCount=documentCount;this.nodeCount=nodeCount;this.listenerCount=listenerCount;this.usedGPUMemoryKBytes=usedGPUMemoryKBytes;}
70 WebInspector.CountersGraph.Counter.prototype={__proto__:WebInspector.MemoryStatistics.Counter.prototype}
71 WebInspector.CounterUI.prototype={setRange:function(minValue,maxValue)
72 {this._range.textContent=WebInspector.UIString("[%d:%d]",minValue,maxValue);},updateCurrentValue:function(countersEntry)
73 {this._value.textContent=WebInspector.UIString(this._currentValueLabel,this.valueGetter(countersEntry));},clearCurrentValueAndMarker:function(ctx)
74 {this._value.textContent="";this.restoreImageUnderMarker(ctx);},saveImageUnderMarker:function(ctx,x,y,radius)
75 {const w=radius+1;var imageData=ctx.getImageData(x-w,y-w,2*w,2*w);this._imageUnderMarker={x:x-w,y:y-w,imageData:imageData};},restoreImageUnderMarker:function(ctx)
76 {if(!this.visible)
77 return;if(this._imageUnderMarker)
78 ctx.putImageData(this._imageUnderMarker.imageData,this._imageUnderMarker.x,this._imageUnderMarker.y);this.discardImageUnderMarker();},discardImageUnderMarker:function()
79 {delete this._imageUnderMarker;},__proto__:WebInspector.CounterUIBase.prototype}
80 WebInspector.CountersGraph.prototype={_createCurrentValuesBar:function()
81 {this._currentValuesBar=this._canvasContainer.createChild("div");this._currentValuesBar.id="counter-values-bar";this._canvasContainer.classList.add("dom-counters");},resizeElement:function()
82 {return this._currentValuesBar;},_createCounterUIList:function()
83 {function getDocumentCount(entry)
84 {return entry.documentCount;}
85 function getNodeCount(entry)
86 {return entry.nodeCount;}
87 function getListenerCount(entry)
88 {return entry.listenerCount;}
89 function getUsedGPUMemoryKBytes(entry)
90 {return entry.usedGPUMemoryKBytes;}
91 var counterUIs=[new WebInspector.CounterUI(this,"Documents","Documents: %d","#d00",getDocumentCount),new WebInspector.CounterUI(this,"Nodes","Nodes: %d","#0a0",getNodeCount),new WebInspector.CounterUI(this,"Listeners","Listeners: %d","#00d",getListenerCount)];if(WebInspector.experimentsSettings.gpuTimeline.isEnabled())
92 counterUIs.push(new WebInspector.CounterUI(this,"GPU Memory","GPU Memory [KB]: %d","#c0c",getUsedGPUMemoryKBytes));return counterUIs;},_onRecordAdded:function(event)
93 {function findInsertionLocation(array,item,comparator)
94 {var index=array.length;while(index>0&&comparator(array[index-1],item)>0)
95 --index;return index;}
96 function addStatistics(record)
97 {var counters=record["counters"];if(!counters)
98 return;var time=record.endTime||record.startTime;var counter=new WebInspector.CountersGraph.Counter(time,counters["documents"],counters["nodes"],counters["jsEventListeners"],counters["gpuMemoryUsedKB"]);function compare(record,time)
99 {return record.time-time;}
100 var index=findInsertionLocation(this._counters,time,compare);this._counters.splice(index,0,counter);if("gpuMemoryUsedKB"in counters){for(var i=index-1;i>=0&&typeof this._counters[i].usedGPUMemoryKBytes==="undefined";--i){}
101 var usedGPUMemoryKBytes=this._counters[i>=0?i:index].usedGPUMemoryKBytes;for(i=Math.max(i,0);i<index;++i)
102 this._counters[i].usedGPUMemoryKBytes=usedGPUMemoryKBytes;var copyFrom=index>0?index-1:index+1;if(copyFrom<this._counters.length){this._counters[index].documentCount=this._counters[copyFrom].documentCount;this._counters[index].nodeCount=this._counters[copyFrom].nodeCount;this._counters[index].listenerCount=this._counters[copyFrom].listenerCount;}else{this._counters[index].documentCount=0;this._counters[index].nodeCount=0;this._counters[index].listenerCount=0;}}}
103 WebInspector.TimelinePresentationModel.forAllRecords([event.data],null,addStatistics.bind(this));},draw:function()
104 {WebInspector.MemoryStatistics.prototype.draw.call(this);for(var i=0;i<this._counterUI.length;i++)
105 this._drawGraph(this._counterUI[i]);},_restoreImageUnderMarker:function(ctx)
106 {for(var i=0;i<this._counterUI.length;i++){var counterUI=this._counterUI[i];if(!counterUI.visible)
107 continue;counterUI.restoreImageUnderMarker(ctx);}},_saveImageUnderMarker:function(ctx,x,index)
108 {const radius=2;for(var i=0;i<this._counterUI.length;i++){var counterUI=this._counterUI[i];if(!counterUI.visible)
109 continue;var y=counterUI.graphYValues[index];counterUI.saveImageUnderMarker(ctx,x,y,radius);}},_drawMarker:function(ctx,x,index)
110 {this._saveImageUnderMarker(ctx,x,index);const radius=2;for(var i=0;i<this._counterUI.length;i++){var counterUI=this._counterUI[i];if(!counterUI.visible)
111 continue;var y=counterUI.graphYValues[index];ctx.beginPath();ctx.arc(x+0.5,y+0.5,radius,0,Math.PI*2,true);ctx.lineWidth=1;ctx.fillStyle=counterUI.graphColor;ctx.strokeStyle=counterUI.graphColor;ctx.fill();ctx.stroke();ctx.closePath();}},_drawGraph:function(counterUI)
112 {var canvas=this._canvas;var ctx=canvas.getContext("2d");var width=canvas.width;var height=this._clippedHeight;var originY=this._originY;var valueGetter=counterUI.valueGetter;if(!this._counters.length)
113 return;var maxValue;var minValue;for(var i=this._minimumIndex;i<=this._maximumIndex;i++){var value=valueGetter(this._counters[i]);if(minValue===undefined||value<minValue)
114 minValue=value;if(maxValue===undefined||value>maxValue)
115 maxValue=value;}
116 minValue=minValue||0;maxValue=maxValue||1;counterUI.setRange(minValue,maxValue);if(!counterUI.visible)
117 return;var yValues=counterUI.graphYValues;yValues.length=this._counters.length;var maxYRange=maxValue-minValue;var yFactor=maxYRange?height/(maxYRange):1;ctx.save();ctx.translate(0.5,0.5);ctx.beginPath();var value=valueGetter(this._counters[this._minimumIndex])||0;var currentY=Math.round(originY+height-(value-minValue)*yFactor);ctx.moveTo(0,currentY);for(var i=this._minimumIndex;i<=this._maximumIndex;i++){var x=Math.round(this._counters[i].x);ctx.lineTo(x,currentY);var currentValue=valueGetter(this._counters[i]);if(typeof currentValue!=="undefined")
118 value=currentValue;currentY=Math.round(originY+height-(value-minValue)*yFactor);ctx.lineTo(x,currentY);yValues[i]=currentY;}
119 ctx.lineTo(width,currentY);ctx.lineWidth=1;ctx.strokeStyle=counterUI.graphColor;ctx.stroke();ctx.closePath();ctx.restore();},_discardImageUnderMarker:function()
120 {for(var i=0;i<this._counterUI.length;i++)
121 this._counterUI[i].discardImageUnderMarker();},__proto__:WebInspector.MemoryStatistics.prototype};WebInspector.PieChart=function(totalValue)
122 {this.element=document.createElement("div");this.element.className="pie-chart";this.element.createChild("div","pie-chart-background");var totalString=Number.secondsToString(totalValue,true);this.element.createChild("div","pie-chart-foreground").textContent=totalString;this._totalValue=totalValue;this._lastAngle=0;}
123 WebInspector.PieChart.prototype={addSlice:function(value,color)
124 {var sliceAngle=value/this._totalValue*360;if(sliceAngle>180){this._innerAddSlice(180,color);sliceAngle-=180;}
125 this._innerAddSlice(sliceAngle,color);},_innerAddSlice:function(sliceAngle,color)
126 {var sliceElement=this.element.createChild("div","pie-chart-slice");sliceElement.style.webkitTransform="rotate("+Number(this._lastAngle).toFixed(2)+"deg)"
127 var innerSliceElement=sliceElement.createChild("div","pie-chart-slice-inner");innerSliceElement.style.backgroundColor=color;innerSliceElement.style.webkitTransform="rotate("+Number(sliceAngle).toFixed(2)+"deg)";this._lastAngle+=sliceAngle;}};WebInspector.TimelineModel=function()
128 {this._records=[];this._stringPool=new StringPool();this._minimumRecordTime=-1;this._maximumRecordTime=-1;WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded,this._onRecordAdded,this);WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted,this._onStarted,this);WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped,this._onStopped,this);}
129 WebInspector.TimelineModel.TransferChunkLengthBytes=5000000;WebInspector.TimelineModel.RecordType={Root:"Root",Program:"Program",EventDispatch:"EventDispatch",GPUTask:"GPUTask",BeginFrame:"BeginFrame",ActivateLayerTree:"ActivateLayerTree",ScheduleStyleRecalculation:"ScheduleStyleRecalculation",RecalculateStyles:"RecalculateStyles",InvalidateLayout:"InvalidateLayout",Layout:"Layout",AutosizeText:"AutosizeText",PaintSetup:"PaintSetup",Paint:"Paint",Rasterize:"Rasterize",ScrollLayer:"ScrollLayer",DecodeImage:"DecodeImage",ResizeImage:"ResizeImage",CompositeLayers:"CompositeLayers",ParseHTML:"ParseHTML",TimerInstall:"TimerInstall",TimerRemove:"TimerRemove",TimerFire:"TimerFire",XHRReadyStateChange:"XHRReadyStateChange",XHRLoad:"XHRLoad",EvaluateScript:"EvaluateScript",MarkLoad:"MarkLoad",MarkDOMContent:"MarkDOMContent",MarkFirstPaint:"MarkFirstPaint",TimeStamp:"TimeStamp",Time:"Time",TimeEnd:"TimeEnd",ScheduleResourceRequest:"ScheduleResourceRequest",ResourceSendRequest:"ResourceSendRequest",ResourceReceiveResponse:"ResourceReceiveResponse",ResourceReceivedData:"ResourceReceivedData",ResourceFinish:"ResourceFinish",FunctionCall:"FunctionCall",GCEvent:"GCEvent",RequestAnimationFrame:"RequestAnimationFrame",CancelAnimationFrame:"CancelAnimationFrame",FireAnimationFrame:"FireAnimationFrame",WebSocketCreate:"WebSocketCreate",WebSocketSendHandshakeRequest:"WebSocketSendHandshakeRequest",WebSocketReceiveHandshakeResponse:"WebSocketReceiveHandshakeResponse",WebSocketDestroy:"WebSocketDestroy",}
130 WebInspector.TimelineModel.Events={RecordAdded:"RecordAdded",RecordsCleared:"RecordsCleared",RecordingStarted:"RecordingStarted",RecordingStopped:"RecordingStopped"}
131 WebInspector.TimelineModel.startTimeInSeconds=function(record)
132 {return record.startTime/1000;}
133 WebInspector.TimelineModel.endTimeInSeconds=function(record)
134 {return(record.endTime||record.startTime)/1000;}
135 WebInspector.TimelineModel.durationInSeconds=function(record)
136 {return WebInspector.TimelineModel.endTimeInSeconds(record)-WebInspector.TimelineModel.startTimeInSeconds(record);}
137 WebInspector.TimelineModel.aggregateTimeForRecord=function(total,rawRecord)
138 {var childrenTime=0;var children=rawRecord["children"]||[];for(var i=0;i<children.length;++i){WebInspector.TimelineModel.aggregateTimeForRecord(total,children[i]);childrenTime+=WebInspector.TimelineModel.durationInSeconds(children[i]);}
139 var categoryName=WebInspector.TimelinePresentationModel.recordStyle(rawRecord).category.name;var ownTime=WebInspector.TimelineModel.durationInSeconds(rawRecord)-childrenTime;total[categoryName]=(total[categoryName]||0)+ownTime;}
140 WebInspector.TimelineModel.aggregateTimeByCategory=function(total,addend)
141 {for(var category in addend)
142 total[category]=(total[category]||0)+addend[category];}
143 WebInspector.TimelineModel.prototype={startRecording:function(includeCounters)
144 {this._clientInitiatedRecording=true;this.reset();var maxStackFrames=WebInspector.settings.timelineCaptureStacks.get()?30:0;var includeGPUEvents=WebInspector.experimentsSettings.gpuTimeline.isEnabled();WebInspector.timelineManager.start(maxStackFrames,includeCounters,includeGPUEvents,this._fireRecordingStarted.bind(this));},stopRecording:function()
145 {if(!this._clientInitiatedRecording){WebInspector.timelineManager.start(undefined,undefined,undefined,stopTimeline.bind(this));return;}
146 function stopTimeline()
147 {WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));}
148 this._clientInitiatedRecording=false;WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));},get records()
149 {return this._records;},_onRecordAdded:function(event)
150 {if(this._collectionEnabled)
151 this._addRecord((event.data));},_onStarted:function(event)
152 {if(event.data){this._fireRecordingStarted();}},_onStopped:function(event)
153 {if(event.data){this._fireRecordingStopped();}},_fireRecordingStarted:function()
154 {this._collectionEnabled=true;this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStarted);},_fireRecordingStopped:function()
155 {this._collectionEnabled=false;this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);},_addRecord:function(record)
156 {this._stringPool.internObjectStrings(record);this._records.push(record);this._updateBoundaries(record);this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordAdded,record);},loadFromFile:function(file,progress)
157 {var delegate=new WebInspector.TimelineModelLoadFromFileDelegate(this,progress);var fileReader=this._createFileReader(file,delegate);var loader=new WebInspector.TimelineModelLoader(this,fileReader,progress);fileReader.start(loader);},loadFromURL:function(url,progress)
158 {var delegate=new WebInspector.TimelineModelLoadFromFileDelegate(this,progress);var urlReader=new WebInspector.ChunkedXHRReader(url,delegate);var loader=new WebInspector.TimelineModelLoader(this,urlReader,progress);urlReader.start(loader);},_createFileReader:function(file,delegate)
159 {return new WebInspector.ChunkedFileReader(file,WebInspector.TimelineModel.TransferChunkLengthBytes,delegate);},_createFileWriter:function()
160 {return new WebInspector.FileOutputStream();},saveToFile:function()
161 {var now=new Date();var fileName="TimelineRawData-"+now.toISO8601Compact()+".json";var stream=this._createFileWriter();function callback(accepted)
162 {if(!accepted)
163 return;var saver=new WebInspector.TimelineSaver(stream);saver.save(this._records,window.navigator.appVersion);}
164 stream.open(fileName,callback.bind(this));},reset:function()
165 {this._records=[];this._stringPool.reset();this._minimumRecordTime=-1;this._maximumRecordTime=-1;this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordsCleared);},minimumRecordTime:function()
166 {return this._minimumRecordTime;},maximumRecordTime:function()
167 {return this._maximumRecordTime;},_updateBoundaries:function(record)
168 {var startTime=WebInspector.TimelineModel.startTimeInSeconds(record);var endTime=WebInspector.TimelineModel.endTimeInSeconds(record);if(this._minimumRecordTime===-1||startTime<this._minimumRecordTime)
169 this._minimumRecordTime=startTime;if(this._maximumRecordTime===-1||endTime>this._maximumRecordTime)
170 this._maximumRecordTime=endTime;},recordOffsetInSeconds:function(rawRecord)
171 {return WebInspector.TimelineModel.startTimeInSeconds(rawRecord)-this._minimumRecordTime;},__proto__:WebInspector.Object.prototype}
172 WebInspector.TimelineModelLoader=function(model,reader,progress)
173 {this._model=model;this._reader=reader;this._progress=progress;this._buffer="";this._firstChunk=true;}
174 WebInspector.TimelineModelLoader.prototype={write:function(chunk)
175 {var data=this._buffer+chunk;var lastIndex=0;var index;do{index=lastIndex;lastIndex=WebInspector.TextUtils.findBalancedCurlyBrackets(data,index);}while(lastIndex!==-1)
176 var json=data.slice(0,index)+"]";this._buffer=data.slice(index);if(!index)
177 return;if(!this._firstChunk)
178 json="[0"+json;var items;try{items=(JSON.parse(json));}catch(e){WebInspector.showErrorMessage("Malformed timeline data.");this._model.reset();this._reader.cancel();this._progress.done();return;}
179 if(this._firstChunk){this._version=items[0];this._firstChunk=false;this._model.reset();}
180 for(var i=1,size=items.length;i<size;++i)
181 this._model._addRecord(items[i]);},close:function(){}}
182 WebInspector.TimelineModelLoadFromFileDelegate=function(model,progress)
183 {this._model=model;this._progress=progress;}
184 WebInspector.TimelineModelLoadFromFileDelegate.prototype={onTransferStarted:function()
185 {this._progress.setTitle(WebInspector.UIString("Loading\u2026"));},onChunkTransferred:function(reader)
186 {if(this._progress.isCanceled()){reader.cancel();this._progress.done();this._model.reset();return;}
187 var totalSize=reader.fileSize();if(totalSize){this._progress.setTotalWork(totalSize);this._progress.setWorked(reader.loadedSize());}},onTransferFinished:function()
188 {this._progress.done();},onError:function(reader,event)
189 {this._progress.done();this._model.reset();switch(event.target.error.code){case FileError.NOT_FOUND_ERR:WebInspector.showErrorMessage(WebInspector.UIString("File \"%s\" not found.",reader.fileName()));break;case FileError.NOT_READABLE_ERR:WebInspector.showErrorMessage(WebInspector.UIString("File \"%s\" is not readable",reader.fileName()));break;case FileError.ABORT_ERR:break;default:WebInspector.showErrorMessage(WebInspector.UIString("An error occurred while reading the file \"%s\"",reader.fileName()));}}}
190 WebInspector.TimelineSaver=function(stream)
191 {this._stream=stream;}
192 WebInspector.TimelineSaver.prototype={save:function(records,version)
193 {this._records=records;this._recordIndex=0;this._prologue="["+JSON.stringify(version);this._writeNextChunk(this._stream);},_writeNextChunk:function(stream)
194 {const separator=",\n";var data=[];var length=0;if(this._prologue){data.push(this._prologue);length+=this._prologue.length;delete this._prologue;}else{if(this._recordIndex===this._records.length){stream.close();return;}
195 data.push("");}
196 while(this._recordIndex<this._records.length){var item=JSON.stringify(this._records[this._recordIndex]);var itemLength=item.length+separator.length;if(length+itemLength>WebInspector.TimelineModel.TransferChunkLengthBytes)
197 break;length+=itemLength;data.push(item);++this._recordIndex;}
198 if(this._recordIndex===this._records.length)
199 data.push(data.pop()+"]");stream.write(data.join(separator),this._writeNextChunk.bind(this));}};WebInspector.TimelineOverviewPane=function(model)
200 {WebInspector.View.call(this);this.element.id="timeline-overview-pane";this._eventDividers=[];this._model=model;this._overviewGrid=new WebInspector.OverviewGrid("timeline");this.element.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.TimelineOverviewCalculator();model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onRecordAdded,this);model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._reset,this);this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);}
201 WebInspector.TimelineOverviewPane.Events={WindowChanged:"WindowChanged"};WebInspector.TimelineOverviewPane.prototype={wasShown:function()
202 {this._update();},onResize:function()
203 {this._update();},setOverviewControl:function(overviewControl)
204 {if(this._overviewControl===overviewControl)
205 return;if(this._overviewControl)
206 this._overviewControl.detach();this._overviewControl=overviewControl;this._overviewControl.show(this._overviewGrid.element);this._update();},_update:function()
207 {delete this._refreshTimeout;this._overviewCalculator.setWindow(this._model.minimumRecordTime(),this._model.maximumRecordTime());this._overviewCalculator.setDisplayWindow(0,this._overviewGrid.clientWidth());if(this._overviewControl)
208 this._overviewControl.update();this._overviewGrid.updateDividers(this._overviewCalculator);this._updateEventDividers();},_updateEventDividers:function()
209 {var records=this._eventDividers;this._overviewGrid.removeEventDividers();var dividers=[];for(var i=0;i<records.length;++i){var record=records[i];var positions=this._overviewCalculator.computeBarGraphPercentages(record);var dividerPosition=Math.round(positions.start*10);if(dividers[dividerPosition])
210 continue;var divider=WebInspector.TimelinePresentationModel.createEventDivider(record.type);divider.style.left=positions.start+"%";dividers[dividerPosition]=divider;}
211 this._overviewGrid.addEventDividers(dividers);},_onRecordAdded:function(event)
212 {var record=event.data;var eventDividers=this._eventDividers;function addEventDividers(record)
213 {if(WebInspector.TimelinePresentationModel.isEventDivider(record))
214 eventDividers.push(record);}
215 WebInspector.TimelinePresentationModel.forAllRecords([record],addEventDividers);this._scheduleRefresh();},_reset:function()
216 {this._overviewCalculator.reset();this._overviewGrid.reset();this._overviewGrid.setResizeEnabled(false);this._eventDividers=[];this._overviewGrid.updateDividers(this._overviewCalculator);if(this._overviewControl)
217 this._overviewControl.reset();this._update();},windowLeft:function()
218 {return this._overviewGrid.windowLeft();},windowRight:function()
219 {return this._overviewGrid.windowRight();},_onWindowChanged:function()
220 {if(this._ignoreWindowChangedEvent)
221 return;this.dispatchEventToListeners(WebInspector.TimelineOverviewPane.Events.WindowChanged);},setWindow:function(left,right)
222 {this._ignoreWindowChangedEvent=true;this._overviewGrid.setWindow(left,right);this._overviewGrid.setResizeEnabled(this._model.records.length);this._ignoreWindowChangedEvent=false;},_scheduleRefresh:function()
223 {if(this._refreshTimeout)
224 return;if(!this.isShowing())
225 return;this._refreshTimeout=setTimeout(this._update.bind(this),300);},__proto__:WebInspector.View.prototype}
226 WebInspector.TimelineOverviewCalculator=function()
227 {}
228 WebInspector.TimelineOverviewCalculator.prototype={computePosition:function(time)
229 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this.paddingLeft;},computeBarGraphPercentages:function(record)
230 {var start=(WebInspector.TimelineModel.startTimeInSeconds(record)-this._minimumBoundary)/this.boundarySpan()*100;var end=(WebInspector.TimelineModel.endTimeInSeconds(record)-this._minimumBoundary)/this.boundarySpan()*100;return{start:start,end:end};},setWindow:function(minimum,maximum)
231 {this._minimumBoundary=minimum>=0?minimum:undefined;this._maximumBoundary=maximum>=0?maximum:undefined;},setDisplayWindow:function(paddingLeft,clientWidth)
232 {this._workingArea=clientWidth-paddingLeft;this.paddingLeft=paddingLeft;},reset:function()
233 {this.setWindow();},formatTime:function(value,hires)
234 {return Number.secondsToString(value,hires);},maximumBoundary:function()
235 {return this._maximumBoundary;},minimumBoundary:function()
236 {return this._minimumBoundary;},zeroTime:function()
237 {return this._minimumBoundary;},boundarySpan:function()
238 {return this._maximumBoundary-this._minimumBoundary;}}
239 WebInspector.TimelineOverviewBase=function(model)
240 {WebInspector.View.call(this);this.element.classList.add("fill");this._model=model;this._canvas=this.element.createChild("canvas","fill");this._context=this._canvas.getContext("2d");}
241 WebInspector.TimelineOverviewBase.prototype={update:function(){},reset:function(){},windowTimes:function(windowLeft,windowRight)
242 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximumRecordTime()-absoluteMin;return{startTime:absoluteMin+timeSpan*windowLeft,endTime:absoluteMin+timeSpan*windowRight};},windowBoundaries:function(startTime,endTime)
243 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximumRecordTime()-absoluteMin;var haveRecords=absoluteMin>=0;return{left:haveRecords&&startTime?Math.min((startTime-absoluteMin)/timeSpan,1):0,right:haveRecords&&endTime<Infinity?(endTime-absoluteMin)/timeSpan:1}},resetCanvas:function()
244 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canvas.height=this.element.clientHeight*window.devicePixelRatio;},__proto__:WebInspector.View.prototype};WebInspector.TimelinePresentationModel=function()
245 {this._linkifier=new WebInspector.Linkifier();this._glueRecords=false;this._filters=[];this.reset();}
246 WebInspector.TimelinePresentationModel.categories=function()
247 {if(WebInspector.TimelinePresentationModel._categories)
248 return WebInspector.TimelinePresentationModel._categories;WebInspector.TimelinePresentationModel._categories={loading:new WebInspector.TimelineCategory("loading",WebInspector.UIString("Loading"),0,"#5A8BCC","#8EB6E9","#70A2E3"),scripting:new WebInspector.TimelineCategory("scripting",WebInspector.UIString("Scripting"),1,"#D8AA34","#F3D07A","#F1C453"),rendering:new WebInspector.TimelineCategory("rendering",WebInspector.UIString("Rendering"),2,"#8266CC","#AF9AEB","#9A7EE6"),painting:new WebInspector.TimelineCategory("painting",WebInspector.UIString("Painting"),2,"#5FA050","#8DC286","#71B363"),other:new WebInspector.TimelineCategory("other",WebInspector.UIString("Other"),-1,"#BBBBBB","#DDDDDD","#DDDDDD"),idle:new WebInspector.TimelineCategory("idle",WebInspector.UIString("Idle"),-1,"#DDDDDD","#FFFFFF","#FFFFFF")};return WebInspector.TimelinePresentationModel._categories;};WebInspector.TimelinePresentationModel._initRecordStyles=function()
249 {if(WebInspector.TimelinePresentationModel._recordStylesMap)
250 return WebInspector.TimelinePresentationModel._recordStylesMap;var recordTypes=WebInspector.TimelineModel.RecordType;var categories=WebInspector.TimelinePresentationModel.categories();var recordStyles={};recordStyles[recordTypes.Root]={title:"#root",category:categories["loading"]};recordStyles[recordTypes.Program]={title:WebInspector.UIString("Other"),category:categories["other"]};recordStyles[recordTypes.EventDispatch]={title:WebInspector.UIString("Event"),category:categories["scripting"]};recordStyles[recordTypes.BeginFrame]={title:WebInspector.UIString("Frame Start"),category:categories["rendering"]};recordStyles[recordTypes.ScheduleStyleRecalculation]={title:WebInspector.UIString("Schedule Style Recalculation"),category:categories["rendering"]};recordStyles[recordTypes.RecalculateStyles]={title:WebInspector.UIString("Recalculate Style"),category:categories["rendering"]};recordStyles[recordTypes.InvalidateLayout]={title:WebInspector.UIString("Invalidate Layout"),category:categories["rendering"]};recordStyles[recordTypes.Layout]={title:WebInspector.UIString("Layout"),category:categories["rendering"]};recordStyles[recordTypes.AutosizeText]={title:WebInspector.UIString("Autosize Text"),category:categories["rendering"]};recordStyles[recordTypes.PaintSetup]={title:WebInspector.UIString("Paint Setup"),category:categories["painting"]};recordStyles[recordTypes.Paint]={title:WebInspector.UIString("Paint"),category:categories["painting"]};recordStyles[recordTypes.Rasterize]={title:WebInspector.UIString("Paint"),category:categories["painting"]};recordStyles[recordTypes.ScrollLayer]={title:WebInspector.UIString("Scroll"),category:categories["rendering"]};recordStyles[recordTypes.DecodeImage]={title:WebInspector.UIString("Image Decode"),category:categories["painting"]};recordStyles[recordTypes.ResizeImage]={title:WebInspector.UIString("Image Resize"),category:categories["painting"]};recordStyles[recordTypes.CompositeLayers]={title:WebInspector.UIString("Composite Layers"),category:categories["painting"]};recordStyles[recordTypes.ParseHTML]={title:WebInspector.UIString("Parse HTML"),category:categories["loading"]};recordStyles[recordTypes.TimerInstall]={title:WebInspector.UIString("Install Timer"),category:categories["scripting"]};recordStyles[recordTypes.TimerRemove]={title:WebInspector.UIString("Remove Timer"),category:categories["scripting"]};recordStyles[recordTypes.TimerFire]={title:WebInspector.UIString("Timer Fired"),category:categories["scripting"]};recordStyles[recordTypes.XHRReadyStateChange]={title:WebInspector.UIString("XHR Ready State Change"),category:categories["scripting"]};recordStyles[recordTypes.XHRLoad]={title:WebInspector.UIString("XHR Load"),category:categories["scripting"]};recordStyles[recordTypes.EvaluateScript]={title:WebInspector.UIString("Evaluate Script"),category:categories["scripting"]};recordStyles[recordTypes.ResourceSendRequest]={title:WebInspector.UIString("Send Request"),category:categories["loading"]};recordStyles[recordTypes.ResourceReceiveResponse]={title:WebInspector.UIString("Receive Response"),category:categories["loading"]};recordStyles[recordTypes.ResourceFinish]={title:WebInspector.UIString("Finish Loading"),category:categories["loading"]};recordStyles[recordTypes.FunctionCall]={title:WebInspector.UIString("Function Call"),category:categories["scripting"]};recordStyles[recordTypes.ResourceReceivedData]={title:WebInspector.UIString("Receive Data"),category:categories["loading"]};recordStyles[recordTypes.GCEvent]={title:WebInspector.UIString("GC Event"),category:categories["scripting"]};recordStyles[recordTypes.MarkDOMContent]={title:WebInspector.UIString("DOMContentLoaded event"),category:categories["scripting"]};recordStyles[recordTypes.MarkLoad]={title:WebInspector.UIString("Load event"),category:categories["scripting"]};recordStyles[recordTypes.MarkFirstPaint]={title:WebInspector.UIString("First paint"),category:categories["painting"]};recordStyles[recordTypes.TimeStamp]={title:WebInspector.UIString("Stamp"),category:categories["scripting"]};recordStyles[recordTypes.Time]={title:WebInspector.UIString("Time"),category:categories["scripting"]};recordStyles[recordTypes.TimeEnd]={title:WebInspector.UIString("Time End"),category:categories["scripting"]};recordStyles[recordTypes.ScheduleResourceRequest]={title:WebInspector.UIString("Schedule Request"),category:categories["loading"]};recordStyles[recordTypes.RequestAnimationFrame]={title:WebInspector.UIString("Request Animation Frame"),category:categories["scripting"]};recordStyles[recordTypes.CancelAnimationFrame]={title:WebInspector.UIString("Cancel Animation Frame"),category:categories["scripting"]};recordStyles[recordTypes.FireAnimationFrame]={title:WebInspector.UIString("Animation Frame Fired"),category:categories["scripting"]};recordStyles[recordTypes.WebSocketCreate]={title:WebInspector.UIString("Create WebSocket"),category:categories["scripting"]};recordStyles[recordTypes.WebSocketSendHandshakeRequest]={title:WebInspector.UIString("Send WebSocket Handshake"),category:categories["scripting"]};recordStyles[recordTypes.WebSocketReceiveHandshakeResponse]={title:WebInspector.UIString("Receive WebSocket Handshake"),category:categories["scripting"]};recordStyles[recordTypes.WebSocketDestroy]={title:WebInspector.UIString("Destroy WebSocket"),category:categories["scripting"]};WebInspector.TimelinePresentationModel._recordStylesMap=recordStyles;return recordStyles;}
251 WebInspector.TimelinePresentationModel.recordStyle=function(record)
252 {var recordStyles=WebInspector.TimelinePresentationModel._initRecordStyles();var result=recordStyles[record.type];if(!result){result={title:WebInspector.UIString("Unknown: %s",record.type),category:WebInspector.TimelinePresentationModel.categories()["other"]};recordStyles[record.type]=result;}
253 return result;}
254 WebInspector.TimelinePresentationModel.categoryForRecord=function(record)
255 {return WebInspector.TimelinePresentationModel.recordStyle(record).category;}
256 WebInspector.TimelinePresentationModel.isEventDivider=function(record)
257 {var recordTypes=WebInspector.TimelineModel.RecordType;if(record.type===recordTypes.TimeStamp)
258 return true;if(record.type===recordTypes.MarkFirstPaint)
259 return true;if(record.type===recordTypes.MarkDOMContent||record.type===recordTypes.MarkLoad){if(record.data&&((typeof record.data.isMainFrame)==="boolean"))
260 return record.data.isMainFrame;}
261 return false;}
262 WebInspector.TimelinePresentationModel.forAllRecords=function(recordsArray,preOrderCallback,postOrderCallback)
263 {if(!recordsArray)
264 return;var stack=[{array:recordsArray,index:0}];while(stack.length){var entry=stack[stack.length-1];var records=entry.array;if(entry.index<records.length){var record=records[entry.index];if(preOrderCallback&&preOrderCallback(record))
265 return;if(record.children)
266 stack.push({array:record.children,index:0,record:record});else if(postOrderCallback&&postOrderCallback(record))
267 return;++entry.index;}else{if(entry.record&&postOrderCallback&&postOrderCallback(entry.record))
268 return;stack.pop();}}}
269 WebInspector.TimelinePresentationModel.needsPreviewElement=function(recordType)
270 {if(!recordType)
271 return false;const recordTypes=WebInspector.TimelineModel.RecordType;switch(recordType){case recordTypes.ScheduleResourceRequest:case recordTypes.ResourceSendRequest:case recordTypes.ResourceReceiveResponse:case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:return true;default:return false;}}
272 WebInspector.TimelinePresentationModel.createEventDivider=function(recordType,title)
273 {var eventDivider=document.createElement("div");eventDivider.className="resources-event-divider";var recordTypes=WebInspector.TimelineModel.RecordType;if(recordType===recordTypes.MarkDOMContent)
274 eventDivider.className+=" resources-blue-divider";else if(recordType===recordTypes.MarkLoad)
275 eventDivider.className+=" resources-red-divider";else if(recordType===recordTypes.MarkFirstPaint)
276 eventDivider.className+=" resources-green-divider";else if(recordType===recordTypes.TimeStamp)
277 eventDivider.className+=" resources-orange-divider";else if(recordType===recordTypes.BeginFrame)
278 eventDivider.className+=" timeline-frame-divider";if(title)
279 eventDivider.title=title;return eventDivider;}
280 WebInspector.TimelinePresentationModel._hiddenRecords={}
281 WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkDOMContent]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkLoad]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkFirstPaint]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.InvalidateLayout]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.GPUTask]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.ActivateLayerTree]=1;WebInspector.TimelinePresentationModel.prototype={addFilter:function(filter)
282 {this._filters.push(filter);},setSearchFilter:function(filter)
283 {this._searchFilter=filter;},rootRecord:function()
284 {return this._rootRecord;},frames:function()
285 {return this._frames;},reset:function()
286 {this._linkifier.reset();this._rootRecord=new WebInspector.TimelinePresentationModel.Record(this,{type:WebInspector.TimelineModel.RecordType.Root},null,null,null,false);this._sendRequestRecords={};this._scheduledResourceRequests={};this._timerRecords={};this._requestAnimationFrameRecords={};this._eventDividerRecords=[];this._timeRecords={};this._timeRecordStack=[];this._frames=[];this._minimumRecordTime=-1;this._layoutInvalidateStack={};this._lastScheduleStyleRecalculation={};this._webSocketCreateRecords={};this._coalescingBuckets={};},addFrame:function(frame)
287 {if(!frame.isBackground)
288 this._frames.push(frame);},addRecord:function(record)
289 {if(this._minimumRecordTime===-1||record.startTime<this._minimumRecordTime)
290 this._minimumRecordTime=WebInspector.TimelineModel.startTimeInSeconds(record);var records;if(record.type===WebInspector.TimelineModel.RecordType.Program)
291 records=this._foldSyncTimeRecords(record.children||[]);else
292 records=[record];var result=Array(records.length);for(var i=0;i<records.length;++i)
293 result[i]=this._innerAddRecord(this._rootRecord,records[i]);return result;},_innerAddRecord:function(parentRecord,record)
294 {const recordTypes=WebInspector.TimelineModel.RecordType;var isHiddenRecord=record.type in WebInspector.TimelinePresentationModel._hiddenRecords;var origin;var coalescingBucket;if(!isHiddenRecord){var newParentRecord=this._findParentRecord(record);if(newParentRecord){origin=parentRecord;parentRecord=newParentRecord;}
295 if(parentRecord===this._rootRecord)
296 coalescingBucket=record.thread?record.type:"mainThread";var coalescedRecord=this._findCoalescedParent(record,parentRecord,coalescingBucket);if(coalescedRecord){if(!origin)
297 origin=parentRecord;parentRecord=coalescedRecord;}}
298 var children=record.children;var scriptDetails=null;if(record.data&&record.data["scriptName"]){scriptDetails={scriptName:record.data["scriptName"],scriptLine:record.data["scriptLine"]}};if((record.type===recordTypes.TimerFire||record.type===recordTypes.FireAnimationFrame)&&children&&children.length){var childRecord=children[0];if(childRecord.type===recordTypes.FunctionCall){scriptDetails={scriptName:childRecord.data["scriptName"],scriptLine:childRecord.data["scriptLine"]};children=childRecord.children.concat(children.slice(1));}}
299 var formattedRecord=new WebInspector.TimelinePresentationModel.Record(this,record,parentRecord,origin,scriptDetails,isHiddenRecord);if(WebInspector.TimelinePresentationModel.isEventDivider(formattedRecord))
300 this._eventDividerRecords.push(formattedRecord);if(isHiddenRecord)
301 return formattedRecord;formattedRecord.collapsed=parentRecord===this._rootRecord;if(coalescingBucket)
302 this._coalescingBuckets[coalescingBucket]=formattedRecord;if(children){children=this._foldSyncTimeRecords(children);for(var i=0;i<children.length;++i)
303 this._innerAddRecord(formattedRecord,children[i]);}
304 formattedRecord.calculateAggregatedStats();if(parentRecord.coalesced)
305 this._updateCoalescingParent(formattedRecord);else if(origin)
306 this._updateAncestorStats(formattedRecord);origin=formattedRecord.origin();if(!origin.isRoot()&&!origin.coalesced)
307 origin.selfTime-=formattedRecord.endTime-formattedRecord.startTime;return formattedRecord;},_updateAncestorStats:function(record)
308 {var lastChildEndTime=record.lastChildEndTime;var aggregatedStats=record.aggregatedStats;for(var currentRecord=record.parent;currentRecord&&!currentRecord.isRoot();currentRecord=currentRecord.parent){currentRecord._cpuTime+=record._cpuTime;if(currentRecord.lastChildEndTime<lastChildEndTime)
309 currentRecord.lastChildEndTime=lastChildEndTime;for(var category in aggregatedStats)
310 currentRecord.aggregatedStats[category]+=aggregatedStats[category];}},_findCoalescedParent:function(record,newParent,bucket)
311 {const coalescingThresholdSeconds=0.005;var lastRecord=bucket?this._coalescingBuckets[bucket]:newParent.children.peekLast();if(lastRecord&&lastRecord.coalesced)
312 lastRecord=lastRecord.children.peekLast();var startTime=WebInspector.TimelineModel.startTimeInSeconds(record);var endTime=WebInspector.TimelineModel.endTimeInSeconds(record);if(!lastRecord)
313 return null;if(lastRecord.type!==record.type)
314 return null;if(lastRecord.endTime+coalescingThresholdSeconds<startTime)
315 return null;if(endTime+coalescingThresholdSeconds<lastRecord.startTime)
316 return null;if(WebInspector.TimelinePresentationModel.coalescingKeyForRecord(record)!==WebInspector.TimelinePresentationModel.coalescingKeyForRecord(lastRecord._record))
317 return null;if(lastRecord.parent.coalesced)
318 return lastRecord.parent;return this._replaceWithCoalescedRecord(lastRecord);},_replaceWithCoalescedRecord:function(record)
319 {var rawRecord={type:record._record.type,startTime:record._record.startTime,endTime:record._record.endTime,data:{}};if(record._record.thread)
320 rawRecord.thread="aggregated";if(record.type===WebInspector.TimelineModel.RecordType.TimeStamp)
321 rawRecord.data.message=record.data.message;var coalescedRecord=new WebInspector.TimelinePresentationModel.Record(this,rawRecord,null,null,null,false);var parent=record.parent;coalescedRecord.coalesced=true;coalescedRecord.collapsed=true;coalescedRecord._children.push(record);record.parent=coalescedRecord;if(record.hasWarnings()||record.childHasWarnings())
322 coalescedRecord._childHasWarnings=true;coalescedRecord.parent=parent;parent._children[parent._children.indexOf(record)]=coalescedRecord;WebInspector.TimelineModel.aggregateTimeByCategory(coalescedRecord._aggregatedStats,record._aggregatedStats);return coalescedRecord;},_updateCoalescingParent:function(record)
323 {var parentRecord=record.parent;WebInspector.TimelineModel.aggregateTimeByCategory(parentRecord._aggregatedStats,record._aggregatedStats);if(parentRecord.startTime>record._record.startTime)
324 parentRecord._record.startTime=record._record.startTime;if(parentRecord.endTime<record._record.endTime){parentRecord._record.endTime=record._record.endTime;parentRecord.lastChildEndTime=parentRecord.endTime;}},_foldSyncTimeRecords:function(records)
325 {var recordTypes=WebInspector.TimelineModel.RecordType;for(var i=0;i<records.length&&records[i].type!==recordTypes.Time;++i){}
326 if(i===records.length)
327 return records;var result=[];var stack=[];for(var i=0;i<records.length;++i){result.push(records[i]);if(records[i].type===recordTypes.Time){stack.push(result.length-1);continue;}
328 if(records[i].type!==recordTypes.TimeEnd)
329 continue;while(stack.length){var begin=stack.pop();if(result[begin].data.message!==records[i].data.message)
330 continue;var timeEndRecord=(result.pop());var children=result.splice(begin+1,result.length-begin);result[begin]=this._createSynchronousTimeRecord(result[begin],timeEndRecord,children);break;}}
331 return result;},_createSynchronousTimeRecord:function(beginRecord,endRecord,children)
332 {return{type:beginRecord.type,startTime:beginRecord.startTime,endTime:endRecord.startTime,stackTrace:beginRecord.stackTrace,children:children,data:{message:beginRecord.data.message,isSynchronous:true},};},_findParentRecord:function(record)
333 {if(!this._glueRecords)
334 return null;var recordTypes=WebInspector.TimelineModel.RecordType;switch(record.type){case recordTypes.ResourceReceiveResponse:case recordTypes.ResourceFinish:case recordTypes.ResourceReceivedData:return this._sendRequestRecords[record.data["requestId"]];case recordTypes.ResourceSendRequest:return this._rootRecord;case recordTypes.TimerFire:return this._timerRecords[record.data["timerId"]];case recordTypes.ResourceSendRequest:return this._scheduledResourceRequests[record.data["url"]];case recordTypes.FireAnimationFrame:return this._requestAnimationFrameRecords[record.data["id"]];}},setGlueRecords:function(glue)
335 {this._glueRecords=glue;},invalidateFilteredRecords:function()
336 {delete this._filteredRecords;},filteredRecords:function()
337 {if(this._filteredRecords)
338 return this._filteredRecords;var recordsInWindow=[];var stack=[{children:this._rootRecord.children,index:0,parentIsCollapsed:false,parentRecord:{}}];var revealedDepth=0;function revealRecordsInStack(){for(var depth=revealedDepth+1;depth<stack.length;++depth){if(stack[depth-1].parentIsCollapsed){stack[depth].parentRecord.parent._expandable=true;return;}
339 stack[depth-1].parentRecord.collapsed=false;recordsInWindow.push(stack[depth].parentRecord);stack[depth].windowLengthBeforeChildrenTraversal=recordsInWindow.length;stack[depth].parentIsRevealed=true;revealedDepth=depth;}}
340 while(stack.length){var entry=stack[stack.length-1];var records=entry.children;if(records&&entry.index<records.length){var record=records[entry.index];++entry.index;if(this.isVisible(record)){record.parent._expandable=true;if(this._searchFilter)
341 revealRecordsInStack();if(!entry.parentIsCollapsed){recordsInWindow.push(record);revealedDepth=stack.length;entry.parentRecord.collapsed=false;}}
342 record._expandable=false;stack.push({children:record.children,index:0,parentIsCollapsed:(entry.parentIsCollapsed||(record.collapsed&&(!this._searchFilter||record.clicked))),parentRecord:record,windowLengthBeforeChildrenTraversal:recordsInWindow.length});}else{stack.pop();revealedDepth=Math.min(revealedDepth,stack.length-1);entry.parentRecord._visibleChildrenCount=recordsInWindow.length-entry.windowLengthBeforeChildrenTraversal;}}
343 this._filteredRecords=recordsInWindow;return recordsInWindow;},filteredFrames:function(startTime,endTime)
344 {function compareStartTime(value,object)
345 {return value-object.startTime;}
346 function compareEndTime(value,object)
347 {return value-object.endTime;}
348 var firstFrame=insertionIndexForObjectInListSortedByFunction(startTime,this._frames,compareStartTime);var lastFrame=insertionIndexForObjectInListSortedByFunction(endTime,this._frames,compareEndTime);while(lastFrame<this._frames.length&&this._frames[lastFrame].endTime<=endTime)
349 ++lastFrame;return this._frames.slice(firstFrame,lastFrame);},eventDividerRecords:function()
350 {return this._eventDividerRecords;},isVisible:function(record)
351 {for(var i=0;i<this._filters.length;++i){if(!this._filters[i].accept(record))
352 return false;}
353 return!this._searchFilter||this._searchFilter.accept(record);},generateMainThreadBarPopupContent:function(info)
354 {var firstTaskIndex=info.firstTaskIndex;var lastTaskIndex=info.lastTaskIndex;var tasks=info.tasks;var messageCount=lastTaskIndex-firstTaskIndex+1;var cpuTime=0;for(var i=firstTaskIndex;i<=lastTaskIndex;++i){var task=tasks[i];cpuTime+=WebInspector.TimelineModel.endTimeInSeconds(task)-WebInspector.TimelineModel.startTimeInSeconds(task);}
355 var startTime=WebInspector.TimelineModel.startTimeInSeconds(tasks[firstTaskIndex]);var endTime=WebInspector.TimelineModel.endTimeInSeconds(tasks[lastTaskIndex]);var duration=endTime-startTime;var offset=this._minimumRecordTime;var contentHelper=new WebInspector.TimelinePopupContentHelper(info.name);var durationText=WebInspector.UIString("%s (at %s)",Number.secondsToString(duration,true),Number.secondsToString(startTime-offset,true));contentHelper.appendTextRow(WebInspector.UIString("Duration"),durationText);contentHelper.appendTextRow(WebInspector.UIString("CPU time"),Number.secondsToString(cpuTime,true));contentHelper.appendTextRow(WebInspector.UIString("Message Count"),messageCount);return contentHelper.contentTable();},__proto__:WebInspector.Object.prototype}
356 WebInspector.TimelinePresentationModel.Record=function(presentationModel,record,parentRecord,origin,scriptDetails,hidden)
357 {this._linkifier=presentationModel._linkifier;this._aggregatedStats={};this._record=record;this._children=[];if(!hidden&&parentRecord){this.parent=parentRecord;if(this.isBackground)
358 WebInspector.TimelinePresentationModel.insertRetrospectiveRecord(parentRecord,this);else
359 parentRecord.children.push(this);}
360 if(origin)
361 this._origin=origin;this._selfTime=this.endTime-this.startTime;this._lastChildEndTime=this.endTime;this._startTimeOffset=this.startTime-presentationModel._minimumRecordTime;if(record.data){if(record.data["url"])
362 this.url=record.data["url"];if(record.data["rootNode"])
363 this._relatedBackendNodeId=record.data["rootNode"];else if(record.data["elementId"])
364 this._relatedBackendNodeId=record.data["elementId"];}
365 if(scriptDetails){this.scriptName=scriptDetails.scriptName;this.scriptLine=scriptDetails.scriptLine;}
366 if(parentRecord&&parentRecord.callSiteStackTrace)
367 this.callSiteStackTrace=parentRecord.callSiteStackTrace;var recordTypes=WebInspector.TimelineModel.RecordType;switch(record.type){case recordTypes.ResourceSendRequest:presentationModel._sendRequestRecords[record.data["requestId"]]=this;break;case recordTypes.ScheduleResourceRequest:presentationModel._scheduledResourceRequests[record.data["url"]]=this;break;case recordTypes.ResourceReceiveResponse:var sendRequestRecord=presentationModel._sendRequestRecords[record.data["requestId"]];if(sendRequestRecord){this.url=sendRequestRecord.url;sendRequestRecord._refreshDetails();if(sendRequestRecord.parent!==presentationModel._rootRecord&&sendRequestRecord.parent.type===recordTypes.ScheduleResourceRequest)
368 sendRequestRecord.parent._refreshDetails();}
369 break;case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:var sendRequestRecord=presentationModel._sendRequestRecords[record.data["requestId"]];if(sendRequestRecord)
370 this.url=sendRequestRecord.url;break;case recordTypes.TimerInstall:this.timeout=record.data["timeout"];this.singleShot=record.data["singleShot"];presentationModel._timerRecords[record.data["timerId"]]=this;break;case recordTypes.TimerFire:var timerInstalledRecord=presentationModel._timerRecords[record.data["timerId"]];if(timerInstalledRecord){this.callSiteStackTrace=timerInstalledRecord.stackTrace;this.timeout=timerInstalledRecord.timeout;this.singleShot=timerInstalledRecord.singleShot;}
371 break;case recordTypes.RequestAnimationFrame:presentationModel._requestAnimationFrameRecords[record.data["id"]]=this;break;case recordTypes.FireAnimationFrame:var requestAnimationRecord=presentationModel._requestAnimationFrameRecords[record.data["id"]];if(requestAnimationRecord)
372 this.callSiteStackTrace=requestAnimationRecord.stackTrace;break;case recordTypes.Time:if(record.data.isSynchronous)
373 break;var message=record.data["message"];var oldReference=presentationModel._timeRecords[message];if(oldReference)
374 break;presentationModel._timeRecords[message]=this;if(origin)
375 presentationModel._timeRecordStack.push(this);break;case recordTypes.TimeEnd:var message=record.data["message"];var timeRecord=presentationModel._timeRecords[message];delete presentationModel._timeRecords[message];if(timeRecord){this.timeRecord=timeRecord;timeRecord.timeEndRecord=this;var intervalDuration=this.startTime-timeRecord.startTime;this.intervalDuration=intervalDuration;timeRecord.intervalDuration=intervalDuration;}
376 break;case recordTypes.ScheduleStyleRecalculation:presentationModel._lastScheduleStyleRecalculation[this.frameId]=this;break;case recordTypes.RecalculateStyles:var scheduleStyleRecalculationRecord=presentationModel._lastScheduleStyleRecalculation[this.frameId];if(!scheduleStyleRecalculationRecord)
377 break;this.callSiteStackTrace=scheduleStyleRecalculationRecord.stackTrace;break;case recordTypes.InvalidateLayout:var styleRecalcStack;if(!presentationModel._layoutInvalidateStack[this.frameId]){for(var outerRecord=parentRecord;outerRecord;outerRecord=record.parent){if(outerRecord.type===recordTypes.RecalculateStyles){styleRecalcStack=outerRecord.callSiteStackTrace;break;}}}
378 presentationModel._layoutInvalidateStack[this.frameId]=styleRecalcStack||this.stackTrace;break;case recordTypes.Layout:var layoutInvalidateStack=presentationModel._layoutInvalidateStack[this.frameId];if(layoutInvalidateStack)
379 this.callSiteStackTrace=layoutInvalidateStack;if(this.stackTrace)
380 this.addWarning(WebInspector.UIString("Forced synchronous layout is a possible performance bottleneck."));presentationModel._layoutInvalidateStack[this.frameId]=null;this.highlightQuad=record.data.root||WebInspector.TimelinePresentationModel.quadFromRectData(record.data);this._relatedBackendNodeId=record.data["rootNode"];break;case recordTypes.AutosizeText:if(record.data.needsRelayout&&parentRecord.type===recordTypes.Layout)
381 parentRecord.addWarning(WebInspector.UIString("Layout required two passes due to text autosizing, consider setting viewport."));break;case recordTypes.Paint:this.highlightQuad=record.data.clip||WebInspector.TimelinePresentationModel.quadFromRectData(record.data);break;case recordTypes.WebSocketCreate:this.webSocketURL=record.data["url"];if(typeof record.data["webSocketProtocol"]!=="undefined")
382 this.webSocketProtocol=record.data["webSocketProtocol"];presentationModel._webSocketCreateRecords[record.data["identifier"]]=this;break;case recordTypes.WebSocketSendHandshakeRequest:case recordTypes.WebSocketReceiveHandshakeResponse:case recordTypes.WebSocketDestroy:var webSocketCreateRecord=presentationModel._webSocketCreateRecords[record.data["identifier"]];if(webSocketCreateRecord){this.webSocketURL=webSocketCreateRecord.webSocketURL;if(typeof webSocketCreateRecord.webSocketProtocol!=="undefined")
383 this.webSocketProtocol=webSocketCreateRecord.webSocketProtocol;}
384 break;}}
385 WebInspector.TimelinePresentationModel.adoptRecord=function(newParent,record)
386 {record.parent.children.splice(record.parent.children.indexOf(record));WebInspector.TimelinePresentationModel.insertRetrospectiveRecord(newParent,record);record.parent=newParent;}
387 WebInspector.TimelinePresentationModel.insertRetrospectiveRecord=function(parent,record)
388 {function compareStartTime(value,record)
389 {return value<record.startTime?-1:1;}
390 parent.children.splice(insertionIndexForObjectInListSortedByFunction(record.startTime,parent.children,compareStartTime),0,record);}
391 WebInspector.TimelinePresentationModel.Record.prototype={get lastChildEndTime()
392 {return this._lastChildEndTime;},set lastChildEndTime(time)
393 {this._lastChildEndTime=time;},get selfTime()
394 {return this.coalesced?this._lastChildEndTime-this.startTime:this._selfTime;},set selfTime(time)
395 {this._selfTime=time;},get cpuTime()
396 {return this._cpuTime;},isRoot:function()
397 {return this.type===WebInspector.TimelineModel.RecordType.Root;},origin:function()
398 {return this._origin||this.parent;},get children()
399 {return this._children;},get visibleChildrenCount()
400 {return this._visibleChildrenCount||0;},get expandable()
401 {return!!this._expandable;},get category()
402 {return WebInspector.TimelinePresentationModel.recordStyle(this._record).category},get title()
403 {return this.type===WebInspector.TimelineModel.RecordType.TimeStamp?this._record.data["message"]:WebInspector.TimelinePresentationModel.recordStyle(this._record).title;},get startTime()
404 {return WebInspector.TimelineModel.startTimeInSeconds(this._record);},get endTime()
405 {return WebInspector.TimelineModel.endTimeInSeconds(this._record);},get isBackground()
406 {return!!this._record.thread;},get data()
407 {return this._record.data;},get type()
408 {return this._record.type;},get frameId()
409 {return this._record.frameId;},get usedHeapSizeDelta()
410 {return this._record.usedHeapSizeDelta||0;},get jsHeapSizeUsed()
411 {return this._record.counters?this._record.counters.jsHeapSizeUsed:0;},get stackTrace()
412 {if(this._record.stackTrace&&this._record.stackTrace.length)
413 return this._record.stackTrace;return null;},containsTime:function(time)
414 {return this.startTime<=time&&time<=this.endTime;},generatePopupContent:function(callback)
415 {var barrier=new CallbackBarrier();if(WebInspector.TimelinePresentationModel.needsPreviewElement(this.type)&&!this._imagePreviewElement)
416 WebInspector.DOMPresentationUtils.buildImagePreviewContents(this.url,false,barrier.createCallback(this._setImagePreviewElement.bind(this)));if(this._relatedBackendNodeId&&!this._relatedNode)
417 WebInspector.domAgent.pushNodeByBackendIdToFrontend(this._relatedBackendNodeId,barrier.createCallback(this._setRelatedNode.bind(this)));barrier.callWhenDone(callbackWrapper.bind(this));function callbackWrapper()
418 {callback(this._generatePopupContentSynchronously());}},getUserObject:function(key)
419 {if(!this._userObjects)
420 return null;return this._userObjects.get(key);},setUserObject:function(key,value)
421 {if(!this._userObjects)
422 this._userObjects=new StringMap();this._userObjects.put(key,value);},_setImagePreviewElement:function(element)
423 {this._imagePreviewElement=element;},_setRelatedNode:function(nodeId)
424 {if(typeof nodeId==="number")
425 this._relatedNode=WebInspector.domAgent.nodeForId(nodeId);},_generatePopupContentSynchronously:function()
426 {var fragment=document.createDocumentFragment();var pie=WebInspector.TimelinePresentationModel.generatePieChart(this._aggregatedStats,this.category.name);if(!this.coalesced&&this._children.length){pie.pieChart.addSlice(this._selfTime,this.category.fillColorStop1);var rowElement=document.createElement("div");pie.footerElement.insertBefore(rowElement,pie.footerElement.firstChild);rowElement.createChild("div","timeline-aggregated-category timeline-"+this.category.name);rowElement.createTextChild(WebInspector.UIString("%s %s (Self)",Number.secondsToString(this._selfTime,true),this.category.title));}
427 fragment.appendChild(pie.element);var contentHelper=new WebInspector.TimelineDetailsContentHelper(true);contentHelper.appendTextRow(WebInspector.UIString("Started at"),Number.secondsToString(this._startTimeOffset));if(this.coalesced)
428 return fragment;const recordTypes=WebInspector.TimelineModel.RecordType;var callSiteStackTraceLabel;var callStackLabel;var relatedNodeLabel;switch(this.type){case recordTypes.GCEvent:contentHelper.appendTextRow(WebInspector.UIString("Collected"),Number.bytesToString(this.data["usedHeapSizeDelta"]));break;case recordTypes.TimerFire:callSiteStackTraceLabel=WebInspector.UIString("Timer installed");case recordTypes.TimerInstall:case recordTypes.TimerRemove:contentHelper.appendTextRow(WebInspector.UIString("Timer ID"),this.data["timerId"]);if(typeof this.timeout==="number"){contentHelper.appendTextRow(WebInspector.UIString("Timeout"),Number.secondsToString(this.timeout/1000));contentHelper.appendTextRow(WebInspector.UIString("Repeats"),!this.singleShot);}
429 break;case recordTypes.FireAnimationFrame:callSiteStackTraceLabel=WebInspector.UIString("Animation frame requested");contentHelper.appendTextRow(WebInspector.UIString("Callback ID"),this.data["id"]);break;case recordTypes.FunctionCall:if(this.scriptName)
430 contentHelper.appendElementRow(WebInspector.UIString("Location"),this._linkifyLocation(this.scriptName,this.scriptLine,0));break;case recordTypes.ScheduleResourceRequest:case recordTypes.ResourceSendRequest:case recordTypes.ResourceReceiveResponse:case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:contentHelper.appendElementRow(WebInspector.UIString("Resource"),WebInspector.linkifyResourceAsNode(this.url));if(this._imagePreviewElement)
431 contentHelper.appendElementRow(WebInspector.UIString("Preview"),this._imagePreviewElement);if(this.data["requestMethod"])
432 contentHelper.appendTextRow(WebInspector.UIString("Request Method"),this.data["requestMethod"]);if(typeof this.data["statusCode"]==="number")
433 contentHelper.appendTextRow(WebInspector.UIString("Status Code"),this.data["statusCode"]);if(this.data["mimeType"])
434 contentHelper.appendTextRow(WebInspector.UIString("MIME Type"),this.data["mimeType"]);if(this.data["encodedDataLength"])
435 contentHelper.appendTextRow(WebInspector.UIString("Encoded Data Length"),WebInspector.UIString("%d Bytes",this.data["encodedDataLength"]));break;case recordTypes.EvaluateScript:if(this.data&&this.url)
436 contentHelper.appendElementRow(WebInspector.UIString("Script"),this._linkifyLocation(this.url,this.data["lineNumber"]));break;case recordTypes.Paint:var clip=this.data["clip"];if(clip){contentHelper.appendTextRow(WebInspector.UIString("Location"),WebInspector.UIString("(%d, %d)",clip[0],clip[1]));var clipWidth=WebInspector.TimelinePresentationModel.quadWidth(clip);var clipHeight=WebInspector.TimelinePresentationModel.quadHeight(clip);contentHelper.appendTextRow(WebInspector.UIString("Dimensions"),WebInspector.UIString("%d Ã— %d",clipWidth,clipHeight));}else{if(typeof this.data["x"]!=="undefined"&&typeof this.data["y"]!=="undefined")
437 contentHelper.appendTextRow(WebInspector.UIString("Location"),WebInspector.UIString("(%d, %d)",this.data["x"],this.data["y"]));if(typeof this.data["width"]!=="undefined"&&typeof this.data["height"]!=="undefined")
438 contentHelper.appendTextRow(WebInspector.UIString("Dimensions"),WebInspector.UIString("%d\u2009\u00d7\u2009%d",this.data["width"],this.data["height"]));}
439 case recordTypes.PaintSetup:case recordTypes.Rasterize:case recordTypes.ScrollLayer:relatedNodeLabel=WebInspector.UIString("Layer root");break;case recordTypes.AutosizeText:relatedNodeLabel=WebInspector.UIString("Root node");break;case recordTypes.DecodeImage:case recordTypes.ResizeImage:relatedNodeLabel=WebInspector.UIString("Image element");if(this.url)
440 contentHelper.appendElementRow(WebInspector.UIString("Image URL"),WebInspector.linkifyResourceAsNode(this.url));break;case recordTypes.RecalculateStyles:if(this.data["elementCount"])
441 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"),this.data["elementCount"]);callStackLabel=WebInspector.UIString("Styles recalculation forced");break;case recordTypes.Layout:if(this.data["dirtyObjects"])
442 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layout"),this.data["dirtyObjects"]);if(this.data["totalObjects"])
443 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"),this.data["totalObjects"]);if(typeof this.data["partialLayout"]==="boolean"){contentHelper.appendTextRow(WebInspector.UIString("Layout scope"),this.data["partialLayout"]?WebInspector.UIString("Partial"):WebInspector.UIString("Whole document"));}
444 callSiteStackTraceLabel=WebInspector.UIString("Layout invalidated");callStackLabel=WebInspector.UIString("Layout forced");relatedNodeLabel=WebInspector.UIString("Layout root");break;case recordTypes.Time:case recordTypes.TimeEnd:contentHelper.appendTextRow(WebInspector.UIString("Message"),this.data["message"]);if(typeof this.intervalDuration==="number")
445 contentHelper.appendTextRow(WebInspector.UIString("Interval Duration"),Number.secondsToString(this.intervalDuration,true));break;case recordTypes.WebSocketCreate:case recordTypes.WebSocketSendHandshakeRequest:case recordTypes.WebSocketReceiveHandshakeResponse:case recordTypes.WebSocketDestroy:if(typeof this.webSocketURL!=="undefined")
446 contentHelper.appendTextRow(WebInspector.UIString("URL"),this.webSocketURL);if(typeof this.webSocketProtocol!=="undefined")
447 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"),this.webSocketProtocol);if(typeof this.data["message"]!=="undefined")
448 contentHelper.appendTextRow(WebInspector.UIString("Message"),this.data["message"]);break;default:if(this.detailsNode())
449 contentHelper.appendElementRow(WebInspector.UIString("Details"),this.detailsNode().childNodes[1].cloneNode());break;}
450 if(this._relatedNode)
451 contentHelper.appendElementRow(relatedNodeLabel||WebInspector.UIString("Related node"),this._createNodeAnchor(this._relatedNode));if(this.scriptName&&this.type!==recordTypes.FunctionCall)
452 contentHelper.appendElementRow(WebInspector.UIString("Function Call"),this._linkifyLocation(this.scriptName,this.scriptLine,0));if(this.jsHeapSizeUsed){if(this.usedHeapSizeDelta){var sign=this.usedHeapSizeDelta>0?"+":"-";contentHelper.appendTextRow(WebInspector.UIString("Used JavaScript Heap Size"),WebInspector.UIString("%s (%s%s)",Number.bytesToString(this.jsHeapSizeUsed),sign,Number.bytesToString(Math.abs(this.usedHeapSizeDelta))));}else if(this.category===WebInspector.TimelinePresentationModel.categories().scripting)
453 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScript Heap Size"),Number.bytesToString(this.jsHeapSizeUsed));}
454 if(this.callSiteStackTrace)
455 contentHelper.appendStackTrace(callSiteStackTraceLabel||WebInspector.UIString("Call Site stack"),this.callSiteStackTrace,this._linkifyCallFrame.bind(this));if(this.stackTrace)
456 contentHelper.appendStackTrace(callStackLabel||WebInspector.UIString("Call Stack"),this.stackTrace,this._linkifyCallFrame.bind(this));if(this._warnings){var ul=document.createElement("ul");for(var i=0;i<this._warnings.length;++i)
457 ul.createChild("li").textContent=this._warnings[i];contentHelper.appendElementRow(WebInspector.UIString("Warning"),ul);}
458 fragment.appendChild(contentHelper.element);return fragment;},_createNodeAnchor:function(node)
459 {var span=document.createElement("span");span.classList.add("node-link");span.addEventListener("click",onClick,false);WebInspector.DOMPresentationUtils.decorateNodeLabel(node,span);function onClick()
460 {(WebInspector.showPanel("elements")).revealAndSelectNode(node.id);}
461 return span;},_refreshDetails:function()
462 {delete this._detailsNode;},detailsNode:function()
463 {if(typeof this._detailsNode==="undefined"){this._detailsNode=this._getRecordDetails();if(this._detailsNode&&!this.coalesced){this._detailsNode.insertBefore(document.createTextNode("("),this._detailsNode.firstChild);this._detailsNode.appendChild(document.createTextNode(")"));}}
464 return this._detailsNode;},_createSpanWithText:function(textContent)
465 {var node=document.createElement("span");node.textContent=textContent;return node;},_getRecordDetails:function()
466 {var details;if(this.coalesced)
467 return this._createSpanWithText(WebInspector.UIString("× %d",this.children.length));switch(this.type){case WebInspector.TimelineModel.RecordType.GCEvent:details=WebInspector.UIString("%s collected",Number.bytesToString(this.data["usedHeapSizeDelta"]));break;case WebInspector.TimelineModel.RecordType.TimerFire:details=this._linkifyScriptLocation(this.data["timerId"]);break;case WebInspector.TimelineModel.RecordType.FunctionCall:if(this.scriptName)
468 details=this._linkifyLocation(this.scriptName,this.scriptLine,0);break;case WebInspector.TimelineModel.RecordType.FireAnimationFrame:details=this._linkifyScriptLocation(this.data["id"]);break;case WebInspector.TimelineModel.RecordType.EventDispatch:details=this.data?this.data["type"]:null;break;case WebInspector.TimelineModel.RecordType.Paint:var width=this.data.clip?WebInspector.TimelinePresentationModel.quadWidth(this.data.clip):this.data.width;var height=this.data.clip?WebInspector.TimelinePresentationModel.quadHeight(this.data.clip):this.data.height;if(width&&height)
469 details=WebInspector.UIString("%d\u2009\u00d7\u2009%d",width,height);break;case WebInspector.TimelineModel.RecordType.TimerInstall:case WebInspector.TimelineModel.RecordType.TimerRemove:details=this._linkifyTopCallFrame(this.data["timerId"]);break;case WebInspector.TimelineModel.RecordType.RequestAnimationFrame:case WebInspector.TimelineModel.RecordType.CancelAnimationFrame:details=this._linkifyTopCallFrame(this.data["id"]);break;case WebInspector.TimelineModel.RecordType.ParseHTML:case WebInspector.TimelineModel.RecordType.RecalculateStyles:details=this._linkifyTopCallFrame();break;case WebInspector.TimelineModel.RecordType.EvaluateScript:details=this.url?this._linkifyLocation(this.url,this.data["lineNumber"],0):null;break;case WebInspector.TimelineModel.RecordType.XHRReadyStateChange:case WebInspector.TimelineModel.RecordType.XHRLoad:case WebInspector.TimelineModel.RecordType.ScheduleResourceRequest:case WebInspector.TimelineModel.RecordType.ResourceSendRequest:case WebInspector.TimelineModel.RecordType.ResourceReceivedData:case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse:case WebInspector.TimelineModel.RecordType.ResourceFinish:case WebInspector.TimelineModel.RecordType.DecodeImage:case WebInspector.TimelineModel.RecordType.ResizeImage:details=WebInspector.displayNameForURL(this.url);break;case WebInspector.TimelineModel.RecordType.Time:case WebInspector.TimelineModel.RecordType.TimeEnd:details=this.data["message"];break;default:details=this.scriptName?this._linkifyLocation(this.scriptName,this.scriptLine,0):(this._linkifyTopCallFrame()||null);break;}
470 if(details){if(details instanceof Node)
471 details.tabIndex=-1;else
472 return this._createSpanWithText(""+details);}
473 return details||null;},_linkifyLocation:function(url,lineNumber,columnNumber)
474 {columnNumber=columnNumber?columnNumber-1:0;return this._linkifier.linkifyLocation(url,lineNumber-1,columnNumber,"timeline-details");},_linkifyCallFrame:function(callFrame)
475 {return this._linkifyLocation(callFrame.url,callFrame.lineNumber,callFrame.columnNumber);},_linkifyTopCallFrame:function(defaultValue)
476 {if(this.stackTrace)
477 return this._linkifyCallFrame(this.stackTrace[0]);if(this.callSiteStackTrace)
478 return this._linkifyCallFrame(this.callSiteStackTrace[0]);return defaultValue;},_linkifyScriptLocation:function(defaultValue)
479 {return this.scriptName?this._linkifyLocation(this.scriptName,this.scriptLine,0):""+defaultValue;},calculateAggregatedStats:function()
480 {this._aggregatedStats={};this._cpuTime=this._selfTime;for(var index=this._children.length;index;--index){var child=this._children[index-1];for(var category in child._aggregatedStats)
481 this._aggregatedStats[category]=(this._aggregatedStats[category]||0)+child._aggregatedStats[category];}
482 for(var category in this._aggregatedStats)
483 this._cpuTime+=this._aggregatedStats[category];this._aggregatedStats[this.category.name]=(this._aggregatedStats[this.category.name]||0)+this._selfTime;},get aggregatedStats()
484 {return this._aggregatedStats;},addWarning:function(message)
485 {if(this._warnings)
486 this._warnings.push(message);else
487 this._warnings=[message];for(var parent=this.parent;parent&&!parent._childHasWarnings;parent=parent.parent)
488 parent._childHasWarnings=true;},hasWarnings:function()
489 {return!!this._warnings;},childHasWarnings:function()
490 {return this._childHasWarnings;}}
491 WebInspector.TimelinePresentationModel._generateAggregatedInfo=function(aggregatedStats)
492 {var cell=document.createElement("span");cell.className="timeline-aggregated-info";for(var index in aggregatedStats){var label=document.createElement("div");label.className="timeline-aggregated-category timeline-"+index;cell.appendChild(label);var text=document.createElement("span");text.textContent=Number.secondsToString(aggregatedStats[index],true);cell.appendChild(text);}
493 return cell;}
494 WebInspector.TimelinePresentationModel.generatePieChart=function(aggregatedStats,firstCategoryName)
495 {var element=document.createElement("div");element.className="timeline-aggregated-info";var total=0;var categoryNames=[];if(firstCategoryName)
496 categoryNames.push(firstCategoryName);for(var categoryName in WebInspector.TimelinePresentationModel.categories()){if(aggregatedStats[categoryName]){total+=aggregatedStats[categoryName];if(firstCategoryName!==categoryName)
497 categoryNames.push(categoryName);}}
498 var pieChart=new WebInspector.PieChart(total);element.appendChild(pieChart.element);var footerElement=element.createChild("div","timeline-aggregated-info-legend");for(var i=0;i<categoryNames.length;++i){var category=WebInspector.TimelinePresentationModel.categories()[categoryNames[i]];pieChart.addSlice(aggregatedStats[category.name],category.fillColorStop0);var rowElement=footerElement.createChild("div");rowElement.createChild("div","timeline-aggregated-category timeline-"+category.name);rowElement.createTextChild(WebInspector.UIString("%s %s",Number.secondsToString(aggregatedStats[category.name],true),category.title));}
499 return{pieChart:pieChart,element:element,footerElement:footerElement};}
500 WebInspector.TimelinePresentationModel.generatePopupContentForFrame=function(frame)
501 {var contentHelper=new WebInspector.TimelinePopupContentHelper(WebInspector.UIString("Frame"));var durationInSeconds=frame.endTime-frame.startTime;var durationText=WebInspector.UIString("%s (at %s)",Number.secondsToString(frame.endTime-frame.startTime,true),Number.secondsToString(frame.startTimeOffset,true));contentHelper.appendTextRow(WebInspector.UIString("Duration"),durationText);contentHelper.appendTextRow(WebInspector.UIString("FPS"),Math.floor(1/durationInSeconds));contentHelper.appendTextRow(WebInspector.UIString("CPU time"),Number.secondsToString(frame.cpuTime,true));contentHelper.appendTextRow(WebInspector.UIString("Thread"),frame.isBackground?WebInspector.UIString("background"):WebInspector.UIString("main"));contentHelper.appendElementRow(WebInspector.UIString("Aggregated Time"),WebInspector.TimelinePresentationModel._generateAggregatedInfo(frame.timeByCategory));return contentHelper.contentTable();}
502 WebInspector.TimelinePresentationModel.generatePopupContentForFrameStatistics=function(statistics)
503 {function formatTimeAndFPS(time)
504 {return WebInspector.UIString("%s (%.0f FPS)",Number.secondsToString(time,true),1/time);}
505 var contentHelper=new WebInspector.TimelineDetailsContentHelper(false);contentHelper.appendTextRow(WebInspector.UIString("Minimum Time"),formatTimeAndFPS(statistics.minDuration));contentHelper.appendTextRow(WebInspector.UIString("Average Time"),formatTimeAndFPS(statistics.average));contentHelper.appendTextRow(WebInspector.UIString("Maximum Time"),formatTimeAndFPS(statistics.maxDuration));contentHelper.appendTextRow(WebInspector.UIString("Standard Deviation"),Number.secondsToString(statistics.stddev,true));return contentHelper.element;}
506 WebInspector.TimelinePresentationModel.createFillStyle=function(context,width,height,color0,color1,color2)
507 {var gradient=context.createLinearGradient(0,0,width,height);gradient.addColorStop(0,color0);gradient.addColorStop(0.25,color1);gradient.addColorStop(0.75,color1);gradient.addColorStop(1,color2);return gradient;}
508 WebInspector.TimelinePresentationModel.createFillStyleForCategory=function(context,width,height,category)
509 {return WebInspector.TimelinePresentationModel.createFillStyle(context,width,height,category.fillColorStop0,category.fillColorStop1,category.borderColor);}
510 WebInspector.TimelinePresentationModel.createStyleRuleForCategory=function(category)
511 {var selector=".timeline-category-"+category.name+" .timeline-graph-bar, "+".panel.timeline .timeline-filters-header .filter-checkbox-filter.filter-checkbox-filter-"+category.name+" .checkbox-filter-checkbox, "+".popover .timeline-"+category.name+", "+".timeline-details-view .timeline-"+category.name+", "+".timeline-category-"+category.name+" .timeline-tree-icon"
512 return selector+" { background-image: -webkit-linear-gradient("+
513 category.fillColorStop0+", "+category.fillColorStop1+" 25%, "+category.fillColorStop1+" 25%, "+category.fillColorStop1+");"+" border-color: "+category.borderColor+"}";}
514 WebInspector.TimelinePresentationModel.coalescingKeyForRecord=function(rawRecord)
515 {var recordTypes=WebInspector.TimelineModel.RecordType;switch(rawRecord.type)
516 {case recordTypes.EventDispatch:return rawRecord.data["type"];case recordTypes.Time:return rawRecord.data["message"];case recordTypes.TimeStamp:return rawRecord.data["message"];default:return null;}}
517 WebInspector.TimelinePresentationModel.quadWidth=function(quad)
518 {return Math.round(Math.sqrt(Math.pow(quad[0]-quad[2],2)+Math.pow(quad[1]-quad[3],2)));}
519 WebInspector.TimelinePresentationModel.quadHeight=function(quad)
520 {return Math.round(Math.sqrt(Math.pow(quad[0]-quad[6],2)+Math.pow(quad[1]-quad[7],2)));}
521 WebInspector.TimelinePresentationModel.quadFromRectData=function(data)
522 {if(typeof data["x"]==="undefined"||typeof data["y"]==="undefined")
523 return null;var x0=data["x"];var x1=data["x"]+data["width"];var y0=data["y"];var y1=data["y"]+data["height"];return[x0,y0,x1,y0,x1,y1,x0,y1];}
524 WebInspector.TimelinePresentationModel.Filter=function()
525 {}
526 WebInspector.TimelinePresentationModel.Filter.prototype={accept:function(record){return false;}}
527 WebInspector.TimelineCategory=function(name,title,overviewStripGroupIndex,borderColor,fillColorStop0,fillColorStop1)
528 {this.name=name;this.title=title;this.overviewStripGroupIndex=overviewStripGroupIndex;this.borderColor=borderColor;this.fillColorStop0=fillColorStop0;this.fillColorStop1=fillColorStop1;this.hidden=false;}
529 WebInspector.TimelineCategory.Events={VisibilityChanged:"VisibilityChanged"};WebInspector.TimelineCategory.prototype={get hidden()
530 {return this._hidden;},set hidden(hidden)
531 {this._hidden=hidden;this.dispatchEventToListeners(WebInspector.TimelineCategory.Events.VisibilityChanged,this);},__proto__:WebInspector.Object.prototype}
532 WebInspector.TimelinePopupContentHelper=function(title)
533 {this._contentTable=document.createElement("table");var titleCell=this._createCell(WebInspector.UIString("%s - Details",title),"timeline-details-title");titleCell.colSpan=2;var titleRow=document.createElement("tr");titleRow.appendChild(titleCell);this._contentTable.appendChild(titleRow);}
534 WebInspector.TimelinePopupContentHelper.prototype={contentTable:function()
535 {return this._contentTable;},_createCell:function(content,styleName)
536 {var text=document.createElement("label");text.appendChild(document.createTextNode(content));var cell=document.createElement("td");cell.className="timeline-details";if(styleName)
537 cell.className+=" "+styleName;cell.textContent=content;return cell;},appendTextRow:function(title,content)
538 {var row=document.createElement("tr");row.appendChild(this._createCell(title,"timeline-details-row-title"));row.appendChild(this._createCell(content,"timeline-details-row-data"));this._contentTable.appendChild(row);},appendElementRow:function(title,content)
539 {var row=document.createElement("tr");var titleCell=this._createCell(title,"timeline-details-row-title");row.appendChild(titleCell);var cell=document.createElement("td");cell.className="details";if(content instanceof Node)
540 cell.appendChild(content);else
541 cell.createTextChild(content||"");row.appendChild(cell);this._contentTable.appendChild(row);}}
542 WebInspector.TimelineDetailsContentHelper=function(monospaceValues)
543 {this.element=document.createElement("div");this.element.className="timeline-details-view-block";this._monospaceValues=monospaceValues;}
544 WebInspector.TimelineDetailsContentHelper.prototype={appendTextRow:function(title,value)
545 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowElement.createChild("span","timeline-details-view-row-title").textContent=WebInspector.UIString("%s: ",title);rowElement.createChild("span","timeline-details-view-row-value"+(this._monospaceValues?" monospace":"")).textContent=value;},appendElementRow:function(title,content)
546 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowElement.createChild("span","timeline-details-view-row-title").textContent=WebInspector.UIString("%s: ",title);var valueElement=rowElement.createChild("span","timeline-details-view-row-details"+(this._monospaceValues?" monospace":""));if(content instanceof Node)
547 valueElement.appendChild(content);else
548 valueElement.createTextChild(content||"");},appendStackTrace:function(title,stackTrace,callFrameLinkifier)
549 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowElement.createChild("span","timeline-details-view-row-title").textContent=WebInspector.UIString("%s: ",title);var stackTraceElement=rowElement.createChild("div","timeline-details-view-row-stack-trace monospace");for(var i=0;i<stackTrace.length;++i){var stackFrame=stackTrace[i];var row=stackTraceElement.createChild("div");row.createTextChild(stackFrame.functionName||WebInspector.UIString("(anonymous function)"));row.createTextChild(" @ ");var urlElement=callFrameLinkifier(stackFrame);row.appendChild(urlElement);}}};WebInspector.TimelineFrameController=function(model,frameOverview,presentationModel)
550 {this._lastMainThreadFrame=null;this._lastBackgroundFrame=null;this._model=model;this._frameOverview=frameOverview;this._presentationModel=presentationModel;this._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onRecordAdded,this);this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._onRecordsCleared,this);this._frameOverview.reset();var records=model.records;for(var i=0;i<records.length;++i)
551 this._addRecord(records[i]);this._frameOverview.update();}
552 WebInspector.TimelineFrameController.prototype={_onRecordAdded:function(event)
553 {this._addRecord(event.data);},_onRecordsCleared:function()
554 {this._lastMainThreadFrame=null;this._lastBackgroundFrame=null;},_addRecord:function(record)
555 {var records;var programRecord;if(record.type===WebInspector.TimelineModel.RecordType.Program){programRecord=record;if(this._lastMainThreadFrame)
556 this._lastMainThreadFrame.timeByCategory["other"]+=WebInspector.TimelineModel.durationInSeconds(programRecord);records=record["children"]||[];}else
557 records=[record];records.forEach(this._innerAddRecord.bind(this,programRecord));},_innerAddRecord:function(programRecord,record)
558 {var isFrameRecord=record.type===WebInspector.TimelineModel.RecordType.BeginFrame;var programTimeCarryover=isFrameRecord&&programRecord?WebInspector.TimelineModel.endTimeInSeconds(programRecord)-WebInspector.TimelineModel.startTimeInSeconds(record):0;var lastFrame=record.thread?this._lastBackgroundFrame:this._lastMainThreadFrame;if(isFrameRecord&&lastFrame){this._flushFrame(lastFrame,record,programTimeCarryover);lastFrame=this._createFrame(record,programTimeCarryover);}else if(record.type===WebInspector.TimelineModel.RecordType.ActivateLayerTree){if(lastFrame)
559 lastFrame.mainThreadFrameId=record.data.id;}else{if(!lastFrame)
560 lastFrame=this._createFrame(record,programTimeCarryover);if(!record.thread){WebInspector.TimelineModel.aggregateTimeForRecord(lastFrame.timeByCategory,record);var duration=WebInspector.TimelineModel.durationInSeconds(record);lastFrame.cpuTime+=duration;lastFrame.timeByCategory["other"]-=duration;}else if(!isFrameRecord&&WebInspector.TimelinePresentationModel.recordStyle(record).category===WebInspector.TimelinePresentationModel.categories().painting){this._updatePaintingDuration(record);}}
561 if(record.thread)
562 this._lastBackgroundFrame=lastFrame;else
563 this._lastMainThreadFrame=lastFrame;},_flushFrame:function(frame,record,programTimeCarryover)
564 {frame.endTime=WebInspector.TimelineModel.startTimeInSeconds(record);frame.duration=frame.endTime-frame.startTime;frame.timeByCategory["other"]-=programTimeCarryover;frame.cpuTime+=frame.timeByCategory["other"];if(frame.isBackground){var paintDuration=this._paintEndTime-this._paintStartTime;if(paintDuration)
565 frame.timeByCategory[WebInspector.TimelinePresentationModel.categories().painting.name]=paintDuration;}
566 this._frameOverview.addFrame(frame);this._presentationModel.addFrame(frame);},_createFrame:function(record,programTimeCarryover)
567 {var frame=new WebInspector.TimelineFrame();frame.startTime=WebInspector.TimelineModel.startTimeInSeconds(record);frame.startTimeOffset=this._model.recordOffsetInSeconds(record);frame.timeByCategory["other"]=programTimeCarryover;frame.isBackground=!!record.thread;frame.id=record.data&&record.data["id"];if(frame.isBackground){this._paintStartTime=null;this._paintEndTime=null;}
568 return frame;},_updatePaintingDuration:function(record)
569 {var startTime=WebInspector.TimelineModel.startTimeInSeconds(record);this._paintStartTime=this._paintStartTime?Math.min(this._paintStartTime,startTime):startTime;var endTime=WebInspector.TimelineModel.endTimeInSeconds(record);this._paintEndTime=this._paintEndTime?Math.max(this._paintEndTime,endTime):endTime;},dispose:function()
570 {this._model.removeEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onRecordAdded,this);this._model.removeEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._onRecordsCleared,this);}}
571 WebInspector.FrameStatistics=function(frames)
572 {this.frameCount=frames.length;this.minDuration=Infinity;this.maxDuration=0;this.timeByCategory={};this.startOffset=frames[0].startTimeOffset;var lastFrame=frames[this.frameCount-1];this.endOffset=lastFrame.startTimeOffset+lastFrame.duration;var totalDuration=0;var sumOfSquares=0;for(var i=0;i<this.frameCount;++i){var duration=frames[i].duration;totalDuration+=duration;sumOfSquares+=duration*duration;this.minDuration=Math.min(this.minDuration,duration);this.maxDuration=Math.max(this.maxDuration,duration);WebInspector.TimelineModel.aggregateTimeByCategory(this.timeByCategory,frames[i].timeByCategory);}
573 this.average=totalDuration/this.frameCount;var variance=sumOfSquares/this.frameCount-this.average*this.average;this.stddev=Math.sqrt(variance);}
574 WebInspector.TimelineFrame=function()
575 {this.timeByCategory={};this.cpuTime=0;this.mainThreadFrameId;};WebInspector.TimelineEventOverview=function(model)
576 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-overview-events";this._fillStyles={};var categories=WebInspector.TimelinePresentationModel.categories();for(var category in categories){this._fillStyles[category]=WebInspector.TimelinePresentationModel.createFillStyleForCategory(this._context,0,WebInspector.TimelineEventOverview._stripGradientHeight,categories[category]);categories[category].addEventListener(WebInspector.TimelineCategory.Events.VisibilityChanged,this._onCategoryVisibilityChanged,this);}
577 this._disabledCategoryFillStyle=WebInspector.TimelinePresentationModel.createFillStyle(this._context,0,WebInspector.TimelineEventOverview._stripGradientHeight,"rgb(218, 218, 218)","rgb(170, 170, 170)","rgb(143, 143, 143)");this._disabledCategoryBorderStyle="rgb(143, 143, 143)";}
578 WebInspector.TimelineEventOverview._numberOfStrips=3;WebInspector.TimelineEventOverview._stripGradientHeight=120;WebInspector.TimelineEventOverview.prototype={update:function()
579 {this.resetCanvas();var stripHeight=Math.round(this._canvas.height/WebInspector.TimelineEventOverview._numberOfStrips);var timeOffset=this._model.minimumRecordTime();var timeSpan=this._model.maximumRecordTime()-timeOffset;var scale=this._canvas.width/timeSpan;var lastBarByGroup=[];this._context.fillStyle="rgba(0, 0, 0, 0.05)";for(var i=1;i<WebInspector.TimelineEventOverview._numberOfStrips;i+=2)
580 this._context.fillRect(0.5,i*stripHeight+0.5,this._canvas.width,stripHeight);function appendRecord(record)
581 {if(record.type===WebInspector.TimelineModel.RecordType.BeginFrame)
582 return;var recordStart=Math.floor((WebInspector.TimelineModel.startTimeInSeconds(record)-timeOffset)*scale);var recordEnd=Math.ceil((WebInspector.TimelineModel.endTimeInSeconds(record)-timeOffset)*scale);var category=WebInspector.TimelinePresentationModel.categoryForRecord(record);if(category.overviewStripGroupIndex<0)
583 return;var bar=lastBarByGroup[category.overviewStripGroupIndex];const barsMergeThreshold=2;if(bar&&bar.category===category&&bar.end+barsMergeThreshold>=recordStart){if(recordEnd>bar.end)
584 bar.end=recordEnd;return;}
585 if(bar)
586 this._renderBar(bar.start,bar.end,stripHeight,bar.category);lastBarByGroup[category.overviewStripGroupIndex]={start:recordStart,end:recordEnd,category:category};}
587 WebInspector.TimelinePresentationModel.forAllRecords(this._model.records,appendRecord.bind(this));for(var i=0;i<lastBarByGroup.length;++i){if(lastBarByGroup[i])
588 this._renderBar(lastBarByGroup[i].start,lastBarByGroup[i].end,stripHeight,lastBarByGroup[i].category);}},_onCategoryVisibilityChanged:function()
589 {this.update();},_renderBar:function(begin,end,height,category)
590 {const stripPadding=4*window.devicePixelRatio;const innerStripHeight=height-2*stripPadding;var x=begin+0.5;var y=category.overviewStripGroupIndex*height+stripPadding+0.5;var width=Math.max(end-begin,1);this._context.save();this._context.translate(x,y);this._context.scale(1,innerStripHeight/WebInspector.TimelineEventOverview._stripGradientHeight);this._context.fillStyle=category.hidden?this._disabledCategoryFillStyle:this._fillStyles[category.name];this._context.fillRect(0,0,width,WebInspector.TimelineEventOverview._stripGradientHeight);this._context.strokeStyle=category.hidden?this._disabledCategoryBorderStyle:category.borderColor;this._context.strokeRect(0,0,width,WebInspector.TimelineEventOverview._stripGradientHeight);this._context.restore();},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector.TimelineFrameOverview=function(model)
591 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-overview-frames";this.reset();this._outerPadding=4*window.devicePixelRatio;this._maxInnerBarWidth=10*window.devicePixelRatio;this._topPadding=6*window.devicePixelRatio;this._actualPadding=5*window.devicePixelRatio;this._actualOuterBarWidth=this._maxInnerBarWidth+this._actualPadding;this._fillStyles={};var categories=WebInspector.TimelinePresentationModel.categories();for(var category in categories)
592 this._fillStyles[category]=WebInspector.TimelinePresentationModel.createFillStyleForCategory(this._context,this._maxInnerBarWidth,0,categories[category]);this._frameTopShadeGradient=this._context.createLinearGradient(0,0,0,this._topPadding);this._frameTopShadeGradient.addColorStop(0,"rgba(255, 255, 255, 0.9)");this._frameTopShadeGradient.addColorStop(1,"rgba(255, 255, 255, 0.2)");}
593 WebInspector.TimelineFrameOverview.prototype={reset:function()
594 {this._recordsPerBar=1;this._barTimes=[];this._mainThreadFrames=[];this._backgroundFrames=[];this._framesById={};},update:function()
595 {this.resetCanvas();this._barTimes=[];var backgroundFramesHeight=15*window.devicePixelRatio;var mainThreadFramesHeight=this._canvas.height-backgroundFramesHeight;const minBarWidth=4*window.devicePixelRatio;var frameCount=this._backgroundFrames.length||this._mainThreadFrames.length;var framesPerBar=Math.max(1,frameCount*minBarWidth/this._canvas.width);var mainThreadVisibleFrames;var backgroundVisibleFrames;if(this._backgroundFrames.length){backgroundVisibleFrames=this._aggregateFrames(this._backgroundFrames,framesPerBar);mainThreadVisibleFrames=new Array(backgroundVisibleFrames.length);for(var i=0;i<backgroundVisibleFrames.length;++i){var frameId=backgroundVisibleFrames[i].mainThreadFrameId;mainThreadVisibleFrames[i]=frameId&&this._framesById[frameId];}}else{mainThreadVisibleFrames=this._aggregateFrames(this._mainThreadFrames,framesPerBar);}
596 this._context.save();this._setCanvasWindow(0,backgroundFramesHeight,this._canvas.width,mainThreadFramesHeight);var scale=(mainThreadFramesHeight-this._topPadding)/this._computeTargetFrameLength(mainThreadVisibleFrames);this._renderBars(mainThreadVisibleFrames,scale,mainThreadFramesHeight);this._context.fillStyle=this._frameTopShadeGradient;this._context.fillRect(0,0,this._canvas.width,this._topPadding);this._drawFPSMarks(scale,mainThreadFramesHeight);this._context.restore();var bottom=backgroundFramesHeight+0.5;this._context.strokeStyle="rgba(120, 120, 120, 0.8)";this._context.beginPath();this._context.moveTo(0,bottom);this._context.lineTo(this._canvas.width,bottom);this._context.stroke();if(backgroundVisibleFrames){const targetFPS=30.0;scale=(backgroundFramesHeight-this._topPadding)/(1.0/targetFPS);this._renderBars(backgroundVisibleFrames,scale,backgroundFramesHeight);}},addFrame:function(frame)
597 {var frames;if(frame.isBackground){frames=this._backgroundFrames;}else{frames=this._mainThreadFrames;this._framesById[frame.id]=frame;}
598 frames.push(frame);},_setCanvasWindow:function(x0,y0,width,height)
599 {this._context.translate(x0,y0);this._context.beginPath();this._context.moveTo(0,0);this._context.lineTo(width,0);this._context.lineTo(width,height);this._context.lineTo(0,height);this._context.lineTo(0,0);this._context.clip();},_aggregateFrames:function(frames,framesPerBar)
600 {var visibleFrames=[];for(var barNumber=0,currentFrame=0;currentFrame<frames.length;++barNumber){var barStartTime=frames[currentFrame].startTime;var longestFrame=null;var longestDuration=0;for(var lastFrame=Math.min(Math.floor((barNumber+1)*framesPerBar),frames.length);currentFrame<lastFrame;++currentFrame){var duration=this._frameDuration(frames[currentFrame]);if(!longestFrame||longestDuration<duration){longestFrame=frames[currentFrame];longestDuration=duration;}}
601 var barEndTime=frames[currentFrame-1].endTime;if(longestFrame){visibleFrames.push(longestFrame);this._barTimes.push({startTime:barStartTime,endTime:barEndTime});}}
602 return visibleFrames;},_frameDuration:function(frame)
603 {var relatedFrame=frame.mainThreadFrameId&&this._framesById[frame.mainThreadFrameId];return frame.duration+(relatedFrame?relatedFrame.duration:0);},_computeTargetFrameLength:function(frames)
604 {var durations=[];for(var i=0;i<frames.length;++i){if(frames[i])
605 durations.push(frames[i].duration);}
606 var medianFrameLength=durations.qselect(Math.floor(durations.length/2));const targetFPS=30;var result=1.0/targetFPS;if(result>=medianFrameLength)
607 return result;var maxFrameLength=Math.max.apply(Math,durations);return Math.min(medianFrameLength*2,maxFrameLength);},_renderBars:function(frames,scale,windowHeight)
608 {const maxPadding=5*window.devicePixelRatio;this._actualOuterBarWidth=Math.min((this._canvas.width-2*this._outerPadding)/frames.length,this._maxInnerBarWidth+maxPadding);this._actualPadding=Math.min(Math.floor(this._actualOuterBarWidth/3),maxPadding);var barWidth=this._actualOuterBarWidth-this._actualPadding;for(var i=0;i<frames.length;++i){if(frames[i])
609 this._renderBar(this._barNumberToScreenPosition(i),barWidth,windowHeight,frames[i],scale);}},_barNumberToScreenPosition:function(n)
610 {return this._outerPadding+this._actualOuterBarWidth*n;},_drawFPSMarks:function(scale,height)
611 {const fpsMarks=[30,60];this._context.save();this._context.beginPath();this._context.font=(10*window.devicePixelRatio)+"px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");this._context.textAlign="right";this._context.textBaseline="alphabetic";const labelPadding=4*window.devicePixelRatio;const baselineHeight=3*window.devicePixelRatio;var lineHeight=12*window.devicePixelRatio;var labelTopMargin=0;var labelOffsetY=0;for(var i=0;i<fpsMarks.length;++i){var fps=fpsMarks[i];var y=height-Math.floor(1.0/fps*scale)-0.5;var label=WebInspector.UIString("%d\u2009fps",fps);var labelWidth=this._context.measureText(label).width+2*labelPadding;var labelX=this._canvas.width;if(!i&&labelTopMargin<y-lineHeight)
612 labelOffsetY=-lineHeight;var labelY=y+labelOffsetY;if(labelY<labelTopMargin||labelY+lineHeight>height)
613 break;this._context.moveTo(0,y);this._context.lineTo(this._canvas.width,y);this._context.fillStyle="rgba(255, 255, 255, 0.5)";this._context.fillRect(labelX-labelWidth,labelY,labelWidth,lineHeight);this._context.fillStyle="black";this._context.fillText(label,labelX-labelPadding,labelY+lineHeight-baselineHeight);labelTopMargin=labelY+lineHeight;}
614 this._context.strokeStyle="rgba(60, 60, 60, 0.4)";this._context.stroke();this._context.restore();},_renderBar:function(left,width,windowHeight,frame,scale)
615 {var categories=Object.keys(WebInspector.TimelinePresentationModel.categories());if(!categories.length)
616 return;var x=Math.floor(left)+0.5;width=Math.floor(width);for(var i=0,bottomOffset=windowHeight;i<categories.length;++i){var category=categories[i];var duration=frame.timeByCategory[category];if(!duration)
617 continue;var height=Math.round(duration*scale);var y=Math.floor(bottomOffset-height)+0.5;this._context.save();this._context.translate(x,0);this._context.scale(width/this._maxInnerBarWidth,1);this._context.fillStyle=this._fillStyles[category];this._context.fillRect(0,y,this._maxInnerBarWidth,Math.floor(height));this._context.strokeStyle=WebInspector.TimelinePresentationModel.categories()[category].borderColor;this._context.beginPath();this._context.moveTo(0,y);this._context.lineTo(this._maxInnerBarWidth,y);this._context.stroke();this._context.restore();bottomOffset-=height;}
618 var y0=Math.floor(windowHeight-frame.duration*scale)+0.5;var y1=windowHeight+0.5;this._context.strokeStyle="rgba(90, 90, 90, 0.3)";this._context.beginPath();this._context.moveTo(x,y1);this._context.lineTo(x,y0);this._context.lineTo(x+width,y0);this._context.lineTo(x+width,y1);this._context.stroke();},windowTimes:function(windowLeft,windowRight)
619 {if(!this._barTimes.length)
620 return WebInspector.TimelineOverviewBase.prototype.windowTimes.call(this,windowLeft,windowRight);var windowSpan=this._canvas.width;var leftOffset=windowLeft*windowSpan-this._outerPadding+this._actualPadding;var rightOffset=windowRight*windowSpan-this._outerPadding;var firstBar=Math.floor(Math.max(leftOffset,0)/this._actualOuterBarWidth);var lastBar=Math.min(Math.floor(rightOffset/this._actualOuterBarWidth),this._barTimes.length-1);if(firstBar>=this._barTimes.length)
621 return{startTime:Infinity,endTime:Infinity};const snapToRightTolerancePixels=3;return{startTime:this._barTimes[firstBar].startTime,endTime:(rightOffset+snapToRightTolerancePixels>windowSpan)||(lastBar>=this._barTimes.length)?Infinity:this._barTimes[lastBar].endTime}},windowBoundaries:function(startTime,endTime)
622 {if(this._barTimes.length===0)
623 return{left:0,right:1};function barStartComparator(time,barTime)
624 {return time-barTime.startTime;}
625 function barEndComparator(time,barTime)
626 {if(time===barTime.endTime)
627 return 1;return time-barTime.endTime;}
628 return{left:this._windowBoundaryFromTime(startTime,barEndComparator),right:this._windowBoundaryFromTime(endTime,barStartComparator)}},_windowBoundaryFromTime:function(time,comparator)
629 {if(time===Infinity)
630 return 1;var index=this._firstBarAfter(time,comparator);if(!index)
631 return 0;return(this._barNumberToScreenPosition(index)-this._actualPadding/2)/this._canvas.width;},_firstBarAfter:function(time,comparator)
632 {return insertionIndexForObjectInListSortedByFunction(time,this._barTimes,comparator);},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector.TimelineMemoryOverview=function(model)
633 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-overview-memory";this._maxHeapSizeLabel=this.element.createChild("div","max memory-graph-label");this._minHeapSizeLabel=this.element.createChild("div","min memory-graph-label");}
634 WebInspector.TimelineMemoryOverview.prototype={update:function()
635 {this.resetCanvas();var records=this._model.records;if(!records.length)
636 return;const lowerOffset=3;var maxUsedHeapSize=0;var minUsedHeapSize=100000000000;var minTime=this._model.minimumRecordTime();var maxTime=this._model.maximumRecordTime();WebInspector.TimelinePresentationModel.forAllRecords(records,function(r){if(!r.counters||!r.counters.jsHeapSizeUsed)
637 return;maxUsedHeapSize=Math.max(maxUsedHeapSize,r.counters.jsHeapSizeUsed);minUsedHeapSize=Math.min(minUsedHeapSize,r.counters.jsHeapSizeUsed);});minUsedHeapSize=Math.min(minUsedHeapSize,maxUsedHeapSize);var width=this._canvas.width;var height=this._canvas.height-lowerOffset;var xFactor=width/(maxTime-minTime);var yFactor=height/Math.max(maxUsedHeapSize-minUsedHeapSize,1);var histogram=new Array(width);WebInspector.TimelinePresentationModel.forAllRecords(records,function(r){if(!r.counters||!r.counters.jsHeapSizeUsed)
638 return;var x=Math.round((WebInspector.TimelineModel.endTimeInSeconds(r)-minTime)*xFactor);var y=(r.counters.jsHeapSizeUsed-minUsedHeapSize)*yFactor;histogram[x]=Math.max(histogram[x]||0,y);});var y=0;var isFirstPoint=true;var ctx=this._context;ctx.save();ctx.translate(0.5,0.5);ctx.beginPath();ctx.moveTo(-1,this._canvas.height);for(var x=0;x<histogram.length;x++){if(typeof histogram[x]==="undefined")
639 continue;if(isFirstPoint){isFirstPoint=false;y=histogram[x];ctx.lineTo(-1,height-y);}
640 ctx.lineTo(x,height-y);y=histogram[x];ctx.lineTo(x,height-y);}
641 ctx.lineTo(width,height-y);ctx.lineTo(width,this._canvas.height);ctx.lineTo(-1,this._canvas.height);ctx.closePath();var gradient=ctx.createLinearGradient(0,0,0,height);gradient.addColorStop(0,"rgba(192,204,255,1)");gradient.addColorStop(1,"rgba(192,204,255,0.4)");ctx.fillStyle=gradient;ctx.fill();ctx.lineWidth=0.5;ctx.strokeStyle="#666";ctx.stroke();ctx.restore();this._maxHeapSizeLabel.textContent=Number.bytesToString(maxUsedHeapSize);this._minHeapSizeLabel.textContent=Number.bytesToString(minUsedHeapSize);},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector.TimelineView=function(panel,model,glueRecordsSetting,mode)
642 {WebInspector.View.call(this);this.element.classList.add("timeline-view");this.element.classList.add("hbox");this._panel=panel;this._model=model;this._currentMode=mode;this._calculator=new WebInspector.TimelineCalculator(this._model);this._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onTimelineEventRecorded,this);this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._onRecordsCleared,this);this._presentationModel=new WebInspector.TimelinePresentationModel();this._durationFilter=new WebInspector.TimelineIsLongFilter();this._windowFilter=new WebInspector.TimelineWindowFilter();this._presentationModel.addFilter(this._windowFilter);this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter());this._presentationModel.addFilter(this._durationFilter);this._frameMode=mode===WebInspector.TimelinePanel.Mode.Frames;this._boundariesAreValid=true;this._scrollTop=0;this._detailsSplitView=new WebInspector.SplitView(false,"timeline-details");this._detailsSplitView.element.classList.remove("fill");this._detailsSplitView.element.classList.add("timeline-details-split");this._detailsSplitView.sidebarElement().classList.add("timeline-details");this._detailsSplitView.mainElement().classList.add("vbox");this._detailsSplitView.setMainElementConstraints(undefined,40);this._detailsView=new WebInspector.TimelineDetailsView();this._detailsSplitView.setSidebarView(this._detailsView);this._detailsSplitView.installResizer(this._detailsView.titleElement());WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged,this._dockSideChanged.bind(this));WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));this._dockSideChanged();this._searchableView=new WebInspector.SearchableView(this);this._searchableView.element.classList.add("searchable-view");this._detailsSplitView.setMainView(this._searchableView);this._views=[];this._recordsView=this._createRecordsView();this._views.push(this._recordsView);this._stackView=new WebInspector.StackView(false);this._stackView.show(this._searchableView.element);this._stackView.element.classList.add("timeline-view-stack");this._recordsViewMainElement=this._stackView.appendView(this._recordsView,"timeline-records").mainElement();this._recordsViewMainElement.classList.add("timeline-records-view");this._recordsViewMainElement.appendChild(this._timelineGrid.gridHeaderElement);if(this._currentMode===WebInspector.TimelinePanel.Mode.Memory){this._memoryStatistics=new WebInspector.CountersGraph(this,this._model);this._views.push(this._memoryStatistics);this._memoryStatistics.addEventListener(WebInspector.TimelineView.Events.SidebarResized,this._sidebarResized,this);this._stackView.appendView(this._memoryStatistics,"timeline-memory");}
643 this._popoverHelper=new WebInspector.PopoverHelper(this.element,this._getPopoverAnchor.bind(this),this._showPopover.bind(this));this.element.addEventListener("mousemove",this._mouseMove.bind(this),false);this.element.addEventListener("mouseout",this._mouseOut.bind(this),false);this.element.addEventListener("keydown",this._keyDown.bind(this),false);this._expandOffset=15;this._windowStartTime=0;this._windowEndTime=Infinity;this._allRecordsCount=0;this._presentationModel.setGlueRecords(glueRecordsSetting.get());this._glueRecordsSetting=glueRecordsSetting;this._glueRecordsSetting.addChangeListener(this._onGlueRecordsSettingChanged,this);switch(mode){case WebInspector.TimelinePanel.Mode.Events:this._overviewControl=new WebInspector.TimelineEventOverview(this._model);break;case WebInspector.TimelinePanel.Mode.Frames:this._overviewControl=new WebInspector.TimelineFrameOverview(this._model);this._presentationModel.setGlueRecords(false);this._frameController=new WebInspector.TimelineFrameController(this._model,this._overviewControl,this._presentationModel);break;case WebInspector.TimelinePanel.Mode.Memory:this._overviewControl=new WebInspector.TimelineMemoryOverview(this._model);break;}
644 this._detailsSplitView.show(this.element);}
645 WebInspector.TimelineView.Events={SidebarResized:"SidebarResized"}
646 WebInspector.TimelineView.commonUIFilters=function()
647 {var filters=WebInspector.TimelineView._commonUIFilters;if(filters)
648 return filters;filters={};filters._textFilterUI=new WebInspector.TextFilterUI();var durationOptions=[];for(var presetIndex=0;presetIndex<WebInspector.TimelinePanel.durationFilterPresetsMs.length;++presetIndex){var durationMs=WebInspector.TimelinePanel.durationFilterPresetsMs[presetIndex];var durationOption={};if(!durationMs){durationOption.label=WebInspector.UIString("All");durationOption.title=WebInspector.UIString("Show all records");}else{durationOption.label=WebInspector.UIString("\u2265 %dms",durationMs);durationOption.title=WebInspector.UIString("Hide records shorter than %dms",durationMs);}
649 durationOption.value=durationMs;durationOptions.push(durationOption);}
650 filters._durationFilterUI=new WebInspector.ComboBoxFilterUI(durationOptions);filters._categoryFiltersUI={};var categoryTypes=[];var categories=WebInspector.TimelinePresentationModel.categories();for(var categoryName in categories){var category=categories[categoryName];if(category.overviewStripGroupIndex<0)
651 continue;var filter=new WebInspector.CheckboxFilterUI(category.name,category.title);filters._categoryFiltersUI[category.name]=filter;}
652 WebInspector.TimelineView._commonUIFilters=filters;return filters;}
653 WebInspector.TimelineView.prototype={_createRecordsView:function()
654 {var recordsView=new WebInspector.SidebarView(WebInspector.SidebarView.SidebarPosition.Start,"timeline-split");recordsView.addEventListener(WebInspector.SidebarView.EventTypes.Resized,this._sidebarResized,this);recordsView.setSecondIsSidebar(false);this._containerElement=recordsView.element;this._containerElement.tabIndex=0;this._containerElement.id="timeline-container";this._containerElement.addEventListener("scroll",this._onScroll.bind(this),false);recordsView.sidebarElement().classList.add("vbox");recordsView.sidebarElement().createChild("div","timeline-records-title").textContent=WebInspector.UIString("RECORDS");this._sidebarListElement=recordsView.sidebarElement().createChild("div","timeline-records-list");this._gridContainer=new WebInspector.ViewWithResizeCallback(this._onViewportResize.bind(this));this._gridContainer.element.classList.add("fill");this._gridContainer.element.id="resources-container-content";recordsView.setMainView(this._gridContainer);this._timelineGrid=new WebInspector.TimelineGrid();this._itemsGraphsElement=this._timelineGrid.itemsGraphsElement;this._itemsGraphsElement.id="timeline-graphs";this._gridContainer.element.appendChild(this._timelineGrid.element);this._timelineGrid.gridHeaderElement.id="timeline-grid-header";this._timelineGrid.gridHeaderElement.classList.add("fill");this._topGapElement=this._itemsGraphsElement.createChild("div","timeline-gap");this._graphRowsElement=this._itemsGraphsElement.createChild("div");this._bottomGapElement=this._itemsGraphsElement.createChild("div","timeline-gap");this._expandElements=this._itemsGraphsElement.createChild("div");this._expandElements.id="orphan-expand-elements";this._mainThreadTasks=([]);this._gpuTasks=([]);var utilizationStripsElement=this._timelineGrid.gridHeaderElement.createChild("div","timeline-utilization-strips vbox");this._cpuBarsElement=utilizationStripsElement.createChild("div","timeline-utilization-strip");if(WebInspector.experimentsSettings.gpuTimeline.isEnabled())
655 this._gpuBarsElement=utilizationStripsElement.createChild("div","timeline-utilization-strip gpu");return recordsView;},searchableView:function()
656 {return this._searchableView;},supportsGlueParentMode:function()
657 {return!this._frameMode;},_onGlueRecordsSettingChanged:function()
658 {this._presentationModel.setGlueRecords(this._glueRecordsSetting.get());this._repopulateRecords();},windowStartTime:function()
659 {return this._windowStartTime||this._model.minimumRecordTime();},windowEndTime:function()
660 {return this._windowEndTime<Infinity?this._windowEndTime:this._model.maximumRecordTime();},overviewControl:function()
661 {return this._overviewControl;},get calculator()
662 {return this._calculator;},createUIFilters:function(filterBar)
663 {var filters=this._filters;if(!filters){this._filters=WebInspector.TimelineView.commonUIFilters();filters=this._filters;filters._textFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterChanged,this._textFilterChanged,this);filters._durationFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterChanged,this._durationFilterChanged,this);for(var categoryName in filters._categoryFiltersUI)
664 filters._categoryFiltersUI[categoryName].addEventListener(WebInspector.FilterUI.Events.FilterChanged,this._categoriesFilterChanged.bind(this,categoryName),this);}
665 filterBar.addFilter(filters._textFilterUI);filterBar.addFilter(filters._durationFilterUI);for(var categoryName in filters._categoryFiltersUI)
666 filterBar.addFilter(filters._categoryFiltersUI[categoryName]);return true;},_textFilterChanged:function(event)
667 {var searchQuery=this._filters._textFilterUI.value();this._presentationModel.setSearchFilter(null);delete this._searchFilter;function cleanRecord(record)
668 {delete record.clicked;}
669 WebInspector.TimelinePresentationModel.forAllRecords(this._presentationModel.rootRecord().children,cleanRecord);this.searchCanceled();if(searchQuery){this._searchFilter=new WebInspector.TimelineSearchFilter(createPlainTextSearchRegex(searchQuery,"i"));this._presentationModel.setSearchFilter(this._searchFilter);}
670 this._invalidateAndScheduleRefresh(true,true);},_durationFilterChanged:function()
671 {var duration=this._filters._durationFilterUI.value();var minimumRecordDuration=+duration/1000.0;this._durationFilter.setMinimumRecordDuration(minimumRecordDuration);this._invalidateAndScheduleRefresh(true,true);},_categoriesFilterChanged:function(name,event)
672 {var categories=WebInspector.TimelinePresentationModel.categories();categories[name].hidden=!this._filters._categoryFiltersUI[name].checked();this._invalidateAndScheduleRefresh(true,true);},_dockSideChanged:function()
673 {var dockSide=WebInspector.dockController.dockSide();var vertically=false;if(dockSide===WebInspector.DockController.State.DockedToBottom)
674 vertically=true;else
675 vertically=!WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._detailsSplitView.setVertical(vertically);this._detailsView.setVertical(vertically);},_rootRecord:function()
676 {return this._presentationModel.rootRecord();},_updateRecordsCounter:function(recordsInWindowCount)
677 {this._panel.recordsCounter.setText(WebInspector.UIString("%d of %d records shown",recordsInWindowCount,this._allRecordsCount));},_updateFrameStatistics:function(frames)
678 {this._lastFrameStatistics=frames.length?new WebInspector.FrameStatistics(frames):null;},_updateEventDividers:function()
679 {this._timelineGrid.removeEventDividers();var clientWidth=this._graphRowsElementWidth;var dividers=[];var eventDividerRecords=this._presentationModel.eventDividerRecords();for(var i=0;i<eventDividerRecords.length;++i){var record=eventDividerRecords[i];var positions=this._calculator.computeBarGraphWindowPosition(record);var dividerPosition=Math.round(positions.left);if(dividerPosition<0||dividerPosition>=clientWidth||dividers[dividerPosition])
680 continue;var divider=WebInspector.TimelinePresentationModel.createEventDivider(record.type,record.title);divider.style.left=dividerPosition+"px";dividers[dividerPosition]=divider;}
681 this._timelineGrid.addEventDividers(dividers);},_updateFrameBars:function(frames)
682 {var clientWidth=this._graphRowsElementWidth;if(this._frameContainer)
683 this._frameContainer.removeChildren();else{const frameContainerBorderWidth=1;this._frameContainer=document.createElement("div");this._frameContainer.classList.add("fill");this._frameContainer.classList.add("timeline-frame-container");this._frameContainer.style.height=WebInspector.TimelinePanel.rowHeight+frameContainerBorderWidth+"px";this._frameContainer.addEventListener("dblclick",this._onFrameDoubleClicked.bind(this),false);}
684 var dividers=[this._frameContainer];for(var i=0;i<frames.length;++i){var frame=frames[i];var frameStart=this._calculator.computePosition(frame.startTime);var frameEnd=this._calculator.computePosition(frame.endTime);var frameStrip=document.createElement("div");frameStrip.className="timeline-frame-strip";var actualStart=Math.max(frameStart,0);var width=frameEnd-actualStart;frameStrip.style.left=actualStart+"px";frameStrip.style.width=width+"px";frameStrip._frame=frame;const minWidthForFrameInfo=60;if(width>minWidthForFrameInfo)
685 frameStrip.textContent=Number.secondsToString(frame.endTime-frame.startTime,true);this._frameContainer.appendChild(frameStrip);if(actualStart>0){var frameMarker=WebInspector.TimelinePresentationModel.createEventDivider(WebInspector.TimelineModel.RecordType.BeginFrame);frameMarker.style.left=frameStart+"px";dividers.push(frameMarker);}}
686 this._timelineGrid.addEventDividers(dividers);},_onFrameDoubleClicked:function(event)
687 {var frameBar=event.target.enclosingNodeOrSelfWithClass("timeline-frame-strip");if(!frameBar)
688 return;this._setWindowTimes(frameBar._frame.startTime,frameBar._frame.endTime);},_updateWindowBoundaries:function()
689 {var windowBoundaries=this.overviewControl().windowBoundaries(this._windowStartTime,this._windowEndTime);this._panel.setWindow(windowBoundaries.left,windowBoundaries.right);},windowTimes:function()
690 {return{windowStartTime:this._windowStartTime,windowEndTime:this._windowEndTime};},setWindowTimes:function(windowTimes)
691 {if(!windowTimes)
692 return;this._setWindowTimes(windowTimes.windowStartTime,windowTimes.windowEndTime);},_setWindowTimes:function(startTime,endTime)
693 {this._windowStartTime=startTime;this._windowEndTime=endTime;this._windowFilter.setWindowTimes(startTime,endTime);var windowBoundaries=this.overviewControl().windowBoundaries(startTime,endTime);this._panel.setWindow(windowBoundaries.left,windowBoundaries.right);},_repopulateRecords:function()
694 {this._resetView();this._automaticallySizeWindow=false;var records=this._model.records;for(var i=0;i<records.length;++i)
695 this._innerAddRecordToTimeline(records[i]);this._invalidateAndScheduleRefresh(false,false);},_onTimelineEventRecorded:function(event)
696 {if(this._innerAddRecordToTimeline((event.data)))
697 this._invalidateAndScheduleRefresh(false,false);},_innerAddRecordToTimeline:function(record)
698 {if(record.type===WebInspector.TimelineModel.RecordType.Program)
699 this._mainThreadTasks.push(record);if(record.type===WebInspector.TimelineModel.RecordType.GPUTask){this._gpuTasks.push(record);return WebInspector.TimelineModel.startTimeInSeconds(record)<this._windowEndTime;}
700 var records=this._presentationModel.addRecord(record);this._allRecordsCount+=records.length;var hasVisibleRecords=false;var presentationModel=this._presentationModel;function checkVisible(record)
701 {hasVisibleRecords|=presentationModel.isVisible(record);}
702 WebInspector.TimelinePresentationModel.forAllRecords(records,checkVisible);function isAdoptedRecord(record)
703 {return record.parent!==presentationModel.rootRecord;}
704 return hasVisibleRecords||records.some(isAdoptedRecord);},_sidebarResized:function(event)
705 {var width=(event.data);this.setSidebarWidth(width);this._panel.setSidebarWidth(width);},setSidebarWidth:function(width)
706 {this._timelineGrid.gridHeaderElement.style.left=width+"px";for(var i=0;i<this._views.length;++i)
707 this._views[i].setSidebarWidth(width);},_onViewportResize:function()
708 {this._resize(this._recordsView.sidebarWidth());},_resize:function(sidebarWidth)
709 {this._closeRecordDetails();this._graphRowsElementWidth=this._graphRowsElement.offsetWidth;this._containerElementHeight=this._containerElement.clientHeight;this._timelineGrid.gridHeaderElement.style.width=this._itemsGraphsElement.offsetWidth+"px";this._scheduleRefresh(false,true);},_resetView:function()
710 {this._presentationModel.reset();this._boundariesAreValid=false;this._adjustScrollPosition(0);this._closeRecordDetails();this._allRecordsCount=0;this._automaticallySizeWindow=true;this._mainThreadTasks=[];this._gpuTasks=[];},_onRecordsCleared:function()
711 {this._windowStartTime=0;this._windowEndTime=Infinity;this._resetView();this.overviewControl().reset();this._windowFilter.reset();this._invalidateAndScheduleRefresh(true,true);},elementsToRestoreScrollPositionsFor:function()
712 {return[this._containerElement];},wasShown:function()
713 {WebInspector.View.prototype.wasShown.call(this);this._repopulateRecords();this._updateSelectionDetails();this._updateWindowBoundaries();if(!WebInspector.TimelinePanel._categoryStylesInitialized){WebInspector.TimelinePanel._categoryStylesInitialized=true;this._injectCategoryStyles();}
714 this._onViewportResize();this._refresh();},willHide:function()
715 {this._closeRecordDetails();WebInspector.View.prototype.willHide.call(this);},_onScroll:function(event)
716 {this._closeRecordDetails();this._scrollTop=this._containerElement.scrollTop;var dividersTop=Math.max(0,this._scrollTop);this._timelineGrid.setScrollAndDividerTop(this._scrollTop,dividersTop);this._scheduleRefresh(true,true);},_invalidateAndScheduleRefresh:function(preserveBoundaries,userGesture)
717 {this._presentationModel.invalidateFilteredRecords();delete this._searchResults;this._scheduleRefresh(preserveBoundaries,userGesture);},_selectRecord:function(record)
718 {if(record===this._lastSelectedRecord)
719 return;if(this._lastSelectedRecord){var listRow=(this._lastSelectedRecord.getUserObject("WebInspector.TimelineRecordListRow"));if(listRow)
720 listRow.renderAsSelected(false);var graphRow=(this._lastSelectedRecord.getUserObject("WebInspector.TimelineRecordGraphRow"));if(graphRow)
721 graphRow.renderAsSelected(false);}
722 if(!record){this._updateSelectionDetails();return;}
723 this._lastSelectedRecord=record;this._revealRecord(record);var listRow=(record.getUserObject("WebInspector.TimelineRecordListRow"));if(listRow)
724 listRow.renderAsSelected(true);var graphRow=(record.getUserObject("WebInspector.TimelineRecordGraphRow"));if(graphRow)
725 graphRow.renderAsSelected(true);record.generatePopupContent(showCallback.bind(this));function showCallback(element)
726 {this._detailsView.setContent(record.title,element);}},_updateSelectionDetails:function()
727 {var startTime=this.windowStartTime()*1000;var endTime=this.windowEndTime()*1000;if(startTime<0)
728 return;var aggregatedStats={};function compareEndTime(value,task)
729 {return value<task.endTime?-1:1;}
730 function aggregateTimeForRecordWithinWindow(rawRecord)
731 {if(!rawRecord.endTime||rawRecord.endTime<startTime||rawRecord.startTime>endTime)
732 return;var childrenTime=0;var children=rawRecord.children||[];for(var i=0;i<children.length;++i){var child=children[i];if(!child.endTime||child.endTime<startTime||child.startTime>endTime)
733 continue;childrenTime+=Math.min(endTime,child.endTime)-Math.max(startTime,child.startTime);aggregateTimeForRecordWithinWindow(child);}
734 var categoryName=WebInspector.TimelinePresentationModel.categoryForRecord(rawRecord).name;var ownTime=Math.min(endTime,rawRecord.endTime)-Math.max(startTime,rawRecord.startTime)-childrenTime;aggregatedStats[categoryName]=(aggregatedStats[categoryName]||0)+ownTime/1000;}
735 var taskIndex=insertionIndexForObjectInListSortedByFunction(startTime,this._mainThreadTasks,compareEndTime);for(;taskIndex<this._mainThreadTasks.length;++taskIndex){var task=this._mainThreadTasks[taskIndex];if(task.startTime>endTime)
736 break;aggregateTimeForRecordWithinWindow(task);}
737 var aggregatedTotal=0;for(var categoryName in aggregatedStats)
738 aggregatedTotal+=aggregatedStats[categoryName];aggregatedStats["idle"]=Math.max(0,(endTime-startTime)/1000-aggregatedTotal);var fragment=document.createDocumentFragment();var pie=WebInspector.TimelinePresentationModel.generatePieChart(aggregatedStats);fragment.appendChild(pie.element);if(this._frameMode&&this._lastFrameStatistics){var title=WebInspector.UIString("%s \u2013 %s (%d frames)",Number.secondsToString(this._lastFrameStatistics.startOffset,true),Number.secondsToString(this._lastFrameStatistics.endOffset,true),this._lastFrameStatistics.frameCount);fragment.appendChild(WebInspector.TimelinePresentationModel.generatePopupContentForFrameStatistics(this._lastFrameStatistics));}else{var title=WebInspector.UIString("%s \u2013 %s",this._calculator.formatTime(0,true),this._calculator.formatTime(this._calculator.boundarySpan(),true));}
739 this._detailsView.setContent(title,fragment);},windowChanged:function(left,right)
740 {var windowTimes=this.overviewControl().windowTimes(left,right);this._windowStartTime=windowTimes.startTime;this._windowEndTime=windowTimes.endTime;this._windowFilter.setWindowTimes(windowTimes.startTime,windowTimes.endTime);this._invalidateAndScheduleRefresh(false,true);this._selectRecord(null);},_scheduleRefresh:function(preserveBoundaries,userGesture)
741 {this._closeRecordDetails();this._boundariesAreValid&=preserveBoundaries;if(!this.isShowing())
742 return;if(preserveBoundaries||userGesture)
743 this._refresh();else{if(!this._refreshTimeout)
744 this._refreshTimeout=setTimeout(this._refresh.bind(this),300);}},_refresh:function()
745 {if(this._refreshTimeout){clearTimeout(this._refreshTimeout);delete this._refreshTimeout;}
746 this._timelinePaddingLeft=this._expandOffset;this._calculator.setWindow(this.windowStartTime(),this.windowEndTime());this._calculator.setDisplayWindow(this._timelinePaddingLeft,this._graphRowsElementWidth);var recordsInWindowCount=this._refreshRecords();this._updateRecordsCounter(recordsInWindowCount);if(!this._boundariesAreValid){this._updateEventDividers();var frames=this._frameController&&this._presentationModel.filteredFrames(this.windowStartTime(),this.windowEndTime());if(frames){this._updateFrameStatistics(frames);const maxFramesForFrameBars=30;if(frames.length&&frames.length<maxFramesForFrameBars){this._timelineGrid.removeDividers();this._updateFrameBars(frames);}else
747 this._timelineGrid.updateDividers(this._calculator);}else
748 this._timelineGrid.updateDividers(this._calculator);this._refreshAllUtilizationBars();}
749 if(this._currentMode===WebInspector.TimelinePanel.Mode.Memory)
750 this._memoryStatistics.refresh();this._updateWindowBoundaries();this._boundariesAreValid=true;},revealRecordAt:function(time)
751 {var recordToReveal;function findRecordToReveal(record)
752 {if(record.containsTime(time)){recordToReveal=record;return true;}
753 if(!recordToReveal||record.endTime<time&&recordToReveal.endTime<record.endTime)
754 recordToReveal=record;return false;}
755 WebInspector.TimelinePresentationModel.forAllRecords(this._presentationModel.rootRecord().children,null,findRecordToReveal);if(!recordToReveal){this._containerElement.scrollTop=0;return;}
756 this._selectRecord(recordToReveal);},_revealRecord:function(recordToReveal)
757 {var needRefresh=false;for(var parent=recordToReveal.parent;parent!==this._rootRecord();parent=parent.parent){if(!parent.collapsed)
758 continue;this._presentationModel.invalidateFilteredRecords();parent.collapsed=false;needRefresh=true;}
759 var recordsInWindow=this._presentationModel.filteredRecords();var index=recordsInWindow.indexOf(recordToReveal);var itemOffset=index*WebInspector.TimelinePanel.rowHeight;var visibleTop=this._scrollTop-WebInspector.TimelinePanel.headerHeight;var visibleBottom=visibleTop+this._containerElementHeight-WebInspector.TimelinePanel.rowHeight;if(itemOffset<visibleTop)
760 this._containerElement.scrollTop=itemOffset;else if(itemOffset>visibleBottom)
761 this._containerElement.scrollTop=itemOffset-this._containerElementHeight+WebInspector.TimelinePanel.headerHeight+WebInspector.TimelinePanel.rowHeight;else if(needRefresh)
762 this._refreshRecords();},_refreshRecords:function()
763 {var recordsInWindow=this._presentationModel.filteredRecords();var visibleTop=this._scrollTop;var visibleBottom=visibleTop+this._containerElementHeight;var rowHeight=WebInspector.TimelinePanel.rowHeight;var headerHeight=WebInspector.TimelinePanel.headerHeight;var startIndex=Math.max(0,Math.min(Math.floor((visibleTop-headerHeight)/rowHeight),recordsInWindow.length-1));var endIndex=Math.min(recordsInWindow.length,Math.ceil(visibleBottom/rowHeight));var lastVisibleLine=Math.max(0,Math.floor((visibleBottom-headerHeight)/rowHeight));if(this._automaticallySizeWindow&&recordsInWindow.length>lastVisibleLine){this._automaticallySizeWindow=false;this._selectRecord(null);var windowStartTime=startIndex?recordsInWindow[startIndex].startTime:this._model.minimumRecordTime();this._setWindowTimes(windowStartTime,recordsInWindow[Math.max(0,lastVisibleLine-1)].endTime);recordsInWindow=this._presentationModel.filteredRecords();endIndex=Math.min(recordsInWindow.length,lastVisibleLine);}else{this._updateWindowBoundaries();}
764 this._topGapElement.style.height=(startIndex*rowHeight)+"px";this._recordsView.sidebarElement().firstChild.style.flexBasis=(startIndex*rowHeight+headerHeight)+"px";this._bottomGapElement.style.height=(recordsInWindow.length-endIndex)*rowHeight+"px";var rowsHeight=headerHeight+recordsInWindow.length*rowHeight;var totalHeight=Math.max(this._containerElementHeight,rowsHeight);this._recordsView.firstElement().style.height=totalHeight+"px";this._recordsView.secondElement().style.height=totalHeight+"px";this._recordsView.resizerElement().style.height=totalHeight+"px";var listRowElement=this._sidebarListElement.firstChild;var width=this._graphRowsElementWidth;this._itemsGraphsElement.removeChild(this._graphRowsElement);var graphRowElement=this._graphRowsElement.firstChild;var scheduleRefreshCallback=this._invalidateAndScheduleRefresh.bind(this,true,true);var selectRecordCallback=this._selectRecord.bind(this);this._itemsGraphsElement.removeChild(this._expandElements);this._expandElements.removeChildren();for(var i=0;i<endIndex;++i){var record=recordsInWindow[i];if(i<startIndex){var lastChildIndex=i+record.visibleChildrenCount;if(lastChildIndex>=startIndex&&lastChildIndex<endIndex){var expandElement=new WebInspector.TimelineExpandableElement(this._expandElements);var positions=this._calculator.computeBarGraphWindowPosition(record);expandElement._update(record,i,positions.left-this._expandOffset,positions.width);}}else{if(!listRowElement){listRowElement=new WebInspector.TimelineRecordListRow(selectRecordCallback,scheduleRefreshCallback).element;this._sidebarListElement.appendChild(listRowElement);}
765 if(!graphRowElement){graphRowElement=new WebInspector.TimelineRecordGraphRow(this._itemsGraphsElement,selectRecordCallback,scheduleRefreshCallback).element;this._graphRowsElement.appendChild(graphRowElement);}
766 listRowElement.row.update(record,visibleTop);graphRowElement.row.update(record,this._calculator,this._expandOffset,i);if(this._lastSelectedRecord===record){listRowElement.row.renderAsSelected(true);graphRowElement.row.renderAsSelected(true);}
767 listRowElement=listRowElement.nextSibling;graphRowElement=graphRowElement.nextSibling;}}
768 while(listRowElement){var nextElement=listRowElement.nextSibling;listRowElement.row.dispose();listRowElement=nextElement;}
769 while(graphRowElement){var nextElement=graphRowElement.nextSibling;graphRowElement.row.dispose();graphRowElement=nextElement;}
770 this._itemsGraphsElement.insertBefore(this._graphRowsElement,this._bottomGapElement);this._itemsGraphsElement.appendChild(this._expandElements);this._adjustScrollPosition(recordsInWindow.length*rowHeight+headerHeight);this._updateSearchHighlight(false,true);return recordsInWindow.length;},_refreshAllUtilizationBars:function()
771 {this._refreshUtilizationBars(WebInspector.UIString("CPU"),this._mainThreadTasks,this._cpuBarsElement);if(WebInspector.experimentsSettings.gpuTimeline.isEnabled())
772 this._refreshUtilizationBars(WebInspector.UIString("GPU"),this._gpuTasks,this._gpuBarsElement);},_refreshUtilizationBars:function(name,tasks,container)
773 {if(!container)
774 return;const barOffset=3;const minGap=3;var minWidth=WebInspector.TimelineCalculator._minWidth;var widthAdjustment=minWidth/2;var width=this._graphRowsElementWidth;var boundarySpan=this.windowEndTime()-this.windowStartTime();var scale=boundarySpan/(width-minWidth-this._timelinePaddingLeft);var startTime=(this.windowStartTime()-this._timelinePaddingLeft*scale)*1000;var endTime=startTime+width*scale*1000;function compareEndTime(value,task)
775 {return value<task.endTime?-1:1;}
776 var taskIndex=insertionIndexForObjectInListSortedByFunction(startTime,tasks,compareEndTime);var foreignStyle="gpu-task-foreign";var element=container.firstChild;var lastElement;var lastLeft;var lastRight;for(;taskIndex<tasks.length;++taskIndex){var task=tasks[taskIndex];if(task.startTime>endTime)
777 break;var left=Math.max(0,this._calculator.computePosition(WebInspector.TimelineModel.startTimeInSeconds(task))+barOffset-widthAdjustment);var right=Math.min(width,this._calculator.computePosition(WebInspector.TimelineModel.endTimeInSeconds(task))+barOffset+widthAdjustment);if(lastElement){var gap=Math.floor(left)-Math.ceil(lastRight);if(gap<minGap){if(!task.data["foreign"])
778 lastElement.classList.remove(foreignStyle);lastRight=right;lastElement._tasksInfo.lastTaskIndex=taskIndex;continue;}
779 lastElement.style.width=(lastRight-lastLeft)+"px";}
780 if(!element)
781 element=container.createChild("div","timeline-graph-bar");element.style.left=left+"px";element._tasksInfo={name:name,tasks:tasks,firstTaskIndex:taskIndex,lastTaskIndex:taskIndex};if(task.data["foreign"])
782 element.classList.add(foreignStyle);lastLeft=left;lastRight=right;lastElement=element;element=element.nextSibling;}
783 if(lastElement)
784 lastElement.style.width=(lastRight-lastLeft)+"px";while(element){var nextElement=element.nextSibling;element._tasksInfo=null;container.removeChild(element);element=nextElement;}},_adjustScrollPosition:function(totalHeight)
785 {if((this._scrollTop+this._containerElementHeight)>totalHeight+1)
786 this._containerElement.scrollTop=(totalHeight-this._containerElement.offsetHeight);},_getPopoverAnchor:function(element)
787 {var anchor=element.enclosingNodeOrSelfWithClass("timeline-graph-bar");if(anchor&&anchor._tasksInfo)
788 return anchor;return element.enclosingNodeOrSelfWithClass("timeline-frame-strip");},_mouseOut:function()
789 {this._hideQuadHighlight();},_mouseMove:function(e)
790 {var rowElement=e.target.enclosingNodeOrSelfWithClass("timeline-tree-item");if(rowElement&&rowElement.row&&rowElement.row._record.highlightQuad)
791 this._highlightQuad(rowElement.row._record.highlightQuad);else
792 this._hideQuadHighlight();var taskBarElement=e.target.enclosingNodeOrSelfWithClass("timeline-graph-bar");if(taskBarElement&&taskBarElement._tasksInfo){var offset=taskBarElement.offsetLeft;this._timelineGrid.showCurtains(offset>=0?offset:0,taskBarElement.offsetWidth);}else
793 this._timelineGrid.hideCurtains();},_keyDown:function(event)
794 {if(!this._lastSelectedRecord||event.shiftKey||event.metaKey||event.ctrlKey)
795 return;var record=this._lastSelectedRecord;var recordsInWindow=this._presentationModel.filteredRecords();var index=recordsInWindow.indexOf(record);var recordsInPage=Math.floor(this._containerElementHeight/WebInspector.TimelinePanel.rowHeight);var rowHeight=WebInspector.TimelinePanel.rowHeight;if(index===-1)
796 index=0;switch(event.keyIdentifier){case"Left":if(record.parent){if((!record.expandable||record.collapsed)&&record.parent!==this._presentationModel.rootRecord()){this._selectRecord(record.parent);}else{record.collapsed=true;record.clicked=true;this._invalidateAndScheduleRefresh(true,true);}}
797 event.consume(true);break;case"Up":if(--index<0)
798 break;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"Right":if(record.expandable&&record.collapsed){record.collapsed=false;record.clicked=true;this._invalidateAndScheduleRefresh(true,true);}else{if(++index>=recordsInWindow.length)
799 break;this._selectRecord(recordsInWindow[index]);}
800 event.consume(true);break;case"Down":if(++index>=recordsInWindow.length)
801 break;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"PageUp":index=Math.max(0,index-recordsInPage);this._scrollTop=Math.max(0,this._scrollTop-recordsInPage*rowHeight);this._containerElement.scrollTop=this._scrollTop;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"PageDown":index=Math.min(recordsInWindow.length-1,index+recordsInPage);this._scrollTop=Math.min(this._containerElement.scrollHeight-this._containerElementHeight,this._scrollTop+recordsInPage*rowHeight);this._containerElement.scrollTop=this._scrollTop;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"Home":index=0;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"End":index=recordsInWindow.length-1;this._selectRecord(recordsInWindow[index]);event.consume(true);break;}},_highlightQuad:function(quad)
802 {if(this._highlightedQuad===quad)
803 return;this._highlightedQuad=quad;DOMAgent.highlightQuad(quad,WebInspector.Color.PageHighlight.Content.toProtocolRGBA(),WebInspector.Color.PageHighlight.ContentOutline.toProtocolRGBA());},_hideQuadHighlight:function()
804 {if(this._highlightedQuad){delete this._highlightedQuad;DOMAgent.hideHighlight();}},_showPopover:function(anchor,popover)
805 {if(anchor.classList.contains("timeline-frame-strip")){var frame=anchor._frame;popover.show(WebInspector.TimelinePresentationModel.generatePopupContentForFrame(frame),anchor);}else{if(anchor.row&&anchor.row._record)
806 anchor.row._record.generatePopupContent(showCallback);else if(anchor._tasksInfo)
807 popover.show(this._presentationModel.generateMainThreadBarPopupContent(anchor._tasksInfo),anchor,null,null,WebInspector.Popover.Orientation.Bottom);}
808 function showCallback(popupContent)
809 {popover.show(popupContent,anchor);}},_closeRecordDetails:function()
810 {this._popoverHelper.hidePopover();},_injectCategoryStyles:function()
811 {var style=document.createElement("style");var categories=WebInspector.TimelinePresentationModel.categories();style.textContent=Object.values(categories).map(WebInspector.TimelinePresentationModel.createStyleRuleForCategory).join("\n");document.head.appendChild(style);},jumpToNextSearchResult:function()
812 {if(!this._searchResults||!this._searchResults.length)
813 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._selectedSearchResult):-1;this._jumpToSearchResult(index+1);},jumpToPreviousSearchResult:function()
814 {if(!this._searchResults||!this._searchResults.length)
815 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._selectedSearchResult):0;this._jumpToSearchResult(index-1);},_jumpToSearchResult:function(index)
816 {this._selectSearchResult((index+this._searchResults.length)%this._searchResults.length);this._highlightSelectedSearchResult(true);},_selectSearchResult:function(index)
817 {this._selectedSearchResult=this._searchResults[index];this._searchableView.updateCurrentMatchIndex(index);},_highlightSelectedSearchResult:function(selectRecord)
818 {this._clearHighlight();if(this._searchFilter)
819 return;var record=this._selectedSearchResult;if(!record)
820 return;if(selectRecord)
821 this._selectRecord(record);for(var element=this._sidebarListElement.firstChild;element;element=element.nextSibling){if(element.row._record===record){element.row.highlight(this._searchRegExp,this._highlightDomChanges);break;}}},_clearHighlight:function()
822 {if(this._highlightDomChanges)
823 WebInspector.revertDomChanges(this._highlightDomChanges);this._highlightDomChanges=[];},_updateSearchHighlight:function(revealRecord,shouldJump)
824 {if(this._searchFilter||!this._searchRegExp){this._clearHighlight();return;}
825 if(!this._searchResults)
826 this._updateSearchResults(shouldJump);this._highlightSelectedSearchResult(revealRecord);},_updateSearchResults:function(shouldJump)
827 {var searchRegExp=this._searchRegExp;if(!searchRegExp)
828 return;var matches=[];var presentationModel=this._presentationModel;function processRecord(record)
829 {if(presentationModel.isVisible(record)&&WebInspector.TimelineRecordListRow.testContentMatching(record,searchRegExp))
830 matches.push(record);return false;}
831 WebInspector.TimelinePresentationModel.forAllRecords(presentationModel.rootRecord().children,processRecord);var matchesCount=matches.length;if(matchesCount){this._searchResults=matches;this._searchableView.updateSearchMatchesCount(matchesCount);var selectedIndex=matches.indexOf(this._selectedSearchResult);if(shouldJump&&selectedIndex===-1)
832 selectedIndex=0;this._selectSearchResult(selectedIndex);}else{this._searchableView.updateSearchMatchesCount(0);delete this._selectedSearchResult;}},searchCanceled:function()
833 {this._clearHighlight();delete this._searchResults;delete this._selectedSearchResult;delete this._searchRegExp;},performSearch:function(query,shouldJump)
834 {this._searchRegExp=createPlainTextSearchRegex(query,"i");delete this._searchResults;this._updateSearchHighlight(true,shouldJump);},__proto__:WebInspector.View.prototype}
835 WebInspector.TimelineCalculator=function(model)
836 {this._model=model;}
837 WebInspector.TimelineCalculator._minWidth=5;WebInspector.TimelineCalculator.prototype={computePosition:function(time)
838 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this.paddingLeft;},computeBarGraphPercentages:function(record)
839 {var start=(record.startTime-this._minimumBoundary)/this.boundarySpan()*100;var end=(record.startTime+record.selfTime-this._minimumBoundary)/this.boundarySpan()*100;var endWithChildren=(record.lastChildEndTime-this._minimumBoundary)/this.boundarySpan()*100;var cpuWidth=record.coalesced?endWithChildren-start:record.cpuTime/this.boundarySpan()*100;return{start:start,end:end,endWithChildren:endWithChildren,cpuWidth:cpuWidth};},computeBarGraphWindowPosition:function(record)
840 {var percentages=this.computeBarGraphPercentages(record);var widthAdjustment=0;var left=this.computePosition(record.startTime);var width=(percentages.end-percentages.start)/100*this._workingArea;if(width<WebInspector.TimelineCalculator._minWidth){widthAdjustment=WebInspector.TimelineCalculator._minWidth-width;width=WebInspector.TimelineCalculator._minWidth;}
841 var widthWithChildren=(percentages.endWithChildren-percentages.start)/100*this._workingArea+widthAdjustment;var cpuWidth=percentages.cpuWidth/100*this._workingArea+widthAdjustment;if(percentages.endWithChildren>percentages.end)
842 widthWithChildren+=widthAdjustment;return{left:left,width:width,widthWithChildren:widthWithChildren,cpuWidth:cpuWidth};},setWindow:function(minimumBoundary,maximumBoundary)
843 {this._minimumBoundary=minimumBoundary;this._maximumBoundary=maximumBoundary;},setDisplayWindow:function(paddingLeft,clientWidth)
844 {this._workingArea=clientWidth-WebInspector.TimelineCalculator._minWidth-paddingLeft;this.paddingLeft=paddingLeft;},formatTime:function(value,hires)
845 {return Number.secondsToString(value+this._minimumBoundary-this._model.minimumRecordTime(),hires);},maximumBoundary:function()
846 {return this._maximumBoundary;},minimumBoundary:function()
847 {return this._minimumBoundary;},zeroTime:function()
848 {return this._model.minimumRecordTime();},boundarySpan:function()
849 {return this._maximumBoundary-this._minimumBoundary;}}
850 WebInspector.TimelineRecordListRow=function(selectRecord,scheduleRefresh)
851 {this.element=document.createElement("div");this.element.row=this;this.element.style.cursor="pointer";this.element.addEventListener("click",this._onClick.bind(this),false);this.element.addEventListener("mouseover",this._onMouseOver.bind(this),false);this.element.addEventListener("mouseout",this._onMouseOut.bind(this),false);this._warningElement=this.element.createChild("div","timeline-tree-item-warning hidden");this._expandArrowElement=this.element.createChild("div","timeline-tree-item-expand-arrow");this._expandArrowElement.addEventListener("click",this._onExpandClick.bind(this),false);var iconElement=this.element.createChild("span","timeline-tree-icon");this._typeElement=this.element.createChild("span","type");this._dataElement=this.element.createChild("span","data dimmed");this._scheduleRefresh=scheduleRefresh;this._selectRecord=selectRecord;}
852 WebInspector.TimelineRecordListRow.prototype={update:function(record,offset)
853 {this._record=record;this._offset=offset;this.element.className="timeline-tree-item timeline-category-"+record.category.name;var paddingLeft=5;var step=-3;for(var currentRecord=record.parent?record.parent.parent:null;currentRecord;currentRecord=currentRecord.parent)
854 paddingLeft+=12/(Math.max(1,step++));this.element.style.paddingLeft=paddingLeft+"px";if(record.isBackground)
855 this.element.classList.add("background");this._typeElement.textContent=record.title;if(this._dataElement.firstChild)
856 this._dataElement.removeChildren();this._warningElement.enableStyleClass("hidden",!record.hasWarnings()&&!record.childHasWarnings());this._warningElement.enableStyleClass("timeline-tree-item-child-warning",record.childHasWarnings()&&!record.hasWarnings());if(record.detailsNode())
857 this._dataElement.appendChild(record.detailsNode());this._expandArrowElement.enableStyleClass("parent",record.children&&record.children.length);this._expandArrowElement.enableStyleClass("expanded",record.visibleChildrenCount);this._record.setUserObject("WebInspector.TimelineRecordListRow",this);},highlight:function(regExp,domChanges)
858 {var matchInfo=this.element.textContent.match(regExp);if(matchInfo)
859 WebInspector.highlightSearchResult(this.element,matchInfo.index,matchInfo[0].length,domChanges);},dispose:function()
860 {this.element.remove();},_onExpandClick:function(event)
861 {this._record.collapsed=!this._record.collapsed;this._record.clicked=true;this._scheduleRefresh();event.consume(true);},_onClick:function(event)
862 {this._selectRecord(this._record);},renderAsSelected:function(selected)
863 {this.element.enableStyleClass("selected",selected);},_onMouseOver:function(event)
864 {this.element.classList.add("hovered");var graphRow=(this._record.getUserObject("WebInspector.TimelineRecordGraphRow"));graphRow.element.classList.add("hovered");},_onMouseOut:function(event)
865 {this.element.classList.remove("hovered");var graphRow=(this._record.getUserObject("WebInspector.TimelineRecordGraphRow"));graphRow.element.classList.remove("hovered");}}
866 WebInspector.TimelineRecordListRow.testContentMatching=function(record,regExp)
867 {var toSearchText=record.title;if(record.detailsNode())
868 toSearchText+=" "+record.detailsNode().textContent;return regExp.test(toSearchText);}
869 WebInspector.TimelineRecordGraphRow=function(graphContainer,selectRecord,scheduleRefresh)
870 {this.element=document.createElement("div");this.element.row=this;this.element.addEventListener("mouseover",this._onMouseOver.bind(this),false);this.element.addEventListener("mouseout",this._onMouseOut.bind(this),false);this.element.addEventListener("click",this._onClick.bind(this),false);this._barAreaElement=document.createElement("div");this._barAreaElement.className="timeline-graph-bar-area";this.element.appendChild(this._barAreaElement);this._barWithChildrenElement=document.createElement("div");this._barWithChildrenElement.className="timeline-graph-bar with-children";this._barWithChildrenElement.row=this;this._barAreaElement.appendChild(this._barWithChildrenElement);this._barCpuElement=document.createElement("div");this._barCpuElement.className="timeline-graph-bar cpu"
871 this._barCpuElement.row=this;this._barAreaElement.appendChild(this._barCpuElement);this._barElement=document.createElement("div");this._barElement.className="timeline-graph-bar";this._barElement.row=this;this._barAreaElement.appendChild(this._barElement);this._expandElement=new WebInspector.TimelineExpandableElement(graphContainer);this._selectRecord=selectRecord;this._scheduleRefresh=scheduleRefresh;}
872 WebInspector.TimelineRecordGraphRow.prototype={update:function(record,calculator,expandOffset,index)
873 {this._record=record;this.element.className="timeline-graph-side timeline-category-"+record.category.name;if(record.isBackground)
874 this.element.classList.add("background");var barPosition=calculator.computeBarGraphWindowPosition(record);this._barWithChildrenElement.style.left=barPosition.left+"px";this._barWithChildrenElement.style.width=barPosition.widthWithChildren+"px";this._barElement.style.left=barPosition.left+"px";this._barElement.style.width=barPosition.width+"px";this._barCpuElement.style.left=barPosition.left+"px";this._barCpuElement.style.width=barPosition.cpuWidth+"px";this._expandElement._update(record,index,barPosition.left-expandOffset,barPosition.width);this._record.setUserObject("WebInspector.TimelineRecordGraphRow",this);},_onClick:function(event)
875 {if(this._expandElement._arrow.containsEventPoint(event))
876 this._expand();this._selectRecord(this._record);},renderAsSelected:function(selected)
877 {this.element.enableStyleClass("selected",selected);},_expand:function()
878 {this._record.collapsed=!this._record.collapsed;this._record.clicked=true;this._scheduleRefresh();},_onMouseOver:function(event)
879 {this.element.classList.add("hovered");var listRow=(this._record.getUserObject("WebInspector.TimelineRecordListRow"));listRow.element.classList.add("hovered");},_onMouseOut:function(event)
880 {this.element.classList.remove("hovered");var listRow=(this._record.getUserObject("WebInspector.TimelineRecordListRow"));listRow.element.classList.remove("hovered");},dispose:function()
881 {this.element.remove();this._expandElement._dispose();}}
882 WebInspector.TimelineExpandableElement=function(container)
883 {this._element=container.createChild("div","timeline-expandable");this._element.createChild("div","timeline-expandable-left");this._arrow=this._element.createChild("div","timeline-expandable-arrow");}
884 WebInspector.TimelineExpandableElement.prototype={_update:function(record,index,left,width)
885 {const rowHeight=WebInspector.TimelinePanel.rowHeight;if(record.visibleChildrenCount||record.expandable){this._element.style.top=index*rowHeight+"px";this._element.style.left=left+"px";this._element.style.width=Math.max(12,width+25)+"px";if(!record.collapsed){this._element.style.height=(record.visibleChildrenCount+1)*rowHeight+"px";this._element.classList.add("timeline-expandable-expanded");this._element.classList.remove("timeline-expandable-collapsed");}else{this._element.style.height=rowHeight+"px";this._element.classList.add("timeline-expandable-collapsed");this._element.classList.remove("timeline-expandable-expanded");}
886 this._element.classList.remove("hidden");}else
887 this._element.classList.add("hidden");},_dispose:function()
888 {this._element.remove();}}
889 WebInspector.TimelineCategoryFilter=function()
890 {}
891 WebInspector.TimelineCategoryFilter.prototype={accept:function(record)
892 {return!record.category.hidden&&record.type!==WebInspector.TimelineModel.RecordType.BeginFrame;}}
893 WebInspector.TimelineIsLongFilter=function()
894 {this._minimumRecordDuration=0;}
895 WebInspector.TimelineIsLongFilter.prototype={setMinimumRecordDuration:function(value)
896 {this._minimumRecordDuration=value;},accept:function(record)
897 {return this._minimumRecordDuration?((record.lastChildEndTime-record.startTime)>=this._minimumRecordDuration):true;}}
898 WebInspector.TimelineSearchFilter=function(regExp)
899 {this._regExp=regExp;}
900 WebInspector.TimelineSearchFilter.prototype={accept:function(record)
901 {return WebInspector.TimelineRecordListRow.testContentMatching(record,this._regExp);}}
902 WebInspector.TimelineWindowFilter=function()
903 {this.reset();}
904 WebInspector.TimelineWindowFilter.prototype={reset:function()
905 {this._windowStartTime=0;this._windowEndTime=Infinity;},setWindowTimes:function(windowStartTime,windowEndTime)
906 {this._windowStartTime=windowStartTime;this._windowEndTime=windowEndTime;},accept:function(record)
907 {return record.lastChildEndTime>=this._windowStartTime&&record.startTime<=this._windowEndTime;}}
908 WebInspector.TimelineDetailsView=function()
909 {WebInspector.View.call(this);this.element=document.createElement("div");this.element.className="timeline-details-view fill vbox";this._titleElement=this.element.createChild("div","timeline-details-view-title");this._titleElement.textContent=WebInspector.UIString("DETAILS");this._contentElement=this.element.createChild("div","timeline-details-view-body");}
910 WebInspector.TimelineDetailsView.prototype={titleElement:function()
911 {return this._titleElement;},setContent:function(title,node)
912 {this._titleElement.textContent=WebInspector.UIString("DETAILS: %s",title);this._contentElement.removeChildren();this._contentElement.appendChild(node);},setVertical:function(vertical)
913 {this._contentElement.enableStyleClass("hbox",!vertical);this._contentElement.enableStyleClass("vbox",vertical);},__proto__:WebInspector.View.prototype};WebInspector.TimelinePanel=function()
914 {WebInspector.Panel.call(this,"timeline");this.registerRequiredCSS("timelinePanel.css");this.registerRequiredCSS("filter.css");this.element.classList.add("vbox");this.element.addEventListener("contextmenu",this._contextMenu.bind(this),false);this._model=new WebInspector.TimelineModel();this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted,this._onRecordingStarted,this);this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped,this._onRecordingStopped,this);this._presentationModeSetting=WebInspector.settings.createSetting("timelineOverviewMode",WebInspector.TimelinePanel.Mode.Events);this._glueRecordsSetting=WebInspector.settings.createSetting("timelineGlueRecords",false);this._createStatusBarItems();this._createPresentationSelector();this._overviewPane=new WebInspector.TimelineOverviewPane(this._model);this._overviewPane.addEventListener(WebInspector.TimelineOverviewPane.Events.WindowChanged,this._onWindowChanged.bind(this));this._overviewPane.show(this._presentationSelector.element);this._createFileSelector();this._registerShortcuts();WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillReloadPage,this._willReloadPage,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.Load,this._loadEventFired,this);this._selectPresentationMode(this._presentationModeSetting.get());}
915 WebInspector.TimelinePanel.Mode={Events:"Events",Frames:"Frames",Memory:"Memory"};WebInspector.TimelinePanel.rowHeight=18;WebInspector.TimelinePanel.headerHeight=20;WebInspector.TimelinePanel.durationFilterPresetsMs=[0,1,15];WebInspector.TimelinePanel.prototype={setSidebarWidth:function(width)
916 {this._topPaneSidebarElement.style.flexBasis=width+"px";},_onWindowChanged:function()
917 {this._currentView.windowChanged(this._overviewPane.windowLeft(),this._overviewPane.windowRight());},setWindow:function(left,right)
918 {this._overviewPane.setWindow(left,right);},_viewForMode:function(mode)
919 {var view=this._views[mode];if(!view){switch(mode){case WebInspector.TimelinePanel.Mode.Events:case WebInspector.TimelinePanel.Mode.Frames:case WebInspector.TimelinePanel.Mode.Memory:view=new WebInspector.TimelineView(this,this._model,this._glueRecordsSetting,mode);this._views[mode]=view;break;default:console.assert(false,"Unknown mode: "+mode);}}
920 return view;},_createPresentationSelector:function()
921 {this._views={};this._presentationSelector=new WebInspector.View();this._presentationSelector.element.classList.add("hbox");this._presentationSelector.element.id="timeline-overview-panel";this._presentationSelector.show(this.element);this._topPaneSidebarElement=this._presentationSelector.element.createChild("div");this._topPaneSidebarElement.id="timeline-overview-sidebar";var overviewTreeElement=this._topPaneSidebarElement.createChild("ol","sidebar-tree vbox");var topPaneSidebarTree=new TreeOutline(overviewTreeElement);this._overviewItems={};for(var mode in WebInspector.TimelinePanel.Mode){this._overviewItems[mode]=new WebInspector.SidebarTreeElement("timeline-overview-sidebar-"+mode.toLowerCase(),WebInspector.UIString(mode));var item=this._overviewItems[mode];item.onselect=this._onModeChanged.bind(this,mode);topPaneSidebarTree.appendChild(item);}},_createStatusBarItems:function()
922 {var panelStatusBarElement=this.element.createChild("div","panel-status-bar");this._statusBarButtons=([]);this.toggleTimelineButton=new WebInspector.StatusBarButton(WebInspector.UIString("Record"),"record-profile-status-bar-item");this.toggleTimelineButton.addEventListener("click",this._toggleTimelineButtonClicked,this);this._statusBarButtons.push(this.toggleTimelineButton);panelStatusBarElement.appendChild(this.toggleTimelineButton.element);this.clearButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear"),"clear-status-bar-item");this.clearButton.addEventListener("click",this._onClearButtonClick,this);this._statusBarButtons.push(this.clearButton);panelStatusBarElement.appendChild(this.clearButton.element);this._filterBar=new WebInspector.FilterBar();panelStatusBarElement.appendChild(this._filterBar.filterButton().element);this.garbageCollectButton=new WebInspector.StatusBarButton(WebInspector.UIString("Collect Garbage"),"garbage-collect-status-bar-item");this.garbageCollectButton.addEventListener("click",this._garbageCollectButtonClicked,this);this._statusBarButtons.push(this.garbageCollectButton);panelStatusBarElement.appendChild(this.garbageCollectButton.element);this._glueParentButton=new WebInspector.StatusBarButton(WebInspector.UIString("Glue asynchronous events to causes"),"glue-async-status-bar-item");this._glueParentButton.toggled=this._glueRecordsSetting.get();this._glueParentButton.addEventListener("click",this._glueParentButtonClicked,this);this._statusBarButtons.push(this._glueParentButton);panelStatusBarElement.appendChild(this._glueParentButton.element);panelStatusBarElement.appendChild(WebInspector.SettingsTab.createSettingCheckbox(WebInspector.UIString("Capture stacks"),WebInspector.settings.timelineCaptureStacks,true,undefined,WebInspector.UIString("Capture JavaScript stack on every timeline event")));this._statusTextContainer=panelStatusBarElement.createChild("div");this.recordsCounter=new WebInspector.StatusBarText("","timeline-records-counter");this._statusTextContainer.appendChild(this.recordsCounter.element);this._miscStatusBarItems=panelStatusBarElement.createChild("div","status-bar-item");this._filtersContainer=this.element.createChild("div","timeline-filters-header hidden");this._filtersContainer.appendChild(this._filterBar.filtersElement());this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggled,this._onFiltersToggled,this);},_updateFiltersBar:function()
923 {this._filterBar.clear();var hasFilters=this._currentView.createUIFilters(this._filterBar);this._filterBar.filterButton().setEnabled(hasFilters);},defaultFocusedElement:function()
924 {return this.element;},searchableView:function()
925 {return this._currentView.searchableView();},_onFiltersToggled:function(event)
926 {var toggled=(event.data);this._filtersContainer.enableStyleClass("hidden",!toggled);this.onResize();},_prepareToLoadTimeline:function()
927 {if(this._operationInProgress)
928 return null;if(this._recordingInProgress()){this.toggleTimelineButton.toggled=false;this._stopRecording();}
929 var progressIndicator=new WebInspector.ProgressIndicator();progressIndicator.addEventListener(WebInspector.ProgressIndicator.Events.Done,this._setOperationInProgress.bind(this,null));this._setOperationInProgress(progressIndicator);return progressIndicator;},_setOperationInProgress:function(indicator)
930 {this._operationInProgress=!!indicator;for(var i=0;i<this._statusBarButtons.length;++i)
931 this._statusBarButtons[i].setEnabled(!this._operationInProgress);this._glueParentButton.setEnabled(!this._operationInProgress&&!this._currentView.supportsGlueParentMode());this._statusTextContainer.enableStyleClass("hidden",!!indicator);this._miscStatusBarItems.removeChildren();if(indicator)
932 this._miscStatusBarItems.appendChild(indicator.element);},_registerShortcuts:function()
933 {this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.StartStopRecording,this._toggleTimelineButtonClicked.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.SaveToFile,this._saveToFile.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.LoadFromFile,this._selectFileToLoad.bind(this));},_createFileSelector:function()
934 {if(this._fileSelectorElement)
935 this._fileSelectorElement.remove();this._fileSelectorElement=WebInspector.createFileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this._fileSelectorElement);},_contextMenu:function(event)
936 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Save Timeline data\u2026":"Save Timeline Data\u2026"),this._saveToFile.bind(this),this._operationInProgress);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Load Timeline data\u2026":"Load Timeline Data\u2026"),this._selectFileToLoad.bind(this),this._operationInProgress);contextMenu.show();},_saveToFile:function()
937 {if(this._operationInProgress)
938 return true;this._model.saveToFile();return true;},_selectFileToLoad:function(){this._fileSelectorElement.click();return true;},_loadFromFile:function(file)
939 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator)
940 return;this._model.loadFromFile(file,progressIndicator);this._createFileSelector();},loadFromURL:function(url)
941 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator)
942 return;this._model.loadFromURL(url,progressIndicator);},_selectPresentationMode:function(mode)
943 {if(!this._overviewItems[mode])
944 mode=WebInspector.TimelinePanel.Mode.Events;this._overviewItems[mode].revealAndSelect(false);},_onModeChanged:function(mode)
945 {this.element.classList.remove("timeline-"+this._presentationModeSetting.get().toLowerCase()+"-view");this._presentationModeSetting.set(mode);this.element.classList.add("timeline-"+mode.toLowerCase()+"-view");var windowTimes=null;if(this._currentView){this._currentView.detach();windowTimes=this._currentView.windowTimes();}
946 this._currentView=this._viewForMode(mode);this._updateFiltersBar();this._currentView.setWindowTimes(windowTimes);this._overviewPane.setOverviewControl(this._currentView.overviewControl());this._currentView.show(this.element);this._glueParentButton.setEnabled(this._currentView.supportsGlueParentMode());},_startRecording:function(userInitiated)
947 {this._userInitiatedRecording=userInitiated;this._model.startRecording(true);if(userInitiated)
948 WebInspector.userMetrics.TimelineStarted.record();},_stopRecording:function()
949 {this._userInitiatedRecording=false;this._model.stopRecording();},_toggleTimelineButtonClicked:function()
950 {if(this._operationInProgress)
951 return true;if(this._recordingInProgress())
952 this._stopRecording();else
953 this._startRecording(true);return true;},_garbageCollectButtonClicked:function()
954 {HeapProfilerAgent.collectGarbage();},_glueParentButtonClicked:function()
955 {var newValue=!this._glueParentButton.toggled;this._glueParentButton.toggled=newValue;this._glueRecordsSetting.set(newValue);},_onClearButtonClick:function()
956 {this._model.reset();},_onRecordingStarted:function()
957 {this.toggleTimelineButton.title=WebInspector.UIString("Stop");this.toggleTimelineButton.toggled=true;},_recordingInProgress:function()
958 {return this.toggleTimelineButton.toggled;},_onRecordingStopped:function()
959 {this.toggleTimelineButton.title=WebInspector.UIString("Record");this.toggleTimelineButton.toggled=false;},_willReloadPage:function(event)
960 {if(this._operationInProgress||this._userInitiatedRecording||!this.isShowing())
961 return;this._startRecording(false);},_loadEventFired:function(event)
962 {if(!this._recordingInProgress()||this._userInitiatedRecording)
963 return;this._stopRecording();},__proto__:WebInspector.Panel.prototype}