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

Side by Side Diff: chrome_linux64/resources/inspector/TimelinePanel.js

Issue 310483004: Roll reference builds to 35.0.1916.114. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 WebInspector.MemoryStatistics=function(timelineView,model) 1 WebInspector.CountersGraph=function(delegate,model)
2 {WebInspector.View.call(this);this._timelineView=timelineView;this.element.class List.add("fill");this._counters=[];model.addEventListener(WebInspector.TimelineM odel.Events.RecordAdded,this._onRecordAdded,this);model.addEventListener(WebInsp ector.TimelineModel.Events.RecordsCleared,this._onRecordsCleared,this);this._mem orySidebarView=new WebInspector.SidebarView(WebInspector.SidebarView.SidebarPosi tion.Start,undefined);this._memorySidebarView.element.id="memory-graphs-containe r";this._memorySidebarView.addEventListener(WebInspector.SidebarView.EventTypes. Resized,this._sidebarResized.bind(this));this._canvasContainer=this._memorySideb arView.mainElement();this._canvasContainer.id="memory-graphs-canvas-container";t his._createCurrentValuesBar();this._canvas=this._canvasContainer.createChild("ca nvas","fill");this._canvas.id="memory-counters-graph";this._lastMarkerXPosition= 0;this._canvas.addEventListener("mouseover",this._onMouseOver.bind(this),true);t his._canvas.addEventListener("mousemove",this._onMouseMove.bind(this),true);this ._canvas.addEventListener("mouseout",this._onMouseOut.bind(this),true);this._can vas.addEventListener("click",this._onClick.bind(this),true);this._timelineGrid=n ew WebInspector.TimelineGrid();this._canvasContainer.appendChild(this._timelineG rid.dividersElement);this._memorySidebarView.sidebarElement().createChild("div", "sidebar-tree sidebar-tree-section").textContent=WebInspector.UIString("COUNTERS ");this._counterUI=this._createCounterUIList();this._memorySidebarView.show(this .element);} 2 {WebInspector.SplitView.call(this,true,false);this.element.id="memory-graphs-con tainer";this._delegate=delegate;this._model=model;this._calculator=new WebInspec tor.TimelineCalculator(this._model);this._graphsContainer=this.mainElement();thi s._createCurrentValuesBar();this._canvasView=new WebInspector.VBoxWithResizeCall back(this._resize.bind(this));this._canvasView.show(this._graphsContainer);this. _canvasContainer=this._canvasView.element;this._canvasContainer.id="memory-graph s-canvas-container";this._canvas=this._canvasContainer.createChild("canvas");thi s._canvas.id="memory-counters-graph";this._canvasContainer.addEventListener("mou seover",this._onMouseMove.bind(this),true);this._canvasContainer.addEventListene r("mousemove",this._onMouseMove.bind(this),true);this._canvasContainer.addEventL istener("mouseout",this._onMouseOut.bind(this),true);this._canvasContainer.addEv entListener("click",this._onClick.bind(this),true);this._timelineGrid=new WebIns pector.TimelineGrid();this._canvasContainer.appendChild(this._timelineGrid.divid ersElement);this.sidebarElement().createChild("div","sidebar-tree sidebar-tree-s ection").textContent=WebInspector.UIString("COUNTERS");this._counters=[];this._c ounterUI=[];}
3 WebInspector.MemoryStatistics.Counter=function(time) 3 WebInspector.CountersGraph.prototype={_createCurrentValuesBar:function()
4 {this.time=time;} 4 {this._currentValuesBar=this._graphsContainer.createChild("div");this._currentVa luesBar.id="counter-values-bar";},createCounter:function(uiName,uiValueTemplate, color)
5 {var counter=new WebInspector.CountersGraph.Counter();this._counters.push(counte r);this._counterUI.push(new WebInspector.CountersGraph.CounterUI(this,uiName,uiV alueTemplate,color,counter));return counter;},reset:function()
6 {for(var i=0;i<this._counters.length;++i){this._counters[i].reset();this._counte rUI[i].reset();}
7 this.refresh();},_resize:function()
8 {var parentElement=this._canvas.parentElement;this._canvas.width=parentElement.c lientWidth;this._canvas.height=parentElement.clientHeight;var timelinePaddingLef t=15;this._calculator.setDisplayWindow(timelinePaddingLeft,this._canvas.width);t his.refresh();},setWindowTimes:function(startTime,endTime)
9 {this._calculator.setWindow(startTime,endTime);this.scheduleRefresh();},schedule Refresh:function()
10 {if(this._refreshTimer)
11 return;this._refreshTimer=setTimeout(this.refresh.bind(this),300);},draw:functio n()
12 {for(var i=0;i<this._counters.length;++i){this._counters[i]._calculateVisibleInd exes(this._calculator);this._counters[i]._calculateXValues(this._canvas.width);}
13 this._clear();this._setVerticalClip(10,this._canvas.height-20);for(var i=0;i<thi s._counterUI.length;i++)
14 this._drawGraph(this._counterUI[i]);},_onClick:function(event)
15 {var x=event.x-this._canvasContainer.totalOffsetLeft();var minDistance=Infinity; var bestTime;for(var i=0;i<this._counterUI.length;++i){var counterUI=this._count erUI[i];if(!counterUI.counter.times.length)
16 continue;var index=counterUI._recordIndexAt(x);var distance=Math.abs(x-counterUI .counter.x[index]);if(distance<minDistance){minDistance=distance;bestTime=counte rUI.counter.times[index];}}
17 if(bestTime!==undefined)
18 this._revealRecordAt(bestTime);},_revealRecordAt:function(time)
19 {var recordToReveal;function findRecordToReveal(record)
20 {if(record.startTime<=time&&time<=record.endTime){recordToReveal=record;return t rue;}
21 if(!recordToReveal||record.endTime<time&&recordToReveal.endTime<record.endTime)
22 recordToReveal=record;return false;}
23 this._model.forAllRecords(null,findRecordToReveal);this._delegate.selectRecord(r ecordToReveal);},_onMouseOut:function(event)
24 {delete this._markerXPosition;this._clearCurrentValueAndMarker();},_clearCurrent ValueAndMarker:function()
25 {for(var i=0;i<this._counterUI.length;i++)
26 this._counterUI[i]._clearCurrentValueAndMarker();},_onMouseMove:function(event)
27 {var x=event.x-this._canvasContainer.totalOffsetLeft();this._markerXPosition=x;t his._refreshCurrentValues();},_refreshCurrentValues:function()
28 {if(this._markerXPosition===undefined)
29 return;for(var i=0;i<this._counterUI.length;++i)
30 this._counterUI[i].updateCurrentValue(this._markerXPosition);},refresh:function( )
31 {delete this._refreshTimer;this._timelineGrid.updateDividers(this._calculator);t his.draw();this._refreshCurrentValues();},refreshRecords:function()
32 {this.reset();var records=this._model.records();for(var i=0;i<records.length;++i )
33 this.addRecord(records[i]);},_setVerticalClip:function(originY,height)
34 {this._originY=originY;this._clippedHeight=height;},_clear:function()
35 {var ctx=this._canvas.getContext("2d");ctx.clearRect(0,0,ctx.canvas.width,ctx.ca nvas.height);},highlightSearchResult:function(record,regex,selectRecord)
36 {},setSelectedRecord:function(record)
37 {},_drawGraph:function(counterUI)
38 {var canvas=this._canvas;var ctx=canvas.getContext("2d");var width=canvas.width; var height=this._clippedHeight;var originY=this._originY;var counter=counterUI.c ounter;var values=counter.values;if(!values.length)
39 return;var bounds=counter._calculateBounds();var minValue=bounds.min;var maxValu e=bounds.max;counterUI.setRange(minValue,maxValue);if(!counterUI.visible())
40 return;var yValues=counterUI.graphYValues;yValues.length=this._counters.length;v ar maxYRange=maxValue-minValue;var yFactor=maxYRange?height/(maxYRange):1;ctx.sa ve();ctx.translate(0.5,0.5);ctx.beginPath();var value=values[counter._minimumInd ex];var currentY=Math.round(originY+height-(value-minValue)*yFactor);ctx.moveTo( 0,currentY);for(var i=counter._minimumIndex;i<=counter._maximumIndex;i++){var x= Math.round(counter.x[i]);ctx.lineTo(x,currentY);var currentValue=values[i];if(ty peof currentValue!=="undefined")
41 value=currentValue;currentY=Math.round(originY+height-(value-minValue)*yFactor); ctx.lineTo(x,currentY);yValues[i]=currentY;}
42 ctx.lineTo(width,currentY);ctx.lineWidth=1;ctx.strokeStyle=counterUI.graphColor; ctx.stroke();if(counter._limitValue){var limitLineY=Math.round(originY+height-(c ounter._limitValue-minValue)*yFactor);ctx.moveTo(0,limitLineY);ctx.lineTo(width, limitLineY);ctx.strokeStyle=counterUI.limitColor;ctx.stroke();}
43 ctx.closePath();ctx.restore();},__proto__:WebInspector.SplitView.prototype}
44 WebInspector.CountersGraph.Counter=function()
45 {this.times=[];this.values=[];}
46 WebInspector.CountersGraph.Counter.prototype={appendSample:function(time,value)
47 {if(this.values.length&&this.values.peekLast()===value)
48 return;this.times.push(time);this.values.push(value);},reset:function()
49 {this.times=[];this.values=[];},setLimit:function(value)
50 {this._limitValue=value;},_calculateBounds:function()
51 {var maxValue;var minValue;for(var i=this._minimumIndex;i<=this._maximumIndex;i+ +){var value=this.values[i];if(minValue===undefined||value<minValue)
52 minValue=value;if(maxValue===undefined||value>maxValue)
53 maxValue=value;}
54 minValue=minValue||0;maxValue=maxValue||1;if(this._limitValue){if(maxValue>this. _limitValue*0.5)
55 maxValue=Math.max(maxValue,this._limitValue);minValue=Math.min(minValue,this._li mitValue);}
56 return{min:minValue,max:maxValue};},_calculateVisibleIndexes:function(calculator )
57 {var start=calculator.minimumBoundary();var end=calculator.maximumBoundary();thi s._minimumIndex=Number.constrain(this.times.upperBound(start)-1,0,this.times.len gth-1);this._maximumIndex=Number.constrain(this.times.lowerBound(end),0,this.tim es.length-1);this._minTime=start;this._maxTime=end;},_calculateXValues:function( width)
58 {if(!this.values.length)
59 return;var xFactor=width/(this._maxTime-this._minTime);this.x=new Array(this.val ues.length);this.x[this._minimumIndex]=0;for(var i=this._minimumIndex+1;i<this._ maximumIndex;i++)
60 this.x[i]=xFactor*(this.times[i]-this._minTime);this.x[this._maximumIndex]=width ;}}
61 WebInspector.CountersGraph.CounterUI=function(memoryCountersPane,title,currentVa lueLabel,graphColor,counter)
62 {this._memoryCountersPane=memoryCountersPane;this.counter=counter;var container= memoryCountersPane.sidebarElement().createChild("div","memory-counter-sidebar-in fo");var swatchColor=graphColor;this._swatch=new WebInspector.SwatchCheckbox(Web Inspector.UIString(title),swatchColor);this._swatch.addEventListener(WebInspecto r.SwatchCheckbox.Events.Changed,this._toggleCounterGraph.bind(this));container.a ppendChild(this._swatch.element);this._range=this._swatch.element.createChild("s pan");this._value=memoryCountersPane._currentValuesBar.createChild("span","memor y-counter-value");this._value.style.color=graphColor;this.graphColor=graphColor; this.limitColor=WebInspector.Color.parse(graphColor).setAlpha(0.3).toString(WebI nspector.Color.Format.RGBA);this.graphYValues=[];this._currentValueLabel=current ValueLabel;this._marker=memoryCountersPane._canvasContainer.createChild("div","m emory-counter-marker");this._marker.style.backgroundColor=graphColor;this._clear CurrentValueAndMarker();}
63 WebInspector.CountersGraph.CounterUI.prototype={reset:function()
64 {this._range.textContent="";},setRange:function(minValue,maxValue)
65 {this._range.textContent=WebInspector.UIString("[%d:%d]",minValue,maxValue);},_t oggleCounterGraph:function(event)
66 {this._value.classList.toggle("hidden",!this._swatch.checked);this._memoryCounte rsPane.refresh();},_recordIndexAt:function(x)
67 {return this.counter.x.upperBound(x,null,this.counter._minimumIndex+1,this.count er._maximumIndex+1)-1;},updateCurrentValue:function(x)
68 {if(!this.visible()||!this.counter.values.length)
69 return;var index=this._recordIndexAt(x);this._value.textContent=WebInspector.UIS tring(this._currentValueLabel,this.counter.values[index]);var y=this.graphYValue s[index];this._marker.style.left=x+"px";this._marker.style.top=y+"px";this._mark er.classList.remove("hidden");},_clearCurrentValueAndMarker:function()
70 {this._value.textContent="";this._marker.classList.add("hidden");},visible:funct ion()
71 {return this._swatch.checked;}}
5 WebInspector.SwatchCheckbox=function(title,color) 72 WebInspector.SwatchCheckbox=function(title,color)
6 {this.element=document.createElement("div");this._swatch=this.element.createChil d("div","swatch");this.element.createChild("span","title").textContent=title;thi s._color=color;this.checked=true;this.element.addEventListener("click",this._tog gleCheckbox.bind(this),true);} 73 {this.element=document.createElement("div");this._swatch=this.element.createChil d("div","swatch");this.element.createChild("span","title").textContent=title;thi s._color=color;this.checked=true;this.element.addEventListener("click",this._tog gleCheckbox.bind(this),true);}
7 WebInspector.SwatchCheckbox.Events={Changed:"Changed"} 74 WebInspector.SwatchCheckbox.Events={Changed:"Changed"}
8 WebInspector.SwatchCheckbox.prototype={get checked() 75 WebInspector.SwatchCheckbox.prototype={get checked()
9 {return this._checked;},set checked(v) 76 {return this._checked;},set checked(v)
10 {this._checked=v;if(this._checked) 77 {this._checked=v;if(this._checked)
11 this._swatch.style.backgroundColor=this._color;else 78 this._swatch.style.backgroundColor=this._color;else
12 this._swatch.style.backgroundColor="";},_toggleCheckbox:function(event) 79 this._swatch.style.backgroundColor="";},_toggleCheckbox:function(event)
13 {this.checked=!this.checked;this.dispatchEventToListeners(WebInspector.SwatchChe ckbox.Events.Changed);},__proto__:WebInspector.Object.prototype} 80 {this.checked=!this.checked;this.dispatchEventToListeners(WebInspector.SwatchChe ckbox.Events.Changed);},__proto__:WebInspector.Object.prototype};WebInspector.Me moryCountersGraph=function(delegate,model)
14 WebInspector.CounterUIBase=function(memoryCountersPane,title,graphColor,valueGet ter) 81 {WebInspector.CountersGraph.call(this,delegate,model);this._countersByName={};th is._countersByName["documents"]=this.createCounter(WebInspector.UIString("Docume nts"),WebInspector.UIString("Documents: %d"),"#d00");this._countersByName["nodes "]=this.createCounter(WebInspector.UIString("Nodes"),WebInspector.UIString("Node s: %d"),"#0a0");this._countersByName["jsEventListeners"]=this.createCounter(WebI nspector.UIString("Listeners"),WebInspector.UIString("Listeners: %d"),"#00d");if (WebInspector.experimentsSettings.gpuTimeline.isEnabled())
15 {this._memoryCountersPane=memoryCountersPane;this.valueGetter=valueGetter;var co ntainer=memoryCountersPane._memorySidebarView.sidebarElement().createChild("div" ,"memory-counter-sidebar-info");var swatchColor=graphColor;this._swatch=new WebI nspector.SwatchCheckbox(WebInspector.UIString(title),swatchColor);this._swatch.a ddEventListener(WebInspector.SwatchCheckbox.Events.Changed,this._toggleCounterGr aph.bind(this));container.appendChild(this._swatch.element);this._value=null;thi s.graphColor=graphColor;this.strokeColor=graphColor;this.graphYValues=[];} 82 this._countersByName["gpuMemoryUsedKB"]=this.createCounter(WebInspector.UIString ("GPU Memory"),WebInspector.UIString("GPU Memory [KB]: %d"),"#c0c");}
16 WebInspector.CounterUIBase.prototype={_toggleCounterGraph:function(event) 83 WebInspector.MemoryCountersGraph.prototype={addRecord:function(record)
17 {if(this._swatch.checked) 84 {function addStatistics(record)
18 this._value.classList.remove("hidden");else 85 {var counters=record.counters;if(!counters)
19 this._value.classList.add("hidden");this._memoryCountersPane.refresh();},updateC urrentValue:function(countersEntry) 86 return;for(var name in counters){var counter=this._countersByName[name];if(count er)
20 {this._value.textContent=Number.bytesToString(this.valueGetter(countersEntry));} ,clearCurrentValueAndMarker:function(ctx) 87 counter.appendSample(record.endTime||record.startTime,counters[name]);}}
21 {this._value.textContent="";},get visible() 88 WebInspector.TimelineModel.forAllRecords([record],null,addStatistics.bind(this)) ;this.scheduleRefresh();},__proto__:WebInspector.CountersGraph.prototype};WebIns pector.PieChart=function(totalValue,formatter)
22 {return this._swatch.checked;},} 89 {const shadowOffset=0.04;this.element=document.createElementWithClass("div","pie -chart");var svg=this._createSVGChild(this.element,"svg");svg.setAttribute("widt h","100%");svg.setAttribute("height",(100*(1+shadowOffset))+"%");this._group=thi s._createSVGChild(svg,"g");var shadow=this._createSVGChild(this._group,"circle") ;shadow.setAttribute("r",1);shadow.setAttribute("cy",shadowOffset);shadow.setAtt ribute("fill","hsl(0,0%,70%)");var background=this._createSVGChild(this._group," circle");background.setAttribute("r",1);background.setAttribute("fill","hsl(0,0% ,92%)");if(totalValue){var totalString=formatter?formatter(totalValue):totalValu e;this._totalElement=this.element.createChild("div","pie-chart-foreground");this ._totalElement.textContent=totalString;this._totalValue=totalValue;}
23 WebInspector.MemoryStatistics.prototype={_createCurrentValuesBar:function() 90 this._lastAngle=-Math.PI/2;this.setSize(100);}
24 {throw new Error("Not implemented");},_createCounterUIList:function() 91 WebInspector.PieChart.prototype={setTotal:function(value)
25 {throw new Error("Not implemented");},_onRecordsCleared:function() 92 {this._totalValue=value;},setSize:function(value)
26 {this._counters=[];},height:function() 93 {this._group.setAttribute("transform","scale("+(value/2)+") translate(1,1)");var size=value+"px";this.element.style.width=size;this.element.style.height=size;if (this._totalElement)
27 {return this._memorySidebarView.element.offsetHeight;},setSidebarWidth:function( width) 94 this._totalElement.style.lineHeight=size;},addSlice:function(value,color)
28 {this._memorySidebarView.setSidebarWidth(width);},_sidebarResized:function(event ) 95 {var sliceAngle=value/this._totalValue*2*Math.PI;if(!isFinite(sliceAngle))
29 {this.dispatchEventToListeners(WebInspector.TimelineView.Events.SidebarResized,( event.data));this.onResize();},_canvasHeight:function() 96 return;sliceAngle=Math.min(sliceAngle,2*Math.PI*0.9999);var path=this._createSVG Child(this._group,"path");var x1=Math.cos(this._lastAngle);var y1=Math.sin(this. _lastAngle);this._lastAngle+=sliceAngle;var x2=Math.cos(this._lastAngle);var y2= Math.sin(this._lastAngle);var largeArc=sliceAngle>Math.PI?1:0;path.setAttribute( "d","M0,0 L"+x1+","+y1+" A1,1,0,"+largeArc+",1,"+x2+","+y2+" Z");path.setAttribu te("fill",color);},_createSVGChild:function(parent,childType)
30 {throw new Error("Not implemented");},onResize:function() 97 {var child=document.createElementNS("http://www.w3.org/2000/svg",childType);pare nt.appendChild(child);return child;}};WebInspector.TimelineModel=function()
31 {var width=this._canvasContainer.offsetWidth+1;this._canvas.style.width=width+"p x";this._timelineGrid.dividersElement.style.width=width+"px";var parentElement=t his._canvas.parentElement;this._canvas.width=width;this._canvas.height=parentEle ment.clientHeight-15;this.refresh();},_onRecordAdded:function(event) 98 {this._filters=[];this._bindings=new WebInspector.TimelineModel.InterRecordBindi ngs();this.reset();WebInspector.timelineManager.addEventListener(WebInspector.Ti melineManager.EventTypes.TimelineEventRecorded,this._onRecordAdded,this);WebInsp ector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.T imelineStarted,this._onStarted,this);WebInspector.timelineManager.addEventListen er(WebInspector.TimelineManager.EventTypes.TimelineStopped,this._onStopped,this) ;WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.Even tTypes.TimelineProgress,this._onProgress,this);}
32 {throw new Error("Not implemented");},draw:function() 99 WebInspector.TimelineModel.TransferChunkLengthBytes=5000000;WebInspector.Timelin eModel.RecordType={Root:"Root",Program:"Program",EventDispatch:"EventDispatch",G PUTask:"GPUTask",RequestMainThreadFrame:"RequestMainThreadFrame",BeginFrame:"Beg inFrame",ActivateLayerTree:"ActivateLayerTree",DrawFrame:"DrawFrame",ScheduleSty leRecalculation:"ScheduleStyleRecalculation",RecalculateStyles:"RecalculateStyle s",InvalidateLayout:"InvalidateLayout",Layout:"Layout",UpdateLayerTree:"UpdateLa yerTree",AutosizeText:"AutosizeText",PaintSetup:"PaintSetup",Paint:"Paint",Raste rize:"Rasterize",ScrollLayer:"ScrollLayer",DecodeImage:"DecodeImage",ResizeImage :"ResizeImage",CompositeLayers:"CompositeLayers",ParseHTML:"ParseHTML",TimerInst all:"TimerInstall",TimerRemove:"TimerRemove",TimerFire:"TimerFire",XHRReadyState Change:"XHRReadyStateChange",XHRLoad:"XHRLoad",EvaluateScript:"EvaluateScript",M arkLoad:"MarkLoad",MarkDOMContent:"MarkDOMContent",MarkFirstPaint:"MarkFirstPain t",TimeStamp:"TimeStamp",ConsoleTime:"ConsoleTime",ScheduleResourceRequest:"Sche duleResourceRequest",ResourceSendRequest:"ResourceSendRequest",ResourceReceiveRe sponse:"ResourceReceiveResponse",ResourceReceivedData:"ResourceReceivedData",Res ourceFinish:"ResourceFinish",FunctionCall:"FunctionCall",GCEvent:"GCEvent",Reque stAnimationFrame:"RequestAnimationFrame",CancelAnimationFrame:"CancelAnimationFr ame",FireAnimationFrame:"FireAnimationFrame",WebSocketCreate:"WebSocketCreate",W ebSocketSendHandshakeRequest:"WebSocketSendHandshakeRequest",WebSocketReceiveHan dshakeResponse:"WebSocketReceiveHandshakeResponse",WebSocketDestroy:"WebSocketDe stroy",EmbedderCallback:"EmbedderCallback",}
33 {this._calculateVisibleIndexes();this._calculateXValues();this._clear();this._se tVerticalClip(10,this._canvas.height-20);},_calculateVisibleIndexes:function() 100 WebInspector.TimelineModel.Events={RecordAdded:"RecordAdded",RecordsCleared:"Rec ordsCleared",RecordingStarted:"RecordingStarted",RecordingStopped:"RecordingStop ped",RecordingProgress:"RecordingProgress",RecordFilterChanged:"RecordFilterChan ged"}
34 {var calculator=this._timelineView.calculator;var start=calculator.minimumBounda ry()*1000;var end=calculator.maximumBoundary()*1000;function comparator(value,sa mple) 101 WebInspector.TimelineModel.forAllRecords=function(recordsArray,preOrderCallback, postOrderCallback)
35 {return value-sample.time;} 102 {function processRecords(records,depth)
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) 103 {for(var i=0;i<records.length;++i){var record=records[i];if(preOrderCallback&&pr eOrderCallback(record,depth))
37 {var x=event.x-event.target.offsetParent.offsetLeft;var i=this._recordIndexAt(x) ;var counter=this._counters[i];if(counter) 104 return true;if(processRecords(record.children,depth+1))
38 this._timelineView.revealRecordAt(counter.time/1000);},_onMouseOut:function(even t) 105 return true;if(postOrderCallback&&postOrderCallback(record,depth))
39 {delete this._markerXPosition;var ctx=this._canvas.getContext("2d");this._clearC urrentValueAndMarker(ctx);},_clearCurrentValueAndMarker:function(ctx) 106 return true;}
40 {for(var i=0;i<this._counterUI.length;i++) 107 return false;}
41 this._counterUI[i].clearCurrentValueAndMarker(ctx);},_onMouseOver:function(event ) 108 return processRecords(recordsArray,0);}
42 {this._onMouseMove(event);},_onMouseMove:function(event) 109 WebInspector.TimelineModel.prototype={forAllRecords:function(preOrderCallback,po stOrderCallback)
43 {var x=event.x-event.target.offsetParent.offsetLeft 110 {WebInspector.TimelineModel.forAllRecords(this._records,preOrderCallback,postOrd erCallback);},addFilter:function(filter)
44 this._markerXPosition=x;this._refreshCurrentValues();},_refreshCurrentValues:fun ction() 111 {this._filters.push(filter);filter._model=this;},forAllFilteredRecords:function( callback)
45 {if(!this._counters.length) 112 {function processRecord(record,depth)
46 return;if(this._markerXPosition===undefined) 113 {var visible=this.isVisible(record);if(visible){if(callback(record,depth))
47 return;if(this._maximumIndex===-1) 114 return true;}
48 return;var i=this._recordIndexAt(this._markerXPosition);this._updateCurrentValue (this._counters[i]);this._highlightCurrentPositionOnGraphs(this._markerXPosition ,i);},_updateCurrentValue:function(counterEntry) 115 for(var i=0;i<record.children.length;++i){if(processRecord.call(this,record.chil dren[i],visible?depth+1:depth))
49 {for(var j=0;j<this._counterUI.length;j++) 116 return true;}
50 this._counterUI[j].updateCurrentValue(counterEntry);},_recordIndexAt:function(x) 117 return false;}
51 {var i;for(i=this._minimumIndex+1;i<=this._maximumIndex;i++){var statX=this._cou nters[i].x;if(x<statX) 118 for(var i=0;i<this._records.length;++i)
52 break;} 119 processRecord.call(this,this._records[i],0);},isVisible:function(record)
53 i--;return i;},_highlightCurrentPositionOnGraphs:function(x,index) 120 {for(var i=0;i<this._filters.length;++i){if(!this._filters[i].accept(record))
54 {var ctx=this._canvas.getContext("2d");this._restoreImageUnderMarker(ctx);this._ drawMarker(ctx,x,index);},_restoreImageUnderMarker:function(ctx) 121 return false;}
55 {throw new Error("Not implemented");},_drawMarker:function(ctx,x,index) 122 return true;},_filterChanged:function()
56 {throw new Error("Not implemented");},refresh:function() 123 {this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordFilterCha nged);},startRecording:function()
57 {this._timelineGrid.updateDividers(this._timelineView.calculator);this.draw();th is._refreshCurrentValues();},_setVerticalClip:function(originY,height) 124 {this._clientInitiatedRecording=true;this.reset();var maxStackFrames=WebInspecto r.settings.timelineCaptureStacks.get()?30:0;this._bufferEvents=WebInspector.expe rimentsSettings.timelineNoLiveUpdate.isEnabled();var includeGPUEvents=WebInspect or.experimentsSettings.gpuTimeline.isEnabled();var liveEvents=[WebInspector.Time lineModel.RecordType.BeginFrame,WebInspector.TimelineModel.RecordType.DrawFrame, WebInspector.TimelineModel.RecordType.RequestMainThreadFrame,WebInspector.Timeli neModel.RecordType.ActivateLayerTree];var includeCounters=true;WebInspector.time lineManager.start(maxStackFrames,this._bufferEvents,liveEvents.join(","),include Counters,includeGPUEvents,this._fireRecordingStarted.bind(this));},stopRecording :function()
58 {this._originY=originY;this._clippedHeight=height;},_calculateXValues:function() 125 {if(!this._clientInitiatedRecording){WebInspector.timelineManager.start(undefine d,undefined,undefined,undefined,undefined,stopTimeline.bind(this));return;}
59 {if(!this._counters.length)
60 return;var width=this._canvas.width;var xFactor=width/(this._maxTime-this._minTi me);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._counter s[this._maximumIndex].x=width;},_clear:function()
62 {var ctx=this._canvas.getContext("2d");ctx.clearRect(0,0,ctx.canvas.width,ctx.ca nvas.height);this._discardImageUnderMarker();},_discardImageUnderMarker:function ()
63 {throw new Error("Not implemented");},__proto__:WebInspector.View.prototype};Web Inspector.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=memoryCountersP ane._currentValuesBar.createChild("span","memory-counter-value");this._value.sty le.color=color;this._currentValueLabel=currentValueLabel;this.graphColor=color;t his.graphYValues=[];}
68 WebInspector.CountersGraph.Counter=function(time,documentCount,nodeCount,listene rCount,usedGPUMemoryKBytes)
69 {WebInspector.MemoryStatistics.Counter.call(this,time);this.documentCount=docume ntCount;this.nodeCount=nodeCount;this.listenerCount=listenerCount;this.usedGPUMe moryKBytes=usedGPUMemoryKBytes;}
70 WebInspector.CountersGraph.Counter.prototype={__proto__:WebInspector.MemoryStati stics.Counter.prototype}
71 WebInspector.CounterUI.prototype={setRange:function(minValue,maxValue)
72 {this._range.textContent=WebInspector.UIString("[%d:%d]",minValue,maxValue);},up dateCurrentValue:function(countersEntry)
73 {this._value.textContent=WebInspector.UIString(this._currentValueLabel,this.valu eGetter(countersEntry));},clearCurrentValueAndMarker:function(ctx)
74 {this._value.textContent="";this.restoreImageUnderMarker(ctx);},saveImageUnderMa rker:function(ctx,x,y,radius)
75 {const w=radius+1;var imageData=ctx.getImageData(x-w,y-w,2*w,2*w);this._imageUnd erMarker={x:x-w,y:y-w,imageData:imageData};},restoreImageUnderMarker:function(ct x)
76 {if(!this.visible)
77 return;if(this._imageUnderMarker)
78 ctx.putImageData(this._imageUnderMarker.imageData,this._imageUnderMarker.x,this. _imageUnderMarker.y);this.discardImageUnderMarker();},discardImageUnderMarker:fu nction()
79 {delete this._imageUnderMarker;},__proto__:WebInspector.CounterUIBase.prototype}
80 WebInspector.CountersGraph.prototype={_createCurrentValuesBar:function()
81 {this._currentValuesBar=this._canvasContainer.createChild("div");this._currentVa luesBar.id="counter-values-bar";this._canvasContainer.classList.add("dom-counter s");},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","#d0 0",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(e vent)
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.Co untersGraph.Counter(time,counters["documents"],counters["nodes"],counters["jsEve ntListeners"],counters["gpuMemoryUsedKB"]);function compare(record,time)
99 {return record.time-time;}
100 var index=findInsertionLocation(this._counters,time,compare);this._counters.spli ce(index,0,counter);if("gpuMemoryUsedKB"in counters){for(var i=index-1;i>=0&&typ eof this._counters[i].usedGPUMemoryKBytes==="undefined";--i){}
101 var usedGPUMemoryKBytes=this._counters[i>=0?i:index].usedGPUMemoryKBytes;for(i=M ath.max(i,0);i<index;++i)
102 this._counters[i].usedGPUMemoryKBytes=usedGPUMemoryKBytes;var copyFrom=index>0?i ndex-1:index+1;if(copyFrom<this._counters.length){this._counters[index].document Count=this._counters[copyFrom].documentCount;this._counters[index].nodeCount=thi s._counters[copyFrom].nodeCount;this._counters[index].listenerCount=this._counte rs[copyFrom].listenerCount;}else{this._counters[index].documentCount=0;this._cou nters[index].nodeCount=0;this._counters[index].listenerCount=0;}}}
103 WebInspector.TimelinePresentationModel.forAllRecords([event.data],null,addStatis tics.bind(this));},draw:function()
104 {WebInspector.MemoryStatistics.prototype.draw.call(this);for(var i=0;i<this._cou nterUI.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:functio n(ctx,x,index)
108 {const radius=2;for(var i=0;i<this._counterUI.length;i++){var counterUI=this._co unterUI[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._coun terUI.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();}},_dr awGraph: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=counter UI.valueGetter;if(!this._counters.length)
113 return;var maxValue;var minValue;for(var i=this._minimumIndex;i<=this._maximumIn dex;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;v ar maxYRange=maxValue-minValue;var yFactor=maxYRange?height/(maxYRange):1;ctx.sa ve();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._maximumIn dex;i++){var x=Math.round(this._counters[i].x);ctx.lineTo(x,currentY);var curren tValue=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.MemoryStat istics.prototype};WebInspector.PieChart=function(totalValue)
122 {this.element=document.createElement("div");this.element.className="pie-chart";t his.element.createChild("div","pie-chart-background");var totalString=Number.sec ondsToString(totalValue,true);this.element.createChild("div","pie-chart-foregrou nd").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._innerAddSlic e(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");in nerSliceElement.style.backgroundColor=color;innerSliceElement.style.webkitTransf orm="rotate("+Number(sliceAngle).toFixed(2)+"deg)";this._lastAngle+=sliceAngle;} };WebInspector.TimelineModel=function()
128 {this._records=[];this._stringPool=new StringPool();this._minimumRecordTime=-1;t his._maximumRecordTime=-1;WebInspector.timelineManager.addEventListener(WebInspe ctor.TimelineManager.EventTypes.TimelineEventRecorded,this._onRecordAdded,this); WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.Event Types.TimelineStarted,this._onStarted,this);WebInspector.timelineManager.addEven tListener(WebInspector.TimelineManager.EventTypes.TimelineStopped,this._onStoppe d,this);}
129 WebInspector.TimelineModel.TransferChunkLengthBytes=5000000;WebInspector.Timelin eModel.RecordType={Root:"Root",Program:"Program",EventDispatch:"EventDispatch",G PUTask:"GPUTask",BeginFrame:"BeginFrame",ActivateLayerTree:"ActivateLayerTree",S cheduleStyleRecalculation:"ScheduleStyleRecalculation",RecalculateStyles:"Recalc ulateStyles",InvalidateLayout:"InvalidateLayout",Layout:"Layout",AutosizeText:"A utosizeText",PaintSetup:"PaintSetup",Paint:"Paint",Rasterize:"Rasterize",ScrollL ayer:"ScrollLayer",DecodeImage:"DecodeImage",ResizeImage:"ResizeImage",Composite Layers:"CompositeLayers",ParseHTML:"ParseHTML",TimerInstall:"TimerInstall",Timer Remove:"TimerRemove",TimerFire:"TimerFire",XHRReadyStateChange:"XHRReadyStateCha nge",XHRLoad:"XHRLoad",EvaluateScript:"EvaluateScript",MarkLoad:"MarkLoad",MarkD OMContent:"MarkDOMContent",MarkFirstPaint:"MarkFirstPaint",TimeStamp:"TimeStamp" ,Time:"Time",TimeEnd:"TimeEnd",ScheduleResourceRequest:"ScheduleResourceRequest" ,ResourceSendRequest:"ResourceSendRequest",ResourceReceiveResponse:"ResourceRece iveResponse",ResourceReceivedData:"ResourceReceivedData",ResourceFinish:"Resourc eFinish",FunctionCall:"FunctionCall",GCEvent:"GCEvent",RequestAnimationFrame:"Re questAnimationFrame",CancelAnimationFrame:"CancelAnimationFrame",FireAnimationFr ame:"FireAnimationFrame",WebSocketCreate:"WebSocketCreate",WebSocketSendHandshak eRequest:"WebSocketSendHandshakeRequest",WebSocketReceiveHandshakeResponse:"WebS ocketReceiveHandshakeResponse",WebSocketDestroy:"WebSocketDestroy",}
130 WebInspector.TimelineModel.Events={RecordAdded:"RecordAdded",RecordsCleared:"Rec ordsCleared",RecordingStarted:"RecordingStarted",RecordingStopped:"RecordingStop ped"}
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.Timelin eModel.startTimeInSeconds(record);}
137 WebInspector.TimelineModel.aggregateTimeForRecord=function(total,rawRecord)
138 {var childrenTime=0;var children=rawRecord["children"]||[];for(var i=0;i<childre n.length;++i){WebInspector.TimelineModel.aggregateTimeForRecord(total,children[i ]);childrenTime+=WebInspector.TimelineModel.durationInSeconds(children[i]);}
139 var categoryName=WebInspector.TimelinePresentationModel.recordStyle(rawRecord).c ategory.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=WebInspecto r.settings.timelineCaptureStacks.get()?30:0;var includeGPUEvents=WebInspector.ex perimentsSettings.gpuTimeline.isEnabled();WebInspector.timelineManager.start(max StackFrames,includeCounters,includeGPUEvents,this._fireRecordingStarted.bind(thi s));},stopRecording:function()
145 {if(!this._clientInitiatedRecording){WebInspector.timelineManager.start(undefine d,undefined,undefined,stopTimeline.bind(this));return;}
146 function stopTimeline() 126 function stopTimeline()
147 {WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));} 127 {WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));}
148 this._clientInitiatedRecording=false;WebInspector.timelineManager.stop(this._fir eRecordingStopped.bind(this));},get records() 128 this._clientInitiatedRecording=false;WebInspector.timelineManager.stop(this._fir eRecordingStopped.bind(this));},records:function()
149 {return this._records;},_onRecordAdded:function(event) 129 {return this._records;},_onRecordAdded:function(event)
150 {if(this._collectionEnabled) 130 {if(this._collectionEnabled)
151 this._addRecord((event.data));},_onStarted:function(event) 131 this._addRecord((event.data));},_onStarted:function(event)
152 {if(event.data){this._fireRecordingStarted();}},_onStopped:function(event) 132 {if(event.data){this._fireRecordingStarted();}},_onStopped:function(event)
153 {if(event.data){this._fireRecordingStopped();}},_fireRecordingStarted:function() 133 {if(event.data){this._fireRecordingStopped(null);}},_onProgress:function(event)
154 {this._collectionEnabled=true;this.dispatchEventToListeners(WebInspector.Timelin eModel.Events.RecordingStarted);},_fireRecordingStopped:function() 134 {this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingProgre ss,event.data);},_fireRecordingStarted:function()
155 {this._collectionEnabled=false;this.dispatchEventToListeners(WebInspector.Timeli neModel.Events.RecordingStopped);},_addRecord:function(record) 135 {this._collectionEnabled=true;this.dispatchEventToListeners(WebInspector.Timelin eModel.Events.RecordingStarted);},_fireRecordingStopped:function(error,events)
156 {this._stringPool.internObjectStrings(record);this._records.push(record);this._u pdateBoundaries(record);this.dispatchEventToListeners(WebInspector.TimelineModel .Events.RecordAdded,record);},loadFromFile:function(file,progress) 136 {this._bufferEvents=false;this._collectionEnabled=false;if(events&&events.length ){this.reset();for(var i=0;i<events.length;++i)
137 this._addRecord(events[i]);}
138 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped );},bufferEvents:function()
139 {return this._bufferEvents;},_addRecord:function(payload)
140 {this._internStrings(payload);this._payloads.push(payload);this._updateBoundarie s(payload);var record=this._innerAddRecord(payload,null);this._records.push(reco rd);if(record.type===WebInspector.TimelineModel.RecordType.Program)
141 this._mainThreadTasks.push(record);if(record.type===WebInspector.TimelineModel.R ecordType.GPUTask)
142 this._gpuThreadTasks.push(record);this.dispatchEventToListeners(WebInspector.Tim elineModel.Events.RecordAdded,record);},_innerAddRecord:function(payload,parentR ecord)
143 {var record=new WebInspector.TimelineModel.Record(this,payload,parentRecord);if( WebInspector.TimelineUIUtils.isEventDivider(record))
144 this._eventDividerRecords.push(record);for(var i=0;payload.children&&i<payload.c hildren.length;++i)
145 this._innerAddRecord.call(this,payload.children[i],record);record.calculateAggre gatedStats();if(parentRecord)
146 parentRecord._selfTime-=record.endTime-record.startTime;return record;},loadFrom File: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);},loadFr omURL:function(url,progress) 147 {var delegate=new WebInspector.TimelineModelLoadFromFileDelegate(this,progress); var fileReader=this._createFileReader(file,delegate);var loader=new WebInspector .TimelineModelLoader(this,fileReader,progress);fileReader.start(loader);},loadFr omURL:function(url,progress)
158 {var delegate=new WebInspector.TimelineModelLoadFromFileDelegate(this,progress); var urlReader=new WebInspector.ChunkedXHRReader(url,delegate);var loader=new Web Inspector.TimelineModelLoader(this,urlReader,progress);urlReader.start(loader);} ,_createFileReader:function(file,delegate) 148 {var delegate=new WebInspector.TimelineModelLoadFromFileDelegate(this,progress); var urlReader=new WebInspector.ChunkedXHRReader(url,delegate);var loader=new Web Inspector.TimelineModelLoader(this,urlReader,progress);urlReader.start(loader);} ,_createFileReader:function(file,delegate)
159 {return new WebInspector.ChunkedFileReader(file,WebInspector.TimelineModel.Trans ferChunkLengthBytes,delegate);},_createFileWriter:function() 149 {return new WebInspector.ChunkedFileReader(file,WebInspector.TimelineModel.Trans ferChunkLengthBytes,delegate);},_createFileWriter:function()
160 {return new WebInspector.FileOutputStream();},saveToFile:function() 150 {return new WebInspector.FileOutputStream();},saveToFile:function()
161 {var now=new Date();var fileName="TimelineRawData-"+now.toISO8601Compact()+".jso n";var stream=this._createFileWriter();function callback(accepted) 151 {var now=new Date();var fileName="TimelineRawData-"+now.toISO8601Compact()+".jso n";var stream=this._createFileWriter();function callback(accepted)
162 {if(!accepted) 152 {if(!accepted)
163 return;var saver=new WebInspector.TimelineSaver(stream);saver.save(this._records ,window.navigator.appVersion);} 153 return;var saver=new WebInspector.TimelineSaver(stream);saver.save(this._payload s,window.navigator.appVersion);}
164 stream.open(fileName,callback.bind(this));},reset:function() 154 stream.open(fileName,callback.bind(this));},reset:function()
165 {this._records=[];this._stringPool.reset();this._minimumRecordTime=-1;this._maxi mumRecordTime=-1;this.dispatchEventToListeners(WebInspector.TimelineModel.Events .RecordsCleared);},minimumRecordTime:function() 155 {this._records=[];this._payloads=[];this._stringPool={};this._minimumRecordTime= -1;this._maximumRecordTime=-1;this._bindings._reset();this._mainThreadTasks=[];t his._gpuThreadTasks=[];this._eventDividerRecords=[];this.dispatchEventToListener s(WebInspector.TimelineModel.Events.RecordsCleared);},minimumRecordTime:function ()
166 {return this._minimumRecordTime;},maximumRecordTime:function() 156 {return this._minimumRecordTime;},maximumRecordTime:function()
167 {return this._maximumRecordTime;},_updateBoundaries:function(record) 157 {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) 158 {var startTime=record.startTime;var endTime=record.endTime;if(this._minimumRecor dTime===-1||startTime<this._minimumRecordTime)
169 this._minimumRecordTime=startTime;if(this._maximumRecordTime===-1||endTime>this. _maximumRecordTime) 159 this._minimumRecordTime=startTime;if((this._maximumRecordTime===-1&&endTime)||en dTime>this._maximumRecordTime)
170 this._maximumRecordTime=endTime;},recordOffsetInSeconds:function(rawRecord) 160 this._maximumRecordTime=endTime;},mainThreadTasks:function()
171 {return WebInspector.TimelineModel.startTimeInSeconds(rawRecord)-this._minimumRe cordTime;},__proto__:WebInspector.Object.prototype} 161 {return this._mainThreadTasks;},gpuThreadTasks:function()
162 {return this._gpuThreadTasks;},eventDividerRecords:function()
163 {return this._eventDividerRecords;},_internStrings:function(record)
164 {for(var name in record){var value=record[name];if(typeof value!=="string")
165 continue;var interned=this._stringPool[value];if(typeof interned==="string")
166 record[name]=interned;else
167 this._stringPool[value]=value;}
168 var children=record.children;for(var i=0;children&&i<children.length;++i)
169 this._internStrings(children[i]);},__proto__:WebInspector.Object.prototype}
170 WebInspector.TimelineModel.InterRecordBindings=function(){this._reset();}
171 WebInspector.TimelineModel.InterRecordBindings.prototype={_reset:function()
172 {this._sendRequestRecords={};this._timerRecords={};this._requestAnimationFrameRe cords={};this._layoutInvalidateStack={};this._lastScheduleStyleRecalculation={}; this._webSocketCreateRecords={};}}
173 WebInspector.TimelineModel.Record=function(model,record,parentRecord)
174 {this._model=model;var bindings=this._model._bindings;this._aggregatedStats={};t his._record=record;this._children=[];if(parentRecord){this.parent=parentRecord;p arentRecord.children.push(this);}
175 this._selfTime=this.endTime-this.startTime;this._lastChildEndTime=this.endTime;t his._startTimeOffset=this.startTime-model.minimumRecordTime();if(record.data){if (record.data["url"])
176 this.url=record.data["url"];if(record.data["rootNode"])
177 this._relatedBackendNodeId=record.data["rootNode"];else if(record.data["elementI d"])
178 this._relatedBackendNodeId=record.data["elementId"];if(record.data["scriptName"] ){this.scriptName=record.data["scriptName"];this.scriptLine=record.data["scriptL ine"];}}
179 if(parentRecord&&parentRecord.callSiteStackTrace)
180 this.callSiteStackTrace=parentRecord.callSiteStackTrace;var recordTypes=WebInspe ctor.TimelineModel.RecordType;switch(record.type){case recordTypes.ResourceSendR equest:bindings._sendRequestRecords[record.data["requestId"]]=this;break;case re cordTypes.ResourceReceiveResponse:var sendRequestRecord=bindings._sendRequestRec ords[record.data["requestId"]];if(sendRequestRecord)
181 this.url=sendRequestRecord.url;break;case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:var sendRequestRecord=bindings._sendRequestRecords[re cord.data["requestId"]];if(sendRequestRecord)
182 this.url=sendRequestRecord.url;break;case recordTypes.TimerInstall:this.timeout= record.data["timeout"];this.singleShot=record.data["singleShot"];bindings._timer Records[record.data["timerId"]]=this;break;case recordTypes.TimerFire:var timerI nstalledRecord=bindings._timerRecords[record.data["timerId"]];if(timerInstalledR ecord){this.callSiteStackTrace=timerInstalledRecord.stackTrace;this.timeout=time rInstalledRecord.timeout;this.singleShot=timerInstalledRecord.singleShot;}
183 break;case recordTypes.RequestAnimationFrame:bindings._requestAnimationFrameReco rds[record.data["id"]]=this;break;case recordTypes.FireAnimationFrame:var reques tAnimationRecord=bindings._requestAnimationFrameRecords[record.data["id"]];if(re questAnimationRecord)
184 this.callSiteStackTrace=requestAnimationRecord.stackTrace;break;case recordTypes .ConsoleTime:var message=record.data["message"];break;case recordTypes.ScheduleS tyleRecalculation:bindings._lastScheduleStyleRecalculation[this.frameId]=this;br eak;case recordTypes.RecalculateStyles:var scheduleStyleRecalculationRecord=bind ings._lastScheduleStyleRecalculation[this.frameId];if(!scheduleStyleRecalculatio nRecord)
185 break;this.callSiteStackTrace=scheduleStyleRecalculationRecord.stackTrace;break; case recordTypes.InvalidateLayout:var styleRecalcStack;if(!bindings._layoutInval idateStack[this.frameId]){if(parentRecord.type===recordTypes.RecalculateStyles)
186 styleRecalcStack=parentRecord.callSiteStackTrace;}
187 bindings._layoutInvalidateStack[this.frameId]=styleRecalcStack||this.stackTrace; break;case recordTypes.Layout:var layoutInvalidateStack=bindings._layoutInvalida teStack[this.frameId];if(layoutInvalidateStack)
188 this.callSiteStackTrace=layoutInvalidateStack;if(this.stackTrace)
189 this.addWarning(WebInspector.UIString("Forced synchronous layout is a possible p erformance bottleneck."));bindings._layoutInvalidateStack[this.frameId]=null;thi s.highlightQuad=record.data.root||WebInspector.TimelineModel._quadFromRectData(r ecord.data);this._relatedBackendNodeId=record.data["rootNode"];break;case record Types.AutosizeText:if(record.data.needsRelayout&&parentRecord.type===recordTypes .Layout)
190 parentRecord.addWarning(WebInspector.UIString("Layout required two passes due to text autosizing, consider setting viewport."));break;case recordTypes.Paint:thi s.highlightQuad=record.data.clip||WebInspector.TimelineModel._quadFromRectData(r ecord.data);break;case recordTypes.WebSocketCreate:this.webSocketURL=record.data ["url"];if(typeof record.data["webSocketProtocol"]!=="undefined")
191 this.webSocketProtocol=record.data["webSocketProtocol"];bindings._webSocketCreat eRecords[record.data["identifier"]]=this;break;case recordTypes.WebSocketSendHan dshakeRequest:case recordTypes.WebSocketReceiveHandshakeResponse:case recordType s.WebSocketDestroy:var webSocketCreateRecord=bindings._webSocketCreateRecords[re cord.data["identifier"]];if(webSocketCreateRecord){this.webSocketURL=webSocketCr eateRecord.webSocketURL;if(typeof webSocketCreateRecord.webSocketProtocol!=="und efined")
192 this.webSocketProtocol=webSocketCreateRecord.webSocketProtocol;}
193 break;case recordTypes.EmbedderCallback:this.embedderCallbackName=record.data["c allbackName"];break;}}
194 WebInspector.TimelineModel.Record.prototype={get lastChildEndTime()
195 {return this._lastChildEndTime;},set lastChildEndTime(time)
196 {this._lastChildEndTime=time;},get selfTime()
197 {return this._selfTime;},get cpuTime()
198 {return this._cpuTime;},isRoot:function()
199 {return this.type===WebInspector.TimelineModel.RecordType.Root;},get children()
200 {return this._children;},get category()
201 {return WebInspector.TimelineUIUtils.categoryForRecord(this);},title:function()
202 {return WebInspector.TimelineUIUtils.recordTitle(this);},get startTime()
203 {return this._startTime||this._record.startTime;},set startTime(startTime)
204 {this._startTime=startTime;},get thread()
205 {return this._record.thread;},get startTimeOffset()
206 {return this._startTimeOffset;},get endTime()
207 {return this._endTime||this._record.endTime||this._record.startTime;},set endTim e(endTime)
208 {this._endTime=endTime;},get data()
209 {return this._record.data;},get type()
210 {return this._record.type;},get frameId()
211 {return this._record.frameId||"";},get usedHeapSizeDelta()
212 {return this._record.usedHeapSizeDelta||0;},get jsHeapSizeUsed()
213 {return this._record.counters?this._record.counters.jsHeapSizeUsed||0:0;},get co unters()
214 {return this._record.counters;},get stackTrace()
215 {if(this._record.stackTrace&&this._record.stackTrace.length)
216 return this._record.stackTrace;return null;},getUserObject:function(key)
217 {if(!this._userObjects)
218 return null;return this._userObjects.get(key);},setUserObject:function(key,value )
219 {if(!this._userObjects)
220 this._userObjects=new StringMap();this._userObjects.put(key,value);},relatedBack endNodeId:function()
221 {return this._relatedBackendNodeId;},calculateAggregatedStats:function()
222 {this._aggregatedStats={};this._cpuTime=this._selfTime;for(var index=this._child ren.length;index;--index){var child=this._children[index-1];for(var category in child._aggregatedStats)
223 this._aggregatedStats[category]=(this._aggregatedStats[category]||0)+child._aggr egatedStats[category];}
224 for(var category in this._aggregatedStats)
225 this._cpuTime+=this._aggregatedStats[category];this._aggregatedStats[this.catego ry.name]=(this._aggregatedStats[this.category.name]||0)+this._selfTime;},get agg regatedStats()
226 {return this._aggregatedStats;},addWarning:function(message)
227 {if(this._warnings)
228 this._warnings.push(message);else{this._warnings=[message];for(var parent=this.p arent;parent&&!parent._childHasWarnings;parent=parent.parent)
229 parent._childHasWarnings=true;}},warnings:function()
230 {return this._warnings;},childHasWarnings:function()
231 {return!!this._childHasWarnings;},testContentMatching:function(regExp)
232 {var tokens=[this.title()];for(var key in this._record.data)
233 tokens.push(this._record.data[key])
234 return regExp.test(tokens.join("|"));}}
235 WebInspector.TimelineModel.Filter=function()
236 {this._model;}
237 WebInspector.TimelineModel.Filter.prototype={accept:function(record)
238 {return true;},notifyFilterChanged:function()
239 {this._model._filterChanged();}}
172 WebInspector.TimelineModelLoader=function(model,reader,progress) 240 WebInspector.TimelineModelLoader=function(model,reader,progress)
173 {this._model=model;this._reader=reader;this._progress=progress;this._buffer="";t his._firstChunk=true;} 241 {this._model=model;this._reader=reader;this._progress=progress;this._buffer="";t his._firstChunk=true;}
174 WebInspector.TimelineModelLoader.prototype={write:function(chunk) 242 WebInspector.TimelineModelLoader.prototype={write:function(chunk)
175 {var data=this._buffer+chunk;var lastIndex=0;var index;do{index=lastIndex;lastIn dex=WebInspector.TextUtils.findBalancedCurlyBrackets(data,index);}while(lastInde x!==-1) 243 {var data=this._buffer+chunk;var lastIndex=0;var index;do{index=lastIndex;lastIn dex=WebInspector.TextUtils.findBalancedCurlyBrackets(data,index);}while(lastInde x!==-1)
176 var json=data.slice(0,index)+"]";this._buffer=data.slice(index);if(!index) 244 var json=data.slice(0,index)+"]";this._buffer=data.slice(index);if(!index)
177 return;if(!this._firstChunk) 245 return;if(!this._firstChunk)
178 json="[0"+json;var items;try{items=(JSON.parse(json));}catch(e){WebInspector.sho wErrorMessage("Malformed timeline data.");this._model.reset();this._reader.cance l();this._progress.done();return;} 246 json="[0"+json;var items;try{items=(JSON.parse(json));}catch(e){WebInspector.con sole.showErrorMessage("Malformed timeline data.");this._model.reset();this._read er.cancel();this._progress.done();return;}
179 if(this._firstChunk){this._version=items[0];this._firstChunk=false;this._model.r eset();} 247 if(this._firstChunk){this._version=items[0];this._firstChunk=false;this._model.r eset();}
180 for(var i=1,size=items.length;i<size;++i) 248 for(var i=1,size=items.length;i<size;++i)
181 this._model._addRecord(items[i]);},close:function(){}} 249 this._model._addRecord(items[i]);},close:function(){}}
182 WebInspector.TimelineModelLoadFromFileDelegate=function(model,progress) 250 WebInspector.TimelineModelLoadFromFileDelegate=function(model,progress)
183 {this._model=model;this._progress=progress;} 251 {this._model=model;this._progress=progress;}
184 WebInspector.TimelineModelLoadFromFileDelegate.prototype={onTransferStarted:func tion() 252 WebInspector.TimelineModelLoadFromFileDelegate.prototype={onTransferStarted:func tion()
185 {this._progress.setTitle(WebInspector.UIString("Loading\u2026"));},onChunkTransf erred:function(reader) 253 {this._progress.setTitle(WebInspector.UIString("Loading\u2026"));},onChunkTransf erred:function(reader)
186 {if(this._progress.isCanceled()){reader.cancel();this._progress.done();this._mod el.reset();return;} 254 {if(this._progress.isCanceled()){reader.cancel();this._progress.done();this._mod el.reset();return;}
187 var totalSize=reader.fileSize();if(totalSize){this._progress.setTotalWork(totalS ize);this._progress.setWorked(reader.loadedSize());}},onTransferFinished:functio n() 255 var totalSize=reader.fileSize();if(totalSize){this._progress.setTotalWork(totalS ize);this._progress.setWorked(reader.loadedSize());}},onTransferFinished:functio n()
188 {this._progress.done();},onError:function(reader,event) 256 {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("Fil e \"%s\" not found.",reader.fileName()));break;case FileError.NOT_READABLE_ERR:W ebInspector.showErrorMessage(WebInspector.UIString("File \"%s\" is not readable" ,reader.fileName()));break;case FileError.ABORT_ERR:break;default:WebInspector.s howErrorMessage(WebInspector.UIString("An error occurred while reading the file \"%s\"",reader.fileName()));}}} 257 {this._progress.done();this._model.reset();switch(event.target.error.code){case FileError.NOT_FOUND_ERR:WebInspector.console.showErrorMessage(WebInspector.UIStr ing("File \"%s\" not found.",reader.fileName()));break;case FileError.NOT_READAB LE_ERR:WebInspector.console.showErrorMessage(WebInspector.UIString("File \"%s\" is not readable",reader.fileName()));break;case FileError.ABORT_ERR:break;defaul t:WebInspector.console.showErrorMessage(WebInspector.UIString("An error occurred while reading the file \"%s\"",reader.fileName()));}}}
190 WebInspector.TimelineSaver=function(stream) 258 WebInspector.TimelineSaver=function(stream)
191 {this._stream=stream;} 259 {this._stream=stream;}
192 WebInspector.TimelineSaver.prototype={save:function(records,version) 260 WebInspector.TimelineSaver.prototype={save:function(payloads,version)
193 {this._records=records;this._recordIndex=0;this._prologue="["+JSON.stringify(ver sion);this._writeNextChunk(this._stream);},_writeNextChunk:function(stream) 261 {this._payloads=payloads;this._recordIndex=0;this._prologue="["+JSON.stringify(v ersion);this._writeNextChunk(this._stream);},_writeNextChunk:function(stream)
194 {const separator=",\n";var data=[];var length=0;if(this._prologue){data.push(thi s._prologue);length+=this._prologue.length;delete this._prologue;}else{if(this._ recordIndex===this._records.length){stream.close();return;} 262 {const separator=",\n";var data=[];var length=0;if(this._prologue){data.push(thi s._prologue);length+=this._prologue.length;delete this._prologue;}else{if(this._ recordIndex===this._payloads.length){stream.close();return;}
195 data.push("");} 263 data.push("");}
196 while(this._recordIndex<this._records.length){var item=JSON.stringify(this._reco rds[this._recordIndex]);var itemLength=item.length+separator.length;if(length+it emLength>WebInspector.TimelineModel.TransferChunkLengthBytes) 264 while(this._recordIndex<this._payloads.length){var item=JSON.stringify(this._pay loads[this._recordIndex]);var itemLength=item.length+separator.length;if(length+ itemLength>WebInspector.TimelineModel.TransferChunkLengthBytes)
197 break;length+=itemLength;data.push(item);++this._recordIndex;} 265 break;length+=itemLength;data.push(item);++this._recordIndex;}
198 if(this._recordIndex===this._records.length) 266 if(this._recordIndex===this._payloads.length)
199 data.push(data.pop()+"]");stream.write(data.join(separator),this._writeNextChunk .bind(this));}};WebInspector.TimelineOverviewPane=function(model) 267 data.push(data.pop()+"]");stream.write(data.join(separator),this._writeNextChunk .bind(this));}}
200 {WebInspector.View.call(this);this.element.id="timeline-overview-pane";this._eve ntDividers=[];this._model=model;this._overviewGrid=new WebInspector.OverviewGrid ("timeline");this.element.appendChild(this._overviewGrid.element);this._overview Calculator=new WebInspector.TimelineOverviewCalculator();model.addEventListener( WebInspector.TimelineModel.Events.RecordAdded,this._onRecordAdded,this);model.ad dEventListener(WebInspector.TimelineModel.Events.RecordsCleared,this._reset,this );this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowCha nged,this._onWindowChanged,this);} 268 WebInspector.TimelineMergingRecordBuffer=function()
269 {this._backgroundRecordsBuffer=[];}
270 WebInspector.TimelineMergingRecordBuffer.prototype={process:function(thread,reco rds)
271 {if(thread){this._backgroundRecordsBuffer=this._backgroundRecordsBuffer.concat(r ecords);return[];}
272 function recordTimestampComparator(a,b)
273 {return a.startTime<b.startTime?-1:1;}
274 var result=this._backgroundRecordsBuffer.mergeOrdered(records,recordTimestampCom parator);this._backgroundRecordsBuffer=[];return result;}}
275 WebInspector.TimelineModel._quadFromRectData=function(data)
276 {if(typeof data["x"]==="undefined"||typeof data["y"]==="undefined")
277 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];};WebInspector.Time lineOverviewPane=function(model)
278 {WebInspector.VBox.call(this);this.element.id="timeline-overview-pane";this._eve ntDividers=[];this._model=model;this._overviewGrid=new WebInspector.OverviewGrid ("timeline");this.element.appendChild(this._overviewGrid.element);this._overview Calculator=new WebInspector.TimelineOverviewCalculator();model.addEventListener( WebInspector.TimelineModel.Events.RecordsCleared,this._reset,this);this._overvie wGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWi ndowChanged,this);}
201 WebInspector.TimelineOverviewPane.Events={WindowChanged:"WindowChanged"};WebInsp ector.TimelineOverviewPane.prototype={wasShown:function() 279 WebInspector.TimelineOverviewPane.Events={WindowChanged:"WindowChanged"};WebInsp ector.TimelineOverviewPane.prototype={wasShown:function()
202 {this._update();},onResize:function() 280 {this._update();},onResize:function()
203 {this._update();},setOverviewControl:function(overviewControl) 281 {this._update();},setOverviewControl:function(overviewControl)
204 {if(this._overviewControl===overviewControl) 282 {if(this._overviewControl===overviewControl)
205 return;if(this._overviewControl) 283 return;var windowTimes=null;if(this._overviewControl){windowTimes=this._overview Control.windowTimes(this._overviewGrid.windowLeft(),this._overviewGrid.windowRig ht());this._overviewControl.detach();}
206 this._overviewControl.detach();this._overviewControl=overviewControl;this._overv iewControl.show(this._overviewGrid.element);this._update();},_update:function() 284 this._overviewControl=overviewControl;this._overviewControl.show(this._overviewG rid.element);this._update();if(windowTimes)
207 {delete this._refreshTimeout;this._overviewCalculator.setWindow(this._model.mini mumRecordTime(),this._model.maximumRecordTime());this._overviewCalculator.setDis playWindow(0,this._overviewGrid.clientWidth());if(this._overviewControl) 285 this.requestWindowTimes(windowTimes.startTime,windowTimes.endTime);},_update:fun ction()
208 this._overviewControl.update();this._overviewGrid.updateDividers(this._overviewC alculator);this._updateEventDividers();},_updateEventDividers:function() 286 {delete this._refreshTimeout;this._overviewCalculator._setWindow(this._model.min imumRecordTime(),this._model.maximumRecordTime());this._overviewCalculator._setD isplayWindow(0,this._overviewGrid.clientWidth());if(this._overviewControl)
287 this._overviewControl.update();this._overviewGrid.updateDividers(this._overviewC alculator);this._updateEventDividers();this._updateWindow();},_updateEventDivide rs:function()
209 {var records=this._eventDividers;this._overviewGrid.removeEventDividers();var di viders=[];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]) 288 {var records=this._eventDividers;this._overviewGrid.removeEventDividers();var di viders=[];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(r ecord.type);divider.style.left=positions.start+"%";dividers[dividerPosition]=div ider;} 289 continue;var divider=WebInspector.TimelineUIUtils.createEventDivider(record.type );divider.style.left=positions.start+"%";dividers[dividerPosition]=divider;}
211 this._overviewGrid.addEventDividers(dividers);},_onRecordAdded:function(event) 290 this._overviewGrid.addEventDividers(dividers);},addRecord:function(record)
212 {var record=event.data;var eventDividers=this._eventDividers;function addEventDi viders(record) 291 {var eventDividers=this._eventDividers;function addEventDividers(record)
213 {if(WebInspector.TimelinePresentationModel.isEventDivider(record)) 292 {if(WebInspector.TimelineUIUtils.isEventDivider(record))
214 eventDividers.push(record);} 293 eventDividers.push(record);}
215 WebInspector.TimelinePresentationModel.forAllRecords([record],addEventDividers); this._scheduleRefresh();},_reset:function() 294 WebInspector.TimelineModel.forAllRecords([record],addEventDividers);this._schedu leRefresh();},_reset:function()
216 {this._overviewCalculator.reset();this._overviewGrid.reset();this._overviewGrid. setResizeEnabled(false);this._eventDividers=[];this._overviewGrid.updateDividers (this._overviewCalculator);if(this._overviewControl) 295 {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() 296 this._overviewControl.reset();this._update();},_onWindowChanged:function(event)
218 {return this._overviewGrid.windowLeft();},windowRight:function() 297 {if(this._muteOnWindowChanged)
219 {return this._overviewGrid.windowRight();},_onWindowChanged:function() 298 return;var windowTimes=this._overviewControl.windowTimes(this._overviewGrid.wind owLeft(),this._overviewGrid.windowRight());this._windowStartTime=windowTimes.sta rtTime;this._windowEndTime=windowTimes.endTime;this.dispatchEventToListeners(Web Inspector.TimelineOverviewPane.Events.WindowChanged,windowTimes);},requestWindow Times:function(startTime,endTime)
220 {if(this._ignoreWindowChangedEvent) 299 {if(startTime===this._windowStartTime&&endTime===this._windowEndTime)
221 return;this.dispatchEventToListeners(WebInspector.TimelineOverviewPane.Events.Wi ndowChanged);},setWindow:function(left,right) 300 return;this._windowStartTime=startTime;this._windowEndTime=endTime;this._updateW indow();this.dispatchEventToListeners(WebInspector.TimelineOverviewPane.Events.W indowChanged,{startTime:startTime,endTime:endTime});},_updateWindow:function()
222 {this._ignoreWindowChangedEvent=true;this._overviewGrid.setWindow(left,right);th is._overviewGrid.setResizeEnabled(this._model.records.length);this._ignoreWindow ChangedEvent=false;},_scheduleRefresh:function() 301 {var windowBoundaries=this._overviewControl.windowBoundaries(this._windowStartTi me,this._windowEndTime);this._muteOnWindowChanged=true;this._overviewGrid.setWin dow(windowBoundaries.left,windowBoundaries.right);this._overviewGrid.setResizeEn abled(!!this._model.records().length);this._muteOnWindowChanged=false;},_schedul eRefresh:function()
223 {if(this._refreshTimeout) 302 {if(this._refreshTimeout)
224 return;if(!this.isShowing()) 303 return;if(!this.isShowing())
225 return;this._refreshTimeout=setTimeout(this._update.bind(this),300);},__proto__: WebInspector.View.prototype} 304 return;this._refreshTimeout=setTimeout(this._update.bind(this),300);},__proto__: WebInspector.VBox.prototype}
226 WebInspector.TimelineOverviewCalculator=function() 305 WebInspector.TimelineOverviewCalculator=function()
227 {} 306 {}
228 WebInspector.TimelineOverviewCalculator.prototype={computePosition:function(time ) 307 WebInspector.TimelineOverviewCalculator.prototype={paddingLeft:function()
229 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this.p addingLeft;},computeBarGraphPercentages:function(record) 308 {return this._paddingLeft;},computePosition:function(time)
230 {var start=(WebInspector.TimelineModel.startTimeInSeconds(record)-this._minimumB oundary)/this.boundarySpan()*100;var end=(WebInspector.TimelineModel.endTimeInSe conds(record)-this._minimumBoundary)/this.boundarySpan()*100;return{start:start, end:end};},setWindow:function(minimum,maximum) 309 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this._ paddingLeft;},computeBarGraphPercentages:function(record)
231 {this._minimumBoundary=minimum>=0?minimum:undefined;this._maximumBoundary=maximu m>=0?maximum:undefined;},setDisplayWindow:function(paddingLeft,clientWidth) 310 {var start=(record.startTime-this._minimumBoundary)/this.boundarySpan()*100;var end=(record.endTime-this._minimumBoundary)/this.boundarySpan()*100;return{start: start,end:end};},_setWindow:function(minimumRecordTime,maximumRecordTime)
232 {this._workingArea=clientWidth-paddingLeft;this.paddingLeft=paddingLeft;},reset: function() 311 {this._minimumBoundary=minimumRecordTime;this._maximumBoundary=maximumRecordTime ;},_setDisplayWindow:function(paddingLeft,clientWidth)
233 {this.setWindow();},formatTime:function(value,hires) 312 {this._workingArea=clientWidth-paddingLeft;this._paddingLeft=paddingLeft;},reset :function()
234 {return Number.secondsToString(value,hires);},maximumBoundary:function() 313 {this._setWindow(0,1000);},formatTime:function(value,precision)
314 {return Number.preciseMillisToString(value-this.zeroTime(),precision);},maximumB oundary:function()
235 {return this._maximumBoundary;},minimumBoundary:function() 315 {return this._maximumBoundary;},minimumBoundary:function()
236 {return this._minimumBoundary;},zeroTime:function() 316 {return this._minimumBoundary;},zeroTime:function()
237 {return this._minimumBoundary;},boundarySpan:function() 317 {return this._minimumBoundary;},boundarySpan:function()
238 {return this._maximumBoundary-this._minimumBoundary;}} 318 {return this._maximumBoundary-this._minimumBoundary;}}
319 WebInspector.TimelineOverview=function(model)
320 {}
321 WebInspector.TimelineOverview.prototype={show:function(parentElement,insertBefor e){},update:function(){},reset:function(){},windowTimes:function(windowLeft,wind owRight){},windowBoundaries:function(startTime,endTime){}}
239 WebInspector.TimelineOverviewBase=function(model) 322 WebInspector.TimelineOverviewBase=function(model)
240 {WebInspector.View.call(this);this.element.classList.add("fill");this._model=mod el;this._canvas=this.element.createChild("canvas","fill");this._context=this._ca nvas.getContext("2d");} 323 {WebInspector.VBox.call(this);this._model=model;this._canvas=this.element.create Child("canvas","fill");this._context=this._canvas.getContext("2d");}
241 WebInspector.TimelineOverviewBase.prototype={update:function(){},reset:function( ){},windowTimes:function(windowLeft,windowRight) 324 WebInspector.TimelineOverviewBase.prototype={update:function()
325 {this.resetCanvas();},reset:function()
326 {},timelineStarted:function(){},timelineStopped:function(){},windowTimes:functio n(windowLeft,windowRight)
242 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximu mRecordTime()-absoluteMin;return{startTime:absoluteMin+timeSpan*windowLeft,endTi me:absoluteMin+timeSpan*windowRight};},windowBoundaries:function(startTime,endTi me) 327 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximu mRecordTime()-absoluteMin;return{startTime:absoluteMin+timeSpan*windowLeft,endTi me:absoluteMin+timeSpan*windowRight};},windowBoundaries:function(startTime,endTi me)
243 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximu mRecordTime()-absoluteMin;var haveRecords=absoluteMin>=0;return{left:haveRecords &&startTime?Math.min((startTime-absoluteMin)/timeSpan,1):0,right:haveRecords&&en dTime<Infinity?(endTime-absoluteMin)/timeSpan:1}},resetCanvas:function() 328 {var absoluteMin=this._model.minimumRecordTime();var timeSpan=this._model.maximu mRecordTime()-absoluteMin;var haveRecords=absoluteMin>=0;return{left:haveRecords &&startTime?Math.min((startTime-absoluteMin)/timeSpan,1):0,right:haveRecords&&en dTime<Infinity?(endTime-absoluteMin)/timeSpan:1}},resetCanvas:function()
244 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canva s.height=this.element.clientHeight*window.devicePixelRatio;},__proto__:WebInspec tor.View.prototype};WebInspector.TimelinePresentationModel=function() 329 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canva s.height=this.element.clientHeight*window.devicePixelRatio;},__proto__:WebInspec tor.VBox.prototype};WebInspector.TimelinePresentationModel=function(model)
245 {this._linkifier=new WebInspector.Linkifier();this._glueRecords=false;this._filt ers=[];this.reset();} 330 {this._model=model;this._filters=[];this._recordToPresentationRecord=new Map();t his.reset();}
246 WebInspector.TimelinePresentationModel.categories=function() 331 WebInspector.TimelinePresentationModel._coalescingRecords={};WebInspector.Timeli nePresentationModel._coalescingRecords[WebInspector.TimelineModel.RecordType.Lay out]=1;WebInspector.TimelinePresentationModel._coalescingRecords[WebInspector.Ti melineModel.RecordType.Paint]=1;WebInspector.TimelinePresentationModel._coalesci ngRecords[WebInspector.TimelineModel.RecordType.Rasterize]=1;WebInspector.Timeli nePresentationModel._coalescingRecords[WebInspector.TimelineModel.RecordType.Dec odeImage]=1;WebInspector.TimelinePresentationModel._coalescingRecords[WebInspect or.TimelineModel.RecordType.ResizeImage]=1;WebInspector.TimelinePresentationMode l.prototype={setWindowTimes:function(startTime,endTime)
247 {if(WebInspector.TimelinePresentationModel._categories) 332 {this._windowStartTime=startTime;this._windowEndTime=endTime;},toPresentationRec ord:function(record)
248 return WebInspector.TimelinePresentationModel._categories;WebInspector.TimelineP resentationModel._categories={loading:new WebInspector.TimelineCategory("loading ",WebInspector.UIString("Loading"),0,"#5A8BCC","#8EB6E9","#70A2E3"),scripting:ne w WebInspector.TimelineCategory("scripting",WebInspector.UIString("Scripting"),1 ,"#D8AA34","#F3D07A","#F1C453"),rendering:new WebInspector.TimelineCategory("ren dering",WebInspector.UIString("Rendering"),2,"#8266CC","#AF9AEB","#9A7EE6"),pain ting:new WebInspector.TimelineCategory("painting",WebInspector.UIString("Paintin g"),2,"#5FA050","#8DC286","#71B363"),other:new WebInspector.TimelineCategory("ot her",WebInspector.UIString("Other"),-1,"#BBBBBB","#DDDDDD","#DDDDDD"),idle:new W ebInspector.TimelineCategory("idle",WebInspector.UIString("Idle"),-1,"#DDDDDD"," #FFFFFF","#FFFFFF")};return WebInspector.TimelinePresentationModel._categories;} ;WebInspector.TimelinePresentationModel._initRecordStyles=function() 333 {return record?this._recordToPresentationRecord.get(record)||null:null;},rootRec ord:function()
249 {if(WebInspector.TimelinePresentationModel._recordStylesMap) 334 {return this._rootRecord;},reset:function()
250 return WebInspector.TimelinePresentationModel._recordStylesMap;var recordTypes=W ebInspector.TimelineModel.RecordType;var categories=WebInspector.TimelinePresent ationModel.categories();var recordStyles={};recordStyles[recordTypes.Root]={titl e:"#root",category:categories["loading"]};recordStyles[recordTypes.Program]={tit le:WebInspector.UIString("Other"),category:categories["other"]};recordStyles[rec ordTypes.EventDispatch]={title:WebInspector.UIString("Event"),category:categorie s["scripting"]};recordStyles[recordTypes.BeginFrame]={title:WebInspector.UIStrin g("Frame Start"),category:categories["rendering"]};recordStyles[recordTypes.Sche duleStyleRecalculation]={title:WebInspector.UIString("Schedule Style Recalculati on"),category:categories["rendering"]};recordStyles[recordTypes.RecalculateStyle s]={title:WebInspector.UIString("Recalculate Style"),category:categories["render ing"]};recordStyles[recordTypes.InvalidateLayout]={title:WebInspector.UIString(" Invalidate Layout"),category:categories["rendering"]};recordStyles[recordTypes.L ayout]={title:WebInspector.UIString("Layout"),category:categories["rendering"]}; recordStyles[recordTypes.AutosizeText]={title:WebInspector.UIString("Autosize Te xt"),category:categories["rendering"]};recordStyles[recordTypes.PaintSetup]={tit le:WebInspector.UIString("Paint Setup"),category:categories["painting"]};recordS tyles[recordTypes.Paint]={title:WebInspector.UIString("Paint"),category:categori es["painting"]};recordStyles[recordTypes.Rasterize]={title:WebInspector.UIString ("Paint"),category:categories["painting"]};recordStyles[recordTypes.ScrollLayer] ={title:WebInspector.UIString("Scroll"),category:categories["rendering"]};record Styles[recordTypes.DecodeImage]={title:WebInspector.UIString("Image Decode"),cat egory:categories["painting"]};recordStyles[recordTypes.ResizeImage]={title:WebIn spector.UIString("Image Resize"),category:categories["painting"]};recordStyles[r ecordTypes.CompositeLayers]={title:WebInspector.UIString("Composite Layers"),cat egory:categories["painting"]};recordStyles[recordTypes.ParseHTML]={title:WebInsp ector.UIString("Parse HTML"),category:categories["loading"]};recordStyles[record Types.TimerInstall]={title:WebInspector.UIString("Install Timer"),category:categ ories["scripting"]};recordStyles[recordTypes.TimerRemove]={title:WebInspector.UI String("Remove Timer"),category:categories["scripting"]};recordStyles[recordType s.TimerFire]={title:WebInspector.UIString("Timer Fired"),category:categories["sc ripting"]};recordStyles[recordTypes.XHRReadyStateChange]={title:WebInspector.UIS tring("XHR Ready State Change"),category:categories["scripting"]};recordStyles[r ecordTypes.XHRLoad]={title:WebInspector.UIString("XHR Load"),category:categories ["scripting"]};recordStyles[recordTypes.EvaluateScript]={title:WebInspector.UISt ring("Evaluate Script"),category:categories["scripting"]};recordStyles[recordTyp es.ResourceSendRequest]={title:WebInspector.UIString("Send Request"),category:ca tegories["loading"]};recordStyles[recordTypes.ResourceReceiveResponse]={title:We bInspector.UIString("Receive Response"),category:categories["loading"]};recordSt yles[recordTypes.ResourceFinish]={title:WebInspector.UIString("Finish Loading"), category:categories["loading"]};recordStyles[recordTypes.FunctionCall]={title:We bInspector.UIString("Function Call"),category:categories["scripting"]};recordSty les[recordTypes.ResourceReceivedData]={title:WebInspector.UIString("Receive Data "),category:categories["loading"]};recordStyles[recordTypes.GCEvent]={title:WebI nspector.UIString("GC Event"),category:categories["scripting"]};recordStyles[rec ordTypes.MarkDOMContent]={title:WebInspector.UIString("DOMContentLoaded event"), category:categories["scripting"]};recordStyles[recordTypes.MarkLoad]={title:WebI nspector.UIString("Load event"),category:categories["scripting"]};recordStyles[r ecordTypes.MarkFirstPaint]={title:WebInspector.UIString("First paint"),category: categories["painting"]};recordStyles[recordTypes.TimeStamp]={title:WebInspector. UIString("Stamp"),category:categories["scripting"]};recordStyles[recordTypes.Tim e]={title:WebInspector.UIString("Time"),category:categories["scripting"]};record Styles[recordTypes.TimeEnd]={title:WebInspector.UIString("Time End"),category:ca tegories["scripting"]};recordStyles[recordTypes.ScheduleResourceRequest]={title: WebInspector.UIString("Schedule Request"),category:categories["loading"]};record Styles[recordTypes.RequestAnimationFrame]={title:WebInspector.UIString("Request Animation Frame"),category:categories["scripting"]};recordStyles[recordTypes.Can celAnimationFrame]={title:WebInspector.UIString("Cancel Animation Frame"),catego ry: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.WebSocket SendHandshakeRequest]={title:WebInspector.UIString("Send WebSocket Handshake"),c ategory:categories["scripting"]};recordStyles[recordTypes.WebSocketReceiveHandsh akeResponse]={title:WebInspector.UIString("Receive WebSocket Handshake"),categor y:categories["scripting"]};recordStyles[recordTypes.WebSocketDestroy]={title:Web Inspector.UIString("Destroy WebSocket"),category:categories["scripting"]};WebIns pector.TimelinePresentationModel._recordStylesMap=recordStyles;return recordStyl es;} 335 {this._recordToPresentationRecord.clear();var rootPayload={type:WebInspector.Tim elineModel.RecordType.Root};var rootRecord=new WebInspector.TimelineModel.Record (this._model,(rootPayload),null);this._rootRecord=new WebInspector.TimelinePrese ntationModel.Record(rootRecord,null);this._coalescingBuckets={};this._windowStar tTime=0;this._windowEndTime=Infinity;},addRecord:function(record)
251 WebInspector.TimelinePresentationModel.recordStyle=function(record) 336 {var records;if(record.type===WebInspector.TimelineModel.RecordType.Program)
252 {var recordStyles=WebInspector.TimelinePresentationModel._initRecordStyles();var result=recordStyles[record.type];if(!result){result={title:WebInspector.UIStrin g("Unknown: %s",record.type),category:WebInspector.TimelinePresentationModel.cat egories()["other"]};recordStyles[record.type]=result;} 337 records=record.children;else
253 return result;} 338 records=[record];for(var i=0;i<records.length;++i)
254 WebInspector.TimelinePresentationModel.categoryForRecord=function(record) 339 this._innerAddRecord(this._rootRecord,records[i]);},_innerAddRecord:function(par entRecord,record)
255 {return WebInspector.TimelinePresentationModel.recordStyle(record).category;} 340 {var coalescingBucket;if(parentRecord===this._rootRecord)
256 WebInspector.TimelinePresentationModel.isEventDivider=function(record) 341 coalescingBucket=record.thread?record.type:"mainThread";var coalescedRecord=this ._findCoalescedParent(record,parentRecord,coalescingBucket);if(coalescedRecord)
257 {var recordTypes=WebInspector.TimelineModel.RecordType;if(record.type===recordTy pes.TimeStamp) 342 parentRecord=coalescedRecord;var formattedRecord=new WebInspector.TimelinePresen tationModel.Record(record,parentRecord);this._recordToPresentationRecord.put(rec ord,formattedRecord);formattedRecord._collapsed=parentRecord===this._rootRecord; if(coalescingBucket)
258 return true;if(record.type===recordTypes.MarkFirstPaint) 343 this._coalescingBuckets[coalescingBucket]=formattedRecord;for(var i=0;record.chi ldren&&i<record.children.length;++i)
259 return true;if(record.type===recordTypes.MarkDOMContent||record.type===recordTyp es.MarkLoad){if(record.data&&((typeof record.data.isMainFrame)==="boolean")) 344 this._innerAddRecord(formattedRecord,record.children[i]);if(parentRecord._coales ced)
260 return record.data.isMainFrame;} 345 this._updateCoalescingParent(formattedRecord);},_findCoalescedParent:function(re cord,newParent,bucket)
261 return false;} 346 {const coalescingThresholdMillis=5;var lastRecord=bucket?this._coalescingBuckets [bucket]:newParent._presentationChildren.peekLast();if(lastRecord&&lastRecord._c oalesced)
262 WebInspector.TimelinePresentationModel.forAllRecords=function(recordsArray,preOr derCallback,postOrderCallback) 347 lastRecord=lastRecord._presentationChildren.peekLast();var startTime=record.star tTime;var endTime=record.endTime;if(!lastRecord)
263 {if(!recordsArray) 348 return null;if(lastRecord.record().type!==record.type)
264 return;var stack=[{array:recordsArray,index:0}];while(stack.length){var entry=st ack[stack.length-1];var records=entry.array;if(entry.index<records.length){var r ecord=records[entry.index];if(preOrderCallback&&preOrderCallback(record)) 349 return null;if(!WebInspector.TimelinePresentationModel._coalescingRecords[record .type])
265 return;if(record.children) 350 return null;if(lastRecord.record().endTime+coalescingThresholdMillis<startTime)
266 stack.push({array:record.children,index:0,record:record});else if(postOrderCallb ack&&postOrderCallback(record)) 351 return null;if(endTime+coalescingThresholdMillis<lastRecord.record().startTime)
267 return;++entry.index;}else{if(entry.record&&postOrderCallback&&postOrderCallback (entry.record)) 352 return null;if(lastRecord.presentationParent()._coalesced)
268 return;stack.pop();}}} 353 return lastRecord.presentationParent();return this._replaceWithCoalescedRecord(l astRecord);},_replaceWithCoalescedRecord:function(presentationRecord)
269 WebInspector.TimelinePresentationModel.needsPreviewElement=function(recordType) 354 {var record=presentationRecord.record();var rawRecord={type:record.type,startTim e:record.startTime,endTime:record.endTime,data:{}};if(record.thread)
270 {if(!recordType)
271 return false;const recordTypes=WebInspector.TimelineModel.RecordType;switch(reco rdType){case recordTypes.ScheduleResourceRequest:case recordTypes.ResourceSendRe quest:case recordTypes.ResourceReceiveResponse:case recordTypes.ResourceReceived Data:case recordTypes.ResourceFinish:return true;default:return false;}}
272 WebInspector.TimelinePresentationModel.createEventDivider=function(recordType,ti tle)
273 {var eventDivider=document.createElement("div");eventDivider.className="resource s-event-divider";var recordTypes=WebInspector.TimelineModel.RecordType;if(record Type===recordTypes.MarkDOMContent)
274 eventDivider.className+=" resources-blue-divider";else if(recordType===recordTyp es.MarkLoad)
275 eventDivider.className+=" resources-red-divider";else if(recordType===recordType s.MarkFirstPaint)
276 eventDivider.className+=" resources-green-divider";else if(recordType===recordTy pes.TimeStamp)
277 eventDivider.className+=" resources-orange-divider";else if(recordType===recordT ypes.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._hiddenReco rds[WebInspector.TimelineModel.RecordType.MarkLoad]=1;WebInspector.TimelinePrese ntationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkFirstPaint ]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineM odel.RecordType.ScheduleStyleRecalculation]=1;WebInspector.TimelinePresentationM odel._hiddenRecords[WebInspector.TimelineModel.RecordType.InvalidateLayout]=1;We bInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.R ecordType.GPUTask]=1;WebInspector.TimelinePresentationModel._hiddenRecords[WebIn spector.TimelineModel.RecordType.ActivateLayerTree]=1;WebInspector.TimelinePrese ntationModel.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.TimelinePresentationM odel.Record(this,{type:WebInspector.TimelineModel.RecordType.Root},null,null,nul l,false);this._sendRequestRecords={};this._scheduledResourceRequests={};this._ti merRecords={};this._requestAnimationFrameRecords={};this._eventDividerRecords=[] ;this._timeRecords={};this._timeRecordStack=[];this._frames=[];this._minimumReco rdTime=-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);va r 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;},_inn erAddRecord:function(parentRecord,record)
294 {const recordTypes=WebInspector.TimelineModel.RecordType;var isHiddenRecord=reco rd.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:re cord.data["scriptLine"]}};if((record.type===recordTypes.TimerFire||record.type== =recordTypes.FireAnimationFrame)&&children&&children.length){var childRecord=chi ldren[0];if(childRecord.type===recordTypes.FunctionCall){scriptDetails={scriptNa me:childRecord.data["scriptName"],scriptLine:childRecord.data["scriptLine"]};chi ldren=childRecord.children.concat(children.slice(1));}}
299 var formattedRecord=new WebInspector.TimelinePresentationModel.Record(this,recor d,parentRecord,origin,scriptDetails,isHiddenRecord);if(WebInspector.TimelinePres entationModel.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(!o rigin.isRoot()&&!origin.coalesced)
307 origin.selfTime-=formattedRecord.endTime-formattedRecord.startTime;return format tedRecord;},_updateAncestorStats:function(record)
308 {var lastChildEndTime=record.lastChildEndTime;var aggregatedStats=record.aggrega tedStats;for(var currentRecord=record.parent;currentRecord&&!currentRecord.isRoo t();currentRecord=currentRecord.parent){currentRecord._cpuTime+=record._cpuTime; if(currentRecord.lastChildEndTime<lastChildEndTime)
309 currentRecord.lastChildEndTime=lastChildEndTime;for(var category in aggregatedSt ats)
310 currentRecord.aggregatedStats[category]+=aggregatedStats[category];}},_findCoale scedParent:function(record,newParent,bucket)
311 {const coalescingThresholdSeconds=0.005;var lastRecord=bucket?this._coalescingBu ckets[bucket]:newParent.children.peekLast();if(lastRecord&&lastRecord.coalesced)
312 lastRecord=lastRecord.children.peekLast();var startTime=WebInspector.TimelineMod el.startTimeInSeconds(record);var endTime=WebInspector.TimelineModel.endTimeInSe conds(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(rec ord)!==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,endT ime:record._record.endTime,data:{}};if(record._record.thread)
320 rawRecord.thread="aggregated";if(record.type===WebInspector.TimelineModel.Record Type.TimeStamp) 355 rawRecord.thread="aggregated";if(record.type===WebInspector.TimelineModel.Record Type.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;coa lescedRecord._children.push(record);record.parent=coalescedRecord;if(record.hasW arnings()||record.childHasWarnings()) 356 rawRecord.data["message"]=record.data.message;var modelRecord=new WebInspector.T imelineModel.Record(this._model,(rawRecord),null);var coalescedRecord=new WebIns pector.TimelinePresentationModel.Record(modelRecord,null);var parent=presentatio nRecord._presentationParent;coalescedRecord._coalesced=true;coalescedRecord._col lapsed=true;coalescedRecord._presentationChildren.push(presentationRecord);prese ntationRecord._presentationParent=coalescedRecord;if(presentationRecord.hasWarni ngs()||presentationRecord.childHasWarnings())
322 coalescedRecord._childHasWarnings=true;coalescedRecord.parent=parent;parent._chi ldren[parent._children.indexOf(record)]=coalescedRecord;WebInspector.TimelineMod el.aggregateTimeByCategory(coalescedRecord._aggregatedStats,record._aggregatedSt ats);return coalescedRecord;},_updateCoalescingParent:function(record) 357 coalescedRecord._childHasWarnings=true;coalescedRecord._presentationParent=paren t;parent._presentationChildren[parent._presentationChildren.indexOf(presentation Record)]=coalescedRecord;WebInspector.TimelineUIUtils.aggregateTimeByCategory(mo delRecord.aggregatedStats,record.aggregatedStats);return coalescedRecord;},_upda teCoalescingParent:function(presentationRecord)
323 {var parentRecord=record.parent;WebInspector.TimelineModel.aggregateTimeByCatego ry(parentRecord._aggregatedStats,record._aggregatedStats);if(parentRecord.startT ime>record._record.startTime) 358 {var record=presentationRecord.record();var parentRecord=presentationRecord._pre sentationParent.record();WebInspector.TimelineUIUtils.aggregateTimeByCategory(pa rentRecord.aggregatedStats,record.aggregatedStats);if(parentRecord.startTime>rec ord.startTime)
324 parentRecord._record.startTime=record._record.startTime;if(parentRecord.endTime< record._record.endTime){parentRecord._record.endTime=record._record.endTime;pare ntRecord.lastChildEndTime=parentRecord.endTime;}},_foldSyncTimeRecords:function( records) 359 parentRecord.startTime=record.startTime;if(parentRecord.endTime<record.endTime){ parentRecord.endTime=record.endTime;parentRecord.lastChildEndTime=parentRecord.e ndTime;}},setTextFilter:function(textFilter)
325 {var recordTypes=WebInspector.TimelineModel.RecordType;for(var i=0;i<records.len gth&&records[i].type!==recordTypes.Time;++i){} 360 {this._textFilter=textFilter;},invalidateFilteredRecords:function()
326 if(i===records.length)
327 return records;var result=[];var stack=[];for(var i=0;i<records.length;++i){resu lt.push(records[i]);if(records[i].type===recordTypes.Time){stack.push(result.len gth-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,res ult.length-begin);result[begin]=this._createSynchronousTimeRecord(result[begin], timeEndRecord,children);break;}}
331 return result;},_createSynchronousTimeRecord:function(beginRecord,endRecord,chil dren)
332 {return{type:beginRecord.type,startTime:beginRecord.startTime,endTime:endRecord. startTime,stackTrace:beginRecord.stackTrace,children:children,data:{message:begi nRecord.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:c ase recordTypes.ResourceReceivedData:return this._sendRequestRecords[record.data ["requestId"]];case recordTypes.ResourceSendRequest:return this._rootRecord;case recordTypes.TimerFire:return this._timerRecords[record.data["timerId"]];case re cordTypes.ResourceSendRequest:return this._scheduledResourceRequests[record.data ["url"]];case recordTypes.FireAnimationFrame:return this._requestAnimationFrameR ecords[record.data["id"]];}},setGlueRecords:function(glue)
335 {this._glueRecords=glue;},invalidateFilteredRecords:function()
336 {delete this._filteredRecords;},filteredRecords:function() 361 {delete this._filteredRecords;},filteredRecords:function()
337 {if(this._filteredRecords) 362 {if(this._filteredRecords)
338 return this._filteredRecords;var recordsInWindow=[];var stack=[{children:this._r ootRecord.children,index:0,parentIsCollapsed:false,parentRecord:{}}];var reveale dDepth=0;function revealRecordsInStack(){for(var depth=revealedDepth+1;depth<sta ck.length;++depth){if(stack[depth-1].parentIsCollapsed){stack[depth].parentRecor d.parent._expandable=true;return;} 363 return this._filteredRecords;var recordsInWindow=[];var stack=[{children:this._r ootRecord._presentationChildren,index:0,parentIsCollapsed:false,parentRecord:{}} ];var revealedDepth=0;function revealRecordsInStack(){for(var depth=revealedDept h+1;depth<stack.length;++depth){if(stack[depth-1].parentIsCollapsed){stack[depth ].parentRecord._presentationParent._expandable=true;return;}
339 stack[depth-1].parentRecord.collapsed=false;recordsInWindow.push(stack[depth].pa rentRecord);stack[depth].windowLengthBeforeChildrenTraversal=recordsInWindow.len gth;stack[depth].parentIsRevealed=true;revealedDepth=depth;}} 364 stack[depth-1].parentRecord._collapsed=false;recordsInWindow.push(stack[depth].p arentRecord);stack[depth].windowLengthBeforeChildrenTraversal=recordsInWindow.le ngth;stack[depth].parentIsRevealed=true;revealedDepth=depth;}}
340 while(stack.length){var entry=stack[stack.length-1];var records=entry.children;i f(records&&entry.index<records.length){var record=records[entry.index];++entry.i ndex;if(this.isVisible(record)){record.parent._expandable=true;if(this._searchFi lter) 365 while(stack.length){var entry=stack[stack.length-1];var records=entry.children;i f(records&&entry.index<records.length){var record=records[entry.index];++entry.i ndex;var rawRecord=record.record();if(rawRecord.startTime<this._windowEndTime&&r awRecord.endTime>this._windowStartTime){if(this._model.isVisible(rawRecord)){rec ord._presentationParent._expandable=true;if(this._textFilter)
341 revealRecordsInStack();if(!entry.parentIsCollapsed){recordsInWindow.push(record) ;revealedDepth=stack.length;entry.parentRecord.collapsed=false;}} 366 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,parentIsCo llapsed:(entry.parentIsCollapsed||(record.collapsed&&(!this._searchFilter||recor d.clicked))),parentRecord:record,windowLengthBeforeChildrenTraversal:recordsInWi ndow.length});}else{stack.pop();revealedDepth=Math.min(revealedDepth,stack.lengt h-1);entry.parentRecord._visibleChildrenCount=recordsInWindow.length-entry.windo wLengthBeforeChildrenTraversal;}} 367 record._expandable=false;stack.push({children:record._presentationChildren,index :0,parentIsCollapsed:entry.parentIsCollapsed||(record._collapsed&&(!this._textFi lter||record._expandedOrCollapsedWhileFiltered)),parentRecord:record,windowLengt hBeforeChildrenTraversal:recordsInWindow.length});}else{stack.pop();revealedDept h=Math.min(revealedDepth,stack.length-1);entry.parentRecord._visibleChildrenCoun t=recordsInWindow.length-entry.windowLengthBeforeChildrenTraversal;}}
343 this._filteredRecords=recordsInWindow;return recordsInWindow;},filteredFrames:fu nction(startTime,endTime) 368 this._filteredRecords=recordsInWindow;return recordsInWindow;},__proto__:WebInsp ector.Object.prototype}
369 WebInspector.TimelinePresentationModel.Record=function(record,parentRecord)
370 {this._record=record;this._presentationChildren=[];if(parentRecord){this._presen tationParent=parentRecord;parentRecord._presentationChildren.push(this);}
371 if(this.hasWarnings()){for(var parent=this._presentationParent;parent&&!parent._ childHasWarnings;parent=parent._presentationParent)
372 parent._childHasWarnings=true;}
373 if(parentRecord&&parentRecord.callSiteStackTrace)
374 this.callSiteStackTrace=parentRecord.callSiteStackTrace;}
375 WebInspector.TimelinePresentationModel.Record.prototype={record:function()
376 {return this._record;},presentationChildren:function()
377 {return this._presentationChildren;},coalesced:function()
378 {return this._coalesced;},collapsed:function()
379 {return this._collapsed;},setCollapsed:function(collapsed)
380 {this._collapsed=collapsed;this._expandedOrCollapsedWhileFiltered=true;},present ationParent:function()
381 {return this._presentationParent||null;},visibleChildrenCount:function()
382 {return this._visibleChildrenCount||0;},expandable:function()
383 {return!!this._expandable;},hasWarnings:function()
384 {return!!this._record.warnings();},childHasWarnings:function()
385 {return this._childHasWarnings;},listRow:function()
386 {return this._listRow;},setListRow:function(listRow)
387 {this._listRow=listRow;},graphRow:function()
388 {return this._graphRow;},setGraphRow:function(graphRow)
389 {this._graphRow=graphRow;}};WebInspector.TimelineFrameModel=function(model)
390 {this._model=model;this.reset();var records=model.records();for(var i=0;i<record s.length;++i)
391 this.addRecord(records[i]);}
392 WebInspector.TimelineFrameModel.Events={FrameAdded:"FrameAdded"}
393 WebInspector.TimelineFrameModel._mainFrameMarkers=[WebInspector.TimelineModel.Re cordType.ScheduleStyleRecalculation,WebInspector.TimelineModel.RecordType.Invali dateLayout,WebInspector.TimelineModel.RecordType.BeginFrame,WebInspector.Timelin eModel.RecordType.ScrollLayer];WebInspector.TimelineFrameModel.prototype={frames :function()
394 {return this._frames;},filteredFrames:function(startTime,endTime)
344 {function compareStartTime(value,object) 395 {function compareStartTime(value,object)
345 {return value-object.startTime;} 396 {return value-object.startTime;}
346 function compareEndTime(value,object) 397 function compareEndTime(value,object)
347 {return value-object.endTime;} 398 {return value-object.endTime;}
348 var firstFrame=insertionIndexForObjectInListSortedByFunction(startTime,this._fra mes,compareStartTime);var lastFrame=insertionIndexForObjectInListSortedByFunctio n(endTime,this._frames,compareEndTime);while(lastFrame<this._frames.length&&this ._frames[lastFrame].endTime<=endTime) 399 var frames=this._frames;var firstFrame=insertionIndexForObjectInListSortedByFunc tion(startTime,frames,compareEndTime);var lastFrame=insertionIndexForObjectInLis tSortedByFunction(endTime,frames,compareStartTime);return frames.slice(firstFram e,lastFrame);},reset:function()
349 ++lastFrame;return this._frames.slice(firstFrame,lastFrame);},eventDividerRecord s:function() 400 {this._frames=[];this._lastFrame=null;this._lastLayerTree=null;this._hasThreaded Compositing=false;this._mainFrameCommitted=false;this._mainFrameRequested=false; this._aggregatedMainThreadWork=null;this._mergingBuffer=new WebInspector.Timelin eMergingRecordBuffer();},addRecord:function(record)
350 {return this._eventDividerRecords;},isVisible:function(record) 401 {var recordTypes=WebInspector.TimelineModel.RecordType;var programRecord=record. type===recordTypes.Program?record:null;if(programRecord){if(!this._aggregatedMai nThreadWork&&this._findRecordRecursively(WebInspector.TimelineFrameModel._mainFr ameMarkers,programRecord))
351 {for(var i=0;i<this._filters.length;++i){if(!this._filters[i].accept(record)) 402 this._aggregatedMainThreadWork={};}
352 return false;} 403 var records;if(this._model.bufferEvents())
353 return!this._searchFilter||this._searchFilter.accept(record);},generateMainThrea dBarPopupContent:function(info) 404 records=[record];else
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+=WebIns pector.TimelineModel.endTimeInSeconds(task)-WebInspector.TimelineModel.startTime InSeconds(task);} 405 records=this._mergingBuffer.process(record.thread,programRecord?record.children| |[]:[record]);for(var i=0;i<records.length;++i){if(records[i].thread)
355 var startTime=WebInspector.TimelineModel.startTimeInSeconds(tasks[firstTaskIndex ]);var endTime=WebInspector.TimelineModel.endTimeInSeconds(tasks[lastTaskIndex]) ;var duration=endTime-startTime;var offset=this._minimumRecordTime;var contentHe lper=new WebInspector.TimelinePopupContentHelper(info.name);var durationText=Web Inspector.UIString("%s (at %s)",Number.secondsToString(duration,true),Number.sec ondsToString(startTime-offset,true));contentHelper.appendTextRow(WebInspector.UI String("Duration"),durationText);contentHelper.appendTextRow(WebInspector.UIStri ng("CPU time"),Number.secondsToString(cpuTime,true));contentHelper.appendTextRow (WebInspector.UIString("Message Count"),messageCount);return contentHelper.conte ntTable();},__proto__:WebInspector.Object.prototype} 406 this._addBackgroundRecord(records[i]);else
356 WebInspector.TimelinePresentationModel.Record=function(presentationModel,record, parentRecord,origin,scriptDetails,hidden) 407 this._addMainThreadRecord(programRecord,records[i]);}},_addBackgroundRecord:func tion(record)
357 {this._linkifier=presentationModel._linkifier;this._aggregatedStats={};this._rec ord=record;this._children=[];if(!hidden&&parentRecord){this.parent=parentRecord; if(this.isBackground) 408 {var recordTypes=WebInspector.TimelineModel.RecordType;if(!this._lastFrame){if(r ecord.type===recordTypes.BeginFrame||record.type===recordTypes.DrawFrame)
358 WebInspector.TimelinePresentationModel.insertRetrospectiveRecord(parentRecord,th is);else 409 this._startBackgroundFrame(record);return;}
359 parentRecord.children.push(this);} 410 if(record.type===recordTypes.DrawFrame){if(this._mainFrameCommitted||!this._main FrameRequested)
360 if(origin) 411 this._startBackgroundFrame(record);this._mainFrameCommitted=false;}else if(recor d.type===recordTypes.RequestMainThreadFrame){this._mainFrameRequested=true;}else if(record.type===recordTypes.ActivateLayerTree){this._mainFrameRequested=false; this._mainFrameCommitted=true;this._lastFrame._addTimeForCategories(this._aggreg atedMainThreadWorkToAttachToBackgroundFrame);this._aggregatedMainThreadWorkToAtt achToBackgroundFrame={};}
361 this._origin=origin;this._selfTime=this.endTime-this.startTime;this._lastChildEn dTime=this.endTime;this._startTimeOffset=this.startTime-presentationModel._minim umRecordTime;if(record.data){if(record.data["url"]) 412 this._lastFrame._addTimeFromRecord(record);},_addMainThreadRecord:function(progr amRecord,record)
362 this.url=record.data["url"];if(record.data["rootNode"]) 413 {var recordTypes=WebInspector.TimelineModel.RecordType;if(record.type===recordTy pes.UpdateLayerTree)
363 this._relatedBackendNodeId=record.data["rootNode"];else if(record.data["elementI d"]) 414 this._lastLayerTree=record.data["layerTree"]||null;if(!this._hasThreadedComposit ing){if(record.type===recordTypes.BeginFrame)
364 this._relatedBackendNodeId=record.data["elementId"];} 415 this._startMainThreadFrame(record);if(!this._lastFrame)
365 if(scriptDetails){this.scriptName=scriptDetails.scriptName;this.scriptLine=scrip tDetails.scriptLine;} 416 return;this._lastFrame._addTimeFromRecord(record);if(programRecord.children[0]== =record){this._deriveOtherTime(programRecord,this._lastFrame.timeByCategory);thi s._lastFrame._updateCpuTime();}
366 if(parentRecord&&parentRecord.callSiteStackTrace) 417 return;}
367 this.callSiteStackTrace=parentRecord.callSiteStackTrace;var recordTypes=WebInspe ctor.TimelineModel.RecordType;switch(record.type){case recordTypes.ResourceSendR equest:presentationModel._sendRequestRecords[record.data["requestId"]]=this;brea k;case recordTypes.ScheduleResourceRequest:presentationModel._scheduledResourceR equests[record.data["url"]]=this;break;case recordTypes.ResourceReceiveResponse: var sendRequestRecord=presentationModel._sendRequestRecords[record.data["request Id"]];if(sendRequestRecord){this.url=sendRequestRecord.url;sendRequestRecord._re freshDetails();if(sendRequestRecord.parent!==presentationModel._rootRecord&&send RequestRecord.parent.type===recordTypes.ScheduleResourceRequest) 418 if(!this._aggregatedMainThreadWork)
368 sendRequestRecord.parent._refreshDetails();} 419 return;WebInspector.TimelineUIUtils.aggregateTimeForRecord(this._aggregatedMainT hreadWork,record);if(programRecord.children[0]===record)
369 break;case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:var sendRequestRecord=presentationModel._sendRequestRecords[record.data["requestId"] ];if(sendRequestRecord) 420 this._deriveOtherTime(programRecord,this._aggregatedMainThreadWork);if(record.ty pe===recordTypes.CompositeLayers){this._aggregatedMainThreadWorkToAttachToBackgr oundFrame=this._aggregatedMainThreadWork;this._aggregatedMainThreadWork=null;}}, _deriveOtherTime:function(programRecord,timeByCategory)
370 this.url=sendRequestRecord.url;break;case recordTypes.TimerInstall:this.timeout= record.data["timeout"];this.singleShot=record.data["singleShot"];presentationMod el._timerRecords[record.data["timerId"]]=this;break;case recordTypes.TimerFire:v ar timerInstalledRecord=presentationModel._timerRecords[record.data["timerId"]]; if(timerInstalledRecord){this.callSiteStackTrace=timerInstalledRecord.stackTrace ;this.timeout=timerInstalledRecord.timeout;this.singleShot=timerInstalledRecord. singleShot;} 421 {var accounted=0;for(var i=0;i<programRecord.children.length;++i)
371 break;case recordTypes.RequestAnimationFrame:presentationModel._requestAnimation FrameRecords[record.data["id"]]=this;break;case recordTypes.FireAnimationFrame:v ar requestAnimationRecord=presentationModel._requestAnimationFrameRecords[record .data["id"]];if(requestAnimationRecord) 422 accounted+=programRecord.children[i].endTime-programRecord.children[i].startTime ;var otherTime=programRecord.endTime-programRecord.startTime-accounted;timeByCat egory["other"]=(timeByCategory["other"]||0)+otherTime;},_startBackgroundFrame:fu nction(record)
372 this.callSiteStackTrace=requestAnimationRecord.stackTrace;break;case recordTypes .Time:if(record.data.isSynchronous) 423 {if(!this._hasThreadedCompositing){this._lastFrame=null;this._hasThreadedComposi ting=true;}
373 break;var message=record.data["message"];var oldReference=presentationModel._tim eRecords[message];if(oldReference) 424 if(this._lastFrame)
374 break;presentationModel._timeRecords[message]=this;if(origin) 425 this._flushFrame(this._lastFrame,record);this._lastFrame=new WebInspector.Timeli neFrame(record);},_startMainThreadFrame:function(record)
375 presentationModel._timeRecordStack.push(this);break;case recordTypes.TimeEnd:var message=record.data["message"];var timeRecord=presentationModel._timeRecords[me ssage];delete presentationModel._timeRecords[message];if(timeRecord){this.timeRe cord=timeRecord;timeRecord.timeEndRecord=this;var intervalDuration=this.startTim e-timeRecord.startTime;this.intervalDuration=intervalDuration;timeRecord.interva lDuration=intervalDuration;} 426 {if(this._lastFrame)
376 break;case recordTypes.ScheduleStyleRecalculation:presentationModel._lastSchedul eStyleRecalculation[this.frameId]=this;break;case recordTypes.RecalculateStyles: var scheduleStyleRecalculationRecord=presentationModel._lastScheduleStyleRecalcu lation[this.frameId];if(!scheduleStyleRecalculationRecord) 427 this._flushFrame(this._lastFrame,record);this._lastFrame=new WebInspector.Timeli neFrame(record);},_flushFrame:function(frame,record)
377 break;this.callSiteStackTrace=scheduleStyleRecalculationRecord.stackTrace;break; case recordTypes.InvalidateLayout:var styleRecalcStack;if(!presentationModel._la youtInvalidateStack[this.frameId]){for(var outerRecord=parentRecord;outerRecord; outerRecord=record.parent){if(outerRecord.type===recordTypes.RecalculateStyles){ styleRecalcStack=outerRecord.callSiteStackTrace;break;}}} 428 {frame._setLayerTree(this._lastLayerTree);frame._setEndTime(record.startTime);th is._frames.push(frame);this.dispatchEventToListeners(WebInspector.TimelineFrameM odel.Events.FrameAdded,frame);},_findRecordRecursively:function(types,record)
378 presentationModel._layoutInvalidateStack[this.frameId]=styleRecalcStack||this.st ackTrace;break;case recordTypes.Layout:var layoutInvalidateStack=presentationMod el._layoutInvalidateStack[this.frameId];if(layoutInvalidateStack) 429 {if(types.indexOf(record.type)>=0)
379 this.callSiteStackTrace=layoutInvalidateStack;if(this.stackTrace) 430 return record;if(!record.children)
380 this.addWarning(WebInspector.UIString("Forced synchronous layout is a possible p erformance bottleneck."));presentationModel._layoutInvalidateStack[this.frameId] =null;this.highlightQuad=record.data.root||WebInspector.TimelinePresentationMode l.quadFromRectData(record.data);this._relatedBackendNodeId=record.data["rootNode "];break;case recordTypes.AutosizeText:if(record.data.needsRelayout&&parentRecor d.type===recordTypes.Layout) 431 return null;for(var i=0;i<record.children.length;++i){var result=this._findRecor dRecursively(types,record.children[i]);if(result)
381 parentRecord.addWarning(WebInspector.UIString("Layout required two passes due to text autosizing, consider setting viewport."));break;case recordTypes.Paint:thi s.highlightQuad=record.data.clip||WebInspector.TimelinePresentationModel.quadFro mRectData(record.data);break;case recordTypes.WebSocketCreate:this.webSocketURL= record.data["url"];if(typeof record.data["webSocketProtocol"]!=="undefined") 432 return result;}
382 this.webSocketProtocol=record.data["webSocketProtocol"];presentationModel._webSo cketCreateRecords[record.data["identifier"]]=this;break;case recordTypes.WebSock etSendHandshakeRequest:case recordTypes.WebSocketReceiveHandshakeResponse:case r ecordTypes.WebSocketDestroy:var webSocketCreateRecord=presentationModel._webSock etCreateRecords[record.data["identifier"]];if(webSocketCreateRecord){this.webSoc ketURL=webSocketCreateRecord.webSocketURL;if(typeof webSocketCreateRecord.webSoc ketProtocol!=="undefined") 433 return null;},__proto__:WebInspector.Object.prototype}
383 this.webSocketProtocol=webSocketCreateRecord.webSocketProtocol;}
384 break;}}
385 WebInspector.TimelinePresentationModel.adoptRecord=function(newParent,record)
386 {record.parent.children.splice(record.parent.children.indexOf(record));WebInspec tor.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.star tTime,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;},se t 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).categor y},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 endTim e()
405 {return WebInspector.TimelineModel.endTimeInSeconds(this._record);},get isBackgr ound()
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 stack Trace()
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.nee dsPreviewElement(this.type)&&!this._imagePreviewElement)
416 WebInspector.DOMPresentationUtils.buildImagePreviewContents(this.url,false,barri er.createCallback(this._setImagePreviewElement.bind(this)));if(this._relatedBack endNodeId&&!this._relatedNode)
417 WebInspector.domAgent.pushNodeByBackendIdToFrontend(this._relatedBackendNodeId,b arrier.createCallback(this._setRelatedNode.bind(this)));barrier.callWhenDone(cal lbackWrapper.bind(this));function callbackWrapper()
418 {callback(this._generatePopupContentSynchronously());}},getUserObject:function(k ey)
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);},_setImagePr eviewElement:function(element)
423 {this._imagePreviewElement=element;},_setRelatedNode:function(nodeId)
424 {if(typeof nodeId==="number")
425 this._relatedNode=WebInspector.domAgent.nodeForId(nodeId);},_generatePopupConten tSynchronously:function()
426 {var fragment=document.createDocumentFragment();var pie=WebInspector.TimelinePre sentationModel.generatePieChart(this._aggregatedStats,this.category.name);if(!th is.coalesced&&this._children.length){pie.pieChart.addSlice(this._selfTime,this.c ategory.fillColorStop1);var rowElement=document.createElement("div");pie.footerE lement.insertBefore(rowElement,pie.footerElement.firstChild);rowElement.createCh ild("div","timeline-aggregated-category timeline-"+this.category.name);rowElemen t.createTextChild(WebInspector.UIString("%s %s (Self)",Number.secondsToString(th is._selfTime,true),this.category.title));}
427 fragment.appendChild(pie.element);var contentHelper=new WebInspector.TimelineDet ailsContentHelper(true);contentHelper.appendTextRow(WebInspector.UIString("Start ed at"),Number.secondsToString(this._startTimeOffset));if(this.coalesced)
428 return fragment;const recordTypes=WebInspector.TimelineModel.RecordType;var call SiteStackTraceLabel;var callStackLabel;var relatedNodeLabel;switch(this.type){ca se recordTypes.GCEvent:contentHelper.appendTextRow(WebInspector.UIString("Collec ted"),Number.bytesToString(this.data["usedHeapSizeDelta"]));break;case recordTyp es.TimerFire:callSiteStackTraceLabel=WebInspector.UIString("Timer installed");ca se recordTypes.TimerInstall:case recordTypes.TimerRemove:contentHelper.appendTex tRow(WebInspector.UIString("Timer ID"),this.data["timerId"]);if(typeof this.time out==="number"){contentHelper.appendTextRow(WebInspector.UIString("Timeout"),Num ber.secondsToString(this.timeout/1000));contentHelper.appendTextRow(WebInspector .UIString("Repeats"),!this.singleShot);}
429 break;case recordTypes.FireAnimationFrame:callSiteStackTraceLabel=WebInspector.U IString("Animation frame requested");contentHelper.appendTextRow(WebInspector.UI String("Callback ID"),this.data["id"]);break;case recordTypes.FunctionCall:if(th is.scriptName)
430 contentHelper.appendElementRow(WebInspector.UIString("Location"),this._linkifyLo cation(this.scriptName,this.scriptLine,0));break;case recordTypes.ScheduleResour ceRequest:case recordTypes.ResourceSendRequest:case recordTypes.ResourceReceiveR esponse:case recordTypes.ResourceReceivedData:case recordTypes.ResourceFinish:co ntentHelper.appendElementRow(WebInspector.UIString("Resource"),WebInspector.link ifyResourceAsNode(this.url));if(this._imagePreviewElement)
431 contentHelper.appendElementRow(WebInspector.UIString("Preview"),this._imagePrevi ewElement);if(this.data["requestMethod"])
432 contentHelper.appendTextRow(WebInspector.UIString("Request Method"),this.data["r equestMethod"]);if(typeof this.data["statusCode"]==="number")
433 contentHelper.appendTextRow(WebInspector.UIString("Status Code"),this.data["stat usCode"]);if(this.data["mimeType"])
434 contentHelper.appendTextRow(WebInspector.UIString("MIME Type"),this.data["mimeTy pe"]);if(this.data["encodedDataLength"])
435 contentHelper.appendTextRow(WebInspector.UIString("Encoded Data Length"),WebInsp ector.UIString("%d Bytes",this.data["encodedDataLength"]));break;case recordType s.EvaluateScript:if(this.data&&this.url)
436 contentHelper.appendElementRow(WebInspector.UIString("Script"),this._linkifyLoca tion(this.url,this.data["lineNumber"]));break;case recordTypes.Paint:var clip=th is.data["clip"];if(clip){contentHelper.appendTextRow(WebInspector.UIString("Loca tion"),WebInspector.UIString("(%d, %d)",clip[0],clip[1]));var clipWidth=WebInspe ctor.TimelinePresentationModel.quadWidth(clip);var clipHeight=WebInspector.Timel inePresentationModel.quadHeight(clip);contentHelper.appendTextRow(WebInspector.U IString("Dimensions"),WebInspector.UIString("%d × %d",clipWidth,clipHeight));}el se{if(typeof this.data["x"]!=="undefined"&&typeof this.data["y"]!=="undefined")
437 contentHelper.appendTextRow(WebInspector.UIString("Location"),WebInspector.UIStr ing("(%d, %d)",this.data["x"],this.data["y"]));if(typeof this.data["width"]!=="u ndefined"&&typeof this.data["height"]!=="undefined")
438 contentHelper.appendTextRow(WebInspector.UIString("Dimensions"),WebInspector.UIS tring("%d\u2009\u00d7\u2009%d",this.data["width"],this.data["height"]));}
439 case recordTypes.PaintSetup:case recordTypes.Rasterize:case recordTypes.ScrollLa yer:relatedNodeLabel=WebInspector.UIString("Layer root");break;case recordTypes. AutosizeText:relatedNodeLabel=WebInspector.UIString("Root node");break;case reco rdTypes.DecodeImage:case recordTypes.ResizeImage:relatedNodeLabel=WebInspector.U IString("Image element");if(this.url)
440 contentHelper.appendElementRow(WebInspector.UIString("Image URL"),WebInspector.l inkifyResourceAsNode(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 for ced");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");callStackLab el=WebInspector.UIString("Layout forced");relatedNodeLabel=WebInspector.UIString ("Layout root");break;case recordTypes.Time:case recordTypes.TimeEnd:contentHelp er.appendTextRow(WebInspector.UIString("Message"),this.data["message"]);if(typeo f this.intervalDuration==="number")
445 contentHelper.appendTextRow(WebInspector.UIString("Interval Duration"),Number.se condsToString(this.intervalDuration,true));break;case recordTypes.WebSocketCreat e:case recordTypes.WebSocketSendHandshakeRequest:case recordTypes.WebSocketRecei veHandshakeResponse:case recordTypes.WebSocketDestroy:if(typeof this.webSocketUR L!=="undefined")
446 contentHelper.appendTextRow(WebInspector.UIString("URL"),this.webSocketURL);if(t ypeof this.webSocketProtocol!=="undefined")
447 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"),this.web SocketProtocol);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._link ifyLocation(this.scriptName,this.scriptLine,0));if(this.jsHeapSizeUsed){if(this. usedHeapSizeDelta){var sign=this.usedHeapSizeDelta>0?"+":"-";contentHelper.appen dTextRow(WebInspector.UIString("Used JavaScript Heap Size"),WebInspector.UIStrin g("%s (%s%s)",Number.bytesToString(this.jsHeapSizeUsed),sign,Number.bytesToStrin g(Math.abs(this.usedHeapSizeDelta))));}else if(this.category===WebInspector.Time linePresentationModel.categories().scripting)
453 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScript Heap Size"),N umber.bytesToString(this.jsHeapSizeUsed));}
454 if(this.callSiteStackTrace)
455 contentHelper.appendStackTrace(callSiteStackTraceLabel||WebInspector.UIString("C all Site stack"),this.callSiteStackTrace,this._linkifyCallFrame.bind(this));if(t his.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.appendElementRo w(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.ad dEventListener("click",onClick,false);WebInspector.DOMPresentationUtils.decorate NodeLabel(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._getRecordDet ails();if(this._detailsNode&&!this.coalesced){this._detailsNode.insertBefore(doc ument.createTextNode("("),this._detailsNode.firstChild);this._detailsNode.append Child(document.createTextNode(")"));}}
464 return this._detailsNode;},_createSpanWithText:function(textContent)
465 {var node=document.createElement("span");node.textContent=textContent;return nod e;},_getRecordDetails:function()
466 {var details;if(this.coalesced)
467 return this._createSpanWithText(WebInspector.UIString("× %d",this.children.lengt h));switch(this.type){case WebInspector.TimelineModel.RecordType.GCEvent:details =WebInspector.UIString("%s collected",Number.bytesToString(this.data["usedHeapSi zeDelta"]));break;case WebInspector.TimelineModel.RecordType.TimerFire:details=t his._linkifyScriptLocation(this.data["timerId"]);break;case WebInspector.Timelin eModel.RecordType.FunctionCall:if(this.scriptName)
468 details=this._linkifyLocation(this.scriptName,this.scriptLine,0);break;case WebI nspector.TimelineModel.RecordType.FireAnimationFrame:details=this._linkifyScript Location(this.data["id"]);break;case WebInspector.TimelineModel.RecordType.Event Dispatch:details=this.data?this.data["type"]:null;break;case WebInspector.Timeli neModel.RecordType.Paint:var width=this.data.clip?WebInspector.TimelinePresentat ionModel.quadWidth(this.data.clip):this.data.width;var height=this.data.clip?Web Inspector.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.TimelineMod el.RecordType.TimerRemove:details=this._linkifyTopCallFrame(this.data["timerId"] );break;case WebInspector.TimelineModel.RecordType.RequestAnimationFrame:case We bInspector.TimelineModel.RecordType.CancelAnimationFrame:details=this._linkifyTo pCallFrame(this.data["id"]);break;case WebInspector.TimelineModel.RecordType.Par seHTML:case WebInspector.TimelineModel.RecordType.RecalculateStyles:details=this ._linkifyTopCallFrame();break;case WebInspector.TimelineModel.RecordType.Evaluat eScript:details=this.url?this._linkifyLocation(this.url,this.data["lineNumber"], 0):null;break;case WebInspector.TimelineModel.RecordType.XHRReadyStateChange:cas e WebInspector.TimelineModel.RecordType.XHRLoad:case WebInspector.TimelineModel. RecordType.ScheduleResourceRequest:case WebInspector.TimelineModel.RecordType.Re sourceSendRequest:case WebInspector.TimelineModel.RecordType.ResourceReceivedDat a:case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse:case WebIns pector.TimelineModel.RecordType.ResourceFinish:case WebInspector.TimelineModel.R ecordType.DecodeImage:case WebInspector.TimelineModel.RecordType.ResizeImage:det ails=WebInspector.displayNameForURL(this.url);break;case WebInspector.TimelineMo del.RecordType.Time:case WebInspector.TimelineModel.RecordType.TimeEnd:details=t his.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.linkifyLocati on(url,lineNumber-1,columnNumber,"timeline-details");},_linkifyCallFrame:functio n(callFrame)
475 {return this._linkifyLocation(callFrame.url,callFrame.lineNumber,callFrame.colum nNumber);},_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._child ren.length;index;--index){var child=this._children[index-1];for(var category in child._aggregatedStats)
481 this._aggregatedStats[category]=(this._aggregatedStats[category]||0)+child._aggr egatedStats[category];}
482 for(var category in this._aggregatedStats)
483 this._cpuTime+=this._aggregatedStats[category];this._aggregatedStats[this.catego ry.name]=(this._aggregatedStats[this.category.name]||0)+this._selfTime;},get agg regatedStats()
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._childHasWar nings;parent=parent.parent)
488 parent._childHasWarnings=true;},hasWarnings:function()
489 {return!!this._warnings;},childHasWarnings:function()
490 {return this._childHasWarnings;}}
491 WebInspector.TimelinePresentationModel._generateAggregatedInfo=function(aggregat edStats)
492 {var cell=document.createElement("span");cell.className="timeline-aggregated-inf o";for(var index in aggregatedStats){var label=document.createElement("div");lab el.className="timeline-aggregated-category timeline-"+index;cell.appendChild(lab el);var text=document.createElement("span");text.textContent=Number.secondsToStr ing(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-aggregate d-info";var total=0;var categoryNames=[];if(firstCategoryName)
496 categoryNames.push(firstCategoryName);for(var categoryName in WebInspector.Timel inePresentationModel.categories()){if(aggregatedStats[categoryName]){total+=aggr egatedStats[categoryName];if(firstCategoryName!==categoryName)
497 categoryNames.push(categoryName);}}
498 var pieChart=new WebInspector.PieChart(total);element.appendChild(pieChart.eleme nt);var footerElement=element.createChild("div","timeline-aggregated-info-legend ");for(var i=0;i<categoryNames.length;++i){var category=WebInspector.TimelinePre sentationModel.categories()[categoryNames[i]];pieChart.addSlice(aggregatedStats[ category.name],category.fillColorStop0);var rowElement=footerElement.createChild ("div");rowElement.createChild("div","timeline-aggregated-category timeline-"+ca tegory.name);rowElement.createTextChild(WebInspector.UIString("%s %s",Number.sec ondsToString(aggregatedStats[category.name],true),category.title));}
499 return{pieChart:pieChart,element:element,footerElement:footerElement};}
500 WebInspector.TimelinePresentationModel.generatePopupContentForFrame=function(fra me)
501 {var contentHelper=new WebInspector.TimelinePopupContentHelper(WebInspector.UISt ring("Frame"));var durationInSeconds=frame.endTime-frame.startTime;var durationT ext=WebInspector.UIString("%s (at %s)",Number.secondsToString(frame.endTime-fram e.startTime,true),Number.secondsToString(frame.startTimeOffset,true));contentHel per.appendTextRow(WebInspector.UIString("Duration"),durationText);contentHelper. appendTextRow(WebInspector.UIString("FPS"),Math.floor(1/durationInSeconds));cont entHelper.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.timeByCateg ory));return contentHelper.contentTable();}
502 WebInspector.TimelinePresentationModel.generatePopupContentForFrameStatistics=fu nction(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);contentHe lper.appendTextRow(WebInspector.UIString("Minimum Time"),formatTimeAndFPS(statis tics.minDuration));contentHelper.appendTextRow(WebInspector.UIString("Average Ti me"),formatTimeAndFPS(statistics.average));contentHelper.appendTextRow(WebInspec tor.UIString("Maximum Time"),formatTimeAndFPS(statistics.maxDuration));contentHe lper.appendTextRow(WebInspector.UIString("Standard Deviation"),Number.secondsToS tring(statistics.stddev,true));return contentHelper.element;}
506 WebInspector.TimelinePresentationModel.createFillStyle=function(context,width,he ight,color0,color1,color2)
507 {var gradient=context.createLinearGradient(0,0,width,height);gradient.addColorSt op(0,color0);gradient.addColorStop(0.25,color1);gradient.addColorStop(0.75,color 1);gradient.addColorStop(1,color2);return gradient;}
508 WebInspector.TimelinePresentationModel.createFillStyleForCategory=function(conte xt,width,height,category)
509 {return WebInspector.TimelinePresentationModel.createFillStyle(context,width,hei ght,category.fillColorStop0,category.fillColorStop1,category.borderColor);}
510 WebInspector.TimelinePresentationModel.createStyleRuleForCategory=function(categ ory)
511 {var selector=".timeline-category-"+category.name+" .timeline-graph-bar, "+".pan el.timeline .timeline-filters-header .filter-checkbox-filter.filter-checkbox-fil ter-"+category.name+" .checkbox-filter-checkbox, "+".popover .timeline-"+categor y.name+", "+".timeline-details-view .timeline-"+category.name+", "+".timeline-ca tegory-"+category.name+" .timeline-tree-icon"
512 return selector+" { background-image: -webkit-linear-gradient("+
513 category.fillColorStop0+", "+category.fillColorStop1+" 25%, "+category.fillColor Stop1+" 25%, "+category.fillColorStop1+");"+" border-color: "+category.borderCol or+"}";}
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.T ime: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,border Color,fillColorStop0,fillColorStop1)
528 {this.name=name;this.title=title;this.overviewStripGroupIndex=overviewStripGroup Index;this.borderColor=borderColor;this.fillColorStop0=fillColorStop0;this.fillC olorStop1=fillColorStop1;this.hidden=false;}
529 WebInspector.TimelineCategory.Events={VisibilityChanged:"VisibilityChanged"};Web Inspector.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._createCe ll(WebInspector.UIString("%s - Details",title),"timeline-details-title");titleCe ll.colSpan=2;var titleRow=document.createElement("tr");titleRow.appendChild(titl eCell);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.createTextNo de(content));var cell=document.createElement("td");cell.className="timeline-deta ils";if(styleName)
537 cell.className+=" "+styleName;cell.textContent=content;return cell;},appendTextR ow:function(title,content)
538 {var row=document.createElement("tr");row.appendChild(this._createCell(title,"ti meline-details-row-title"));row.appendChild(this._createCell(content,"timeline-d etails-row-data"));this._contentTable.appendChild(row);},appendElementRow:functi on(title,content)
539 {var row=document.createElement("tr");var titleCell=this._createCell(title,"time line-details-row-title");row.appendChild(titleCell);var cell=document.createElem ent("td");cell.className="details";if(content instanceof Node)
540 cell.appendChild(content);else
541 cell.createTextChild(content||"");row.appendChild(cell);this._contentTable.appen dChild(row);}}
542 WebInspector.TimelineDetailsContentHelper=function(monospaceValues)
543 {this.element=document.createElement("div");this.element.className="timeline-det ails-view-block";this._monospaceValues=monospaceValues;}
544 WebInspector.TimelineDetailsContentHelper.prototype={appendTextRow:function(titl e,value)
545 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);rowElement.createChild("span","timeline-details-vie w-row-value"+(this._monospaceValues?" monospace":"")).textContent=value;},append ElementRow:function(title,content)
546 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);var valueElement=rowElement.createChild("span","tim eline-details-view-row-details"+(this._monospaceValues?" monospace":""));if(cont ent instanceof Node)
547 valueElement.appendChild(content);else
548 valueElement.createTextChild(content||"");},appendStackTrace:function(title,stac kTrace,callFrameLinkifier)
549 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);var stackTraceElement=rowElement.createChild("div", "timeline-details-view-row-stack-trace monospace");for(var i=0;i<stackTrace.leng th;++i){var stackFrame=stackTrace[i];var row=stackTraceElement.createChild("div" );row.createTextChild(stackFrame.functionName||WebInspector.UIString("(anonymous function)"));row.createTextChild(" @ ");var urlElement=callFrameLinkifier(stack Frame);row.appendChild(urlElement);}}};WebInspector.TimelineFrameController=func tion(model,frameOverview,presentationModel)
550 {this._lastMainThreadFrame=null;this._lastBackgroundFrame=null;this._model=model ;this._frameOverview=frameOverview;this._presentationModel=presentationModel;thi s._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._on RecordAdded,this);this._model.addEventListener(WebInspector.TimelineModel.Events .RecordsCleared,this._onRecordsCleared,this);this._frameOverview.reset();var rec ords=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:func tion(record)
555 {var records;var programRecord;if(record.type===WebInspector.TimelineModel.Recor dType.Program){programRecord=record;if(this._lastMainThreadFrame)
556 this._lastMainThreadFrame.timeByCategory["other"]+=WebInspector.TimelineModel.du rationInSeconds(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.BeginFram e;var programTimeCarryover=isFrameRecord&&programRecord?WebInspector.TimelineMod el.endTimeInSeconds(programRecord)-WebInspector.TimelineModel.startTimeInSeconds (record):0;var lastFrame=record.thread?this._lastBackgroundFrame:this._lastMainT hreadFrame;if(isFrameRecord&&lastFrame){this._flushFrame(lastFrame,record,progra mTimeCarryover);lastFrame=this._createFrame(record,programTimeCarryover);}else i f(record.type===WebInspector.TimelineModel.RecordType.ActivateLayerTree){if(last Frame)
559 lastFrame.mainThreadFrameId=record.data.id;}else{if(!lastFrame)
560 lastFrame=this._createFrame(record,programTimeCarryover);if(!record.thread){WebI nspector.TimelineModel.aggregateTimeForRecord(lastFrame.timeByCategory,record);v ar duration=WebInspector.TimelineModel.durationInSeconds(record);lastFrame.cpuTi me+=duration;lastFrame.timeByCategory["other"]-=duration;}else if(!isFrameRecord &&WebInspector.TimelinePresentationModel.recordStyle(record).category===WebInspe ctor.TimelinePresentationModel.categories().painting){this._updatePaintingDurati on(record);}}
561 if(record.thread)
562 this._lastBackgroundFrame=lastFrame;else
563 this._lastMainThreadFrame=lastFrame;},_flushFrame:function(frame,record,programT imeCarryover)
564 {frame.endTime=WebInspector.TimelineModel.startTimeInSeconds(record);frame.durat ion=frame.endTime-frame.startTime;frame.timeByCategory["other"]-=programTimeCarr yover;frame.cpuTime+=frame.timeByCategory["other"];if(frame.isBackground){var pa intDuration=this._paintEndTime-this._paintStartTime;if(paintDuration)
565 frame.timeByCategory[WebInspector.TimelinePresentationModel.categories().paintin g.name]=paintDuration;}
566 this._frameOverview.addFrame(frame);this._presentationModel.addFrame(frame);},_c reateFrame:function(record,programTimeCarryover)
567 {var frame=new WebInspector.TimelineFrame();frame.startTime=WebInspector.Timelin eModel.startTimeInSeconds(record);frame.startTimeOffset=this._model.recordOffset InSeconds(record);frame.timeByCategory["other"]=programTimeCarryover;frame.isBac kground=!!record.thread;frame.id=record.data&&record.data["id"];if(frame.isBackg round){this._paintStartTime=null;this._paintEndTime=null;}
568 return frame;},_updatePaintingDuration:function(record)
569 {var startTime=WebInspector.TimelineModel.startTimeInSeconds(record);this._paint StartTime=this._paintStartTime?Math.min(this._paintStartTime,startTime):startTim e;var endTime=WebInspector.TimelineModel.endTimeInSeconds(record);this._paintEnd Time=this._paintEndTime?Math.max(this._paintEndTime,endTime):endTime;},dispose:f unction()
570 {this._model.removeEventListener(WebInspector.TimelineModel.Events.RecordAdded,t his._onRecordAdded,this);this._model.removeEventListener(WebInspector.TimelineMo del.Events.RecordsCleared,this._onRecordsCleared,this);}}
571 WebInspector.FrameStatistics=function(frames) 434 WebInspector.FrameStatistics=function(frames)
572 {this.frameCount=frames.length;this.minDuration=Infinity;this.maxDuration=0;this .timeByCategory={};this.startOffset=frames[0].startTimeOffset;var lastFrame=fram es[this.frameCount-1];this.endOffset=lastFrame.startTimeOffset+lastFrame.duratio n;var totalDuration=0;var sumOfSquares=0;for(var i=0;i<this.frameCount;++i){var duration=frames[i].duration;totalDuration+=duration;sumOfSquares+=duration*durat ion;this.minDuration=Math.min(this.minDuration,duration);this.maxDuration=Math.m ax(this.maxDuration,duration);WebInspector.TimelineModel.aggregateTimeByCategory (this.timeByCategory,frames[i].timeByCategory);} 435 {this.frameCount=frames.length;this.minDuration=Infinity;this.maxDuration=0;this .timeByCategory={};this.startOffset=frames[0].startTimeOffset;var lastFrame=fram es[this.frameCount-1];this.endOffset=lastFrame.startTimeOffset+lastFrame.duratio n;var totalDuration=0;var sumOfSquares=0;for(var i=0;i<this.frameCount;++i){var duration=frames[i].duration;totalDuration+=duration;sumOfSquares+=duration*durat ion;this.minDuration=Math.min(this.minDuration,duration);this.maxDuration=Math.m ax(this.maxDuration,duration);WebInspector.TimelineUIUtils.aggregateTimeByCatego ry(this.timeByCategory,frames[i].timeByCategory);}
573 this.average=totalDuration/this.frameCount;var variance=sumOfSquares/this.frameC ount-this.average*this.average;this.stddev=Math.sqrt(variance);} 436 this.average=totalDuration/this.frameCount;var variance=sumOfSquares/this.frameC ount-this.average*this.average;this.stddev=Math.sqrt(variance);}
574 WebInspector.TimelineFrame=function() 437 WebInspector.TimelineFrame=function(record)
575 {this.timeByCategory={};this.cpuTime=0;this.mainThreadFrameId;};WebInspector.Tim elineEventOverview=function(model) 438 {this.startTime=record.startTime;this.startTimeOffset=record.startTimeOffset;thi s.endTime=this.startTime;this.duration=0;this.timeByCategory={};this.cpuTime=0;t his.layerTree=null;}
576 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-events";this._fillStyles={};var categories=WebInspector.TimelinePresentat ionModel.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.Visi bilityChanged,this._onCategoryVisibilityChanged,this);} 439 WebInspector.TimelineFrame.prototype={_setEndTime:function(endTime)
577 this._disabledCategoryFillStyle=WebInspector.TimelinePresentationModel.createFil lStyle(this._context,0,WebInspector.TimelineEventOverview._stripGradientHeight," rgb(218, 218, 218)","rgb(170, 170, 170)","rgb(143, 143, 143)");this._disabledCat egoryBorderStyle="rgb(143, 143, 143)";} 440 {this.endTime=endTime;this.duration=this.endTime-this.startTime;},_setLayerTree: function(layerTree)
441 {this.layerTree=layerTree;},_addTimeFromRecord:function(record)
442 {if(!record.endTime)
443 return;WebInspector.TimelineUIUtils.aggregateTimeForRecord(this.timeByCategory,r ecord);this._updateCpuTime();},_addTimeForCategories:function(timeByCategory)
444 {WebInspector.TimelineUIUtils.aggregateTimeByCategory(this.timeByCategory,timeBy Category);this._updateCpuTime();},_updateCpuTime:function()
445 {this.cpuTime=0;for(var key in this.timeByCategory)
446 this.cpuTime+=this.timeByCategory[key];}};WebInspector.TimelineEventOverview=fun ction(model)
447 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-events";this._fillStyles={};var categories=WebInspector.TimelineUIUtils.c ategories();for(var category in categories){this._fillStyles[category]=WebInspec tor.TimelineUIUtils.createFillStyleForCategory(this._context,0,WebInspector.Time lineEventOverview._stripGradientHeight,categories[category]);categories[category ].addEventListener(WebInspector.TimelineCategory.Events.VisibilityChanged,this._ onCategoryVisibilityChanged,this);}
448 this._disabledCategoryFillStyle=WebInspector.TimelineUIUtils.createFillStyle(thi s._context,0,WebInspector.TimelineEventOverview._stripGradientHeight,"hsl(0, 0%, 85%)","hsl(0, 0%, 67%)","hsl(0, 0%, 56%)");this._disabledCategoryBorderStyle="r gb(143, 143, 143)";}
578 WebInspector.TimelineEventOverview._numberOfStrips=3;WebInspector.TimelineEventO verview._stripGradientHeight=120;WebInspector.TimelineEventOverview.prototype={u pdate:function() 449 WebInspector.TimelineEventOverview._numberOfStrips=3;WebInspector.TimelineEventO verview._stripGradientHeight=120;WebInspector.TimelineEventOverview.prototype={u pdate:function()
579 {this.resetCanvas();var stripHeight=Math.round(this._canvas.height/WebInspector. TimelineEventOverview._numberOfStrips);var timeOffset=this._model.minimumRecordT ime();var timeSpan=this._model.maximumRecordTime()-timeOffset;var scale=this._ca nvas.width/timeSpan;var lastBarByGroup=[];this._context.fillStyle="rgba(0, 0, 0, 0.05)";for(var i=1;i<WebInspector.TimelineEventOverview._numberOfStrips;i+=2) 450 {this.resetCanvas();var stripHeight=Math.round(this._canvas.height/WebInspector. TimelineEventOverview._numberOfStrips);var timeOffset=this._model.minimumRecordT ime();var timeSpan=this._model.maximumRecordTime()-timeOffset;var scale=this._ca nvas.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);fun ction appendRecord(record) 451 this._context.fillRect(0.5,i*stripHeight+0.5,this._canvas.width,stripHeight);fun ction appendRecord(record)
581 {if(record.type===WebInspector.TimelineModel.RecordType.BeginFrame) 452 {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.TimelinePr esentationModel.categoryForRecord(record);if(category.overviewStripGroupIndex<0) 453 return;var recordStart=Math.floor((record.startTime-timeOffset)*scale);var recor dEnd=Math.ceil((record.endTime-timeOffset)*scale);var category=WebInspector.Time lineUIUtils.categoryForRecord(record);if(category.overviewStripGroupIndex<0)
583 return;var bar=lastBarByGroup[category.overviewStripGroupIndex];const barsMergeT hreshold=2;if(bar&&bar.category===category&&bar.end+barsMergeThreshold>=recordSt art){if(recordEnd>bar.end) 454 return;var bar=lastBarByGroup[category.overviewStripGroupIndex];const barsMergeT hreshold=2;if(bar&&bar.category===category&&bar.end+barsMergeThreshold>=recordSt art){if(recordEnd>bar.end)
584 bar.end=recordEnd;return;} 455 bar.end=recordEnd;return;}
585 if(bar) 456 if(bar)
586 this._renderBar(bar.start,bar.end,stripHeight,bar.category);lastBarByGroup[categ ory.overviewStripGroupIndex]={start:recordStart,end:recordEnd,category:category} ;} 457 this._renderBar(bar.start,bar.end,stripHeight,bar.category);lastBarByGroup[categ ory.overviewStripGroupIndex]={start:recordStart,end:recordEnd,category:category} ;}
587 WebInspector.TimelinePresentationModel.forAllRecords(this._model.records,appendR ecord.bind(this));for(var i=0;i<lastBarByGroup.length;++i){if(lastBarByGroup[i]) 458 this._model.forAllRecords(appendRecord.bind(this));for(var i=0;i<lastBarByGroup. length;++i){if(lastBarByGroup[i])
588 this._renderBar(lastBarByGroup[i].start,lastBarByGroup[i].end,stripHeight,lastBa rByGroup[i].category);}},_onCategoryVisibilityChanged:function() 459 this._renderBar(lastBarByGroup[i].start,lastBarByGroup[i].end,stripHeight,lastBa rByGroup[i].category);}},_onCategoryVisibilityChanged:function()
589 {this.update();},_renderBar:function(begin,end,height,category) 460 {this.update();},_renderBar:function(begin,end,height,category)
590 {const stripPadding=4*window.devicePixelRatio;const innerStripHeight=height-2*st ripPadding;var x=begin+0.5;var y=category.overviewStripGroupIndex*height+stripPa dding+0.5;var width=Math.max(end-begin,1);this._context.save();this._context.tra nslate(x,y);this._context.scale(1,innerStripHeight/WebInspector.TimelineEventOve rview._stripGradientHeight);this._context.fillStyle=category.hidden?this._disabl edCategoryFillStyle:this._fillStyles[category.name];this._context.fillRect(0,0,w idth,WebInspector.TimelineEventOverview._stripGradientHeight);this._context.stro keStyle=category.hidden?this._disabledCategoryBorderStyle:category.borderColor;t his._context.strokeRect(0,0,width,WebInspector.TimelineEventOverview._stripGradi entHeight);this._context.restore();},__proto__:WebInspector.TimelineOverviewBase .prototype};WebInspector.TimelineFrameOverview=function(model) 461 {const stripPadding=4*window.devicePixelRatio;const innerStripHeight=height-2*st ripPadding;var x=begin+0.5;var y=category.overviewStripGroupIndex*height+stripPa dding+0.5;var width=Math.max(end-begin,1);this._context.save();this._context.tra nslate(x,y);this._context.scale(1,innerStripHeight/WebInspector.TimelineEventOve rview._stripGradientHeight);this._context.fillStyle=category.hidden?this._disabl edCategoryFillStyle:this._fillStyles[category.name];this._context.fillRect(0,0,w idth,WebInspector.TimelineEventOverview._stripGradientHeight);this._context.stro keStyle=category.hidden?this._disabledCategoryBorderStyle:category.borderColor;t his._context.strokeRect(0,0,width,WebInspector.TimelineEventOverview._stripGradi entHeight);this._context.restore();},__proto__:WebInspector.TimelineOverviewBase .prototype};WebInspector.TimelineFrameOverview=function(model,frameModel)
591 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-frames";this.reset();this._outerPadding=4*window.devicePixelRatio;this._m axInnerBarWidth=10*window.devicePixelRatio;this._topPadding=6*window.devicePixel Ratio;this._actualPadding=5*window.devicePixelRatio;this._actualOuterBarWidth=th is._maxInnerBarWidth+this._actualPadding;this._fillStyles={};var categories=WebI nspector.TimelinePresentationModel.categories();for(var category in categories) 462 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-frames";this._frameModel=frameModel;this.reset();this._outerPadding=4*win dow.devicePixelRatio;this._maxInnerBarWidth=10*window.devicePixelRatio;this._top Padding=6*window.devicePixelRatio;this._actualPadding=5*window.devicePixelRatio; this._actualOuterBarWidth=this._maxInnerBarWidth+this._actualPadding;this._fillS tyles={};var categories=WebInspector.TimelineUIUtils.categories();for(var catego ry in categories)
592 this._fillStyles[category]=WebInspector.TimelinePresentationModel.createFillStyl eForCategory(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._fr ameTopShadeGradient.addColorStop(1,"rgba(255, 255, 255, 0.2)");} 463 this._fillStyles[category]=WebInspector.TimelineUIUtils.createFillStyleForCatego ry(this._context,this._maxInnerBarWidth,0,categories[category]);this._frameTopSh adeGradient=this._context.createLinearGradient(0,0,0,this._topPadding);this._fra meTopShadeGradient.addColorStop(0,"rgba(255, 255, 255, 0.9)");this._frameTopShad eGradient.addColorStop(1,"rgba(255, 255, 255, 0.2)");}
593 WebInspector.TimelineFrameOverview.prototype={reset:function() 464 WebInspector.TimelineFrameOverview.prototype={reset:function()
594 {this._recordsPerBar=1;this._barTimes=[];this._mainThreadFrames=[];this._backgro undFrames=[];this._framesById={};},update:function() 465 {this._recordsPerBar=1;this._barTimes=[];},update:function()
595 {this.resetCanvas();this._barTimes=[];var backgroundFramesHeight=15*window.devic ePixelRatio;var mainThreadFramesHeight=this._canvas.height-backgroundFramesHeigh t;const minBarWidth=4*window.devicePixelRatio;var frameCount=this._backgroundFra mes.length||this._mainThreadFrames.length;var framesPerBar=Math.max(1,frameCount *minBarWidth/this._canvas.width);var mainThreadVisibleFrames;var backgroundVisib leFrames;if(this._backgroundFrames.length){backgroundVisibleFrames=this._aggrega teFrames(this._backgroundFrames,framesPerBar);mainThreadVisibleFrames=new Array( backgroundVisibleFrames.length);for(var i=0;i<backgroundVisibleFrames.length;++i ){var frameId=backgroundVisibleFrames[i].mainThreadFrameId;mainThreadVisibleFram es[i]=frameId&&this._framesById[frameId];}}else{mainThreadVisibleFrames=this._ag gregateFrames(this._mainThreadFrames,framesPerBar);} 466 {this.resetCanvas();this._barTimes=[];const minBarWidth=4*window.devicePixelRati o;var frames=this._frameModel.frames();var framesPerBar=Math.max(1,frames.length *minBarWidth/this._canvas.width);var visibleFrames=this._aggregateFrames(frames, framesPerBar);this._context.save();var scale=(this._canvas.height-this._topPaddi ng)/this._computeTargetFrameLength(visibleFrames);this._renderBars(visibleFrames ,scale,this._canvas.height);this._context.fillStyle=this._frameTopShadeGradient; this._context.fillRect(0,0,this._canvas.width,this._topPadding);this._drawFPSMar ks(scale,this._canvas.height);this._context.restore();},_aggregateFrames:functio n(frames,framesPerBar)
596 this._context.save();this._setCanvasWindow(0,backgroundFramesHeight,this._canvas .width,mainThreadFramesHeight);var scale=(mainThreadFramesHeight-this._topPaddin g)/this._computeTargetFrameLength(mainThreadVisibleFrames);this._renderBars(main ThreadVisibleFrames,scale,mainThreadFramesHeight);this._context.fillStyle=this._ frameTopShadeGradient;this._context.fillRect(0,0,this._canvas.width,this._topPad ding);this._drawFPSMarks(scale,mainThreadFramesHeight);this._context.restore();v ar bottom=backgroundFramesHeight+0.5;this._context.strokeStyle="rgba(120, 120, 1 20, 0.8)";this._context.beginPath();this._context.moveTo(0,bottom);this._context .lineTo(this._canvas.width,bottom);this._context.stroke();if(backgroundVisibleFr ames){const targetFPS=30.0;scale=(backgroundFramesHeight-this._topPadding)/(1.0/ targetFPS);this._renderBars(backgroundVisibleFrames,scale,backgroundFramesHeight );}},addFrame:function(frame) 467 {var visibleFrames=[];for(var barNumber=0,currentFrame=0;currentFrame<frames.len gth;++barNumber){var barStartTime=frames[currentFrame].startTime;var longestFram e=null;var longestDuration=0;for(var lastFrame=Math.min(Math.floor((barNumber+1) *framesPerBar),frames.length);currentFrame<lastFrame;++currentFrame){var duratio n=frames[currentFrame].duration;if(!longestFrame||longestDuration<duration){long estFrame=frames[currentFrame];longestDuration=duration;}}
597 {var frames;if(frame.isBackground){frames=this._backgroundFrames;}else{frames=th is._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._conte xt.lineTo(0,height);this._context.lineTo(0,0);this._context.clip();},_aggregateF rames:function(frames,framesPerBar)
600 {var visibleFrames=[];for(var barNumber=0,currentFrame=0;currentFrame<frames.len gth;++barNumber){var barStartTime=frames[currentFrame].startTime;var longestFram e=null;var longestDuration=0;for(var lastFrame=Math.min(Math.floor((barNumber+1) *framesPerBar),frames.length);currentFrame<lastFrame;++currentFrame){var duratio n=this._frameDuration(frames[currentFrame]);if(!longestFrame||longestDuration<du ration){longestFrame=frames[currentFrame];longestDuration=duration;}}
601 var barEndTime=frames[currentFrame-1].endTime;if(longestFrame){visibleFrames.pus h(longestFrame);this._barTimes.push({startTime:barStartTime,endTime:barEndTime}) ;}} 468 var barEndTime=frames[currentFrame-1].endTime;if(longestFrame){visibleFrames.pus h(longestFrame);this._barTimes.push({startTime:barStartTime,endTime:barEndTime}) ;}}
602 return visibleFrames;},_frameDuration:function(frame) 469 return visibleFrames;},_computeTargetFrameLength:function(frames)
603 {var relatedFrame=frame.mainThreadFrameId&&this._framesById[frame.mainThreadFram eId];return frame.duration+(relatedFrame?relatedFrame.duration:0);},_computeTarg etFrameLength:function(frames)
604 {var durations=[];for(var i=0;i<frames.length;++i){if(frames[i]) 470 {var durations=[];for(var i=0;i<frames.length;++i){if(frames[i])
605 durations.push(frames[i].duration);} 471 durations.push(frames[i].duration);}
606 var medianFrameLength=durations.qselect(Math.floor(durations.length/2));const ta rgetFPS=30;var result=1.0/targetFPS;if(result>=medianFrameLength) 472 var medianFrameLength=durations.qselect(Math.floor(durations.length/2));const ta rgetFPS=20;var result=1000.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,windowHe ight) 473 return result;var maxFrameLength=Math.max.apply(Math,durations);return Math.min( medianFrameLength*2,maxFrameLength);},_renderBars:function(frames,scale,windowHe ight)
608 {const maxPadding=5*window.devicePixelRatio;this._actualOuterBarWidth=Math.min(( this._canvas.width-2*this._outerPadding)/frames.length,this._maxInnerBarWidth+ma xPadding);this._actualPadding=Math.min(Math.floor(this._actualOuterBarWidth/3),m axPadding);var barWidth=this._actualOuterBarWidth-this._actualPadding;for(var i= 0;i<frames.length;++i){if(frames[i]) 474 {const maxPadding=5*window.devicePixelRatio;this._actualOuterBarWidth=Math.min(( this._canvas.width-2*this._outerPadding)/frames.length,this._maxInnerBarWidth+ma xPadding);this._actualPadding=Math.min(Math.floor(this._actualOuterBarWidth/3),m axPadding);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) 475 this._renderBar(this._barNumberToScreenPosition(i),barWidth,windowHeight,frames[ i],scale);}},_barNumberToScreenPosition:function(n)
610 {return this._outerPadding+this._actualOuterBarWidth*n;},_drawFPSMarks:function( scale,height) 476 {return this._outerPadding+this._actualOuterBarWidth*n;},_drawFPSMarks:function( scale,height)
611 {const fpsMarks=[30,60];this._context.save();this._context.beginPath();this._con text.font=(10*window.devicePixelRatio)+"px "+window.getComputedStyle(this.elemen t,null).getPropertyValue("font-family");this._context.textAlign="right";this._co ntext.textBaseline="alphabetic";const labelPadding=4*window.devicePixelRatio;con st baselineHeight=3*window.devicePixelRatio;var lineHeight=12*window.devicePixel Ratio;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=WebIns pector.UIString("%d\u2009fps",fps);var labelWidth=this._context.measureText(labe l).width+2*labelPadding;var labelX=this._canvas.width;if(!i&&labelTopMargin<y-li neHeight) 477 {const fpsMarks=[30,60];this._context.save();this._context.beginPath();this._con text.font=(10*window.devicePixelRatio)+"px "+window.getComputedStyle(this.elemen t,null).getPropertyValue("font-family");this._context.textAlign="right";this._co ntext.textBaseline="alphabetic";const labelPadding=4*window.devicePixelRatio;con st baselineHeight=3*window.devicePixelRatio;var lineHeight=12*window.devicePixel Ratio;var labelTopMargin=0;var labelOffsetY=0;for(var i=0;i<fpsMarks.length;++i) {var fps=fpsMarks[i];var y=height-Math.floor(1000.0/fps*scale)-0.5;var label=Web Inspector.UIString("%d\u2009fps",fps);var labelWidth=this._context.measureText(l abel).width+2*labelPadding;var labelX=this._canvas.width;if(!i&&labelTopMargin<y -lineHeight)
612 labelOffsetY=-lineHeight;var labelY=y+labelOffsetY;if(labelY<labelTopMargin||lab elY+lineHeight>height) 478 labelOffsetY=-lineHeight;var labelY=y+labelOffsetY;if(labelY<labelTopMargin||lab elY+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-labe lWidth,labelY,labelWidth,lineHeight);this._context.fillStyle="black";this._conte xt.fillText(label,labelX-labelPadding,labelY+lineHeight-baselineHeight);labelTop Margin=labelY+lineHeight;} 479 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-labe lWidth,labelY,labelWidth,lineHeight);this._context.fillStyle="black";this._conte xt.fillText(label,labelX-labelPadding,labelY+lineHeight-baselineHeight);labelTop Margin=labelY+lineHeight;}
614 this._context.strokeStyle="rgba(60, 60, 60, 0.4)";this._context.stroke();this._c ontext.restore();},_renderBar:function(left,width,windowHeight,frame,scale) 480 this._context.strokeStyle="rgba(60, 60, 60, 0.4)";this._context.stroke();this._c ontext.restore();},_renderBar:function(left,width,windowHeight,frame,scale)
615 {var categories=Object.keys(WebInspector.TimelinePresentationModel.categories()) ;if(!categories.length) 481 {var categories=Object.keys(WebInspector.TimelineUIUtils.categories());var x=Mat h.floor(left)+0.5;width=Math.floor(width);var totalCPUTime=frame.cpuTime;var nor malizedScale=scale;if(totalCPUTime>frame.duration)
616 return;var x=Math.floor(left)+0.5;width=Math.floor(width);for(var i=0,bottomOffs et=windowHeight;i<categories.length;++i){var category=categories[i];var duration =frame.timeByCategory[category];if(!duration) 482 normalizedScale*=frame.duration/totalCPUTime;for(var i=0,bottomOffset=windowHeig ht;i<categories.length;++i){var category=categories[i];var duration=frame.timeBy Category[category];if(!duration)
617 continue;var height=Math.round(duration*scale);var y=Math.floor(bottomOffset-hei ght)+0.5;this._context.save();this._context.translate(x,0);this._context.scale(w idth/this._maxInnerBarWidth,1);this._context.fillStyle=this._fillStyles[category ];this._context.fillRect(0,y,this._maxInnerBarWidth,Math.floor(height));this._co ntext.strokeStyle=WebInspector.TimelinePresentationModel.categories()[category]. borderColor;this._context.beginPath();this._context.moveTo(0,y);this._context.li neTo(this._maxInnerBarWidth,y);this._context.stroke();this._context.restore();bo ttomOffset-=height;} 483 continue;var height=Math.round(duration*normalizedScale);var y=Math.floor(bottom Offset-height)+0.5;this._context.save();this._context.translate(x,0);this._conte xt.scale(width/this._maxInnerBarWidth,1);this._context.fillStyle=this._fillStyle s[category];this._context.fillRect(0,y,this._maxInnerBarWidth,Math.floor(height) );this._context.strokeStyle=WebInspector.TimelineUIUtils.categories()[category]. borderColor;this._context.beginPath();this._context.moveTo(0,y);this._context.li neTo(this._maxInnerBarWidth,y);this._context.stroke();this._context.restore();bo ttomOffset-=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();thi s._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:functi on(windowLeft,windowRight) 484 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();thi s._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:functi on(windowLeft,windowRight)
619 {if(!this._barTimes.length) 485 {if(!this._barTimes.length)
620 return WebInspector.TimelineOverviewBase.prototype.windowTimes.call(this,windowL eft,windowRight);var windowSpan=this._canvas.width;var leftOffset=windowLeft*win dowSpan-this._outerPadding+this._actualPadding;var rightOffset=windowRight*windo wSpan-this._outerPadding;var firstBar=Math.floor(Math.max(leftOffset,0)/this._ac tualOuterBarWidth);var lastBar=Math.min(Math.floor(rightOffset/this._actualOuter BarWidth),this._barTimes.length-1);if(firstBar>=this._barTimes.length) 486 return WebInspector.TimelineOverviewBase.prototype.windowTimes.call(this,windowL eft,windowRight);var windowSpan=this._canvas.width;var leftOffset=windowLeft*win dowSpan-this._outerPadding+this._actualPadding;var rightOffset=windowRight*windo wSpan-this._outerPadding;var firstBar=Math.floor(Math.max(leftOffset,0)/this._ac tualOuterBarWidth);var lastBar=Math.min(Math.floor(rightOffset/this._actualOuter BarWidth),this._barTimes.length-1);if(firstBar>=this._barTimes.length)
621 return{startTime:Infinity,endTime:Infinity};const snapToRightTolerancePixels=3;r eturn{startTime:this._barTimes[firstBar].startTime,endTime:(rightOffset+snapToRi ghtTolerancePixels>windowSpan)||(lastBar>=this._barTimes.length)?Infinity:this._ barTimes[lastBar].endTime}},windowBoundaries:function(startTime,endTime) 487 return{startTime:Infinity,endTime:Infinity};const snapToRightTolerancePixels=3;r eturn{startTime:this._barTimes[firstBar].startTime,endTime:(rightOffset+snapToRi ghtTolerancePixels>windowSpan)||(lastBar>=this._barTimes.length)?Infinity:this._ barTimes[lastBar].endTime}},windowBoundaries:function(startTime,endTime)
622 {if(this._barTimes.length===0) 488 {if(this._barTimes.length===0)
623 return{left:0,right:1};function barStartComparator(time,barTime) 489 return{left:0,right:1};function barStartComparator(time,barTime)
624 {return time-barTime.startTime;} 490 {return time-barTime.startTime;}
625 function barEndComparator(time,barTime) 491 function barEndComparator(time,barTime)
626 {if(time===barTime.endTime) 492 {if(time===barTime.endTime)
627 return 1;return time-barTime.endTime;} 493 return 1;return time-barTime.endTime;}
628 return{left:this._windowBoundaryFromTime(startTime,barEndComparator),right:this. _windowBoundaryFromTime(endTime,barStartComparator)}},_windowBoundaryFromTime:fu nction(time,comparator) 494 return{left:this._windowBoundaryFromTime(startTime,barEndComparator),right:this. _windowBoundaryFromTime(endTime,barStartComparator)}},_windowBoundaryFromTime:fu nction(time,comparator)
629 {if(time===Infinity) 495 {if(time===Infinity)
630 return 1;var index=this._firstBarAfter(time,comparator);if(!index) 496 return 1;var index=this._firstBarAfter(time,comparator);if(!index)
631 return 0;return(this._barNumberToScreenPosition(index)-this._actualPadding/2)/th is._canvas.width;},_firstBarAfter:function(time,comparator) 497 return 0;return(this._barNumberToScreenPosition(index)-this._actualPadding/2)/th is._canvas.width;},_firstBarAfter:function(time,comparator)
632 {return insertionIndexForObjectInListSortedByFunction(time,this._barTimes,compar ator);},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector.Time lineMemoryOverview=function(model) 498 {return insertionIndexForObjectInListSortedByFunction(time,this._barTimes,compar ator);},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector.Time lineMemoryOverview=function(model)
633 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-memory";this._maxHeapSizeLabel=this.element.createChild("div","max memory -graph-label");this._minHeapSizeLabel=this.element.createChild("div","min memory -graph-label");} 499 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-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() 500 WebInspector.TimelineMemoryOverview.prototype={resetHeapSizeLabels:function()
635 {this.resetCanvas();var records=this._model.records;if(!records.length) 501 {this._maxHeapSizeLabel.textContent="";this._minHeapSizeLabel.textContent="";},u pdate:function()
636 return;const lowerOffset=3;var maxUsedHeapSize=0;var minUsedHeapSize=10000000000 0;var minTime=this._model.minimumRecordTime();var maxTime=this._model.maximumRec ordTime();WebInspector.TimelinePresentationModel.forAllRecords(records,function( r){if(!r.counters||!r.counters.jsHeapSizeUsed) 502 {this.resetCanvas();var records=this._model.records();if(!records.length){this.r esetHeapSizeLabels();return;}
637 return;maxUsedHeapSize=Math.max(maxUsedHeapSize,r.counters.jsHeapSizeUsed);minUs edHeapSize=Math.min(minUsedHeapSize,r.counters.jsHeapSizeUsed);});minUsedHeapSiz e=Math.min(minUsedHeapSize,maxUsedHeapSize);var width=this._canvas.width;var hei ght=this._canvas.height-lowerOffset;var xFactor=width/(maxTime-minTime);var yFac tor=height/Math.max(maxUsedHeapSize-minUsedHeapSize,1);var histogram=new Array(w idth);WebInspector.TimelinePresentationModel.forAllRecords(records,function(r){i f(!r.counters||!r.counters.jsHeapSizeUsed) 503 const lowerOffset=3;var maxUsedHeapSize=0;var minUsedHeapSize=100000000000;var m inTime=this._model.minimumRecordTime();var maxTime=this._model.maximumRecordTime ();this._model.forAllRecords(function(r){if(!r.counters||!r.counters.jsHeapSizeU sed)
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._cont ext;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 ") 504 return;maxUsedHeapSize=Math.max(maxUsedHeapSize,r.counters.jsHeapSizeUsed);minUs edHeapSize=Math.min(minUsedHeapSize,r.counters.jsHeapSizeUsed);});minUsedHeapSiz e=Math.min(minUsedHeapSize,maxUsedHeapSize);var width=this._canvas.width;var hei ght=this._canvas.height-lowerOffset;var xFactor=width/(maxTime-minTime);var yFac tor=height/Math.max(maxUsedHeapSize-minUsedHeapSize,1);var histogram=new Array(w idth);this._model.forAllRecords(function(r){if(!r.counters||!r.counters.jsHeapSi zeUsed)
505 return;var x=Math.round((r.endTime-minTime)*xFactor);var y=(r.counters.jsHeapSiz eUsed-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.leng th;x++){if(typeof histogram[x]==="undefined")
639 continue;if(isFirstPoint){isFirstPoint=false;y=histogram[x];ctx.lineTo(-1,height -y);} 506 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);} 507 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,t his._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.pr ototype};WebInspector.TimelineView=function(panel,model,glueRecordsSetting,mode) 508 ctx.lineTo(width,height-y);ctx.lineTo(width,this._canvas.height);ctx.lineTo(-1,t his._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.pr ototype};WebInspector.TimelinePowerOverviewDataProvider=function()
642 {WebInspector.View.call(this);this.element.classList.add("timeline-view");this.e lement.classList.add("hbox");this._panel=panel;this._model=model;this._currentMo de=mode;this._calculator=new WebInspector.TimelineCalculator(this._model);this._ model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded,this._onTim elineEventRecorded,this);this._model.addEventListener(WebInspector.TimelineModel .Events.RecordsCleared,this._onRecordsCleared,this);this._presentationModel=new WebInspector.TimelinePresentationModel();this._durationFilter=new WebInspector.T imelineIsLongFilter();this._windowFilter=new WebInspector.TimelineWindowFilter() ;this._presentationModel.addFilter(this._windowFilter);this._presentationModel.a ddFilter(new WebInspector.TimelineCategoryFilter());this._presentationModel.addF ilter(this._durationFilter);this._frameMode=mode===WebInspector.TimelinePanel.Mo de.Frames;this._boundariesAreValid=true;this._scrollTop=0;this._detailsSplitView =new WebInspector.SplitView(false,"timeline-details");this._detailsSplitView.ele ment.classList.remove("fill");this._detailsSplitView.element.classList.add("time line-details-split");this._detailsSplitView.sidebarElement().classList.add("time line-details");this._detailsSplitView.mainElement().classList.add("vbox");this._ detailsSplitView.setMainElementConstraints(undefined,40);this._detailsView=new W ebInspector.TimelineDetailsView();this._detailsSplitView.setSidebarView(this._de tailsView);this._detailsSplitView.installResizer(this._detailsView.titleElement( ));WebInspector.dockController.addEventListener(WebInspector.DockController.Even ts.DockSideChanged,this._dockSideChanged.bind(this));WebInspector.settings.split VerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this)); this._dockSideChanged();this._searchableView=new WebInspector.SearchableView(thi s);this._searchableView.element.classList.add("searchable-view");this._detailsSp litView.setMainView(this._searchableView);this._views=[];this._recordsView=this. _createRecordsView();this._views.push(this._recordsView);this._stackView=new Web Inspector.StackView(false);this._stackView.show(this._searchableView.element);th is._stackView.element.classList.add("timeline-view-stack");this._recordsViewMain Element=this._stackView.appendView(this._recordsView,"timeline-records").mainEle ment();this._recordsViewMainElement.classList.add("timeline-records-view");this. _recordsViewMainElement.appendChild(this._timelineGrid.gridHeaderElement);if(thi s._currentMode===WebInspector.TimelinePanel.Mode.Memory){this._memoryStatistics= new WebInspector.CountersGraph(this,this._model);this._views.push(this._memorySt atistics);this._memoryStatistics.addEventListener(WebInspector.TimelineView.Even ts.SidebarResized,this._sidebarResized,this);this._stackView.appendView(this._me moryStatistics,"timeline-memory");} 509 {this._records=[];if(Capabilities.canProfilePower)
643 this._popoverHelper=new WebInspector.PopoverHelper(this.element,this._getPopover Anchor.bind(this),this._showPopover.bind(this));this.element.addEventListener("m ousemove",this._mouseMove.bind(this),false);this.element.addEventListener("mouse out",this._mouseOut.bind(this),false);this.element.addEventListener("keydown",th is._keyDown.bind(this),false);this._expandOffset=15;this._windowStartTime=0;this ._windowEndTime=Infinity;this._allRecordsCount=0;this._presentationModel.setGlue Records(glueRecordsSetting.get());this._glueRecordsSetting=glueRecordsSetting;th is._glueRecordsSetting.addChangeListener(this._onGlueRecordsSettingChanged,this) ;switch(mode){case WebInspector.TimelinePanel.Mode.Events:this._overviewControl= new WebInspector.TimelineEventOverview(this._model);break;case WebInspector.Time linePanel.Mode.Frames:this._overviewControl=new WebInspector.TimelineFrameOvervi ew(this._model);this._presentationModel.setGlueRecords(false);this._frameControl ler=new WebInspector.TimelineFrameController(this._model,this._overviewControl,t his._presentationModel);break;case WebInspector.TimelinePanel.Mode.Memory:this._ overviewControl=new WebInspector.TimelineMemoryOverview(this._model);break;} 510 WebInspector.powerProfiler.addEventListener(WebInspector.PowerProfiler.EventType s.PowerEventRecorded,this._onRecordAdded,this);}
644 this._detailsSplitView.show(this.element);} 511 WebInspector.TimelinePowerOverviewDataProvider.prototype={records:function()
645 WebInspector.TimelineView.Events={SidebarResized:"SidebarResized"} 512 {return this._records.slice(0,this._records.length-1);},_onRecordAdded:function( event)
646 WebInspector.TimelineView.commonUIFilters=function() 513 {var record=event.data;var length=this._records.length;if(length)
647 {var filters=WebInspector.TimelineView._commonUIFilters;if(filters) 514 this._records[length-1].value=record.value;this._records.push(record);},__proto_ _:WebInspector.Object.prototype}
648 return filters;filters={};filters._textFilterUI=new WebInspector.TextFilterUI(); var durationOptions=[];for(var presetIndex=0;presetIndex<WebInspector.TimelinePa nel.durationFilterPresetsMs.length;++presetIndex){var durationMs=WebInspector.Ti melinePanel.durationFilterPresetsMs[presetIndex];var durationOption={};if(!durat ionMs){durationOption.label=WebInspector.UIString("All");durationOption.title=We bInspector.UIString("Show all records");}else{durationOption.label=WebInspector. UIString("\u2265 %dms",durationMs);durationOption.title=WebInspector.UIString("H ide records shorter than %dms",durationMs);} 515 WebInspector.TimelinePowerOverview=function(model)
649 durationOption.value=durationMs;durationOptions.push(durationOption);} 516 {WebInspector.TimelineOverviewBase.call(this,model);this.element.id="timeline-ov erview-power";this._dataProvider=new WebInspector.TimelinePowerOverviewDataProvi der();this._maxPowerLabel=this.element.createChild("div","max memory-graph-label ");this._minPowerLabel=this.element.createChild("div","min memory-graph-label"); }
650 filters._durationFilterUI=new WebInspector.ComboBoxFilterUI(durationOptions);fil ters._categoryFiltersUI={};var categoryTypes=[];var categories=WebInspector.Time linePresentationModel.categories();for(var categoryName in categories){var categ ory=categories[categoryName];if(category.overviewStripGroupIndex<0) 517 WebInspector.TimelinePowerOverview.prototype={timelineStarted:function()
651 continue;var filter=new WebInspector.CheckboxFilterUI(category.name,category.tit le);filters._categoryFiltersUI[category.name]=filter;} 518 {if(Capabilities.canProfilePower)
652 WebInspector.TimelineView._commonUIFilters=filters;return filters;} 519 WebInspector.powerProfiler.startProfile();},timelineStopped:function()
653 WebInspector.TimelineView.prototype={_createRecordsView:function() 520 {if(Capabilities.canProfilePower)
654 {var recordsView=new WebInspector.SidebarView(WebInspector.SidebarView.SidebarPo sition.Start,"timeline-split");recordsView.addEventListener(WebInspector.Sidebar View.EventTypes.Resized,this._sidebarResized,this);recordsView.setSecondIsSideba r(false);this._containerElement=recordsView.element;this._containerElement.tabIn dex=0;this._containerElement.id="timeline-container";this._containerElement.addE ventListener("scroll",this._onScroll.bind(this),false);recordsView.sidebarElemen t().classList.add("vbox");recordsView.sidebarElement().createChild("div","timeli ne-records-title").textContent=WebInspector.UIString("RECORDS");this._sidebarLis tElement=recordsView.sidebarElement().createChild("div","timeline-records-list") ;this._gridContainer=new WebInspector.ViewWithResizeCallback(this._onViewportRes ize.bind(this));this._gridContainer.element.classList.add("fill");this._gridCont ainer.element.id="resources-container-content";recordsView.setMainView(this._gri dContainer);this._timelineGrid=new WebInspector.TimelineGrid();this._itemsGraphs Element=this._timelineGrid.itemsGraphsElement;this._itemsGraphsElement.id="timel ine-graphs";this._gridContainer.element.appendChild(this._timelineGrid.element); this._timelineGrid.gridHeaderElement.id="timeline-grid-header";this._timelineGri d.gridHeaderElement.classList.add("fill");this._topGapElement=this._itemsGraphsE lement.createChild("div","timeline-gap");this._graphRowsElement=this._itemsGraph sElement.createChild("div");this._bottomGapElement=this._itemsGraphsElement.crea teChild("div","timeline-gap");this._expandElements=this._itemsGraphsElement.crea teChild("div");this._expandElements.id="orphan-expand-elements";this._mainThread Tasks=([]);this._gpuTasks=([]);var utilizationStripsElement=this._timelineGrid.g ridHeaderElement.createChild("div","timeline-utilization-strips vbox");this._cpu BarsElement=utilizationStripsElement.createChild("div","timeline-utilization-str ip");if(WebInspector.experimentsSettings.gpuTimeline.isEnabled()) 521 WebInspector.powerProfiler.stopProfile();},_resetPowerLabels:function()
655 this._gpuBarsElement=utilizationStripsElement.createChild("div","timeline-utiliz ation-strip gpu");return recordsView;},searchableView:function() 522 {this._maxPowerLabel.textContent="";this._minPowerLabel.textContent="";},update: function()
656 {return this._searchableView;},supportsGlueParentMode:function() 523 {this.resetCanvas();var records=this._dataProvider.records();if(!records.length) {this._resetPowerLabels();return;}
657 {return!this._frameMode;},_onGlueRecordsSettingChanged:function() 524 const lowerOffset=3;var maxPower=0;var minPower=100000000000;var minTime=this._m odel.minimumRecordTime();var maxTime=this._model.maximumRecordTime();for(var i=0 ;i<records.length;i++){var record=records[i];if(record.timestamp<minTime||record .timestamp>maxTime)
658 {this._presentationModel.setGlueRecords(this._glueRecordsSetting.get());this._re populateRecords();},windowStartTime:function() 525 continue;maxPower=Math.max(maxPower,record.value);minPower=Math.min(minPower,rec ord.value);}
659 {return this._windowStartTime||this._model.minimumRecordTime();},windowEndTime:f unction() 526 minPower=Math.min(minPower,maxPower);var width=this._canvas.width;var height=thi s._canvas.height-lowerOffset;var xFactor=width/(maxTime-minTime);var yFactor=hei ght/Math.max(maxPower-minPower,1);var histogram=new Array(width);for(var i=0;i<r ecords.length-1;i++){var record=records[i];if(record.timestamp<minTime||record.t imestamp>maxTime)
660 {return this._windowEndTime<Infinity?this._windowEndTime:this._model.maximumReco rdTime();},overviewControl:function() 527 continue;var x=Math.round((record.timestamp-minTime)*xFactor);var y=Math.round(( record.value-minPower)*yFactor);histogram[x]=Math.max(histogram[x]||0,y);}
661 {return this._overviewControl;},get calculator() 528 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")
662 {return this._calculator;},createUIFilters:function(filterBar) 529 continue;if(isFirstPoint){isFirstPoint=false;y=histogram[x];ctx.lineTo(-1,height -y);}
663 {var filters=this._filters;if(!filters){this._filters=WebInspector.TimelineView. commonUIFilters();filters=this._filters;filters._textFilterUI.addEventListener(W ebInspector.FilterUI.Events.FilterChanged,this._textFilterChanged,this);filters. _durationFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterChanged,th is._durationFilterChanged,this);for(var categoryName in filters._categoryFilters UI) 530 ctx.lineTo(x,height-y);y=histogram[x];ctx.lineTo(x,height-y);}
664 filters._categoryFiltersUI[categoryName].addEventListener(WebInspector.FilterUI. Events.FilterChanged,this._categoriesFilterChanged.bind(this,categoryName),this) ;} 531 ctx.lineTo(width,height-y);ctx.lineTo(width,this._canvas.height);ctx.lineTo(-1,t his._canvas.height);ctx.closePath();ctx.fillStyle="rgba(255,192,0, 0.8);";ctx.fi ll();ctx.lineWidth=0.5;ctx.strokeStyle="rgba(20,0,0,0.8)";ctx.stroke();ctx.resto re();this._maxPowerLabel.textContent=WebInspector.UIString("%.2f\u2009watts",max Power);this._minPowerLabel.textContent=WebInspector.UIString("%.2f\u2009watts",m inPower);;},__proto__:WebInspector.TimelineOverviewBase.prototype};WebInspector. TimelineFlameChartDataProvider=function(model,frameModel)
665 filterBar.addFilter(filters._textFilterUI);filterBar.addFilter(filters._duration FilterUI);for(var categoryName in filters._categoryFiltersUI) 532 {WebInspector.FlameChartDataProvider.call(this);this._model=model;this._frameMod el=frameModel;this._font="bold 12px "+WebInspector.fontFamily();this._linkifier= new WebInspector.Linkifier();}
666 filterBar.addFilter(filters._categoryFiltersUI[categoryName]);return true;},_tex tFilterChanged:function(event) 533 WebInspector.TimelineFlameChartDataProvider.prototype={barHeight:function()
667 {var searchQuery=this._filters._textFilterUI.value();this._presentationModel.set SearchFilter(null);delete this._searchFilter;function cleanRecord(record) 534 {return 20;},textBaseline:function()
668 {delete record.clicked;} 535 {return 6;},textPadding:function()
669 WebInspector.TimelinePresentationModel.forAllRecords(this._presentationModel.roo tRecord().children,cleanRecord);this.searchCanceled();if(searchQuery){this._sear chFilter=new WebInspector.TimelineSearchFilter(createPlainTextSearchRegex(search Query,"i"));this._presentationModel.setSearchFilter(this._searchFilter);} 536 {return 5;},entryFont:function(entryIndex)
670 this._invalidateAndScheduleRefresh(true,true);},_durationFilterChanged:function( ) 537 {return this._font;},entryTitle:function(entryIndex)
671 {var duration=this._filters._durationFilterUI.value();var minimumRecordDuration= +duration/1000.0;this._durationFilter.setMinimumRecordDuration(minimumRecordDura tion);this._invalidateAndScheduleRefresh(true,true);},_categoriesFilterChanged:f unction(name,event) 538 {var record=this._records[entryIndex];if(record===this._cpuThreadRecord)
672 {var categories=WebInspector.TimelinePresentationModel.categories();categories[n ame].hidden=!this._filters._categoryFiltersUI[name].checked();this._invalidateAn dScheduleRefresh(true,true);},_dockSideChanged:function() 539 return WebInspector.UIString("CPU");else if(record===this._gpuThreadRecord)
673 {var dockSide=WebInspector.dockController.dockSide();var vertically=false;if(doc kSide===WebInspector.DockController.State.DockedToBottom) 540 return WebInspector.UIString("GPU");var details=WebInspector.TimelineUIUtils.bui ldDetailsNode(record,this._linkifier);return details?WebInspector.UIString("%s ( %s)",record.title(),details.textContent):record.title();},dividerOffsets:functio n(startTime,endTime)
674 vertically=true;else 541 {if(endTime-startTime<16||endTime-startTime>300)
675 vertically=!WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._d etailsSplitView.setVertical(vertically);this._detailsView.setVertical(vertically );},_rootRecord:function() 542 return null;var frames=this._frameModel.filteredFrames(startTime,endTime);if(fra mes.length>10)
676 {return this._presentationModel.rootRecord();},_updateRecordsCounter:function(re cordsInWindowCount) 543 return null;if(frames.length<3)
677 {this._panel.recordsCounter.setText(WebInspector.UIString("%d of %d records show n",recordsInWindowCount,this._allRecordsCount));},_updateFrameStatistics:functio n(frames) 544 return null;var offsets=[];for(var i=0;i<frames.length;++i)
678 {this._lastFrameStatistics=frames.length?new WebInspector.FrameStatistics(frames ):null;},_updateEventDividers:function() 545 offsets.push(frames[i].startTime);offsets.push(frames.peekLast.endTime)
679 {this._timelineGrid.removeEventDividers();var clientWidth=this._graphRowsElement Width;var dividers=[];var eventDividerRecords=this._presentationModel.eventDivid erRecords();for(var i=0;i<eventDividerRecords.length;++i){var record=eventDivide rRecords[i];var positions=this._calculator.computeBarGraphWindowPosition(record) ;var dividerPosition=Math.round(positions.left);if(dividerPosition<0||dividerPos ition>=clientWidth||dividers[dividerPosition]) 546 return offsets;},reset:function()
680 continue;var divider=WebInspector.TimelinePresentationModel.createEventDivider(r ecord.type,record.title);divider.style.left=dividerPosition+"px";dividers[divide rPosition]=divider;} 547 {this._timelineData=null;},timelineData:function()
548 {if(this._timelineData)
549 return this._timelineData;this._linkifier.reset();this._timelineData={entryLevel s:[],entryTotalTimes:[],entryOffsets:[]};this._records=[];this._entryThreadDepth s={};this._zeroTime=this._model.minimumRecordTime();var cpuThreadRecordPayload={ type:WebInspector.TimelineModel.RecordType.Program};this._cpuThreadRecord=new We bInspector.TimelineModel.Record(this._model,(cpuThreadRecordPayload),null);this. _pushRecord(this._cpuThreadRecord,0,this.zeroTime(),Math.max(this._model.maximum RecordTime(),this.totalTime()+this.zeroTime()));var gpuThreadRecordPayload={type :WebInspector.TimelineModel.RecordType.Program};this._gpuThreadRecord=new WebIns pector.TimelineModel.Record(this._model,(gpuThreadRecordPayload),null);this._pus hRecord(this._gpuThreadRecord,0,this.zeroTime(),Math.max(this._model.maximumReco rdTime(),this.totalTime()+this.zeroTime()));var records=this._model.records();fo r(var i=0;i<records.length;++i){var record=records[i];var thread=record.thread;i f(thread==="gpu")
550 continue;if(!thread){for(var j=0;j<record.children.length;++j)
551 this._appendRecord(record.children[j],1);}else{this._appendRecord(records[i],1); }}
552 var cpuStackDepth=Math.max(4,this._entryThreadDepths[undefined]);delete this._en tryThreadDepths[undefined];var threadBaselines={};var threadBaseline=cpuStackDep th+2;for(var thread in this._entryThreadDepths){threadBaselines[thread]=threadBa seline;threadBaseline+=this._entryThreadDepths[thread];}
553 this._maxStackDepth=threadBaseline;for(var i=0;i<this._records.length;++i){var r ecord=this._records[i];var level=this._timelineData.entryLevels[i];if(record===t his._cpuThreadRecord)
554 level=0;else if(record===this._gpuThreadRecord)
555 level=cpuStackDepth+2;else if(record.thread)
556 level+=threadBaselines[record.thread];this._timelineData.entryLevels[i]=level;}
557 return this._timelineData;},zeroTime:function()
558 {return this._zeroTime;},totalTime:function()
559 {return Math.max(1000,this._model.maximumRecordTime()-this._model.minimumRecordT ime());},maxStackDepth:function()
560 {return this._maxStackDepth;},_appendRecord:function(record,level)
561 {if(!this._model.isVisible(record)){for(var i=0;i<record.children.length;++i)
562 this._appendRecord(record.children[i],level);return;}
563 this._pushRecord(record,level,record.startTime,record.endTime);for(var i=0;i<rec ord.children.length;++i)
564 this._appendRecord(record.children[i],level+1);},_pushRecord:function(record,lev el,startTime,endTime)
565 {var index=this._records.length;this._records.push(record);this._timelineData.en tryOffsets[index]=startTime-this._zeroTime;this._timelineData.entryLevels[index] =level;this._timelineData.entryTotalTimes[index]=endTime-startTime;this._entryTh readDepths[record.thread]=Math.max(level,this._entryThreadDepths[record.thread]| |0);return index;},prepareHighlightedEntryInfo:function(entryIndex)
566 {return null;},canJumpToEntry:function(entryIndex)
567 {return false;},entryColor:function(entryIndex)
568 {var record=this._records[entryIndex];if(record===this._cpuThreadRecord||record= ==this._gpuThreadRecord)
569 return"#555";var category=WebInspector.TimelineUIUtils.categoryForRecord(record) ;return category.fillColorStop1;},decorateEntry:function(entryIndex,context,text ,barX,barY,barWidth,barHeight,offsetToPosition)
570 {if(barWidth<5)
571 return false;var record=this._records[entryIndex];var timelineData=this._timelin eData;var decorated=false;if(record.children.length){var category=WebInspector.T imelineUIUtils.categoryForRecord(record);if(text){context.fillStyle="white";cont ext.font=this._font;context.fillText(text,barX+this.textPadding(),barY+barHeight -this.textBaseline());}
572 var entryOffset=timelineData.entryOffsets[entryIndex];var barSelf=offsetToPositi on(entryOffset+record.selfTime)
573 context.beginPath();context.fillStyle=category.backgroundColor;context.rect(barS elf,barY,barX+barWidth-barSelf,barHeight);context.fill();if(text){context.save() ;context.clip();context.fillStyle=category.borderColor;context.fillText(text,bar X+this.textPadding(),barY+barHeight-this.textBaseline());context.restore();}
574 decorated=true;}
575 if(record.warnings()||record.childHasWarnings()){context.save();context.rect(bar X,barY,barWidth,this.barHeight());context.clip();context.beginPath();context.fil lStyle=record.warnings()?"red":"rgba(255, 0, 0, 0.5)";context.moveTo(barX+barWid th-15,barY+1);context.lineTo(barX+barWidth-1,barY+1);context.lineTo(barX+barWidt h-1,barY+15);context.fill();context.restore();decorated=true;}
576 return decorated;},forceDecoration:function(entryIndex)
577 {var record=this._records[entryIndex];return record.childHasWarnings()||!!record .warnings();},highlightTimeRange:function(entryIndex)
578 {var record=this._records[entryIndex];if(record===this._cpuThreadRecord||record= ==this._gpuThreadRecord)
579 return null;return{startTimeOffset:record.startTime-this._zeroTime,endTimeOffset :record.endTime-this._zeroTime};},paddingLeft:function()
580 {return 0;},textColor:function(entryIndex)
581 {return"white";}}
582 WebInspector.TimelineFlameChart=function(delegate,model,frameModel)
583 {WebInspector.VBox.call(this);this.element.classList.add("timeline-flamechart"); this.registerRequiredCSS("flameChart.css");this._delegate=delegate;this._model=m odel;this._dataProvider=new WebInspector.TimelineFlameChartDataProvider(model,fr ameModel);this._mainView=new WebInspector.FlameChart(this._dataProvider,this,tru e,true);this._mainView.show(this.element);this._model.addEventListener(WebInspec tor.TimelineModel.Events.RecordingStarted,this._onRecordingStarted,this);this._m ainView.addEventListener(WebInspector.FlameChart.Events.EntrySelected,this._onEn trySelected,this);}
584 WebInspector.TimelineFlameChart.prototype={requestWindowTimes:function(windowSta rtTime,windowEndTime)
585 {this._delegate.requestWindowTimes(windowStartTime,windowEndTime);},refreshRecor ds:function(textFilter)
586 {this._dataProvider.reset();this._mainView._scheduleUpdate();},wasShown:function ()
587 {this._mainView._scheduleUpdate();},reset:function()
588 {this._automaticallySizeWindow=true;this._dataProvider.reset();this._mainView.se tWindowTimes(0,Infinity);},_onRecordingStarted:function()
589 {this._automaticallySizeWindow=true;this._mainView.reset();},addRecord:function( record)
590 {this._dataProvider.reset();if(this._automaticallySizeWindow){var minimumRecordT ime=this._model.minimumRecordTime();if(record.startTime>(minimumRecordTime+1000) ){this._automaticallySizeWindow=false;this._delegate.requestWindowTimes(minimumR ecordTime,minimumRecordTime+1000);}
591 this._mainView._scheduleUpdate();}else{if(!this._pendingUpdateTimer)
592 this._pendingUpdateTimer=window.setTimeout(this._updateOnAddRecord.bind(this),30 0);}},_updateOnAddRecord:function()
593 {delete this._pendingUpdateTimer;this._mainView._scheduleUpdate();},setWindowTim es:function(startTime,endTime)
594 {this._mainView.setWindowTimes(startTime,endTime);},setSidebarSize:function(widt h)
595 {},highlightSearchResult:function(record,regex,selectRecord)
596 {},setSelectedRecord:function(record)
597 {var entryRecords=this._dataProvider._records;for(var entryIndex=0;entryIndex<en tryRecords.length;++entryIndex){if(entryRecords[entryIndex]===record){this._main View.setSelectedEntry(entryIndex);return;}}
598 this._mainView.setSelectedEntry(-1);},_onEntrySelected:function(event)
599 {var entryIndex=event.data;var record=this._dataProvider._records[entryIndex];th is._delegate.selectRecord(record);},__proto__:WebInspector.VBox.prototype};WebIn spector.TimelineUIUtils=function(){}
600 WebInspector.TimelineUIUtils.categories=function()
601 {if(WebInspector.TimelineUIUtils._categories)
602 return WebInspector.TimelineUIUtils._categories;WebInspector.TimelineUIUtils._ca tegories={loading:new WebInspector.TimelineCategory("loading",WebInspector.UIStr ing("Loading"),0,"hsl(214, 53%, 58%)","hsl(214, 67%, 90%)","hsl(214, 67%, 74%)", "hsl(214, 67%, 66%)"),scripting:new WebInspector.TimelineCategory("scripting",We bInspector.UIString("Scripting"),1,"hsl(43, 68%, 53%)","hsl(43, 83%, 90%)","hsl( 43, 83%, 72%)","hsl(43, 83%, 64%) "),rendering:new WebInspector.TimelineCategory ("rendering",WebInspector.UIString("Rendering"),2,"hsl(256, 50%, 60%)","hsl(256, 67%, 90%)","hsl(256, 67%, 76%)","hsl(256, 67%, 70%)"),painting:new WebInspector .TimelineCategory("painting",WebInspector.UIString("Painting"),2,"hsl(109, 33%, 47%)","hsl(109, 33%, 90%)","hsl(109, 33%, 64%)","hsl(109, 33%, 55%)"),other:new WebInspector.TimelineCategory("other",WebInspector.UIString("Other"),-1,"hsl(0, 0%, 73%)","hsl(0, 0%, 90%)","hsl(0, 0%, 87%)","hsl(0, 0%, 79%)"),idle:new WebIns pector.TimelineCategory("idle",WebInspector.UIString("Idle"),-1,"hsl(0, 0%, 87%) ","hsl(0, 100%, 100%)","hsl(0, 100%, 100%)","hsl(0, 100%, 100%)")};return WebIns pector.TimelineUIUtils._categories;};WebInspector.TimelineUIUtils._initRecordSty les=function()
603 {if(WebInspector.TimelineUIUtils._recordStylesMap)
604 return WebInspector.TimelineUIUtils._recordStylesMap;var recordTypes=WebInspecto r.TimelineModel.RecordType;var categories=WebInspector.TimelineUIUtils.categorie s();var recordStyles={};recordStyles[recordTypes.Root]={title:"#root",category:c ategories["loading"]};recordStyles[recordTypes.Program]={title:WebInspector.UISt ring("Other"),category:categories["other"]};recordStyles[recordTypes.EventDispat ch]={title:WebInspector.UIString("Event"),category:categories["scripting"]};reco rdStyles[recordTypes.BeginFrame]={title:WebInspector.UIString("Frame Start"),cat egory:categories["rendering"]};recordStyles[recordTypes.ScheduleStyleRecalculati on]={title:WebInspector.UIString("Schedule Style Recalculation"),category:catego ries["rendering"]};recordStyles[recordTypes.RecalculateStyles]={title:WebInspect or.UIString("Recalculate Style"),category:categories["rendering"]};recordStyles[ recordTypes.InvalidateLayout]={title:WebInspector.UIString("Invalidate Layout"), category:categories["rendering"]};recordStyles[recordTypes.Layout]={title:WebIns pector.UIString("Layout"),category:categories["rendering"]};recordStyles[recordT ypes.AutosizeText]={title:WebInspector.UIString("Autosize Text"),category:catego ries["rendering"]};recordStyles[recordTypes.PaintSetup]={title:WebInspector.UISt ring("Paint Setup"),category:categories["painting"]};recordStyles[recordTypes.Pa int]={title:WebInspector.UIString("Paint"),category:categories["painting"]};reco rdStyles[recordTypes.Rasterize]={title:WebInspector.UIString("Paint"),category:c ategories["painting"]};recordStyles[recordTypes.ScrollLayer]={title:WebInspector .UIString("Scroll"),category:categories["rendering"]};recordStyles[recordTypes.D ecodeImage]={title:WebInspector.UIString("Image Decode"),category:categories["pa inting"]};recordStyles[recordTypes.ResizeImage]={title:WebInspector.UIString("Im age Resize"),category:categories["painting"]};recordStyles[recordTypes.Composite Layers]={title:WebInspector.UIString("Composite Layers"),category:categories["pa inting"]};recordStyles[recordTypes.ParseHTML]={title:WebInspector.UIString("Pars e 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"]};recordSty les[recordTypes.XHRReadyStateChange]={title:WebInspector.UIString("XHR Ready Sta te Change"),category:categories["scripting"]};recordStyles[recordTypes.XHRLoad]= {title:WebInspector.UIString("XHR Load"),category:categories["scripting"]};recor dStyles[recordTypes.EvaluateScript]={title:WebInspector.UIString("Evaluate Scrip t"),category:categories["scripting"]};recordStyles[recordTypes.ResourceSendReque st]={title:WebInspector.UIString("Send Request"),category:categories["loading"]} ;recordStyles[recordTypes.ResourceReceiveResponse]={title:WebInspector.UIString( "Receive Response"),category:categories["loading"]};recordStyles[recordTypes.Res ourceFinish]={title:WebInspector.UIString("Finish Loading"),category:categories[ "loading"]};recordStyles[recordTypes.FunctionCall]={title:WebInspector.UIString( "Function Call"),category:categories["scripting"]};recordStyles[recordTypes.Reso urceReceivedData]={title:WebInspector.UIString("Receive Data"),category:categori es["loading"]};recordStyles[recordTypes.GCEvent]={title:WebInspector.UIString("G C Event"),category:categories["scripting"]};recordStyles[recordTypes.MarkDOMCont ent]={title:WebInspector.UIString("DOMContentLoaded event"),category:categories[ "scripting"]};recordStyles[recordTypes.MarkLoad]={title:WebInspector.UIString("L oad event"),category:categories["scripting"]};recordStyles[recordTypes.MarkFirst Paint]={title:WebInspector.UIString("First paint"),category:categories["painting "]};recordStyles[recordTypes.TimeStamp]={title:WebInspector.UIString("Stamp"),ca tegory:categories["scripting"]};recordStyles[recordTypes.ConsoleTime]={title:Web Inspector.UIString("Console Time"),category:categories["scripting"]};recordStyle s[recordTypes.ScheduleResourceRequest]={title:WebInspector.UIString("Schedule Re quest"),category:categories["loading"]};recordStyles[recordTypes.RequestAnimatio nFrame]={title:WebInspector.UIString("Request Animation Frame"),category:categor ies["scripting"]};recordStyles[recordTypes.CancelAnimationFrame]={title:WebInspe ctor.UIString("Cancel Animation Frame"),category:categories["scripting"]};record Styles[recordTypes.FireAnimationFrame]={title:WebInspector.UIString("Animation F rame Fired"),category:categories["scripting"]};recordStyles[recordTypes.WebSocke tCreate]={title:WebInspector.UIString("Create WebSocket"),category:categories["s cripting"]};recordStyles[recordTypes.WebSocketSendHandshakeRequest]={title:WebIn spector.UIString("Send WebSocket Handshake"),category:categories["scripting"]};r ecordStyles[recordTypes.WebSocketReceiveHandshakeResponse]={title:WebInspector.U IString("Receive WebSocket Handshake"),category:categories["scripting"]};recordS tyles[recordTypes.WebSocketDestroy]={title:WebInspector.UIString("Destroy WebSoc ket"),category:categories["scripting"]};recordStyles[recordTypes.EmbedderCallbac k]={title:WebInspector.UIString("Embedder Callback"),category:categories["script ing"]};WebInspector.TimelineUIUtils._recordStylesMap=recordStyles;return recordS tyles;}
605 WebInspector.TimelineUIUtils.recordStyle=function(record)
606 {var recordStyles=WebInspector.TimelineUIUtils._initRecordStyles();var result=re cordStyles[record.type];if(!result){result={title:WebInspector.UIString("Unknown : %s",record.type),category:WebInspector.TimelineUIUtils.categories()["other"]}; recordStyles[record.type]=result;}
607 return result;}
608 WebInspector.TimelineUIUtils.categoryForRecord=function(record)
609 {return WebInspector.TimelineUIUtils.recordStyle(record).category;}
610 WebInspector.TimelineUIUtils.isEventDivider=function(record)
611 {var recordTypes=WebInspector.TimelineModel.RecordType;if(record.type===recordTy pes.TimeStamp)
612 return true;if(record.type===recordTypes.MarkFirstPaint)
613 return true;if(record.type===recordTypes.MarkDOMContent||record.type===recordTyp es.MarkLoad){if(record.data&&((typeof record.data.isMainFrame)==="boolean"))
614 return record.data.isMainFrame;}
615 return false;}
616 WebInspector.TimelineUIUtils.needsPreviewElement=function(recordType)
617 {if(!recordType)
618 return false;const recordTypes=WebInspector.TimelineModel.RecordType;switch(reco rdType){case recordTypes.ScheduleResourceRequest:case recordTypes.ResourceSendRe quest:case recordTypes.ResourceReceiveResponse:case recordTypes.ResourceReceived Data:case recordTypes.ResourceFinish:return true;default:return false;}}
619 WebInspector.TimelineUIUtils.createEventDivider=function(recordType,title)
620 {var eventDivider=document.createElement("div");eventDivider.className="resource s-event-divider";var recordTypes=WebInspector.TimelineModel.RecordType;if(record Type===recordTypes.MarkDOMContent)
621 eventDivider.className+=" resources-blue-divider";else if(recordType===recordTyp es.MarkLoad)
622 eventDivider.className+=" resources-red-divider";else if(recordType===recordType s.MarkFirstPaint)
623 eventDivider.className+=" resources-green-divider";else if(recordType===recordTy pes.TimeStamp)
624 eventDivider.className+=" resources-orange-divider";else if(recordType===recordT ypes.BeginFrame)
625 eventDivider.className+=" timeline-frame-divider";if(title)
626 eventDivider.title=title;return eventDivider;}
627 WebInspector.TimelineUIUtils.generateMainThreadBarPopupContent=function(model,in fo)
628 {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+=task.e ndTime-task.startTime;}
629 var startTime=tasks[firstTaskIndex].startTime;var endTime=tasks[lastTaskIndex].e ndTime;var duration=endTime-startTime;var contentHelper=new WebInspector.Timelin ePopupContentHelper(info.name);var durationText=WebInspector.UIString("%s (at %s )",Number.millisToString(duration,true),Number.millisToString(startTime-model.mi nimumRecordTime(),true));contentHelper.appendTextRow(WebInspector.UIString("Dura tion"),durationText);contentHelper.appendTextRow(WebInspector.UIString("CPU time "),Number.millisToString(cpuTime,true));contentHelper.appendTextRow(WebInspector .UIString("Message Count"),messageCount);return contentHelper.contentTable();}
630 WebInspector.TimelineUIUtils.recordTitle=function(record)
631 {if(record.type===WebInspector.TimelineModel.RecordType.TimeStamp)
632 return record.data["message"];if(WebInspector.TimelineUIUtils.isEventDivider(rec ord)){var startTime=Number.millisToString(record.startTimeOffset);return WebInsp ector.UIString("%s at %s",WebInspector.TimelineUIUtils.recordStyle(record).title ,startTime,true);}
633 return WebInspector.TimelineUIUtils.recordStyle(record).title;}
634 WebInspector.TimelineUIUtils.aggregateTimeByCategory=function(total,addend)
635 {for(var category in addend)
636 total[category]=(total[category]||0)+addend[category];}
637 WebInspector.TimelineUIUtils.aggregateTimeForRecord=function(total,record)
638 {var childrenTime=0;var children=record.children;for(var i=0;i<children.length;+ +i){WebInspector.TimelineUIUtils.aggregateTimeForRecord(total,children[i]);child renTime+=children[i].endTime-children[i].startTime;}
639 var categoryName=WebInspector.TimelineUIUtils.recordStyle(record).category.name; var ownTime=record.endTime-record.startTime-childrenTime;total[categoryName]=(to tal[categoryName]||0)+ownTime;}
640 WebInspector.TimelineUIUtils._generateAggregatedInfo=function(aggregatedStats)
641 {var cell=document.createElement("span");cell.className="timeline-aggregated-inf o";for(var index in aggregatedStats){var label=document.createElement("div");lab el.className="timeline-aggregated-category timeline-"+index;cell.appendChild(lab el);var text=document.createElement("span");text.textContent=Number.millisToStri ng(aggregatedStats[index],true);cell.appendChild(text);}
642 return cell;}
643 WebInspector.TimelineUIUtils.generatePieChart=function(aggregatedStats,selfCateg ory,selfTime)
644 {var element=document.createElement("div");element.className="timeline-aggregate d-info";var total=0;for(var categoryName in aggregatedStats)
645 total+=aggregatedStats[categoryName];function formatter(value)
646 {return Number.millisToString(value,true);}
647 var pieChart=new WebInspector.PieChart(total,formatter);element.appendChild(pieC hart.element);var footerElement=element.createChild("div","timeline-aggregated-i nfo-legend");if(selfCategory&&selfTime){pieChart.addSlice(selfTime,selfCategory. fillColorStop1);var rowElement=footerElement.createChild("div");rowElement.creat eChild("div","timeline-aggregated-category timeline-"+selfCategory.name);rowElem ent.createTextChild(WebInspector.UIString("%s %s (Self)",formatter(selfTime),sel fCategory.title));var categoryTime=aggregatedStats[selfCategory.name];var value= categoryTime-selfTime;if(value>0){pieChart.addSlice(value,selfCategory.fillColor Stop0);rowElement=footerElement.createChild("div");rowElement.createChild("div", "timeline-aggregated-category timeline-"+selfCategory.name);rowElement.createTex tChild(WebInspector.UIString("%s %s (Children)",formatter(value),selfCategory.ti tle));}}
648 for(var categoryName in WebInspector.TimelineUIUtils.categories()){var category= WebInspector.TimelineUIUtils.categories()[categoryName];if(category===selfCatego ry)
649 continue;var value=aggregatedStats[category.name];if(!value)
650 continue;pieChart.addSlice(value,category.fillColorStop0);var rowElement=footerE lement.createChild("div");rowElement.createChild("div","timeline-aggregated-cate gory timeline-"+category.name);rowElement.createTextChild(WebInspector.UIString( "%s %s",formatter(value),category.title));}
651 return element;}
652 WebInspector.TimelineUIUtils.generatePopupContentForFrame=function(frame)
653 {var contentHelper=new WebInspector.TimelinePopupContentHelper(WebInspector.UISt ring("Frame"));var durationInMillis=frame.endTime-frame.startTime;var durationTe xt=WebInspector.UIString("%s (at %s)",Number.millisToString(frame.endTime-frame. startTime,true),Number.millisToString(frame.startTimeOffset,true));contentHelper .appendTextRow(WebInspector.UIString("Duration"),durationText);contentHelper.app endTextRow(WebInspector.UIString("FPS"),Math.floor(1000/durationInMillis));conte ntHelper.appendTextRow(WebInspector.UIString("CPU time"),Number.millisToString(f rame.cpuTime,true));contentHelper.appendElementRow(WebInspector.UIString("Aggreg ated Time"),WebInspector.TimelineUIUtils._generateAggregatedInfo(frame.timeByCat egory));if(WebInspector.experimentsSettings.layersPanel.isEnabled()&&frame.layer Tree){var layerTreeSnapshot=new WebInspector.LayerTreeSnapshot(frame.layerTree); contentHelper.appendElementRow(WebInspector.UIString("Layer tree"),WebInspector. Linkifier.linkifyUsingRevealer(layerTreeSnapshot,WebInspector.UIString("show"))) ;}
654 return contentHelper.contentTable();}
655 WebInspector.TimelineUIUtils.generatePopupContentForFrameStatistics=function(sta tistics)
656 {function formatTimeAndFPS(time)
657 {return WebInspector.UIString("%s (%.0f FPS)",Number.millisToString(time,true),1 /time);}
658 var contentHelper=new WebInspector.TimelineDetailsContentHelper(new WebInspector .Linkifier(),false);contentHelper.appendTextRow(WebInspector.UIString("Minimum T ime"),formatTimeAndFPS(statistics.minDuration));contentHelper.appendTextRow(WebI nspector.UIString("Average Time"),formatTimeAndFPS(statistics.average));contentH elper.appendTextRow(WebInspector.UIString("Maximum Time"),formatTimeAndFPS(stati stics.maxDuration));contentHelper.appendTextRow(WebInspector.UIString("Standard Deviation"),Number.millisToString(statistics.stddev,true));return contentHelper. element;}
659 WebInspector.TimelineUIUtils.createFillStyle=function(context,width,height,color 0,color1,color2)
660 {var gradient=context.createLinearGradient(0,0,width,height);gradient.addColorSt op(0,color0);gradient.addColorStop(0.25,color1);gradient.addColorStop(0.75,color 1);gradient.addColorStop(1,color2);return gradient;}
661 WebInspector.TimelineUIUtils.createFillStyleForCategory=function(context,width,h eight,category)
662 {return WebInspector.TimelineUIUtils.createFillStyle(context,width,height,catego ry.fillColorStop0,category.fillColorStop1,category.borderColor);}
663 WebInspector.TimelineUIUtils.createStyleRuleForCategory=function(category)
664 {var selector=".timeline-category-"+category.name+" .timeline-graph-bar, "+".pan el.timeline .timeline-filters-header .filter-checkbox-filter.filter-checkbox-fil ter-"+category.name+" .checkbox-filter-checkbox, "+".popover .timeline-"+categor y.name+", "+".timeline-details-view .timeline-"+category.name+", "+".timeline-ca tegory-"+category.name+" .timeline-tree-icon"
665 return selector+" { background-image: linear-gradient("+
666 category.fillColorStop0+", "+category.fillColorStop1+" 25%, "+category.fillColor Stop1+" 25%, "+category.fillColorStop1+");"+" border-color: "+category.borderCol or+"}";}
667 WebInspector.TimelineUIUtils.generatePopupContent=function(record,linkifier,call back)
668 {var imageElement=(record.getUserObject("TimelineUIUtils::preview-element")||nul l);var relatedNode=null;var barrier=new CallbackBarrier();if(!imageElement&&WebI nspector.TimelineUIUtils.needsPreviewElement(record.type))
669 WebInspector.DOMPresentationUtils.buildImagePreviewContents(record.url,false,bar rier.createCallback(saveImage));if(record.relatedBackendNodeId())
670 WebInspector.domModel.pushNodesByBackendIdsToFrontend([record.relatedBackendNode Id()],barrier.createCallback(setRelatedNode));barrier.callWhenDone(callbackWrapp er);function saveImage(element)
671 {imageElement=element||null;record.setUserObject("TimelineUIUtils::preview-eleme nt",element);}
672 function setRelatedNode(nodeIds)
673 {if(nodeIds)
674 relatedNode=WebInspector.domModel.nodeForId(nodeIds[0]);}
675 function callbackWrapper()
676 {callback(WebInspector.TimelineUIUtils._generatePopupContentSynchronously(record ,linkifier,imageElement,relatedNode));}}
677 WebInspector.TimelineUIUtils._generatePopupContentSynchronously=function(record, linkifier,imagePreviewElement,relatedNode)
678 {var fragment=document.createDocumentFragment();if(record.children.length)
679 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(record.aggreg atedStats,record.category,record.selfTime));else
680 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(record.aggreg atedStats));const recordTypes=WebInspector.TimelineModel.RecordType;var callSite StackTraceLabel;var callStackLabel;var relatedNodeLabel;var contentHelper=new We bInspector.TimelineDetailsContentHelper(linkifier,true);contentHelper.appendText Row(WebInspector.UIString("Self Time"),Number.millisToString(record.selfTime,tru e));contentHelper.appendTextRow(WebInspector.UIString("Start Time"),Number.milli sToString(record.startTimeOffset));switch(record.type){case recordTypes.GCEvent: contentHelper.appendTextRow(WebInspector.UIString("Collected"),Number.bytesToStr ing(record.data["usedHeapSizeDelta"]));break;case recordTypes.TimerFire:callSite StackTraceLabel=WebInspector.UIString("Timer installed");case recordTypes.TimerI nstall:case recordTypes.TimerRemove:contentHelper.appendTextRow(WebInspector.UIS tring("Timer ID"),record.data["timerId"]);if(typeof record.timeout==="number"){c ontentHelper.appendTextRow(WebInspector.UIString("Timeout"),Number.millisToStrin g(record.timeout));contentHelper.appendTextRow(WebInspector.UIString("Repeats"), !record.singleShot);}
681 break;case recordTypes.FireAnimationFrame:callSiteStackTraceLabel=WebInspector.U IString("Animation frame requested");contentHelper.appendTextRow(WebInspector.UI String("Callback ID"),record.data["id"]);break;case recordTypes.FunctionCall:if( record.scriptName)
682 contentHelper.appendLocationRow(WebInspector.UIString("Location"),record.scriptN ame,record.scriptLine);break;case recordTypes.ScheduleResourceRequest:case recor dTypes.ResourceSendRequest:case recordTypes.ResourceReceiveResponse:case recordT ypes.ResourceReceivedData:case recordTypes.ResourceFinish:contentHelper.appendEl ementRow(WebInspector.UIString("Resource"),WebInspector.linkifyResourceAsNode(re cord.url));if(imagePreviewElement)
683 contentHelper.appendElementRow(WebInspector.UIString("Preview"),imagePreviewElem ent);if(record.data["requestMethod"])
684 contentHelper.appendTextRow(WebInspector.UIString("Request Method"),record.data[ "requestMethod"]);if(typeof record.data["statusCode"]==="number")
685 contentHelper.appendTextRow(WebInspector.UIString("Status Code"),record.data["st atusCode"]);if(record.data["mimeType"])
686 contentHelper.appendTextRow(WebInspector.UIString("MIME Type"),record.data["mime Type"]);if(record.data["encodedDataLength"])
687 contentHelper.appendTextRow(WebInspector.UIString("Encoded Data Length"),WebInsp ector.UIString("%d Bytes",record.data["encodedDataLength"]));break;case recordTy pes.EvaluateScript:if(record.data&&record.url)
688 contentHelper.appendLocationRow(WebInspector.UIString("Script"),record.url,recor d.data["lineNumber"]);break;case recordTypes.Paint:var clip=record.data["clip"]; if(clip){contentHelper.appendTextRow(WebInspector.UIString("Location"),WebInspec tor.UIString("(%d, %d)",clip[0],clip[1]));var clipWidth=WebInspector.TimelineUIU tils._quadWidth(clip);var clipHeight=WebInspector.TimelineUIUtils._quadHeight(cl ip);contentHelper.appendTextRow(WebInspector.UIString("Dimensions"),WebInspector .UIString("%d × %d",clipWidth,clipHeight));}else{if(typeof record.data["x"]!=="u ndefined"&&typeof record.data["y"]!=="undefined")
689 contentHelper.appendTextRow(WebInspector.UIString("Location"),WebInspector.UIStr ing("(%d, %d)",record.data["x"],record.data["y"]));if(typeof record.data["width" ]!=="undefined"&&typeof record.data["height"]!=="undefined")
690 contentHelper.appendTextRow(WebInspector.UIString("Dimensions"),WebInspector.UIS tring("%d\u2009\u00d7\u2009%d",record.data["width"],record.data["height"]));}
691 case recordTypes.PaintSetup:case recordTypes.Rasterize:case recordTypes.ScrollLa yer:relatedNodeLabel=WebInspector.UIString("Layer root");break;case recordTypes. AutosizeText:relatedNodeLabel=WebInspector.UIString("Root node");break;case reco rdTypes.DecodeImage:case recordTypes.ResizeImage:relatedNodeLabel=WebInspector.U IString("Image element");if(record.url)
692 contentHelper.appendElementRow(WebInspector.UIString("Image URL"),WebInspector.l inkifyResourceAsNode(record.url));break;case recordTypes.RecalculateStyles:if(re cord.data["elementCount"])
693 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"),record.da ta["elementCount"]);callStackLabel=WebInspector.UIString("Styles recalculation f orced");break;case recordTypes.Layout:if(record.data["dirtyObjects"])
694 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layout"),reco rd.data["dirtyObjects"]);if(record.data["totalObjects"])
695 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"),record.dat a["totalObjects"]);if(typeof record.data["partialLayout"]==="boolean"){contentHe lper.appendTextRow(WebInspector.UIString("Layout scope"),record.data["partialLay out"]?WebInspector.UIString("Partial"):WebInspector.UIString("Whole document")); }
696 callSiteStackTraceLabel=WebInspector.UIString("Layout invalidated");callStackLab el=WebInspector.UIString("Layout forced");relatedNodeLabel=WebInspector.UIString ("Layout root");break;case recordTypes.ConsoleTime:contentHelper.appendTextRow(W ebInspector.UIString("Message"),record.data["message"]);break;case recordTypes.W ebSocketCreate:case recordTypes.WebSocketSendHandshakeRequest:case recordTypes.W ebSocketReceiveHandshakeResponse:case recordTypes.WebSocketDestroy:if(typeof rec ord.webSocketURL!=="undefined")
697 contentHelper.appendTextRow(WebInspector.UIString("URL"),record.webSocketURL);if (typeof record.webSocketProtocol!=="undefined")
698 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"),record.w ebSocketProtocol);if(typeof record.data["message"]!=="undefined")
699 contentHelper.appendTextRow(WebInspector.UIString("Message"),record.data["messag e"]);break;case recordTypes.EmbedderCallback:contentHelper.appendTextRow(WebInsp ector.UIString("Callback Function"),record.embedderCallbackName);break;default:v ar detailsNode=WebInspector.TimelineUIUtils.buildDetailsNode(record,linkifier);i f(detailsNode)
700 contentHelper.appendElementRow(WebInspector.UIString("Details"),detailsNode);bre ak;}
701 if(relatedNode)
702 contentHelper.appendElementRow(relatedNodeLabel||WebInspector.UIString("Related node"),WebInspector.DOMPresentationUtils.linkifyNodeReference(relatedNode));if(r ecord.scriptName&&record.type!==recordTypes.FunctionCall)
703 contentHelper.appendLocationRow(WebInspector.UIString("Function Call"),record.sc riptName,record.scriptLine);if(record.jsHeapSizeUsed){if(record.usedHeapSizeDelt a){var sign=record.usedHeapSizeDelta>0?"+":"-";contentHelper.appendTextRow(WebIn spector.UIString("Used JavaScript Heap Size"),WebInspector.UIString("%s (%s%s)", Number.bytesToString(record.jsHeapSizeUsed),sign,Number.bytesToString(Math.abs(r ecord.usedHeapSizeDelta))));}else if(record.category===WebInspector.TimelineUIUt ils.categories().scripting)
704 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScript Heap Size"),N umber.bytesToString(record.jsHeapSizeUsed));}
705 if(record.callSiteStackTrace)
706 contentHelper.appendStackTrace(callSiteStackTraceLabel||WebInspector.UIString("C all Site stack"),record.callSiteStackTrace);if(record.stackTrace)
707 contentHelper.appendStackTrace(callStackLabel||WebInspector.UIString("Call Stack "),record.stackTrace);if(record.warnings()){var ul=document.createElement("ul"); for(var i=0;i<record.warnings().length;++i)
708 ul.createChild("li").textContent=record.warnings()[i];contentHelper.appendElemen tRow(WebInspector.UIString("Warning"),ul);}
709 fragment.appendChild(contentHelper.element);return fragment;}
710 WebInspector.TimelineUIUtils._quadWidth=function(quad)
711 {return Math.round(Math.sqrt(Math.pow(quad[0]-quad[2],2)+Math.pow(quad[1]-quad[3 ],2)));}
712 WebInspector.TimelineUIUtils._quadHeight=function(quad)
713 {return Math.round(Math.sqrt(Math.pow(quad[0]-quad[6],2)+Math.pow(quad[1]-quad[7 ],2)));}
714 WebInspector.TimelineUIUtils.buildDetailsNode=function(record,linkifier)
715 {var details;var detailsText;switch(record.type){case WebInspector.TimelineModel .RecordType.GCEvent:detailsText=WebInspector.UIString("%s collected",Number.byte sToString(record.data["usedHeapSizeDelta"]));break;case WebInspector.TimelineMod el.RecordType.TimerFire:detailsText=record.data["timerId"];break;case WebInspect or.TimelineModel.RecordType.FunctionCall:if(record.scriptName)
716 details=linkifyLocation(record.scriptName,record.scriptLine,0);break;case WebIns pector.TimelineModel.RecordType.FireAnimationFrame:detailsText=record.data["id"] ;break;case WebInspector.TimelineModel.RecordType.EventDispatch:detailsText=reco rd.data?record.data["type"]:null;break;case WebInspector.TimelineModel.RecordTyp e.Paint:var width=record.data.clip?WebInspector.TimelineUIUtils._quadWidth(recor d.data.clip):record.data.width;var height=record.data.clip?WebInspector.Timeline UIUtils._quadHeight(record.data.clip):record.data.height;if(width&&height)
717 detailsText=WebInspector.UIString("%d\u2009\u00d7\u2009%d",width,height);break;c ase WebInspector.TimelineModel.RecordType.TimerInstall:case WebInspector.Timelin eModel.RecordType.TimerRemove:details=linkifyTopCallFrame();detailsText=record.d ata["timerId"];break;case WebInspector.TimelineModel.RecordType.RequestAnimation Frame:case WebInspector.TimelineModel.RecordType.CancelAnimationFrame:details=li nkifyTopCallFrame();detailsText=record.data["id"];break;case WebInspector.Timeli neModel.RecordType.ParseHTML:case WebInspector.TimelineModel.RecordType.Recalcul ateStyles:details=linkifyTopCallFrame();break;case WebInspector.TimelineModel.Re cordType.EvaluateScript:details=record.url?linkifyLocation(record.url,record.dat a["lineNumber"],0):null;break;case WebInspector.TimelineModel.RecordType.XHRRead yStateChange:case WebInspector.TimelineModel.RecordType.XHRLoad:case WebInspecto r.TimelineModel.RecordType.ScheduleResourceRequest:case WebInspector.TimelineMod el.RecordType.ResourceSendRequest:case WebInspector.TimelineModel.RecordType.Res ourceReceivedData:case WebInspector.TimelineModel.RecordType.ResourceReceiveResp onse:case WebInspector.TimelineModel.RecordType.ResourceFinish:case WebInspector .TimelineModel.RecordType.DecodeImage:case WebInspector.TimelineModel.RecordType .ResizeImage:detailsText=WebInspector.displayNameForURL(record.url);break;case W ebInspector.TimelineModel.RecordType.ConsoleTime:detailsText=record.data["messag e"];break;case WebInspector.TimelineModel.RecordType.EmbedderCallback:detailsTex t=record.data["callbackName"];break;default:details=record.scriptName?linkifyLoc ation(record.scriptName,record.scriptLine,0):linkifyTopCallFrame();break;}
718 if(!details&&detailsText)
719 details=document.createTextNode(detailsText);return details;function linkifyLoca tion(url,lineNumber,columnNumber)
720 {columnNumber=columnNumber?columnNumber-1:0;return linkifier.linkifyLocation(url ,lineNumber-1,columnNumber,"timeline-details");}
721 function linkifyCallFrame(callFrame)
722 {return linkifyLocation(callFrame.url,callFrame.lineNumber,callFrame.columnNumbe r);}
723 function linkifyTopCallFrame()
724 {if(record.stackTrace)
725 return linkifyCallFrame(record.stackTrace[0]);if(record.callSiteStackTrace)
726 return linkifyCallFrame(record.callSiteStackTrace[0]);return null;}
727 function linkifyScriptLocation()
728 {return record.scriptName?linkifyLocation(record.scriptName,record.scriptLine,0) :null;}}
729 WebInspector.TimelineCategory=function(name,title,overviewStripGroupIndex,border Color,backgroundColor,fillColorStop0,fillColorStop1)
730 {this.name=name;this.title=title;this.overviewStripGroupIndex=overviewStripGroup Index;this.borderColor=borderColor;this.backgroundColor=backgroundColor;this.fil lColorStop0=fillColorStop0;this.fillColorStop1=fillColorStop1;this.hidden=false; }
731 WebInspector.TimelineCategory.Events={VisibilityChanged:"VisibilityChanged"};Web Inspector.TimelineCategory.prototype={get hidden()
732 {return this._hidden;},set hidden(hidden)
733 {this._hidden=hidden;this.dispatchEventToListeners(WebInspector.TimelineCategory .Events.VisibilityChanged,this);},__proto__:WebInspector.Object.prototype}
734 WebInspector.TimelinePopupContentHelper=function(title)
735 {this._contentTable=document.createElement("table");var titleCell=this._createCe ll(WebInspector.UIString("%s - Details",title),"timeline-details-title");titleCe ll.colSpan=2;var titleRow=document.createElement("tr");titleRow.appendChild(titl eCell);this._contentTable.appendChild(titleRow);}
736 WebInspector.TimelinePopupContentHelper.prototype={contentTable:function()
737 {return this._contentTable;},_createCell:function(content,styleName)
738 {var text=document.createElement("label");text.appendChild(document.createTextNo de(content));var cell=document.createElement("td");cell.className="timeline-deta ils";if(styleName)
739 cell.className+=" "+styleName;cell.textContent=content;return cell;},appendTextR ow:function(title,content)
740 {var row=document.createElement("tr");row.appendChild(this._createCell(title,"ti meline-details-row-title"));row.appendChild(this._createCell(content,"timeline-d etails-row-data"));this._contentTable.appendChild(row);},appendElementRow:functi on(title,content)
741 {var row=document.createElement("tr");var titleCell=this._createCell(title,"time line-details-row-title");row.appendChild(titleCell);var cell=document.createElem ent("td");cell.className="details";if(content instanceof Node)
742 cell.appendChild(content);else
743 cell.createTextChild(content||"");row.appendChild(cell);this._contentTable.appen dChild(row);}}
744 WebInspector.TimelineDetailsContentHelper=function(linkifier,monospaceValues)
745 {this._linkifier=linkifier;this.element=document.createElement("div");this.eleme nt.className="timeline-details-view-block";this._monospaceValues=monospaceValues ;}
746 WebInspector.TimelineDetailsContentHelper.prototype={appendTextRow:function(titl e,value)
747 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);rowElement.createChild("span","timeline-details-vie w-row-value"+(this._monospaceValues?" monospace":"")).textContent=value;},append ElementRow:function(title,content)
748 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);var valueElement=rowElement.createChild("span","tim eline-details-view-row-details"+(this._monospaceValues?" monospace":""));if(cont ent instanceof Node)
749 valueElement.appendChild(content);else
750 valueElement.createTextChild(content||"");},appendLocationRow:function(title,url ,line)
751 {this.appendElementRow(title,this._linkifier.linkifyLocation(url,line-1)||"");}, appendStackTrace:function(title,stackTrace)
752 {var rowElement=this.element.createChild("div","timeline-details-view-row");rowE lement.createChild("span","timeline-details-view-row-title").textContent=WebInsp ector.UIString("%s: ",title);var stackTraceElement=rowElement.createChild("div", "timeline-details-view-row-stack-trace monospace");for(var i=0;i<stackTrace.leng th;++i){var stackFrame=stackTrace[i];var row=stackTraceElement.createChild("div" );row.createTextChild(stackFrame.functionName||WebInspector.UIString("(anonymous function)"));row.createTextChild(" @ ");var urlElement=this._linkifier.linkifyL ocation(stackFrame.url,stackFrame.lineNumber-1);row.appendChild(urlElement);}}}; WebInspector.TimelineView=function(delegate,model)
753 {WebInspector.HBox.call(this);this.element.classList.add("timeline-view");this._ delegate=delegate;this._model=model;this._presentationModel=new WebInspector.Tim elinePresentationModel(model);this._calculator=new WebInspector.TimelineCalculat or(model);this._linkifier=new WebInspector.Linkifier();this._boundariesAreValid= true;this._scrollTop=0;this._recordsView=this._createRecordsView();this._records View.addEventListener(WebInspector.SplitView.Events.SidebarSizeChanged,this._sid ebarResized,this);this._recordsView.show(this.element);this._headerElement=this. element.createChild("div","fill");this._headerElement.id="timeline-graph-records -header";this._cpuBarsElement=this._headerElement.createChild("div","timeline-ut ilization-strip");if(WebInspector.experimentsSettings.gpuTimeline.isEnabled())
754 this._gpuBarsElement=this._headerElement.createChild("div","timeline-utilization -strip gpu");this._popoverHelper=new WebInspector.PopoverHelper(this.element,thi s._getPopoverAnchor.bind(this),this._showPopover.bind(this));this.element.addEve ntListener("mousemove",this._mouseMove.bind(this),false);this.element.addEventLi stener("mouseout",this._mouseOut.bind(this),false);this.element.addEventListener ("keydown",this._keyDown.bind(this),false);this._expandOffset=15;}
755 WebInspector.TimelineView.prototype={setFrameModel:function(frameModel)
756 {this._frameModel=frameModel;},_createRecordsView:function()
757 {var recordsView=new WebInspector.SplitView(true,false,"timelinePanelRecorsSplit ViewState");this._containerElement=recordsView.element;this._containerElement.ta bIndex=0;this._containerElement.id="timeline-container";this._containerElement.a ddEventListener("scroll",this._onScroll.bind(this),false);recordsView.sidebarEle ment().createChild("div","timeline-records-title").textContent=WebInspector.UISt ring("RECORDS");this._sidebarListElement=recordsView.sidebarElement().createChil d("div","timeline-records-list");this._gridContainer=new WebInspector.VBoxWithRe sizeCallback(this._onViewportResize.bind(this));this._gridContainer.element.id=" resources-container-content";this._gridContainer.show(recordsView.mainElement()) ;this._timelineGrid=new WebInspector.TimelineGrid();this._gridContainer.element. appendChild(this._timelineGrid.element);this._itemsGraphsElement=this._gridConta iner.element.createChild("div");this._itemsGraphsElement.id="timeline-graphs";th is._topGapElement=this._itemsGraphsElement.createChild("div","timeline-gap");thi s._graphRowsElement=this._itemsGraphsElement.createChild("div");this._bottomGapE lement=this._itemsGraphsElement.createChild("div","timeline-gap");this._expandEl ements=this._itemsGraphsElement.createChild("div");this._expandElements.id="orph an-expand-elements";return recordsView;},_rootRecord:function()
758 {return this._presentationModel.rootRecord();},_updateEventDividers:function()
759 {this._timelineGrid.removeEventDividers();var clientWidth=this._graphRowsElement Width;var dividers=[];var eventDividerRecords=this._model.eventDividerRecords(); for(var i=0;i<eventDividerRecords.length;++i){var record=eventDividerRecords[i]; var positions=this._calculator.computeBarGraphWindowPosition(record);var divider Position=Math.round(positions.left);if(dividerPosition<0||dividerPosition>=clien tWidth||dividers[dividerPosition])
760 continue;var divider=WebInspector.TimelineUIUtils.createEventDivider(record.type ,WebInspector.TimelineUIUtils.recordTitle(record));divider.style.left=dividerPos ition+"px";dividers[dividerPosition]=divider;}
681 this._timelineGrid.addEventDividers(dividers);},_updateFrameBars:function(frames ) 761 this._timelineGrid.addEventDividers(dividers);},_updateFrameBars:function(frames )
682 {var clientWidth=this._graphRowsElementWidth;if(this._frameContainer) 762 {var clientWidth=this._graphRowsElementWidth;if(this._frameContainer)
683 this._frameContainer.removeChildren();else{const frameContainerBorderWidth=1;thi s._frameContainer=document.createElement("div");this._frameContainer.classList.a dd("fill");this._frameContainer.classList.add("timeline-frame-container");this._ frameContainer.style.height=WebInspector.TimelinePanel.rowHeight+frameContainerB orderWidth+"px";this._frameContainer.addEventListener("dblclick",this._onFrameDo ubleClicked.bind(this),false);} 763 this._frameContainer.removeChildren();else{const frameContainerBorderWidth=1;thi s._frameContainer=document.createElement("div");this._frameContainer.classList.a dd("fill");this._frameContainer.classList.add("timeline-frame-container");this._ frameContainer.style.height=WebInspector.TimelinePanel.rowHeight+frameContainerB orderWidth+"px";this._frameContainer.addEventListener("dblclick",this._onFrameDo ubleClicked.bind(this),false);}
684 var dividers=[this._frameContainer];for(var i=0;i<frames.length;++i){var frame=f rames[i];var frameStart=this._calculator.computePosition(frame.startTime);var fr ameEnd=this._calculator.computePosition(frame.endTime);var frameStrip=document.c reateElement("div");frameStrip.className="timeline-frame-strip";var actualStart= Math.max(frameStart,0);var width=frameEnd-actualStart;frameStrip.style.left=actu alStart+"px";frameStrip.style.width=width+"px";frameStrip._frame=frame;const min WidthForFrameInfo=60;if(width>minWidthForFrameInfo) 764 var dividers=[];for(var i=0;i<frames.length;++i){var frame=frames[i];var frameSt art=this._calculator.computePosition(frame.startTime);var frameEnd=this._calcula tor.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";frameSt rip.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.Timeline Model.RecordType.BeginFrame);frameMarker.style.left=frameStart+"px";dividers.pus h(frameMarker);}} 765 frameStrip.textContent=Number.millisToString(frame.endTime-frame.startTime,true) ;this._frameContainer.appendChild(frameStrip);if(actualStart>0){var frameMarker= WebInspector.TimelineUIUtils.createEventDivider(WebInspector.TimelineModel.Recor dType.BeginFrame);frameMarker.style.left=frameStart+"px";dividers.push(frameMark er);}}
686 this._timelineGrid.addEventDividers(dividers);},_onFrameDoubleClicked:function(e vent) 766 this._timelineGrid.addEventDividers(dividers);this._headerElement.appendChild(th is._frameContainer);},_onFrameDoubleClicked:function(event)
687 {var frameBar=event.target.enclosingNodeOrSelfWithClass("timeline-frame-strip"); if(!frameBar) 767 {var frameBar=event.target.enclosingNodeOrSelfWithClass("timeline-frame-strip"); if(!frameBar)
688 return;this._setWindowTimes(frameBar._frame.startTime,frameBar._frame.endTime);} ,_updateWindowBoundaries:function() 768 return;this._delegate.requestWindowTimes(frameBar._frame.startTime,frameBar._fra me.endTime);},addRecord:function(record)
689 {var windowBoundaries=this.overviewControl().windowBoundaries(this._windowStartT ime,this._windowEndTime);this._panel.setWindow(windowBoundaries.left,windowBound aries.right);},windowTimes:function() 769 {this._presentationModel.addRecord(record);this._invalidateAndScheduleRefresh(fa lse,false);},setSidebarSize:function(width)
690 {return{windowStartTime:this._windowStartTime,windowEndTime:this._windowEndTime} ;},setWindowTimes:function(windowTimes) 770 {this._recordsView.setSidebarSize(width);},_sidebarResized:function(event)
691 {if(!windowTimes) 771 {this.dispatchEventToListeners(WebInspector.SplitView.Events.SidebarSizeChanged, event.data);},_onViewportResize:function()
692 return;this._setWindowTimes(windowTimes.windowStartTime,windowTimes.windowEndTim e);},_setWindowTimes:function(startTime,endTime) 772 {this._resize(this._recordsView.sidebarSize());},_resize:function(sidebarWidth)
693 {this._windowStartTime=startTime;this._windowEndTime=endTime;this._windowFilter. setWindowTimes(startTime,endTime);var windowBoundaries=this.overviewControl().wi ndowBoundaries(startTime,endTime);this._panel.setWindow(windowBoundaries.left,wi ndowBoundaries.right);},_repopulateRecords:function() 773 {this._closeRecordDetails();this._graphRowsElementWidth=this._graphRowsElement.o ffsetWidth;this._headerElement.style.left=sidebarWidth+"px";this._headerElement. style.width=this._itemsGraphsElement.offsetWidth+"px";this._scheduleRefresh(fals e,true);},_resetView:function()
694 {this._resetView();this._automaticallySizeWindow=false;var records=this._model.r ecords;for(var i=0;i<records.length;++i) 774 {this._windowStartTime=-1;this._windowEndTime=-1;this._boundariesAreValid=false; this._adjustScrollPosition(0);this._linkifier.reset();this._closeRecordDetails() ;this._automaticallySizeWindow=true;this._presentationModel.reset();},reset:func tion()
695 this._innerAddRecordToTimeline(records[i]);this._invalidateAndScheduleRefresh(fa lse,false);},_onTimelineEventRecorded:function(event) 775 {this._resetView();this._invalidateAndScheduleRefresh(true,true);},elementsToRes toreScrollPositionsFor:function()
696 {if(this._innerAddRecordToTimeline((event.data))) 776 {return[this._containerElement];},refreshRecords:function(textFilter)
697 this._invalidateAndScheduleRefresh(false,false);},_innerAddRecordToTimeline:func tion(record) 777 {this._presentationModel.reset();var records=this._model.records();for(var i=0;i <records.length;++i)
698 {if(record.type===WebInspector.TimelineModel.RecordType.Program) 778 this.addRecord(records[i]);this._automaticallySizeWindow=false;this._presentatio nModel.setTextFilter(textFilter);this._invalidateAndScheduleRefresh(false,true); },wasShown:function()
699 this._mainThreadTasks.push(record);if(record.type===WebInspector.TimelineModel.R ecordType.GPUTask){this._gpuTasks.push(record);return WebInspector.TimelineModel .startTimeInSeconds(record)<this._windowEndTime;} 779 {WebInspector.View.prototype.wasShown.call(this);this._onViewportResize();this._ refresh();},willHide:function()
700 var records=this._presentationModel.addRecord(record);this._allRecordsCount+=rec ords.length;var hasVisibleRecords=false;var presentationModel=this._presentation Model;function checkVisible(record)
701 {hasVisibleRecords|=presentationModel.isVisible(record);}
702 WebInspector.TimelinePresentationModel.forAllRecords(records,checkVisible);funct ion isAdoptedRecord(record)
703 {return record.parent!==presentationModel.rootRecord;}
704 return hasVisibleRecords||records.some(isAdoptedRecord);},_sidebarResized:functi on(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.o ffsetWidth;this._containerElementHeight=this._containerElement.clientHeight;this ._timelineGrid.gridHeaderElement.style.width=this._itemsGraphsElement.offsetWidt h+"px";this._scheduleRefresh(false,true);},_resetView:function()
710 {this._presentationModel.reset();this._boundariesAreValid=false;this._adjustScro llPosition(0);this._closeRecordDetails();this._allRecordsCount=0;this._automatic allySizeWindow=true;this._mainThreadTasks=[];this._gpuTasks=[];},_onRecordsClear ed:function()
711 {this._windowStartTime=0;this._windowEndTime=Infinity;this._resetView();this.ove rviewControl().reset();this._windowFilter.reset();this._invalidateAndScheduleRef resh(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.Timeli nePanel._categoryStylesInitialized){WebInspector.TimelinePanel._categoryStylesIn itialized=true;this._injectCategoryStyles();}
714 this._onViewportResize();this._refresh();},willHide:function()
715 {this._closeRecordDetails();WebInspector.View.prototype.willHide.call(this);},_o nScroll:function(event) 780 {this._closeRecordDetails();WebInspector.View.prototype.willHide.call(this);},_o nScroll:function(event)
716 {this._closeRecordDetails();this._scrollTop=this._containerElement.scrollTop;var dividersTop=Math.max(0,this._scrollTop);this._timelineGrid.setScrollAndDividerT op(this._scrollTop,dividersTop);this._scheduleRefresh(true,true);},_invalidateAn dScheduleRefresh:function(preserveBoundaries,userGesture) 781 {this._closeRecordDetails();this._scrollTop=this._containerElement.scrollTop;var dividersTop=Math.max(0,this._scrollTop);this._timelineGrid.setScrollAndDividerT op(this._scrollTop,dividersTop);this._scheduleRefresh(true,true);},_invalidateAn dScheduleRefresh:function(preserveBoundaries,userGesture)
717 {this._presentationModel.invalidateFilteredRecords();delete this._searchResults; this._scheduleRefresh(preserveBoundaries,userGesture);},_selectRecord:function(r ecord) 782 {this._presentationModel.invalidateFilteredRecords();this._scheduleRefresh(prese rveBoundaries,userGesture);},_selectRecord:function(presentationRecord)
718 {if(record===this._lastSelectedRecord) 783 {if(presentationRecord&&presentationRecord.coalesced()){this._innerSetSelectedRe cord(presentationRecord);var aggregatedStats={};var presentationChildren=present ationRecord.presentationChildren();for(var i=0;i<presentationChildren.length;++i )
719 return;if(this._lastSelectedRecord){var listRow=(this._lastSelectedRecord.getUse rObject("WebInspector.TimelineRecordListRow"));if(listRow) 784 WebInspector.TimelineUIUtils.aggregateTimeByCategory(aggregatedStats,presentatio nChildren[i].record().aggregatedStats);var idle=presentationRecord.record().endT ime-presentationRecord.record().startTime;for(var category in aggregatedStats)
720 listRow.renderAsSelected(false);var graphRow=(this._lastSelectedRecord.getUserOb ject("WebInspector.TimelineRecordGraphRow"));if(graphRow) 785 idle-=aggregatedStats[category];aggregatedStats["idle"]=idle;this._delegate.show AggregatedStatsInDetails(WebInspector.TimelineUIUtils.recordStyle(presentationRe cord.record()).title,aggregatedStats);return;}
721 graphRow.renderAsSelected(false);} 786 this._delegate.selectRecord(presentationRecord?presentationRecord.record():null) ;},setSelectedRecord:function(record)
722 if(!record){this._updateSelectionDetails();return;} 787 {this._innerSetSelectedRecord(this._presentationModel.toPresentationRecord(recor d));},_innerSetSelectedRecord:function(presentationRecord)
723 this._lastSelectedRecord=record;this._revealRecord(record);var listRow=(record.g etUserObject("WebInspector.TimelineRecordListRow"));if(listRow) 788 {if(presentationRecord===this._lastSelectedRecord)
724 listRow.renderAsSelected(true);var graphRow=(record.getUserObject("WebInspector. TimelineRecordGraphRow"));if(graphRow) 789 return;if(this._lastSelectedRecord){if(this._lastSelectedRecord.listRow())
725 graphRow.renderAsSelected(true);record.generatePopupContent(showCallback.bind(th is));function showCallback(element) 790 this._lastSelectedRecord.listRow().renderAsSelected(false);if(this._lastSelected Record.graphRow())
726 {this._detailsView.setContent(record.title,element);}},_updateSelectionDetails:f unction() 791 this._lastSelectedRecord.graphRow().renderAsSelected(false);}
727 {var startTime=this.windowStartTime()*1000;var endTime=this.windowEndTime()*1000 ;if(startTime<0) 792 this._lastSelectedRecord=presentationRecord;if(!presentationRecord)
728 return;var aggregatedStats={};function compareEndTime(value,task) 793 return;this._innerRevealRecord(presentationRecord);if(presentationRecord.listRow ())
729 {return value<task.endTime?-1:1;} 794 presentationRecord.listRow().renderAsSelected(true);if(presentationRecord.graphR ow())
730 function aggregateTimeForRecordWithinWindow(rawRecord) 795 presentationRecord.graphRow().renderAsSelected(true);},setWindowTimes:function(s tartTime,endTime)
731 {if(!rawRecord.endTime||rawRecord.endTime<startTime||rawRecord.startTime>endTime ) 796 {this._windowStartTime=startTime;this._windowEndTime=endTime;this._presentationM odel.setWindowTimes(startTime,endTime);this._automaticallySizeWindow=false;this. _invalidateAndScheduleRefresh(false,true);this._selectRecord(null);},_scheduleRe fresh:function(preserveBoundaries,userGesture)
732 return;var childrenTime=0;var children=rawRecord.children||[];for(var i=0;i<chil dren.length;++i){var child=children[i];if(!child.endTime||child.endTime<startTim e||child.startTime>endTime)
733 continue;childrenTime+=Math.min(endTime,child.endTime)-Math.max(startTime,child. startTime);aggregateTimeForRecordWithinWindow(child);}
734 var categoryName=WebInspector.TimelinePresentationModel.categoryForRecord(rawRec ord).name;var ownTime=Math.min(endTime,rawRecord.endTime)-Math.max(startTime,raw Record.startTime)-childrenTime;aggregatedStats[categoryName]=(aggregatedStats[ca tegoryName]||0)+ownTime/1000;}
735 var taskIndex=insertionIndexForObjectInListSortedByFunction(startTime,this._main ThreadTasks,compareEndTime);for(;taskIndex<this._mainThreadTasks.length;++taskIn dex){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.createDocument Fragment();var pie=WebInspector.TimelinePresentationModel.generatePieChart(aggre gatedStats);fragment.appendChild(pie.element);if(this._frameMode&&this._lastFram eStatistics){var title=WebInspector.UIString("%s \u2013 %s (%d frames)",Number.s econdsToString(this._lastFrameStatistics.startOffset,true),Number.secondsToStrin g(this._lastFrameStatistics.endOffset,true),this._lastFrameStatistics.frameCount );fragment.appendChild(WebInspector.TimelinePresentationModel.generatePopupConte ntForFrameStatistics(this._lastFrameStatistics));}else{var title=WebInspector.UI String("%s \u2013 %s",this._calculator.formatTime(0,true),this._calculator.forma tTime(this._calculator.boundarySpan(),true));}
739 this._detailsView.setContent(title,fragment);},windowChanged:function(left,right )
740 {var windowTimes=this.overviewControl().windowTimes(left,right);this._windowStar tTime=windowTimes.startTime;this._windowEndTime=windowTimes.endTime;this._window Filter.setWindowTimes(windowTimes.startTime,windowTimes.endTime);this._invalidat eAndScheduleRefresh(false,true);this._selectRecord(null);},_scheduleRefresh:func tion(preserveBoundaries,userGesture)
741 {this._closeRecordDetails();this._boundariesAreValid&=preserveBoundaries;if(!thi s.isShowing()) 797 {this._closeRecordDetails();this._boundariesAreValid&=preserveBoundaries;if(!thi s.isShowing())
742 return;if(preserveBoundaries||userGesture) 798 return;if(preserveBoundaries||userGesture)
743 this._refresh();else{if(!this._refreshTimeout) 799 this._refresh();else{if(!this._refreshTimeout)
744 this._refreshTimeout=setTimeout(this._refresh.bind(this),300);}},_refresh:functi on() 800 this._refreshTimeout=setTimeout(this._refresh.bind(this),300);}},_refresh:functi on()
745 {if(this._refreshTimeout){clearTimeout(this._refreshTimeout);delete this._refres hTimeout;} 801 {if(this._refreshTimeout){clearTimeout(this._refreshTimeout);delete this._refres hTimeout;}
746 this._timelinePaddingLeft=this._expandOffset;this._calculator.setWindow(this.win dowStartTime(),this.windowEndTime());this._calculator.setDisplayWindow(this._tim elinePaddingLeft,this._graphRowsElementWidth);var recordsInWindowCount=this._ref reshRecords();this._updateRecordsCounter(recordsInWindowCount);if(!this._boundar iesAreValid){this._updateEventDividers();var frames=this._frameController&&this. _presentationModel.filteredFrames(this.windowStartTime(),this.windowEndTime());i f(frames){this._updateFrameStatistics(frames);const maxFramesForFrameBars=30;if( frames.length&&frames.length<maxFramesForFrameBars){this._timelineGrid.removeDiv iders();this._updateFrameBars(frames);}else 802 var windowStartTime=this._windowStartTime;var windowEndTime=this._windowEndTime; this._timelinePaddingLeft=this._expandOffset;if(windowStartTime===-1)
747 this._timelineGrid.updateDividers(this._calculator);}else 803 windowStartTime=this._model.minimumRecordTime();if(windowEndTime===-1)
804 windowEndTime=this._model.maximumRecordTime();this._calculator.setWindow(windowS tartTime,windowEndTime);this._calculator.setDisplayWindow(this._timelinePaddingL eft,this._graphRowsElementWidth);this._refreshRecords();if(!this._boundariesAreV alid){this._updateEventDividers();if(this._frameContainer)
805 this._frameContainer.remove();if(this._frameModel){var frames=this._frameModel.f ilteredFrames(windowStartTime,windowEndTime);const maxFramesForFrameBars=30;if(f rames.length&&frames.length<maxFramesForFrameBars){this._timelineGrid.removeDivi ders();this._updateFrameBars(frames);}else{this._timelineGrid.updateDividers(thi s._calculator);}}else
748 this._timelineGrid.updateDividers(this._calculator);this._refreshAllUtilizationB ars();} 806 this._timelineGrid.updateDividers(this._calculator);this._refreshAllUtilizationB ars();}
749 if(this._currentMode===WebInspector.TimelinePanel.Mode.Memory) 807 this._boundariesAreValid=true;},_innerRevealRecord:function(recordToReveal)
750 this._memoryStatistics.refresh();this._updateWindowBoundaries();this._boundaries AreValid=true;},revealRecordAt:function(time) 808 {var needRefresh=false;for(var parent=recordToReveal.presentationParent();parent !==this._rootRecord();parent=parent.presentationParent()){if(!parent.collapsed() )
751 {var recordToReveal;function findRecordToReveal(record) 809 continue;this._presentationModel.invalidateFilteredRecords();parent.setCollapsed (false);needRefresh=true;}
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.roo tRecord().children,null,findRecordToReveal);if(!recordToReveal){this._containerE lement.scrollTop=0;return;}
756 this._selectRecord(recordToReveal);},_revealRecord:function(recordToReveal)
757 {var needRefresh=false;for(var parent=recordToReveal.parent;parent!==this._rootR ecord();parent=parent.parent){if(!parent.collapsed)
758 continue;this._presentationModel.invalidateFilteredRecords();parent.collapsed=fa lse;needRefresh=true;}
759 var recordsInWindow=this._presentationModel.filteredRecords();var index=recordsI nWindow.indexOf(recordToReveal);var itemOffset=index*WebInspector.TimelinePanel. rowHeight;var visibleTop=this._scrollTop-WebInspector.TimelinePanel.headerHeight ;var visibleBottom=visibleTop+this._containerElementHeight-WebInspector.Timeline Panel.rowHeight;if(itemOffset<visibleTop) 810 var recordsInWindow=this._presentationModel.filteredRecords();var index=recordsI nWindow.indexOf(recordToReveal);var itemOffset=index*WebInspector.TimelinePanel. rowHeight;var visibleTop=this._scrollTop-WebInspector.TimelinePanel.headerHeight ;var visibleBottom=visibleTop+this._containerElementHeight-WebInspector.Timeline Panel.rowHeight;if(itemOffset<visibleTop)
760 this._containerElement.scrollTop=itemOffset;else if(itemOffset>visibleBottom) 811 this._containerElement.scrollTop=itemOffset;else if(itemOffset>visibleBottom)
761 this._containerElement.scrollTop=itemOffset-this._containerElementHeight+WebInsp ector.TimelinePanel.headerHeight+WebInspector.TimelinePanel.rowHeight;else if(ne edRefresh) 812 this._containerElement.scrollTop=itemOffset-this._containerElementHeight+WebInsp ector.TimelinePanel.headerHeight+WebInspector.TimelinePanel.rowHeight;else if(ne edRefresh)
762 this._refreshRecords();},_refreshRecords:function() 813 this._refreshRecords();},_refreshRecords:function()
763 {var recordsInWindow=this._presentationModel.filteredRecords();var visibleTop=th is._scrollTop;var visibleBottom=visibleTop+this._containerElementHeight;var rowH eight=WebInspector.TimelinePanel.rowHeight;var headerHeight=WebInspector.Timelin ePanel.headerHeight;var startIndex=Math.max(0,Math.min(Math.floor((visibleTop-he aderHeight)/rowHeight),recordsInWindow.length-1));var endIndex=Math.min(recordsI nWindow.length,Math.ceil(visibleBottom/rowHeight));var lastVisibleLine=Math.max( 0,Math.floor((visibleBottom-headerHeight)/rowHeight));if(this._automaticallySize Window&&recordsInWindow.length>lastVisibleLine){this._automaticallySizeWindow=fa lse;this._selectRecord(null);var windowStartTime=startIndex?recordsInWindow[star tIndex].startTime:this._model.minimumRecordTime();this._setWindowTimes(windowSta rtTime,recordsInWindow[Math.max(0,lastVisibleLine-1)].endTime);recordsInWindow=t his._presentationModel.filteredRecords();endIndex=Math.min(recordsInWindow.lengt h,lastVisibleLine);}else{this._updateWindowBoundaries();} 814 {this._containerElementHeight=this._containerElement.clientHeight;var recordsInW indow=this._presentationModel.filteredRecords();var visibleTop=this._scrollTop;v ar visibleBottom=visibleTop+this._containerElementHeight;var rowHeight=WebInspec tor.TimelinePanel.rowHeight;var headerHeight=WebInspector.TimelinePanel.headerHe ight;var startIndex=Math.max(0,Math.min(Math.floor((visibleTop-headerHeight)/row Height),recordsInWindow.length-1));var endIndex=Math.min(recordsInWindow.length, Math.ceil(visibleBottom/rowHeight));var lastVisibleLine=Math.max(0,Math.floor((v isibleBottom-headerHeight)/rowHeight));if(this._automaticallySizeWindow&&records InWindow.length>lastVisibleLine){this._automaticallySizeWindow=false;this._selec tRecord(null);var windowStartTime=startIndex?recordsInWindow[startIndex].record( ).startTime:this._model.minimumRecordTime();var windowEndTime=recordsInWindow[Ma th.max(0,lastVisibleLine-1)].record().endTime;this._delegate.requestWindowTimes( windowStartTime,windowEndTime);recordsInWindow=this._presentationModel.filteredR ecords();endIndex=Math.min(recordsInWindow.length,lastVisibleLine);}
764 this._topGapElement.style.height=(startIndex*rowHeight)+"px";this._recordsView.s idebarElement().firstChild.style.flexBasis=(startIndex*rowHeight+headerHeight)+" px";this._bottomGapElement.style.height=(recordsInWindow.length-endIndex)*rowHei ght+"px";var rowsHeight=headerHeight+recordsInWindow.length*rowHeight;var totalH eight=Math.max(this._containerElementHeight,rowsHeight);this._recordsView.firstE lement().style.height=totalHeight+"px";this._recordsView.secondElement().style.h eight=totalHeight+"px";this._recordsView.resizerElement().style.height=totalHeig ht+"px";var listRowElement=this._sidebarListElement.firstChild;var width=this._g raphRowsElementWidth;this._itemsGraphsElement.removeChild(this._graphRowsElement );var graphRowElement=this._graphRowsElement.firstChild;var scheduleRefreshCallb ack=this._invalidateAndScheduleRefresh.bind(this,true,true);var selectRecordCall back=this._selectRecord.bind(this);this._itemsGraphsElement.removeChild(this._ex pandElements);this._expandElements.removeChildren();for(var i=0;i<endIndex;++i){ var record=recordsInWindow[i];if(i<startIndex){var lastChildIndex=i+record.visib leChildrenCount;if(lastChildIndex>=startIndex&&lastChildIndex<endIndex){var expa ndElement=new WebInspector.TimelineExpandableElement(this._expandElements);var p ositions=this._calculator.computeBarGraphWindowPosition(record);expandElement._u pdate(record,i,positions.left-this._expandOffset,positions.width);}}else{if(!lis tRowElement){listRowElement=new WebInspector.TimelineRecordListRow(selectRecordC allback,scheduleRefreshCallback).element;this._sidebarListElement.appendChild(li stRowElement);} 815 this._topGapElement.style.height=(startIndex*rowHeight)+"px";this._recordsView.s idebarElement().firstElementChild.style.flexBasis=(startIndex*rowHeight+headerHe ight)+"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 .mainElement().style.height=totalHeight+"px";this._recordsView.sidebarElement(). style.height=totalHeight+"px";this._recordsView.resizerElement().style.height=to talHeight+"px";var listRowElement=this._sidebarListElement.firstChild;var width= this._graphRowsElementWidth;this._itemsGraphsElement.removeChild(this._graphRows Element);var graphRowElement=this._graphRowsElement.firstChild;var scheduleRefre shCallback=this._invalidateAndScheduleRefresh.bind(this,true,true);var selectRec ordCallback=this._selectRecord.bind(this);this._itemsGraphsElement.removeChild(t his._expandElements);this._expandElements.removeChildren();for(var i=0;i<endInde x;++i){var record=recordsInWindow[i];if(i<startIndex){var lastChildIndex=i+recor d.visibleChildrenCount();if(lastChildIndex>=startIndex&&lastChildIndex<endIndex) {var expandElement=new WebInspector.TimelineExpandableElement(this._expandElemen ts);var positions=this._calculator.computeBarGraphWindowPosition(record);expandE lement._update(record,i,positions.left-this._expandOffset,positions.width);}}els e{if(!listRowElement){listRowElement=new WebInspector.TimelineRecordListRow(this ._linkifier,selectRecordCallback,scheduleRefreshCallback).element;this._sidebarL istElement.appendChild(listRowElement);}
765 if(!graphRowElement){graphRowElement=new WebInspector.TimelineRecordGraphRow(thi s._itemsGraphsElement,selectRecordCallback,scheduleRefreshCallback).element;this ._graphRowsElement.appendChild(graphRowElement);} 816 if(!graphRowElement){graphRowElement=new WebInspector.TimelineRecordGraphRow(thi s._itemsGraphsElement,selectRecordCallback,scheduleRefreshCallback).element;this ._graphRowsElement.appendChild(graphRowElement);}
766 listRowElement.row.update(record,visibleTop);graphRowElement.row.update(record,t his._calculator,this._expandOffset,i);if(this._lastSelectedRecord===record){list RowElement.row.renderAsSelected(true);graphRowElement.row.renderAsSelected(true) ;} 817 listRowElement.row.update(record,visibleTop);graphRowElement.row.update(record,t his._calculator,this._expandOffset,i);if(this._lastSelectedRecord===record){list RowElement.row.renderAsSelected(true);graphRowElement.row.renderAsSelected(true) ;}
767 listRowElement=listRowElement.nextSibling;graphRowElement=graphRowElement.nextSi bling;}} 818 listRowElement=listRowElement.nextSibling;graphRowElement=graphRowElement.nextSi bling;}}
768 while(listRowElement){var nextElement=listRowElement.nextSibling;listRowElement. row.dispose();listRowElement=nextElement;} 819 while(listRowElement){var nextElement=listRowElement.nextSibling;listRowElement. row.dispose();listRowElement=nextElement;}
769 while(graphRowElement){var nextElement=graphRowElement.nextSibling;graphRowEleme nt.row.dispose();graphRowElement=nextElement;} 820 while(graphRowElement){var nextElement=graphRowElement.nextSibling;graphRowEleme nt.row.dispose();graphRowElement=nextElement;}
770 this._itemsGraphsElement.insertBefore(this._graphRowsElement,this._bottomGapElem ent);this._itemsGraphsElement.appendChild(this._expandElements);this._adjustScro llPosition(recordsInWindow.length*rowHeight+headerHeight);this._updateSearchHigh light(false,true);return recordsInWindow.length;},_refreshAllUtilizationBars:fun ction() 821 this._itemsGraphsElement.insertBefore(this._graphRowsElement,this._bottomGapElem ent);this._itemsGraphsElement.appendChild(this._expandElements);this._adjustScro llPosition(recordsInWindow.length*rowHeight+headerHeight);return recordsInWindow .length;},_refreshAllUtilizationBars:function()
771 {this._refreshUtilizationBars(WebInspector.UIString("CPU"),this._mainThreadTasks ,this._cpuBarsElement);if(WebInspector.experimentsSettings.gpuTimeline.isEnabled ()) 822 {this._refreshUtilizationBars(WebInspector.UIString("CPU"),this._model.mainThrea dTasks(),this._cpuBarsElement);if(WebInspector.experimentsSettings.gpuTimeline.i sEnabled())
772 this._refreshUtilizationBars(WebInspector.UIString("GPU"),this._gpuTasks,this._g puBarsElement);},_refreshUtilizationBars:function(name,tasks,container) 823 this._refreshUtilizationBars(WebInspector.UIString("GPU"),this._model.gpuThreadT asks(),this._gpuBarsElement);},_refreshUtilizationBars:function(name,tasks,conta iner)
773 {if(!container) 824 {if(!container)
774 return;const barOffset=3;const minGap=3;var minWidth=WebInspector.TimelineCalcul ator._minWidth;var widthAdjustment=minWidth/2;var width=this._graphRowsElementWi dth;var boundarySpan=this.windowEndTime()-this.windowStartTime();var scale=bound arySpan/(width-minWidth-this._timelinePaddingLeft);var startTime=(this.windowSta rtTime()-this._timelinePaddingLeft*scale)*1000;var endTime=startTime+width*scale *1000;function compareEndTime(value,task) 825 return;const barOffset=3;const minGap=3;var minWidth=WebInspector.TimelineCalcul ator._minWidth;var widthAdjustment=minWidth/2;var width=this._graphRowsElementWi dth;var boundarySpan=this._windowEndTime-this._windowStartTime;var scale=boundar ySpan/(width-minWidth-this._timelinePaddingLeft);var startTime=(this._windowStar tTime-this._timelinePaddingLeft*scale);var endTime=startTime+width*scale;functio n compareEndTime(value,task)
775 {return value<task.endTime?-1:1;} 826 {return value<task.endTime?-1:1;}
776 var taskIndex=insertionIndexForObjectInListSortedByFunction(startTime,tasks,comp areEndTime);var foreignStyle="gpu-task-foreign";var element=container.firstChild ;var lastElement;var lastLeft;var lastRight;for(;taskIndex<tasks.length;++taskIn dex){var task=tasks[taskIndex];if(task.startTime>endTime) 827 var taskIndex=insertionIndexForObjectInListSortedByFunction(startTime,tasks,comp areEndTime);var foreignStyle="gpu-task-foreign";var element=container.firstChild ;var lastElement;var lastLeft;var lastRight;for(;taskIndex<tasks.length;++taskIn dex){var task=tasks[taskIndex];if(task.startTime>endTime)
777 break;var left=Math.max(0,this._calculator.computePosition(WebInspector.Timeline Model.startTimeInSeconds(task))+barOffset-widthAdjustment);var right=Math.min(wi dth,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"]) 828 break;var left=Math.max(0,this._calculator.computePosition(task.startTime)+barOf fset-widthAdjustment);var right=Math.min(width,this._calculator.computePosition( task.endTime||0)+barOffset+widthAdjustment);if(lastElement){var gap=Math.floor(l eft)-Math.ceil(lastRight);if(gap<minGap){if(!task.data["foreign"])
778 lastElement.classList.remove(foreignStyle);lastRight=right;lastElement._tasksInf o.lastTaskIndex=taskIndex;continue;} 829 lastElement.classList.remove(foreignStyle);lastRight=right;lastElement._tasksInf o.lastTaskIndex=taskIndex;continue;}
779 lastElement.style.width=(lastRight-lastLeft)+"px";} 830 lastElement.style.width=(lastRight-lastLeft)+"px";}
780 if(!element) 831 if(!element)
781 element=container.createChild("div","timeline-graph-bar");element.style.left=lef t+"px";element._tasksInfo={name:name,tasks:tasks,firstTaskIndex:taskIndex,lastTa skIndex:taskIndex};if(task.data["foreign"]) 832 element=container.createChild("div","timeline-graph-bar");element.style.left=lef t+"px";element._tasksInfo={name:name,tasks:tasks,firstTaskIndex:taskIndex,lastTa skIndex:taskIndex};if(task.data["foreign"])
782 element.classList.add(foreignStyle);lastLeft=left;lastRight=right;lastElement=el ement;element=element.nextSibling;} 833 element.classList.add(foreignStyle);lastLeft=left;lastRight=right;lastElement=el ement;element=element.nextSibling;}
783 if(lastElement) 834 if(lastElement)
784 lastElement.style.width=(lastRight-lastLeft)+"px";while(element){var nextElement =element.nextSibling;element._tasksInfo=null;container.removeChild(element);elem ent=nextElement;}},_adjustScrollPosition:function(totalHeight) 835 lastElement.style.width=(lastRight-lastLeft)+"px";while(element){var nextElement =element.nextSibling;element._tasksInfo=null;container.removeChild(element);elem ent=nextElement;}},_adjustScrollPosition:function(totalHeight)
785 {if((this._scrollTop+this._containerElementHeight)>totalHeight+1) 836 {if((this._scrollTop+this._containerElementHeight)>totalHeight+1)
786 this._containerElement.scrollTop=(totalHeight-this._containerElement.offsetHeigh t);},_getPopoverAnchor:function(element) 837 this._containerElement.scrollTop=(totalHeight-this._containerElement.offsetHeigh t);},_getPopoverAnchor:function(element)
787 {var anchor=element.enclosingNodeOrSelfWithClass("timeline-graph-bar");if(anchor &&anchor._tasksInfo) 838 {var anchor=element.enclosingNodeOrSelfWithClass("timeline-graph-bar");if(anchor &&anchor._tasksInfo)
788 return anchor;return element.enclosingNodeOrSelfWithClass("timeline-frame-strip" );},_mouseOut:function() 839 return anchor;return element.enclosingNodeOrSelfWithClass("timeline-frame-strip" );},_mouseOut:function()
789 {this._hideQuadHighlight();},_mouseMove:function(e) 840 {this._hideQuadHighlight();},_mouseMove:function(e)
790 {var rowElement=e.target.enclosingNodeOrSelfWithClass("timeline-tree-item");if(r owElement&&rowElement.row&&rowElement.row._record.highlightQuad) 841 {var rowElement=e.target.enclosingNodeOrSelfWithClass("timeline-tree-item");if(r owElement&&rowElement.row&&rowElement.row._record.record().highlightQuad)
791 this._highlightQuad(rowElement.row._record.highlightQuad);else 842 this._highlightQuad(rowElement.row._record.record().highlightQuad);else
792 this._hideQuadHighlight();var taskBarElement=e.target.enclosingNodeOrSelfWithCla ss("timeline-graph-bar");if(taskBarElement&&taskBarElement._tasksInfo){var offse t=taskBarElement.offsetLeft;this._timelineGrid.showCurtains(offset>=0?offset:0,t askBarElement.offsetWidth);}else 843 this._hideQuadHighlight();var taskBarElement=e.target.enclosingNodeOrSelfWithCla ss("timeline-graph-bar");if(taskBarElement&&taskBarElement._tasksInfo){var offse t=taskBarElement.offsetLeft;this._timelineGrid.showCurtains(offset>=0?offset:0,t askBarElement.offsetWidth);}else
793 this._timelineGrid.hideCurtains();},_keyDown:function(event) 844 this._timelineGrid.hideCurtains();},_keyDown:function(event)
794 {if(!this._lastSelectedRecord||event.shiftKey||event.metaKey||event.ctrlKey) 845 {if(!this._lastSelectedRecord||event.shiftKey||event.metaKey||event.ctrlKey)
795 return;var record=this._lastSelectedRecord;var recordsInWindow=this._presentatio nModel.filteredRecords();var index=recordsInWindow.indexOf(record);var recordsIn Page=Math.floor(this._containerElementHeight/WebInspector.TimelinePanel.rowHeigh t);var rowHeight=WebInspector.TimelinePanel.rowHeight;if(index===-1) 846 return;var record=this._lastSelectedRecord;var recordsInWindow=this._presentatio nModel.filteredRecords();var index=recordsInWindow.indexOf(record);var recordsIn Page=Math.floor(this._containerElementHeight/WebInspector.TimelinePanel.rowHeigh t);var rowHeight=WebInspector.TimelinePanel.rowHeight;if(index===-1)
796 index=0;switch(event.keyIdentifier){case"Left":if(record.parent){if((!record.exp andable||record.collapsed)&&record.parent!==this._presentationModel.rootRecord() ){this._selectRecord(record.parent);}else{record.collapsed=true;record.clicked=t rue;this._invalidateAndScheduleRefresh(true,true);}} 847 index=0;switch(event.keyIdentifier){case"Left":if(record.presentationParent()){i f((!record.expandable()||record.collapsed())&&record.presentationParent()!==this ._presentationModel.rootRecord()){this._selectRecord(record.presentationParent() );}else{record.setCollapsed(true);this._invalidateAndScheduleRefresh(true,true); }}
797 event.consume(true);break;case"Up":if(--index<0) 848 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.cli cked=true;this._invalidateAndScheduleRefresh(true,true);}else{if(++index>=record sInWindow.length) 849 break;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case" Right":if(record.expandable()&&record.collapsed()){record.setCollapsed(false);th is._invalidateAndScheduleRefresh(true,true);}else{if(++index>=recordsInWindow.le ngth)
799 break;this._selectRecord(recordsInWindow[index]);} 850 break;this._selectRecord(recordsInWindow[index]);}
800 event.consume(true);break;case"Down":if(++index>=recordsInWindow.length) 851 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._s crollTop-recordsInPage*rowHeight);this._containerElement.scrollTop=this._scrollT op;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"Pag eDown":index=Math.min(recordsInWindow.length-1,index+recordsInPage);this._scroll Top=Math.min(this._containerElement.scrollHeight-this._containerElementHeight,th is._scrollTop+recordsInPage*rowHeight);this._containerElement.scrollTop=this._sc rollTop;this._selectRecord(recordsInWindow[index]);event.consume(true);break;cas e"Home":index=0;this._selectRecord(recordsInWindow[index]);event.consume(true);b reak;case"End":index=recordsInWindow.length-1;this._selectRecord(recordsInWindow [index]);event.consume(true);break;}},_highlightQuad:function(quad) 852 break;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case" PageUp":index=Math.max(0,index-recordsInPage);this._scrollTop=Math.max(0,this._s crollTop-recordsInPage*rowHeight);this._containerElement.scrollTop=this._scrollT op;this._selectRecord(recordsInWindow[index]);event.consume(true);break;case"Pag eDown":index=Math.min(recordsInWindow.length-1,index+recordsInPage);this._scroll Top=Math.min(this._containerElement.scrollHeight-this._containerElementHeight,th is._scrollTop+recordsInPage*rowHeight);this._containerElement.scrollTop=this._sc rollTop;this._selectRecord(recordsInWindow[index]);event.consume(true);break;cas e"Home":index=0;this._selectRecord(recordsInWindow[index]);event.consume(true);b reak;case"End":index=recordsInWindow.length-1;this._selectRecord(recordsInWindow [index]);event.consume(true);break;}},_highlightQuad:function(quad)
802 {if(this._highlightedQuad===quad) 853 {if(this._highlightedQuad===quad)
803 return;this._highlightedQuad=quad;DOMAgent.highlightQuad(quad,WebInspector.Color .PageHighlight.Content.toProtocolRGBA(),WebInspector.Color.PageHighlight.Content Outline.toProtocolRGBA());},_hideQuadHighlight:function() 854 return;this._highlightedQuad=quad;DOMAgent.highlightQuad(quad,WebInspector.Color .PageHighlight.Content.toProtocolRGBA(),WebInspector.Color.PageHighlight.Content Outline.toProtocolRGBA());},_hideQuadHighlight:function()
804 {if(this._highlightedQuad){delete this._highlightedQuad;DOMAgent.hideHighlight() ;}},_showPopover:function(anchor,popover) 855 {if(this._highlightedQuad){delete this._highlightedQuad;DOMAgent.hideHighlight() ;}},_showPopover:function(anchor,popover)
805 {if(anchor.classList.contains("timeline-frame-strip")){var frame=anchor._frame;p opover.show(WebInspector.TimelinePresentationModel.generatePopupContentForFrame( frame),anchor);}else{if(anchor.row&&anchor.row._record) 856 {if(anchor.classList.contains("timeline-frame-strip")){var frame=anchor._frame;p opover.show(WebInspector.TimelineUIUtils.generatePopupContentForFrame(frame),anc hor);}else if(anchor._tasksInfo){popover.show(WebInspector.TimelineUIUtils.gener ateMainThreadBarPopupContent(this._model,anchor._tasksInfo),anchor,null,null,Web Inspector.Popover.Orientation.Bottom);}
806 anchor.row._record.generatePopupContent(showCallback);else if(anchor._tasksInfo)
807 popover.show(this._presentationModel.generateMainThreadBarPopupContent(anchor._t asksInfo),anchor,null,null,WebInspector.Popover.Orientation.Bottom);}
808 function showCallback(popupContent) 857 function showCallback(popupContent)
809 {popover.show(popupContent,anchor);}},_closeRecordDetails:function() 858 {popover.show(popupContent,anchor);}},_closeRecordDetails:function()
810 {this._popoverHelper.hidePopover();},_injectCategoryStyles:function() 859 {this._popoverHelper.hidePopover();},highlightSearchResult:function(record,regex ,selectRecord)
811 {var style=document.createElement("style");var categories=WebInspector.TimelineP resentationModel.categories();style.textContent=Object.values(categories).map(We bInspector.TimelinePresentationModel.createStyleRuleForCategory).join("\n");docu ment.head.appendChild(style);},jumpToNextSearchResult:function() 860 {if(this._highlightDomChanges)
812 {if(!this._searchResults||!this._searchResults.length) 861 WebInspector.revertDomChanges(this._highlightDomChanges);this._highlightDomChang es=[];var presentationRecord=this._presentationModel.toPresentationRecord(record );if(!presentationRecord)
813 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._se lectedSearchResult):-1;this._jumpToSearchResult(index+1);},jumpToPreviousSearchR esult:function()
814 {if(!this._searchResults||!this._searchResults.length)
815 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._se lectedSearchResult):0;this._jumpToSearchResult(index-1);},_jumpToSearchResult:fu nction(index)
816 {this._selectSearchResult((index+this._searchResults.length)%this._searchResults .length);this._highlightSelectedSearchResult(true);},_selectSearchResult:functio n(index)
817 {this._selectedSearchResult=this._searchResults[index];this._searchableView.upda teCurrentMatchIndex(index);},_highlightSelectedSearchResult:function(selectRecor d)
818 {this._clearHighlight();if(this._searchFilter)
819 return;var record=this._selectedSearchResult;if(!record)
820 return;if(selectRecord) 862 return;if(selectRecord)
821 this._selectRecord(record);for(var element=this._sidebarListElement.firstChild;e lement;element=element.nextSibling){if(element.row._record===record){element.row .highlight(this._searchRegExp,this._highlightDomChanges);break;}}},_clearHighlig ht:function() 863 this._selectRecord(presentationRecord);for(var element=this._sidebarListElement. firstChild;element;element=element.nextSibling){if(element.row._record===present ationRecord){element.row.highlight(regex,this._highlightDomChanges);break;}}},__ proto__:WebInspector.HBox.prototype}
822 {if(this._highlightDomChanges)
823 WebInspector.revertDomChanges(this._highlightDomChanges);this._highlightDomChang es=[];},_updateSearchHighlight:function(revealRecord,shouldJump)
824 {if(this._searchFilter||!this._searchRegExp){this._clearHighlight();return;}
825 if(!this._searchResults)
826 this._updateSearchResults(shouldJump);this._highlightSelectedSearchResult(reveal Record);},_updateSearchResults:function(shouldJump)
827 {var searchRegExp=this._searchRegExp;if(!searchRegExp)
828 return;var matches=[];var presentationModel=this._presentationModel;function pro cessRecord(record)
829 {if(presentationModel.isVisible(record)&&WebInspector.TimelineRecordListRow.test ContentMatching(record,searchRegExp))
830 matches.push(record);return false;}
831 WebInspector.TimelinePresentationModel.forAllRecords(presentationModel.rootRecor d().children,processRecord);var matchesCount=matches.length;if(matchesCount){thi s._searchResults=matches;this._searchableView.updateSearchMatchesCount(matchesCo unt);var selectedIndex=matches.indexOf(this._selectedSearchResult);if(shouldJump &&selectedIndex===-1)
832 selectedIndex=0;this._selectSearchResult(selectedIndex);}else{this._searchableVi ew.updateSearchMatchesCount(0);delete this._selectedSearchResult;}},searchCancel ed:function()
833 {this._clearHighlight();delete this._searchResults;delete this._selectedSearchRe sult;delete this._searchRegExp;},performSearch:function(query,shouldJump)
834 {this._searchRegExp=createPlainTextSearchRegex(query,"i");delete this._searchRes ults;this._updateSearchHighlight(true,shouldJump);},__proto__:WebInspector.View. prototype}
835 WebInspector.TimelineCalculator=function(model) 864 WebInspector.TimelineCalculator=function(model)
836 {this._model=model;} 865 {this._model=model;}
837 WebInspector.TimelineCalculator._minWidth=5;WebInspector.TimelineCalculator.prot otype={computePosition:function(time) 866 WebInspector.TimelineCalculator._minWidth=5;WebInspector.TimelineCalculator.prot otype={paddingLeft:function()
838 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this.p addingLeft;},computeBarGraphPercentages:function(record) 867 {return this._paddingLeft;},computePosition:function(time)
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.bo undarySpan()*100;var cpuWidth=record.coalesced?endWithChildren-start:record.cpuT ime/this.boundarySpan()*100;return{start:start,end:end,endWithChildren:endWithCh ildren,cpuWidth:cpuWidth};},computeBarGraphWindowPosition:function(record) 868 {return(time-this._minimumBoundary)/this.boundarySpan()*this._workingArea+this._ paddingLeft;},computeBarGraphPercentages:function(record)
869 {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.bo undarySpan()*100;var cpuWidth=record.cpuTime/this.boundarySpan()*100;return{star t:start,end:end,endWithChildren:endWithChildren,cpuWidth:cpuWidth};},computeBarG raphWindowPosition:function(record)
840 {var percentages=this.computeBarGraphPercentages(record);var widthAdjustment=0;v ar left=this.computePosition(record.startTime);var width=(percentages.end-percen tages.start)/100*this._workingArea;if(width<WebInspector.TimelineCalculator._min Width){widthAdjustment=WebInspector.TimelineCalculator._minWidth-width;width=Web Inspector.TimelineCalculator._minWidth;} 870 {var percentages=this.computeBarGraphPercentages(record);var widthAdjustment=0;v ar left=this.computePosition(record.startTime);var width=(percentages.end-percen tages.start)/100*this._workingArea;if(width<WebInspector.TimelineCalculator._min Width){widthAdjustment=WebInspector.TimelineCalculator._minWidth-width;width=Web Inspector.TimelineCalculator._minWidth;}
841 var widthWithChildren=(percentages.endWithChildren-percentages.start)/100*this._ workingArea+widthAdjustment;var cpuWidth=percentages.cpuWidth/100*this._workingA rea+widthAdjustment;if(percentages.endWithChildren>percentages.end) 871 var widthWithChildren=(percentages.endWithChildren-percentages.start)/100*this._ workingArea+widthAdjustment;var cpuWidth=percentages.cpuWidth/100*this._workingA rea+widthAdjustment;if(percentages.endWithChildren>percentages.end)
842 widthWithChildren+=widthAdjustment;return{left:left,width:width,widthWithChildre n:widthWithChildren,cpuWidth:cpuWidth};},setWindow:function(minimumBoundary,maxi mumBoundary) 872 widthWithChildren+=widthAdjustment;return{left:left,width:width,widthWithChildre n:widthWithChildren,cpuWidth:cpuWidth};},setWindow:function(minimumBoundary,maxi mumBoundary)
843 {this._minimumBoundary=minimumBoundary;this._maximumBoundary=maximumBoundary;},s etDisplayWindow:function(paddingLeft,clientWidth) 873 {this._minimumBoundary=minimumBoundary;this._maximumBoundary=maximumBoundary;},s etDisplayWindow:function(paddingLeft,clientWidth)
844 {this._workingArea=clientWidth-WebInspector.TimelineCalculator._minWidth-padding Left;this.paddingLeft=paddingLeft;},formatTime:function(value,hires) 874 {this._workingArea=clientWidth-WebInspector.TimelineCalculator._minWidth-padding Left;this._paddingLeft=paddingLeft;},formatTime:function(value,precision)
845 {return Number.secondsToString(value+this._minimumBoundary-this._model.minimumRe cordTime(),hires);},maximumBoundary:function() 875 {return Number.preciseMillisToString(value-this.zeroTime(),precision);},maximumB oundary:function()
846 {return this._maximumBoundary;},minimumBoundary:function() 876 {return this._maximumBoundary;},minimumBoundary:function()
847 {return this._minimumBoundary;},zeroTime:function() 877 {return this._minimumBoundary;},zeroTime:function()
848 {return this._model.minimumRecordTime();},boundarySpan:function() 878 {return this._model.minimumRecordTime();},boundarySpan:function()
849 {return this._maximumBoundary-this._minimumBoundary;}} 879 {return this._maximumBoundary-this._minimumBoundary;}}
850 WebInspector.TimelineRecordListRow=function(selectRecord,scheduleRefresh) 880 WebInspector.TimelineRecordListRow=function(linkifier,selectRecord,scheduleRefre sh)
851 {this.element=document.createElement("div");this.element.row=this;this.element.s tyle.cursor="pointer";this.element.addEventListener("click",this._onClick.bind(t his),false);this.element.addEventListener("mouseover",this._onMouseOver.bind(thi s),false);this.element.addEventListener("mouseout",this._onMouseOut.bind(this),f alse);this._warningElement=this.element.createChild("div","timeline-tree-item-wa rning 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._schedul eRefresh=scheduleRefresh;this._selectRecord=selectRecord;} 881 {this.element=document.createElement("div");this.element.row=this;this.element.s tyle.cursor="pointer";this.element.addEventListener("click",this._onClick.bind(t his),false);this.element.addEventListener("mouseover",this._onMouseOver.bind(thi s),false);this.element.addEventListener("mouseout",this._onMouseOut.bind(this),f alse);this._linkifier=linkifier;this._warningElement=this.element.createChild("d iv","timeline-tree-item-warning hidden");this._expandArrowElement=this.element.c reateChild("div","timeline-tree-item-expand-arrow");this._expandArrowElement.add EventListener("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","d ata dimmed");this._scheduleRefresh=scheduleRefresh;this._selectRecord=selectReco rd;}
852 WebInspector.TimelineRecordListRow.prototype={update:function(record,offset) 882 WebInspector.TimelineRecordListRow.prototype={update:function(presentationRecord ,offset)
853 {this._record=record;this._offset=offset;this.element.className="timeline-tree-i tem timeline-category-"+record.category.name;var paddingLeft=5;var step=-3;for(v ar currentRecord=record.parent?record.parent.parent:null;currentRecord;currentRe cord=currentRecord.parent) 883 {this._record=presentationRecord;var record=presentationRecord.record();this._of fset=offset;this.element.className="timeline-tree-item timeline-category-"+recor d.category.name;var paddingLeft=5;var step=-3;for(var currentRecord=presentation Record.presentationParent()?presentationRecord.presentationParent().presentation Parent():null;currentRecord;currentRecord=currentRecord.presentationParent())
854 paddingLeft+=12/(Math.max(1,step++));this.element.style.paddingLeft=paddingLeft+ "px";if(record.isBackground) 884 paddingLeft+=12/(Math.max(1,step++));this.element.style.paddingLeft=paddingLeft+ "px";if(record.thread)
855 this.element.classList.add("background");this._typeElement.textContent=record.ti tle;if(this._dataElement.firstChild) 885 this.element.classList.add("background");this._typeElement.textContent=record.ti tle();if(this._dataElement.firstChild)
856 this._dataElement.removeChildren();this._warningElement.enableStyleClass("hidden ",!record.hasWarnings()&&!record.childHasWarnings());this._warningElement.enable StyleClass("timeline-tree-item-child-warning",record.childHasWarnings()&&!record .hasWarnings());if(record.detailsNode()) 886 this._dataElement.removeChildren();this._warningElement.classList.toggle("hidden ",!presentationRecord.hasWarnings()&&!presentationRecord.childHasWarnings());thi s._warningElement.classList.toggle("timeline-tree-item-child-warning",presentati onRecord.childHasWarnings()&&!presentationRecord.hasWarnings());if(presentationR ecord.coalesced()){this._dataElement.createTextChild(WebInspector.UIString("× %d ",presentationRecord.presentationChildren().length));}else{var detailsNode=WebIn spector.TimelineUIUtils.buildDetailsNode(record,this._linkifier);if(detailsNode) {this._dataElement.appendChild(document.createTextNode("("));this._dataElement.a ppendChild(detailsNode);this._dataElement.appendChild(document.createTextNode(") "));}}
857 this._dataElement.appendChild(record.detailsNode());this._expandArrowElement.ena bleStyleClass("parent",record.children&&record.children.length);this._expandArro wElement.enableStyleClass("expanded",record.visibleChildrenCount);this._record.s etUserObject("WebInspector.TimelineRecordListRow",this);},highlight:function(reg Exp,domChanges) 887 this._expandArrowElement.classList.toggle("parent",presentationRecord.expandable ());this._expandArrowElement.classList.toggle("expanded",!!presentationRecord.vi sibleChildrenCount());this._record.setListRow(this);},highlight:function(regExp, domChanges)
858 {var matchInfo=this.element.textContent.match(regExp);if(matchInfo) 888 {var matchInfo=this.element.textContent.match(regExp);if(matchInfo)
859 WebInspector.highlightSearchResult(this.element,matchInfo.index,matchInfo[0].len gth,domChanges);},dispose:function() 889 WebInspector.highlightSearchResult(this.element,matchInfo.index,matchInfo[0].len gth,domChanges);},dispose:function()
860 {this.element.remove();},_onExpandClick:function(event) 890 {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) 891 {this._record.setCollapsed(!this._record.collapsed());this._scheduleRefresh();ev ent.consume(true);},_onClick:function(event)
862 {this._selectRecord(this._record);},renderAsSelected:function(selected) 892 {this._selectRecord(this._record);},renderAsSelected:function(selected)
863 {this.element.enableStyleClass("selected",selected);},_onMouseOver:function(even t) 893 {this.element.classList.toggle("selected",selected);},_onMouseOver:function(even t)
864 {this.element.classList.add("hovered");var graphRow=(this._record.getUserObject( "WebInspector.TimelineRecordGraphRow"));graphRow.element.classList.add("hovered" );},_onMouseOut:function(event) 894 {this.element.classList.add("hovered");if(this._record.graphRow())
865 {this.element.classList.remove("hovered");var graphRow=(this._record.getUserObje ct("WebInspector.TimelineRecordGraphRow"));graphRow.element.classList.remove("ho vered");}} 895 this._record.graphRow().element.classList.add("hovered");},_onMouseOut:function( event)
866 WebInspector.TimelineRecordListRow.testContentMatching=function(record,regExp) 896 {this.element.classList.remove("hovered");if(this._record.graphRow())
867 {var toSearchText=record.title;if(record.detailsNode()) 897 this._record.graphRow().element.classList.remove("hovered");}}
868 toSearchText+=" "+record.detailsNode().textContent;return regExp.test(toSearchTe xt);}
869 WebInspector.TimelineRecordGraphRow=function(graphContainer,selectRecord,schedul eRefresh) 898 WebInspector.TimelineRecordGraphRow=function(graphContainer,selectRecord,schedul eRefresh)
870 {this.element=document.createElement("div");this.element.row=this;this.element.a ddEventListener("mouseover",this._onMouseOver.bind(this),false);this.element.add EventListener("mouseout",this._onMouseOut.bind(this),false);this.element.addEven tListener("click",this._onClick.bind(this),false);this._barAreaElement=document. createElement("div");this._barAreaElement.className="timeline-graph-bar-area";th is.element.appendChild(this._barAreaElement);this._barWithChildrenElement=docume nt.createElement("div");this._barWithChildrenElement.className="timeline-graph-b ar with-children";this._barWithChildrenElement.row=this;this._barAreaElement.app endChild(this._barWithChildrenElement);this._barCpuElement=document.createElemen t("div");this._barCpuElement.className="timeline-graph-bar cpu" 899 {this.element=document.createElement("div");this.element.row=this;this.element.a ddEventListener("mouseover",this._onMouseOver.bind(this),false);this.element.add EventListener("mouseout",this._onMouseOut.bind(this),false);this.element.addEven tListener("click",this._onClick.bind(this),false);this._barAreaElement=document. createElement("div");this._barAreaElement.className="timeline-graph-bar-area";th is.element.appendChild(this._barAreaElement);this._barWithChildrenElement=docume nt.createElement("div");this._barWithChildrenElement.className="timeline-graph-b ar with-children";this._barWithChildrenElement.row=this;this._barAreaElement.app endChild(this._barWithChildrenElement);this._barCpuElement=document.createElemen t("div");this._barCpuElement.className="timeline-graph-bar cpu"
871 this._barCpuElement.row=this;this._barAreaElement.appendChild(this._barCpuElemen t);this._barElement=document.createElement("div");this._barElement.className="ti meline-graph-bar";this._barElement.row=this;this._barAreaElement.appendChild(thi s._barElement);this._expandElement=new WebInspector.TimelineExpandableElement(gr aphContainer);this._selectRecord=selectRecord;this._scheduleRefresh=scheduleRefr esh;} 900 this._barCpuElement.row=this;this._barAreaElement.appendChild(this._barCpuElemen t);this._barElement=document.createElement("div");this._barElement.className="ti meline-graph-bar";this._barElement.row=this;this._barAreaElement.appendChild(thi s._barElement);this._expandElement=new WebInspector.TimelineExpandableElement(gr aphContainer);this._selectRecord=selectRecord;this._scheduleRefresh=scheduleRefr esh;}
872 WebInspector.TimelineRecordGraphRow.prototype={update:function(record,calculator ,expandOffset,index) 901 WebInspector.TimelineRecordGraphRow.prototype={update:function(presentationRecor d,calculator,expandOffset,index)
873 {this._record=record;this.element.className="timeline-graph-side timeline-catego ry-"+record.category.name;if(record.isBackground) 902 {this._record=presentationRecord;var record=presentationRecord.record();this.ele ment.className="timeline-graph-side timeline-category-"+record.category.name;if( record.thread)
874 this.element.classList.add("background");var barPosition=calculator.computeBarGr aphWindowPosition(record);this._barWithChildrenElement.style.left=barPosition.le ft+"px";this._barWithChildrenElement.style.width=barPosition.widthWithChildren+" px";this._barElement.style.left=barPosition.left+"px";this._barElement.style.wid th=barPosition.width+"px";this._barCpuElement.style.left=barPosition.left+"px";t his._barCpuElement.style.width=barPosition.cpuWidth+"px";this._expandElement._up date(record,index,barPosition.left-expandOffset,barPosition.width);this._record. setUserObject("WebInspector.TimelineRecordGraphRow",this);},_onClick:function(ev ent) 903 this.element.classList.add("background");var barPosition=calculator.computeBarGr aphWindowPosition(record);this._barWithChildrenElement.style.left=barPosition.le ft+"px";this._barWithChildrenElement.style.width=barPosition.widthWithChildren+" px";this._barElement.style.left=barPosition.left+"px";this._barElement.style.wid th=(presentationRecord.coalesced()?barPosition.widthWithChildren:barPosition.wid th)+"px";this._barCpuElement.style.left=barPosition.left+"px";this._barCpuElemen t.style.width=(presentationRecord.coalesced()?barPosition.widthWithChildren:barP osition.cpuWidth)+"px";this._expandElement._update(presentationRecord,index,barP osition.left-expandOffset,barPosition.width);this._record.setGraphRow(this);},_o nClick:function(event)
875 {if(this._expandElement._arrow.containsEventPoint(event)) 904 {if(this._expandElement._arrow.containsEventPoint(event))
876 this._expand();this._selectRecord(this._record);},renderAsSelected:function(sele cted) 905 this._expand();this._selectRecord(this._record);},renderAsSelected:function(sele cted)
877 {this.element.enableStyleClass("selected",selected);},_expand:function() 906 {this.element.classList.toggle("selected",selected);},_expand:function()
878 {this._record.collapsed=!this._record.collapsed;this._record.clicked=true;this._ scheduleRefresh();},_onMouseOver:function(event) 907 {this._record.setCollapsed(!this._record.collapsed());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) 908 {this.element.classList.add("hovered");if(this._record.listRow())
880 {this.element.classList.remove("hovered");var listRow=(this._record.getUserObjec t("WebInspector.TimelineRecordListRow"));listRow.element.classList.remove("hover ed");},dispose:function() 909 this._record.listRow().element.classList.add("hovered");},_onMouseOut:function(e vent)
910 {this.element.classList.remove("hovered");if(this._record.listRow())
911 this._record.listRow().element.classList.remove("hovered");},dispose:function()
881 {this.element.remove();this._expandElement._dispose();}} 912 {this.element.remove();this._expandElement._dispose();}}
882 WebInspector.TimelineExpandableElement=function(container) 913 WebInspector.TimelineExpandableElement=function(container)
883 {this._element=container.createChild("div","timeline-expandable");this._element. createChild("div","timeline-expandable-left");this._arrow=this._element.createCh ild("div","timeline-expandable-arrow");} 914 {this._element=container.createChild("div","timeline-expandable");this._element. createChild("div","timeline-expandable-left");this._arrow=this._element.createCh ild("div","timeline-expandable-arrow");}
884 WebInspector.TimelineExpandableElement.prototype={_update:function(record,index, left,width) 915 WebInspector.TimelineExpandableElement.prototype={_update:function(record,index, left,width)
885 {const rowHeight=WebInspector.TimelinePanel.rowHeight;if(record.visibleChildrenC ount||record.expandable){this._element.style.top=index*rowHeight+"px";this._elem ent.style.left=left+"px";this._element.style.width=Math.max(12,width+25)+"px";if (!record.collapsed){this._element.style.height=(record.visibleChildrenCount+1)*r owHeight+"px";this._element.classList.add("timeline-expandable-expanded");this._ element.classList.remove("timeline-expandable-collapsed");}else{this._element.st yle.height=rowHeight+"px";this._element.classList.add("timeline-expandable-colla psed");this._element.classList.remove("timeline-expandable-expanded");} 916 {const rowHeight=WebInspector.TimelinePanel.rowHeight;if(record.visibleChildrenC ount()||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.visibleChildrenCoun t()+1)*rowHeight+"px";this._element.classList.add("timeline-expandable-expanded" );this._element.classList.remove("timeline-expandable-collapsed");}else{this._el ement.style.height=rowHeight+"px";this._element.classList.add("timeline-expandab le-collapsed");this._element.classList.remove("timeline-expandable-expanded");}
886 this._element.classList.remove("hidden");}else 917 this._element.classList.remove("hidden");}else
887 this._element.classList.add("hidden");},_dispose:function() 918 this._element.classList.add("hidden");},_dispose:function()
888 {this._element.remove();}} 919 {this._element.remove();}};WebInspector.TimelinePanel=function()
889 WebInspector.TimelineCategoryFilter=function() 920 {WebInspector.Panel.call(this,"timeline");this.registerRequiredCSS("timelinePane l.css");this.registerRequiredCSS("filter.css");this.element.addEventListener("co ntextmenu",this._contextMenu.bind(this),false);this._detailsLinkifier=new WebIns pector.Linkifier();this._windowStartTime=0;this._windowEndTime=Infinity;this._mo del=new WebInspector.TimelineModel();this._model.addEventListener(WebInspector.T imelineModel.Events.RecordingStarted,this._onRecordingStarted,this);this._model. addEventListener(WebInspector.TimelineModel.Events.RecordingStopped,this._onReco rdingStopped,this);this._model.addEventListener(WebInspector.TimelineModel.Event s.RecordsCleared,this._onRecordsCleared,this);this._model.addEventListener(WebIn spector.TimelineModel.Events.RecordingProgress,this._onRecordingProgress,this);t his._model.addEventListener(WebInspector.TimelineModel.Events.RecordFilterChange d,this._refreshViews,this);this._model.addEventListener(WebInspector.TimelineMod el.Events.RecordAdded,this._onRecordAdded,this);this._categoryFilter=new WebInsp ector.TimelineCategoryFilter();this._durationFilter=new WebInspector.TimelineIsL ongFilter();this._textFilter=new WebInspector.TimelineTextFilter();this._model.a ddFilter(new WebInspector.TimelineHiddenFilter());this._model.addFilter(this._ca tegoryFilter);this._model.addFilter(this._durationFilter);this._model.addFilter( this._textFilter);this._presentationModeSetting=WebInspector.settings.createSett ing("timelineOverviewMode",WebInspector.TimelinePanel.Mode.Events);this._createS tatusBarItems();this._topPane=new WebInspector.SplitView(true,false);this._topPa ne.element.id="timeline-overview-panel";this._topPane.show(this.element);this._t opPane.addEventListener(WebInspector.SplitView.Events.SidebarSizeChanged,this._s idebarResized,this);this._topPane.setResizable(false);this._createPresentationSe lector();this._overviewPane=new WebInspector.TimelineOverviewPane(this._model);t his._overviewPane.addEventListener(WebInspector.TimelineOverviewPane.Events.Wind owChanged,this._onWindowChanged.bind(this));this._overviewPane.show(this._topPan e.mainElement());this._createFileSelector();this._registerShortcuts();WebInspect or.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes. WillReloadPage,this._willReloadPage,this);WebInspector.resourceTreeModel.addEven tListener(WebInspector.ResourceTreeModel.EventTypes.Load,this._loadEventFired,th is);this._detailsSplitView=new WebInspector.SplitView(false,true,"timelinePanelD etailsSplitViewState");this._detailsSplitView.element.classList.add("timeline-de tails-split");this._detailsSplitView.sidebarElement().classList.add("timeline-de tails");this._detailsView=new WebInspector.TimelineDetailsView();this._detailsSp litView.installResizer(this._detailsView.titleElement());this._detailsView.show( this._detailsSplitView.sidebarElement());this._searchableView=new WebInspector.S earchableView(this);this._searchableView.setMinimumSize(0,25);this._searchableVi ew.element.classList.add("searchable-view");this._searchableView.show(this._deta ilsSplitView.mainElement());this._stackView=new WebInspector.StackView(false);th is._stackView.show(this._searchableView.element);this._stackView.element.classLi st.add("timeline-view-stack");WebInspector.dockController.addEventListener(WebIn spector.DockController.Events.DockSideChanged,this._dockSideChanged.bind(this)); WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._d ockSideChanged.bind(this));this._dockSideChanged();this._selectPresentationMode( this._presentationModeSetting.get());this._detailsSplitView.show(this.element);}
890 {} 921 WebInspector.TimelinePanel.Mode={Events:"Events",Frames:"Frames",Memory:"Memory" ,FlameChart:"FlameChart",Power:"Power"};WebInspector.TimelinePanel.rowHeight=18; WebInspector.TimelinePanel.headerHeight=20;WebInspector.TimelinePanel.durationFi lterPresetsMs=[0,1,15];WebInspector.TimelinePanel.prototype={searchableView:func tion()
891 WebInspector.TimelineCategoryFilter.prototype={accept:function(record) 922 {return this._searchableView;},wasShown:function()
892 {return!record.category.hidden&&record.type!==WebInspector.TimelineModel.RecordT ype.BeginFrame;}} 923 {if(!WebInspector.TimelinePanel._categoryStylesInitialized){WebInspector.Timelin ePanel._categoryStylesInitialized=true;var style=document.createElement("style") ;var categories=WebInspector.TimelineUIUtils.categories();style.textContent=Obje ct.values(categories).map(WebInspector.TimelineUIUtils.createStyleRuleForCategor y).join("\n");document.head.appendChild(style);}},_dockSideChanged:function()
893 WebInspector.TimelineIsLongFilter=function() 924 {var dockSide=WebInspector.dockController.dockSide();var vertically=false;if(doc kSide===WebInspector.DockController.State.DockedToBottom)
894 {this._minimumRecordDuration=0;} 925 vertically=true;else
895 WebInspector.TimelineIsLongFilter.prototype={setMinimumRecordDuration:function(v alue) 926 vertically=!WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._d etailsSplitView.setVertical(vertically);this._detailsView.setVertical(vertically );},windowStartTime:function()
896 {this._minimumRecordDuration=value;},accept:function(record) 927 {if(this._windowStartTime)
897 {return this._minimumRecordDuration?((record.lastChildEndTime-record.startTime)> =this._minimumRecordDuration):true;}} 928 return this._windowStartTime;if(this._model.minimumRecordTime()!=-1)
898 WebInspector.TimelineSearchFilter=function(regExp) 929 return this._model.minimumRecordTime();return 0;},windowEndTime:function()
899 {this._regExp=regExp;} 930 {if(this._windowEndTime<Infinity)
900 WebInspector.TimelineSearchFilter.prototype={accept:function(record) 931 return this._windowEndTime;if(this._model.maximumRecordTime()!=-1)
901 {return WebInspector.TimelineRecordListRow.testContentMatching(record,this._regE xp);}} 932 return this._model.maximumRecordTime();return Infinity;},_sidebarResized:functio n(event)
902 WebInspector.TimelineWindowFilter=function() 933 {var width=(event.data);this._topPane.setSidebarSize(width);for(var i=0;i<this._ currentViews.length;++i)
903 {this.reset();} 934 this._currentViews[i].setSidebarSize(width);},_onWindowChanged:function(event)
904 WebInspector.TimelineWindowFilter.prototype={reset:function() 935 {this._windowStartTime=event.data.startTime;this._windowEndTime=event.data.endTi me;for(var i=0;i<this._currentViews.length;++i)
905 {this._windowStartTime=0;this._windowEndTime=Infinity;},setWindowTimes:function( windowStartTime,windowEndTime) 936 this._currentViews[i].setWindowTimes(this._windowStartTime,this._windowEndTime); this._updateSelectionDetails();},requestWindowTimes:function(windowStartTime,win dowEndTime)
906 {this._windowStartTime=windowStartTime;this._windowEndTime=windowEndTime;},accep t:function(record) 937 {this._overviewPane.requestWindowTimes(windowStartTime,windowEndTime);},_frameMo del:function()
907 {return record.lastChildEndTime>=this._windowStartTime&&record.startTime<=this._ windowEndTime;}} 938 {if(!this._lazyFrameModel)
908 WebInspector.TimelineDetailsView=function() 939 this._lazyFrameModel=new WebInspector.TimelineFrameModel(this._model);return thi s._lazyFrameModel;},_timelineView:function()
909 {WebInspector.View.call(this);this.element=document.createElement("div");this.el ement.className="timeline-details-view fill vbox";this._titleElement=this.elemen t.createChild("div","timeline-details-view-title");this._titleElement.textConten t=WebInspector.UIString("DETAILS");this._contentElement=this.element.createChild ("div","timeline-details-view-body");} 940 {if(!this._lazyTimelineView)
910 WebInspector.TimelineDetailsView.prototype={titleElement:function() 941 this._lazyTimelineView=new WebInspector.TimelineView(this,this._model);return th is._lazyTimelineView;},_viewsForMode:function(mode)
911 {return this._titleElement;},setContent:function(title,node) 942 {var views=this._viewsMap[mode];if(!views){views={};switch(mode){case WebInspect or.TimelinePanel.Mode.Events:views.overviewView=new WebInspector.TimelineEventOv erview(this._model);views.mainViews=[this._timelineView()];break;case WebInspect or.TimelinePanel.Mode.Frames:views.overviewView=new WebInspector.TimelineFrameOv erview(this._model,this._frameModel());views.mainViews=[this._timelineView()];br eak;case WebInspector.TimelinePanel.Mode.Memory:views.overviewView=new WebInspec tor.TimelineMemoryOverview(this._model);views.mainViews=[this._timelineView(),ne w WebInspector.MemoryCountersGraph(this,this._model)];break;case WebInspector.Ti melinePanel.Mode.FlameChart:views.overviewView=new WebInspector.TimelineFrameOve rview(this._model,this._frameModel());views.mainViews=[new WebInspector.Timeline FlameChart(this,this._model,this._frameModel())];break;case WebInspector.Timelin ePanel.Mode.Power:views.overviewView=new WebInspector.TimelinePowerOverview(this ._model);views.mainViews=[this._timelineView()];break;default:console.assert(fal se,"Unknown mode: "+mode);}
912 {this._titleElement.textContent=WebInspector.UIString("DETAILS: %s",title);this. _contentElement.removeChildren();this._contentElement.appendChild(node);},setVer tical:function(vertical) 943 for(var i=0;i<views.mainViews.length;++i)
913 {this._contentElement.enableStyleClass("hbox",!vertical);this._contentElement.en ableStyleClass("vbox",vertical);},__proto__:WebInspector.View.prototype};WebInsp ector.TimelinePanel=function() 944 views.mainViews[i].addEventListener(WebInspector.SplitView.Events.SidebarSizeCha nged,this._sidebarResized,this);this._viewsMap[mode]=views;}
914 {WebInspector.Panel.call(this,"timeline");this.registerRequiredCSS("timelinePane l.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(WebI nspector.TimelineModel.Events.RecordingStarted,this._onRecordingStarted,this);th is._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped,th is._onRecordingStopped,this);this._presentationModeSetting=WebInspector.settings .createSetting("timelineOverviewMode",WebInspector.TimelinePanel.Mode.Events);th is._glueRecordsSetting=WebInspector.settings.createSetting("timelineGlueRecords" ,false);this._createStatusBarItems();this._createPresentationSelector();this._ov erviewPane=new WebInspector.TimelineOverviewPane(this._model);this._overviewPane .addEventListener(WebInspector.TimelineOverviewPane.Events.WindowChanged,this._o nWindowChanged.bind(this));this._overviewPane.show(this._presentationSelector.el ement);this._createFileSelector();this._registerShortcuts();WebInspector.resourc eTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillReload Page,this._willReloadPage,this);WebInspector.resourceTreeModel.addEventListener( WebInspector.ResourceTreeModel.EventTypes.Load,this._loadEventFired,this);this._ selectPresentationMode(this._presentationModeSetting.get());} 945 return views;},_createPresentationSelector:function()
915 WebInspector.TimelinePanel.Mode={Events:"Events",Frames:"Frames",Memory:"Memory" };WebInspector.TimelinePanel.rowHeight=18;WebInspector.TimelinePanel.headerHeigh t=20;WebInspector.TimelinePanel.durationFilterPresetsMs=[0,1,15];WebInspector.Ti melinePanel.prototype={setSidebarWidth:function(width) 946 {this._viewsMap={};var topPaneSidebarElement=this._topPane.sidebarElement();topP aneSidebarElement.id="timeline-overview-sidebar";var overviewTreeElement=topPane SidebarElement.createChild("ol","sidebar-tree vbox");var topPaneSidebarTree=new TreeOutline(overviewTreeElement);this._overviewItems={};for(var mode in WebInspe ctor.TimelinePanel.Mode){if(mode===WebInspector.TimelinePanel.Mode.FlameChart&&! WebInspector.experimentsSettings.timelineFlameChart.isEnabled()||mode===WebInspe ctor.TimelinePanel.Mode.Power&&!Capabilities.canProfilePower)
916 {this._topPaneSidebarElement.style.flexBasis=width+"px";},_onWindowChanged:funct ion() 947 continue;this._overviewItems[mode]=new WebInspector.SidebarTreeElement("timeline -overview-sidebar-"+mode.toLowerCase(),WebInspector.UIString(mode));var item=thi s._overviewItems[mode];item.onselect=this._onModeChanged.bind(this,mode);topPane SidebarTree.appendChild(item);}},_createStatusBarItems:function()
917 {this._currentView.windowChanged(this._overviewPane.windowLeft(),this._overviewP ane.windowRight());},setWindow:function(left,right) 948 {var panelStatusBarElement=this.element.createChild("div","panel-status-bar");th is._statusBarButtons=([]);this.toggleTimelineButton=new WebInspector.StatusBarBu tton(WebInspector.UIString("Record"),"record-profile-status-bar-item");this.togg leTimelineButton.addEventListener("click",this._toggleTimelineButtonClicked,this );this._statusBarButtons.push(this.toggleTimelineButton);panelStatusBarElement.a ppendChild(this.toggleTimelineButton.element);this.clearButton=new WebInspector. StatusBarButton(WebInspector.UIString("Clear"),"clear-status-bar-item");this.cle arButton.addEventListener("click",this._onClearButtonClick,this);this._statusBar Buttons.push(this.clearButton);panelStatusBarElement.appendChild(this.clearButto n.element);this._filterBar=this._createFilterBar();panelStatusBarElement.appendC hild(this._filterBar.filterButton().element);this.garbageCollectButton=new WebIn spector.StatusBarButton(WebInspector.UIString("Collect Garbage"),"garbage-collec t-status-bar-item");this.garbageCollectButton.addEventListener("click",this._gar bageCollectButtonClicked,this);this._statusBarButtons.push(this.garbageCollectBu tton);panelStatusBarElement.appendChild(this.garbageCollectButton.element);panel StatusBarElement.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebIn spector.UIString("Capture stacks"),WebInspector.settings.timelineCaptureStacks,t rue,undefined,WebInspector.UIString("Capture JavaScript stack on every timeline event")));this._miscStatusBarItems=panelStatusBarElement.createChild("div","stat us-bar-item");this._filtersContainer=this.element.createChild("div","timeline-fi lters-header hidden");this._filtersContainer.appendChild(this._filterBar.filters Element());this._filterBar.addEventListener(WebInspector.FilterBar.Events.Filter sToggled,this._onFiltersToggled,this);this._filterBar.setName("timelinePanel");} ,_createFilterBar:function()
918 {this._overviewPane.setWindow(left,right);},_viewForMode:function(mode) 949 {this._filterBar=new WebInspector.FilterBar();this._filters={};this._filters._te xtFilterUI=new WebInspector.TextFilterUI();this._filters._textFilterUI.addEventL istener(WebInspector.FilterUI.Events.FilterChanged,this._textFilterChanged,this) ;this._filterBar.addFilter(this._filters._textFilterUI);var durationOptions=[];f or(var presetIndex=0;presetIndex<WebInspector.TimelinePanel.durationFilterPreset sMs.length;++presetIndex){var durationMs=WebInspector.TimelinePanel.durationFilt erPresetsMs[presetIndex];var durationOption={};if(!durationMs){durationOption.la bel=WebInspector.UIString("All");durationOption.title=WebInspector.UIString("Sho w all records");}else{durationOption.label=WebInspector.UIString("\u2265 %dms",d urationMs);durationOption.title=WebInspector.UIString("Hide records shorter than %dms",durationMs);}
919 {var view=this._views[mode];if(!view){switch(mode){case WebInspector.TimelinePan el.Mode.Events:case WebInspector.TimelinePanel.Mode.Frames:case WebInspector.Tim elinePanel.Mode.Memory:view=new WebInspector.TimelineView(this,this._model,this. _glueRecordsSetting,mode);this._views[mode]=view;break;default:console.assert(fa lse,"Unknown mode: "+mode);}} 950 durationOption.value=durationMs;durationOptions.push(durationOption);}
920 return view;},_createPresentationSelector:function() 951 this._filters._durationFilterUI=new WebInspector.ComboBoxFilterUI(durationOption s);this._filters._durationFilterUI.addEventListener(WebInspector.FilterUI.Events .FilterChanged,this._durationFilterChanged,this);this._filterBar.addFilter(this. _filters._durationFilterUI);this._filters._categoryFiltersUI={};var categoryType s=[];var categories=WebInspector.TimelineUIUtils.categories();for(var categoryNa me in categories){var category=categories[categoryName];if(category.overviewStri pGroupIndex<0)
921 {this._views={};this._presentationSelector=new WebInspector.View();this._present ationSelector.element.classList.add("hbox");this._presentationSelector.element.i d="timeline-overview-panel";this._presentationSelector.show(this.element);this._ topPaneSidebarElement=this._presentationSelector.element.createChild("div");this ._topPaneSidebarElement.id="timeline-overview-sidebar";var overviewTreeElement=t his._topPaneSidebarElement.createChild("ol","sidebar-tree vbox");var topPaneSide barTree=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._onModeCha nged.bind(this,mode);topPaneSidebarTree.appendChild(item);}},_createStatusBarIte ms:function() 952 continue;var filter=new WebInspector.CheckboxFilterUI(category.name,category.tit le);this._filters._categoryFiltersUI[category.name]=filter;filter.addEventListen er(WebInspector.FilterUI.Events.FilterChanged,this._categoriesFilterChanged.bind (this,categoryName),this);this._filterBar.addFilter(filter);}
922 {var panelStatusBarElement=this.element.createChild("div","panel-status-bar");th is._statusBarButtons=([]);this.toggleTimelineButton=new WebInspector.StatusBarBu tton(WebInspector.UIString("Record"),"record-profile-status-bar-item");this.togg leTimelineButton.addEventListener("click",this._toggleTimelineButtonClicked,this );this._statusBarButtons.push(this.toggleTimelineButton);panelStatusBarElement.a ppendChild(this.toggleTimelineButton.element);this.clearButton=new WebInspector. StatusBarButton(WebInspector.UIString("Clear"),"clear-status-bar-item");this.cle arButton.addEventListener("click",this._onClearButtonClick,this);this._statusBar Buttons.push(this.clearButton);panelStatusBarElement.appendChild(this.clearButto n.element);this._filterBar=new WebInspector.FilterBar();panelStatusBarElement.ap pendChild(this._filterBar.filterButton().element);this.garbageCollectButton=new WebInspector.StatusBarButton(WebInspector.UIString("Collect Garbage"),"garbage-c ollect-status-bar-item");this.garbageCollectButton.addEventListener("click",this ._garbageCollectButtonClicked,this);this._statusBarButtons.push(this.garbageColl ectButton);panelStatusBarElement.appendChild(this.garbageCollectButton.element); this._glueParentButton=new WebInspector.StatusBarButton(WebInspector.UIString("G lue asynchronous events to causes"),"glue-async-status-bar-item");this._gluePare ntButton.toggled=this._glueRecordsSetting.get();this._glueParentButton.addEventL istener("click",this._glueParentButtonClicked,this);this._statusBarButtons.push( this._glueParentButton);panelStatusBarElement.appendChild(this._glueParentButton .element);panelStatusBarElement.appendChild(WebInspector.SettingsTab.createSetti ngCheckbox(WebInspector.UIString("Capture stacks"),WebInspector.settings.timelin eCaptureStacks,true,undefined,WebInspector.UIString("Capture JavaScript stack on every timeline event")));this._statusTextContainer=panelStatusBarElement.create Child("div");this.recordsCounter=new WebInspector.StatusBarText("","timeline-rec ords-counter");this._statusTextContainer.appendChild(this.recordsCounter.element );this._miscStatusBarItems=panelStatusBarElement.createChild("div","status-bar-i tem");this._filtersContainer=this.element.createChild("div","timeline-filters-he ader hidden");this._filtersContainer.appendChild(this._filterBar.filtersElement( ));this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggled ,this._onFiltersToggled,this);},_updateFiltersBar:function() 953 return this._filterBar;},_textFilterChanged:function(event)
923 {this._filterBar.clear();var hasFilters=this._currentView.createUIFilters(this._ filterBar);this._filterBar.filterButton().setEnabled(hasFilters);},defaultFocuse dElement:function() 954 {var searchQuery=this._filters._textFilterUI.value();this.searchCanceled();this. _textFilter.setRegex(searchQuery?createPlainTextSearchRegex(searchQuery,"i"):nul l);},_durationFilterChanged:function()
924 {return this.element;},searchableView:function() 955 {var duration=this._filters._durationFilterUI.value();var minimumRecordDuration= parseInt(duration,10);this._durationFilter.setMinimumRecordDuration(minimumRecor dDuration);},_categoriesFilterChanged:function(name,event)
925 {return this._currentView.searchableView();},_onFiltersToggled:function(event) 956 {var categories=WebInspector.TimelineUIUtils.categories();categories[name].hidde n=!this._filters._categoryFiltersUI[name].checked();this._categoryFilter.notifyF ilterChanged();},defaultFocusedElement:function()
926 {var toggled=(event.data);this._filtersContainer.enableStyleClass("hidden",!togg led);this.onResize();},_prepareToLoadTimeline:function() 957 {return this.element;},_onFiltersToggled:function(event)
958 {var toggled=(event.data);this._filtersContainer.classList.toggle("hidden",!togg led);this.doResize();},_prepareToLoadTimeline:function()
927 {if(this._operationInProgress) 959 {if(this._operationInProgress)
928 return null;if(this._recordingInProgress()){this.toggleTimelineButton.toggled=fa lse;this._stopRecording();} 960 return null;if(this._recordingInProgress()){this.toggleTimelineButton.toggled=fa lse;this._stopRecording();}
929 var progressIndicator=new WebInspector.ProgressIndicator();progressIndicator.add EventListener(WebInspector.ProgressIndicator.Events.Done,this._setOperationInPro gress.bind(this,null));this._setOperationInProgress(progressIndicator);return pr ogressIndicator;},_setOperationInProgress:function(indicator) 961 var progressIndicator=new WebInspector.ProgressIndicator();progressIndicator.add EventListener(WebInspector.ProgressIndicator.Events.Done,this._setOperationInPro gress.bind(this,null));this._setOperationInProgress(progressIndicator);return pr ogressIndicator;},_setOperationInProgress:function(indicator)
930 {this._operationInProgress=!!indicator;for(var i=0;i<this._statusBarButtons.leng th;++i) 962 {this._operationInProgress=!!indicator;for(var i=0;i<this._statusBarButtons.leng th;++i)
931 this._statusBarButtons[i].setEnabled(!this._operationInProgress);this._glueParen tButton.setEnabled(!this._operationInProgress&&!this._currentView.supportsGluePa rentMode());this._statusTextContainer.enableStyleClass("hidden",!!indicator);thi s._miscStatusBarItems.removeChildren();if(indicator) 963 this._statusBarButtons[i].setEnabled(!this._operationInProgress);this._miscStatu sBarItems.removeChildren();if(indicator)
932 this._miscStatusBarItems.appendChild(indicator.element);},_registerShortcuts:fun ction() 964 this._miscStatusBarItems.appendChild(indicator.element);},_registerShortcuts:fun ction()
933 {this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.Star tStopRecording,this._toggleTimelineButtonClicked.bind(this));this.registerShortc uts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.SaveToFile,this._saveToF ile.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePane lShortcuts.LoadFromFile,this._selectFileToLoad.bind(this));},_createFileSelector :function() 965 {this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.Star tStopRecording,this._toggleTimelineButtonClicked.bind(this));this.registerShortc uts(WebInspector.ShortcutsScreen.TimelinePanelShortcuts.SaveToFile,this._saveToF ile.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.TimelinePane lShortcuts.LoadFromFile,this._selectFileToLoad.bind(this));},_createFileSelector :function()
934 {if(this._fileSelectorElement) 966 {if(this._fileSelectorElement)
935 this._fileSelectorElement.remove();this._fileSelectorElement=WebInspector.create FileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this ._fileSelectorElement);},_contextMenu:function(event) 967 this._fileSelectorElement.remove();this._fileSelectorElement=WebInspector.create FileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this ._fileSelectorElement);},_contextMenu:function(event)
936 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebI nspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Save Timeline data\u202 6":"Save Timeline Data\u2026"),this._saveToFile.bind(this),this._operationInProg ress);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenu Titles()?"Load Timeline data\u2026":"Load Timeline Data\u2026"),this._selectFile ToLoad.bind(this),this._operationInProgress);contextMenu.show();},_saveToFile:fu nction() 968 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebI nspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Save Timeline data\u202 6":"Save Timeline Data\u2026"),this._saveToFile.bind(this),this._operationInProg ress);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenu Titles()?"Load Timeline data\u2026":"Load Timeline Data\u2026"),this._selectFile ToLoad.bind(this),this._operationInProgress);contextMenu.show();},_saveToFile:fu nction()
937 {if(this._operationInProgress) 969 {if(this._operationInProgress)
938 return true;this._model.saveToFile();return true;},_selectFileToLoad:function(){ this._fileSelectorElement.click();return true;},_loadFromFile:function(file) 970 return true;this._model.saveToFile();return true;},_selectFileToLoad:function(){ this._fileSelectorElement.click();return true;},_loadFromFile:function(file)
939 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator) 971 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator)
940 return;this._model.loadFromFile(file,progressIndicator);this._createFileSelector ();},loadFromURL:function(url) 972 return;this._model.loadFromFile(file,progressIndicator);this._createFileSelector ();},loadFromURL:function(url)
941 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator) 973 {var progressIndicator=this._prepareToLoadTimeline();if(!progressIndicator)
942 return;this._model.loadFromURL(url,progressIndicator);},_selectPresentationMode: function(mode) 974 return;this._model.loadFromURL(url,progressIndicator);},_selectPresentationMode: function(mode)
943 {if(!this._overviewItems[mode]) 975 {if(!this._overviewItems[mode])
944 mode=WebInspector.TimelinePanel.Mode.Events;this._overviewItems[mode].revealAndS elect(false);},_onModeChanged:function(mode) 976 mode=WebInspector.TimelinePanel.Mode.Events;this._overviewItems[mode].revealAndS elect(false);},_refreshViews:function(totalUpdate)
945 {this.element.classList.remove("timeline-"+this._presentationModeSetting.get().t oLowerCase()+"-view");this._presentationModeSetting.set(mode);this.element.class List.add("timeline-"+mode.toLowerCase()+"-view");var windowTimes=null;if(this._c urrentView){this._currentView.detach();windowTimes=this._currentView.windowTimes ();} 977 {for(var i=0;i<this._currentViews.length;++i){var view=this._currentViews[i];vie w.refreshRecords(this._textFilter._regex);}
946 this._currentView=this._viewForMode(mode);this._updateFiltersBar();this._current View.setWindowTimes(windowTimes);this._overviewPane.setOverviewControl(this._cur rentView.overviewControl());this._currentView.show(this.element);this._glueParen tButton.setEnabled(this._currentView.supportsGlueParentMode());},_startRecording :function(userInitiated) 978 this._updateSelectionDetails();},_onModeChanged:function(mode)
947 {this._userInitiatedRecording=userInitiated;this._model.startRecording(true);if( userInitiated) 979 {this.element.classList.remove("timeline-"+this._presentationModeSetting.get().t oLowerCase()+"-view");this._presentationModeSetting.set(mode);this.element.class List.add("timeline-"+mode.toLowerCase()+"-view");this._stackView.detachChildView s();var views=this._viewsForMode(mode);this._currentViews=views.mainViews;for(va r i=0;i<this._currentViews.length;++i){var view=this._currentViews[i];view.setWi ndowTimes(this.windowStartTime(),this.windowEndTime());this._stackView.appendVie w(view,"timelinePanelTimelineStackSplitViewState");view.refreshRecords(this._tex tFilter._regex);}
980 this._timelineView().setFrameModel(mode===WebInspector.TimelinePanel.Mode.Frames ?this._frameModel():null);this._overviewControl=views.overviewView;this._overvie wPane.setOverviewControl(this._overviewControl);this._updateSelectionDetails();} ,_startRecording:function(userInitiated)
981 {this._userInitiatedRecording=userInitiated;this._model.startRecording();for(var mode in WebInspector.TimelinePanel.Mode)
982 this._viewsForMode(mode).overviewView.timelineStarted();if(userInitiated)
948 WebInspector.userMetrics.TimelineStarted.record();},_stopRecording:function() 983 WebInspector.userMetrics.TimelineStarted.record();},_stopRecording:function()
949 {this._userInitiatedRecording=false;this._model.stopRecording();},_toggleTimelin eButtonClicked:function() 984 {this._userInitiatedRecording=false;this._model.stopRecording();for(var mode in WebInspector.TimelinePanel.Mode)
985 this._viewsForMode(mode).overviewView.timelineStopped();},_toggleTimelineButtonC licked:function()
950 {if(this._operationInProgress) 986 {if(this._operationInProgress)
951 return true;if(this._recordingInProgress()) 987 return true;if(this._recordingInProgress())
952 this._stopRecording();else 988 this._stopRecording();else
953 this._startRecording(true);return true;},_garbageCollectButtonClicked:function() 989 this._startRecording(true);return true;},_garbageCollectButtonClicked:function()
954 {HeapProfilerAgent.collectGarbage();},_glueParentButtonClicked:function() 990 {HeapProfilerAgent.collectGarbage();},_onClearButtonClick:function()
955 {var newValue=!this._glueParentButton.toggled;this._glueParentButton.toggled=new Value;this._glueRecordsSetting.set(newValue);},_onClearButtonClick:function() 991 {this._model.reset();},_onRecordsCleared:function()
956 {this._model.reset();},_onRecordingStarted:function() 992 {this.requestWindowTimes(0,Infinity);delete this._selectedRecord;if(this._lazyFr ameModel)
957 {this.toggleTimelineButton.title=WebInspector.UIString("Stop");this.toggleTimeli neButton.toggled=true;},_recordingInProgress:function() 993 this._lazyFrameModel.reset();for(var i=0;i<this._currentViews.length;++i)
958 {return this.toggleTimelineButton.toggled;},_onRecordingStopped:function() 994 this._currentViews[i].reset();this._overviewControl.reset();this._updateSelectio nDetails();},_onRecordingStarted:function()
959 {this.toggleTimelineButton.title=WebInspector.UIString("Record");this.toggleTime lineButton.toggled=false;},_willReloadPage:function(event) 995 {this.toggleTimelineButton.title=WebInspector.UIString("Stop");this.toggleTimeli neButton.toggled=true;this._showProgressPane();},_recordingInProgress:function()
996 {return this.toggleTimelineButton.toggled;},_showProgressPane:function()
997 {if(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
998 return;this._hideProgressPane();this._progressElement=this._detailsSplitView.mai nElement().createChild("div","timeline-progress-pane");this._progressElement.tex tContent=WebInspector.UIString("%d events collected",0);},_hideProgressPane:func tion()
999 {if(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
1000 return;if(this._progressElement)
1001 this._progressElement.remove();},_onRecordingProgress:function(event)
1002 {if(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
1003 return;this._progressElement.textContent=WebInspector.UIString("%d events collec ted",event.data);},_onRecordingStopped:function()
1004 {this.toggleTimelineButton.title=WebInspector.UIString("Record");this.toggleTime lineButton.toggled=false;this._hideProgressPane();},_onRecordAdded:function(even t)
1005 {this._addRecord((event.data));},_addRecord:function(record)
1006 {if(this._lazyFrameModel)
1007 this._lazyFrameModel.addRecord(record);for(var i=0;i<this._currentViews.length;+ +i)
1008 this._currentViews[i].addRecord(record);this._overviewPane.addRecord(record);thi s._updateSearchHighlight(false,true);},_willReloadPage:function(event)
960 {if(this._operationInProgress||this._userInitiatedRecording||!this.isShowing()) 1009 {if(this._operationInProgress||this._userInitiatedRecording||!this.isShowing())
961 return;this._startRecording(false);},_loadEventFired:function(event) 1010 return;this._startRecording(false);},_loadEventFired:function(event)
962 {if(!this._recordingInProgress()||this._userInitiatedRecording) 1011 {if(!this._recordingInProgress()||this._userInitiatedRecording)
963 return;this._stopRecording();},__proto__:WebInspector.Panel.prototype} 1012 return;this._stopRecording();},jumpToNextSearchResult:function()
1013 {if(!this._searchResults||!this._searchResults.length)
1014 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._se lectedSearchResult):-1;this._jumpToSearchResult(index+1);},jumpToPreviousSearchR esult:function()
1015 {if(!this._searchResults||!this._searchResults.length)
1016 return;var index=this._selectedSearchResult?this._searchResults.indexOf(this._se lectedSearchResult):0;this._jumpToSearchResult(index-1);},_jumpToSearchResult:fu nction(index)
1017 {this._selectSearchResult((index+this._searchResults.length)%this._searchResults .length);this._currentViews[0].highlightSearchResult(this._selectedSearchResult, this._searchRegex,true);},_selectSearchResult:function(index)
1018 {this._selectedSearchResult=this._searchResults[index];this._searchableView.upda teCurrentMatchIndex(index);},_clearHighlight:function()
1019 {this._currentViews[0].highlightSearchResult(null);},_updateSearchHighlight:func tion(revealRecord,shouldJump)
1020 {if(!this._textFilter.isEmpty()||!this._searchRegex){this._clearHighlight();retu rn;}
1021 if(!this._searchResults)
1022 this._updateSearchResults(shouldJump);this._currentViews[0].highlightSearchResul t(this._selectedSearchResult,this._searchRegex,revealRecord);},_updateSearchResu lts:function(shouldJump)
1023 {var searchRegExp=this._searchRegex;if(!searchRegExp)
1024 return;var matches=[];function processRecord(record)
1025 {if(record.endTime<this._windowStartTime||record.startTime>this._windowEndTime)
1026 return;if(record.testContentMatching(searchRegExp))
1027 matches.push(record);}
1028 this._model.forAllFilteredRecords(processRecord.bind(this));var matchesCount=mat ches.length;if(matchesCount){this._searchResults=matches;this._searchableView.up dateSearchMatchesCount(matchesCount);var selectedIndex=matches.indexOf(this._sel ectedSearchResult);if(shouldJump&&selectedIndex===-1)
1029 selectedIndex=0;this._selectSearchResult(selectedIndex);}else{this._searchableVi ew.updateSearchMatchesCount(0);delete this._selectedSearchResult;}},searchCancel ed:function()
1030 {this._clearHighlight();delete this._searchResults;delete this._selectedSearchRe sult;delete this._searchRegex;},performSearch:function(query,shouldJump)
1031 {this._searchRegex=createPlainTextSearchRegex(query,"i");delete this._searchResu lts;this._updateSearchHighlight(true,shouldJump);},_updateSelectionDetails:funct ion()
1032 {if(this._selectedRecord)
1033 return;var startTime=this._windowStartTime;var endTime=this._windowEndTime;if(st artTime<0)
1034 return;var aggregatedStats={};function compareEndTime(value,task)
1035 {return value<task.endTime?-1:1;}
1036 function aggregateTimeForRecordWithinWindow(record)
1037 {if(!record.endTime||record.endTime<startTime||record.startTime>endTime)
1038 return;var childrenTime=0;var children=record.children||[];for(var i=0;i<childre n.length;++i){var child=children[i];if(!child.endTime||child.endTime<startTime|| child.startTime>endTime)
1039 continue;childrenTime+=Math.min(endTime,child.endTime)-Math.max(startTime,child. startTime);aggregateTimeForRecordWithinWindow(child);}
1040 var categoryName=WebInspector.TimelineUIUtils.categoryForRecord(record).name;var ownTime=Math.min(endTime,record.endTime)-Math.max(startTime,record.startTime)-c hildrenTime;aggregatedStats[categoryName]=(aggregatedStats[categoryName]||0)+own Time;}
1041 var mainThreadTasks=this._model.mainThreadTasks();var taskIndex=insertionIndexFo rObjectInListSortedByFunction(startTime,mainThreadTasks,compareEndTime);for(;tas kIndex<mainThreadTasks.length;++taskIndex){var task=mainThreadTasks[taskIndex];i f(task.startTime>endTime)
1042 break;aggregateTimeForRecordWithinWindow(task);}
1043 var aggregatedTotal=0;for(var categoryName in aggregatedStats)
1044 aggregatedTotal+=aggregatedStats[categoryName];aggregatedStats["idle"]=Math.max( 0,endTime-startTime-aggregatedTotal);var fragment=document.createDocumentFragmen t();fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(aggregate dStats));var startOffset=startTime-this._model.minimumRecordTime();var endOffset =endTime-this._model.minimumRecordTime();var title=WebInspector.UIString("%s \u2 013 %s",Number.millisToString(startOffset),Number.millisToString(endOffset));thi s._detailsView.setContent(title,fragment);},selectRecord:function(record)
1045 {this._detailsLinkifier.reset();this._selectedRecord=record;if(!record){this._up dateSelectionDetails();return;}
1046 for(var i=0;i<this._currentViews.length;++i){var view=this._currentViews[i];view .setSelectedRecord(record);}
1047 if(!record){this._updateSelectionDetails();return;}
1048 WebInspector.TimelineUIUtils.generatePopupContent(record,this._detailsLinkifier, showCallback.bind(this));function showCallback(element)
1049 {this._detailsView.setContent(record.title(),element);}},showAggregatedStatsInDe tails:function(title,aggregatedStats)
1050 {this._detailsView.setContent(title,WebInspector.TimelineUIUtils.generatePieChar t(aggregatedStats));},__proto__:WebInspector.Panel.prototype}
1051 WebInspector.TimelineDetailsView=function()
1052 {WebInspector.VBox.call(this);this.element.classList.add("timeline-details-view" );this._titleElement=this.element.createChild("div","timeline-details-view-title ");this._titleElement.textContent=WebInspector.UIString("DETAILS");this._content Element=this.element.createChild("div","timeline-details-view-body");}
1053 WebInspector.TimelineDetailsView.prototype={titleElement:function()
1054 {return this._titleElement;},setContent:function(title,node)
1055 {this._titleElement.textContent=WebInspector.UIString("DETAILS: %s",title);this. _contentElement.removeChildren();this._contentElement.appendChild(node);},setVer tical:function(vertical)
1056 {this._contentElement.classList.toggle("hbox",!vertical);this._contentElement.cl assList.toggle("vbox",vertical);},__proto__:WebInspector.VBox.prototype}
1057 WebInspector.TimelineModeView=function()
1058 {}
1059 WebInspector.TimelineModeView.prototype={reset:function(){},refreshRecords:funct ion(textFilter){},addRecord:function(record){},highlightSearchResult:function(re cord,regex,selectRecord){},setWindowTimes:function(startTime,endTime){},setSideb arSize:function(width){},setSelectedRecord:function(record){}}
1060 WebInspector.TimelineModeViewDelegate=function(){}
1061 WebInspector.TimelineModeViewDelegate.prototype={requestWindowTimes:function(sta rtTime,endTime){},selectRecord:function(record){},showAggregatedStatsInDetails:f unction(title,aggregatedStats){},}
1062 WebInspector.TimelineCategoryFilter=function()
1063 {WebInspector.TimelineModel.Filter.call(this);}
1064 WebInspector.TimelineCategoryFilter.prototype={accept:function(record)
1065 {return!record.category.hidden;},__proto__:WebInspector.TimelineModel.Filter.pro totype}
1066 WebInspector.TimelineIsLongFilter=function()
1067 {WebInspector.TimelineModel.Filter.call(this);this._minimumRecordDuration=0;}
1068 WebInspector.TimelineIsLongFilter.prototype={setMinimumRecordDuration:function(v alue)
1069 {this._minimumRecordDuration=value;this.notifyFilterChanged();},accept:function( record)
1070 {return this._minimumRecordDuration?((record.lastChildEndTime-record.startTime)> =this._minimumRecordDuration):true;},__proto__:WebInspector.TimelineModel.Filter .prototype}
1071 WebInspector.TimelineTextFilter=function()
1072 {WebInspector.TimelineModel.Filter.call(this);}
1073 WebInspector.TimelineTextFilter.prototype={isEmpty:function()
1074 {return!this._regex;},setRegex:function(regex)
1075 {this._regex=regex;this.notifyFilterChanged();},accept:function(record)
1076 {if(!this._regex)
1077 return true;var accept=false;function processRecord(record)
1078 {return record.testContentMatching(this._regex);}
1079 return WebInspector.TimelineModel.forAllRecords([record],processRecord.bind(this ));},__proto__:WebInspector.TimelineModel.Filter.prototype}
1080 WebInspector.TimelineHiddenFilter=function()
1081 {WebInspector.TimelineModel.Filter.call(this);this._hiddenRecords={};this._hidde nRecords[WebInspector.TimelineModel.RecordType.MarkDOMContent]=1;this._hiddenRec ords[WebInspector.TimelineModel.RecordType.MarkLoad]=1;this._hiddenRecords[WebIn spector.TimelineModel.RecordType.MarkFirstPaint]=1;this._hiddenRecords[WebInspec tor.TimelineModel.RecordType.GPUTask]=1;this._hiddenRecords[WebInspector.Timelin eModel.RecordType.ScheduleStyleRecalculation]=1;this._hiddenRecords[WebInspector .TimelineModel.RecordType.InvalidateLayout]=1;this._hiddenRecords[WebInspector.T imelineModel.RecordType.RequestMainThreadFrame]=1;this._hiddenRecords[WebInspect or.TimelineModel.RecordType.ActivateLayerTree]=1;this._hiddenRecords[WebInspecto r.TimelineModel.RecordType.DrawFrame]=1;this._hiddenRecords[WebInspector.Timelin eModel.RecordType.BeginFrame]=1;this._hiddenRecords[WebInspector.TimelineModel.R ecordType.UpdateLayerTree]=1;}
1082 WebInspector.TimelineHiddenFilter.prototype={accept:function(record)
1083 {return!this._hiddenRecords[record.type];},__proto__:WebInspector.TimelineModel. Filter.prototype}
OLDNEW
« no previous file with comments | « chrome_linux64/resources/inspector/SourcesPanel.js ('k') | chrome_linux64/resources/inspector/auditsPanel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698