Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / LayersPanel.js
1 WebInspector.LayerTree=function(model,treeOutline)
2 {WebInspector.Object.call(this);this._model=model;this._treeOutline=treeOutline;this._treeOutline.childrenListElement.addEventListener("mousemove",this._onMouseMove.bind(this),false);this._treeOutline.childrenListElement.addEventListener("mouseout",this._onMouseMove.bind(this),false);this._treeOutline.childrenListElement.addEventListener("contextmenu",this._onContextMenu.bind(this),true);this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._update.bind(this));this._lastHoveredNode=null;}
3 WebInspector.LayerTree.Events={LayerHovered:"LayerHovered",LayerSelected:"LayerSelected"}
4 WebInspector.LayerTree.prototype={selectLayer:function(layer)
5 {this.hoverLayer(null);var node=layer&&this._treeOutline.getCachedTreeElement(layer);if(node)
6 node.revealAndSelect(true);else if(this._treeOutline.selectedTreeElement)
7 this._treeOutline.selectedTreeElement.deselect();},hoverLayer:function(layer)
8 {var node=layer&&this._treeOutline.getCachedTreeElement(layer);if(node===this._lastHoveredNode)
9 return;if(this._lastHoveredNode)
10 this._lastHoveredNode.setHovered(false);if(node)
11 node.setHovered(true);this._lastHoveredNode=node;},_update:function()
12 {var seenLayers={};function updateLayer(layer)
13 {var id=layer.id();if(seenLayers[id])
14 console.assert(false,"Duplicate layer id: "+id);seenLayers[id]=true;var node=this._treeOutline.getCachedTreeElement(layer);var parent=layer===this._model.contentRoot()?this._treeOutline:this._treeOutline.getCachedTreeElement(layer.parent());if(!parent)
15 console.assert(false,"Parent is not in the tree");if(!node){node=new WebInspector.LayerTreeElement(this,layer);parent.appendChild(node);}else{if(node.parent!==parent){node.parent.removeChild(node);parent.appendChild(node);}
16 node._update();}}
17 if(this._model.contentRoot())
18 this._model.forEachLayer(updateLayer.bind(this),this._model.contentRoot());for(var node=(this._treeOutline.children[0]);node&&!node.root;){if(seenLayers[node.representedObject.id()]){node=node.traverseNextTreeElement(false);}else{var nextNode=node.nextSibling||node.parent;node.parent.removeChild(node);if(node===this._lastHoveredNode)
19 this._lastHoveredNode=null;node=nextNode;}}},_onMouseMove:function(event)
20 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(node===this._lastHoveredNode)
21 return;this.dispatchEventToListeners(WebInspector.LayerTree.Events.LayerHovered,node&&node.representedObject);},_selectedNodeChanged:function(node)
22 {var layer=(node.representedObject);this.dispatchEventToListeners(WebInspector.LayerTree.Events.LayerSelected,layer);},_onContextMenu:function(event)
23 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(!node||!node.representedObject)
24 return;var layer=(node.representedObject);if(!layer)
25 return;var nodeId=layer.nodeIdForSelfOrAncestor();if(!nodeId)
26 return;var domNode=WebInspector.domModel.nodeForId(nodeId);if(!domNode)
27 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems(domNode);contextMenu.show();},__proto__:WebInspector.Object.prototype}
28 WebInspector.LayerTreeElement=function(tree,layer)
29 {TreeElement.call(this,"",layer);this._layerTree=tree;this._update();}
30 WebInspector.LayerTreeElement.prototype={onattach:function()
31 {var selection=document.createElement("div");selection.className="selection";this.listItemElement.insertBefore(selection,this.listItemElement.firstChild);},_update:function()
32 {var layer=(this.representedObject);var nodeId=layer.nodeIdForSelfOrAncestor();var node=nodeId?WebInspector.domModel.nodeForId(nodeId):null;var title=document.createDocumentFragment();title.createChild("div","selection");title.appendChild(document.createTextNode(node?WebInspector.DOMPresentationUtils.simpleSelector(node):"#"+layer.id()));var details=title.createChild("span","dimmed");details.textContent=WebInspector.UIString(" (%d × %d)",layer.width(),layer.height());this.title=title;},onselect:function()
33 {this._layerTree._selectedNodeChanged(this);return false;},setHovered:function(hovered)
34 {this.listItemElement.classList.toggle("hovered",hovered);},__proto__:TreeElement.prototype};WebInspector.Layers3DView=function(model)
35 {WebInspector.VBox.call(this);this.element.classList.add("layers-3d-view");this._emptyView=new WebInspector.EmptyView(WebInspector.UIString("Not in the composited mode.\nConsider forcing composited mode in Settings."));this._model=model;this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._update,this);this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPainted,this._onLayerPainted,this);this._rotatingContainerElement=this.element.createChild("div","fill rotating-container");this._transformController=new WebInspector.TransformController(this.element);this._transformController.addEventListener(WebInspector.TransformController.Events.TransformChanged,this._onTransformChanged,this);this.element.addEventListener("dblclick",this._onDoubleClick.bind(this),false);this.element.addEventListener("click",this._onClick.bind(this),false);this.element.addEventListener("mouseout",this._onMouseMove.bind(this),false);this.element.addEventListener("mousemove",this._onMouseMove.bind(this),false);this.element.addEventListener("contextmenu",this._onContextMenu.bind(this),false);this._elementsByLayerId={};this._scaleAdjustmentStylesheet=this.element.ownerDocument.head.createChild("style");this._scaleAdjustmentStylesheet.disabled=true;this._lastOutlinedElement={};this._layerImage=document.createElement("img");this._layerImage.style.width="100%";this._layerImage.style.height="100%";WebInspector.settings.showPaintRects.addChangeListener(this._update,this);}
36 WebInspector.Layers3DView.OutlineType={Hovered:"hovered",Selected:"selected"}
37 WebInspector.Layers3DView.Events={LayerHovered:"LayerHovered",LayerSelected:"LayerSelected",LayerSnapshotRequested:"LayerSnapshotRequested"}
38 WebInspector.Layers3DView.PaintRectColors=[WebInspector.Color.fromRGBA([0,0x5F,0,0x3F]),WebInspector.Color.fromRGBA([0,0xAF,0,0x3F]),WebInspector.Color.fromRGBA([0,0xFF,0,0x3F])]
39 WebInspector.Layers3DView.ScrollRectTitles={RepaintsOnScroll:WebInspector.UIString("repaints on scroll"),TouchEventHandler:WebInspector.UIString("touch event listener"),WheelEventHandler:WebInspector.UIString("mousewheel event listener")}
40 WebInspector.Layers3DView.prototype={onResize:function()
41 {this._update();},willHide:function()
42 {this._scaleAdjustmentStylesheet.disabled=true;},wasShown:function()
43 {this._scaleAdjustmentStylesheet.disabled=false;if(this._needsUpdate)
44 this._update();},_setOutline:function(type,layer)
45 {var element=layer?this._elementForLayer(layer):null;var previousElement=this._lastOutlinedElement[type];if(previousElement===element)
46 return;this._lastOutlinedElement[type]=element;if(previousElement){previousElement.classList.remove(type);this._updateElementColor(previousElement);}
47 if(element){element.classList.add(type);this._updateElementColor(element);}},hoverLayer:function(layer)
48 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,layer);},selectLayer:function(layer)
49 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,null);this._setOutline(WebInspector.Layers3DView.OutlineType.Selected,layer);},showImageForLayer:function(layer,imageURL)
50 {var element=this._elementForLayer(layer);this._layerImage.removeAttribute("src");if(imageURL)
51 this._layerImage.src=imageURL;element.appendChild(this._layerImage);},_scaleToFit:function()
52 {var root=this._model.contentRoot();if(!root)
53 return;const padding=40;var scaleX=this._clientWidth/(root.width()+2*padding);var scaleY=this._clientHeight/(root.height()+2*padding);var autoScale=Math.min(scaleX,scaleY);this._scale=autoScale*this._transformController.scale();this._paddingX=((this._clientWidth/autoScale-root.width())>>1)*this._scale;this._paddingY=((this._clientHeight/autoScale-root.height())>>1)*this._scale;const screenLayerSpacing=20;this._layerSpacing=screenLayerSpacing+"px";const screenLayerThickness=4;var layerThickness=screenLayerThickness+"px";var stylesheetContent=".layer-container .side-wall { height: "+layerThickness+"; width: "+layerThickness+"; } "+".layer-container .back-wall { -webkit-transform: translateZ(-"+layerThickness+"); } "+".layer-container { -webkit-transform: translateZ("+this._layerSpacing+"); }";var stylesheetTextNode=this._scaleAdjustmentStylesheet.firstChild;if(!stylesheetTextNode||stylesheetTextNode.nodeType!==Node.TEXT_NODE||stylesheetTextNode.nextSibling)
54 this._scaleAdjustmentStylesheet.textContent=stylesheetContent;else
55 stylesheetTextNode.nodeValue=stylesheetContent;var style=this._elementForLayer(root).style;style.left=Math.round(this._paddingX)+"px";style.top=Math.round(this._paddingY)+"px";style.webkitTransformOrigin="";},_onTransformChanged:function(event)
56 {var changedTransforms=(event.data);if(changedTransforms&WebInspector.TransformController.TransformType.Scale)
57 this._update();else
58 this._updateTransform();},_updateTransform:function()
59 {var root=this._model.contentRoot();if(!root)
60 return;var offsetX=this._transformController.offsetX();var offsetY=this._transformController.offsetY();var style=this._rotatingContainerElement.style;style.webkitTransform="translateZ(10000px)"+" rotateX("+this._transformController.rotateX()+"deg) rotateY("+this._transformController.rotateY()+"deg)"+" translateX("+offsetX+"px) translateY("+offsetY+"px)";style.webkitTransformOrigin=Math.round(this._paddingX+offsetX+root.width()*this._scale/2)+"px "+Math.round(this._paddingY+offsetY+root.height()*this._scale/2)+"px";},_createScrollRectElement:function(layer)
61 {var element=document.createElement("div");var parentLayerElement=this._elementsByLayerId[layer.id()];element.className="scroll-rect";parentLayerElement.appendChild(element);return element;},_updateScrollRectElement:function(rect,element)
62 {var style=element.style;style.width=Math.round(rect.rect.width*this._scale)+"px";style.height=Math.round(rect.rect.height*this._scale)+"px";style.left=Math.round(rect.rect.x*this._scale)+"px";style.top=Math.round(rect.rect.y*this._scale)+"px";element.title=WebInspector.Layers3DView.ScrollRectTitles[rect.type];},_updateScrollRectsForLayer:function(layer)
63 {var layerDetails=this._elementsByLayerId[layer.id()].__layerDetails;function removeElement(element)
64 {element.remove()}
65 if(layer.scrollRects().length!==layerDetails.scrollRectElements.length){layerDetails.scrollRectElements.forEach(removeElement);layerDetails.scrollRectElements=layer.scrollRects().map(this._createScrollRectElement.bind(this,layer));}
66 for(var i=0;i<layer.scrollRects().length;++i)
67 this._updateScrollRectElement(layer.scrollRects()[i],layerDetails.scrollRectElements[i]);},_update:function()
68 {if(!this.isShowing()){this._needsUpdate=true;return;}
69 if(!this._model.contentRoot()){this._emptyView.show(this.element);this._rotatingContainerElement.removeChildren();return;}
70 this._emptyView.detach();function updateLayer(layer)
71 {this._updateLayerElement(this._elementForLayer(layer));this._updateScrollRectsForLayer(layer);}
72 this._clientWidth=this.element.clientWidth;this._clientHeight=this.element.clientHeight;for(var layerId in this._elementsByLayerId){if(this._model.layerById(layerId))
73 continue;this._elementsByLayerId[layerId].remove();delete this._elementsByLayerId[layerId];}
74 this._scaleToFit();this._updateTransform();this._model.forEachLayer(updateLayer.bind(this));this._needsUpdate=false;},_onLayerPainted:function(event)
75 {var layer=(event.data);this._updatePaintRect(this._elementForLayer(layer));},_elementForLayer:function(layer)
76 {var element=this._elementsByLayerId[layer.id()];if(element){element.__layerDetails.layer=layer;return element;}
77 element=document.createElement("div");element.__layerDetails=new WebInspector.LayerDetails(layer,element.createChild("div","paint-rect"));["fill back-wall","side-wall top","side-wall right","side-wall bottom","side-wall left"].forEach(element.createChild.bind(element,"div"));this._elementsByLayerId[layer.id()]=element;return element;},_updateLayerElement:function(element)
78 {var layer=element.__layerDetails.layer;var style=element.style;var contentRoot=(this._model.contentRoot());var isContentRoot=layer===contentRoot;var isRoot=layer===this._model.root();var parentElement;if(isContentRoot){parentElement=this._rotatingContainerElement;element.__layerDetails.depth=0;}else if(isRoot){parentElement=this._elementForLayer(contentRoot);element.__layerDetails.depth=undefined;}else{parentElement=this._elementForLayer(layer.parent());element.__layerDetails.depth=parentElement.__layerDetails.isAboveContentRoot()?undefined:parentElement.__layerDetails.depth+1;}
79 if(!element.__layerDetails.isAboveContentRoot())
80 element.className="layer-container";else
81 element.className="layer-transparent";element.classList.toggle("invisible",layer.invisible());this._updateElementColor(element);if(parentElement!==element.parentElement)
82 parentElement.appendChild(element);style.width=Math.round(layer.width()*this._scale)+"px";style.height=Math.round(layer.height()*this._scale)+"px";this._updatePaintRect(element);if(isContentRoot||isRoot)
83 return;style.left=Math.round(layer.offsetX()*this._scale)+"px";style.top=Math.round(layer.offsetY()*this._scale)+"px";var transform=layer.transform();if(transform){transform=transform.slice();for(var i=12;i<15;++i)
84 transform[i]*=this._scale;style.webkitTransform="matrix3d("+transform.map(toFixed5).join(",")+") translateZ("+this._layerSpacing+")";var anchor=layer.anchorPoint();style.webkitTransformOrigin=Math.round(anchor[0]*100)+"% "+Math.round(anchor[1]*100)+"% "+anchor[2];}else{style.webkitTransform="";style.webkitTransformOrigin="";}
85 function toFixed5(x)
86 {return x.toFixed(5);}},_updatePaintRect:function(element)
87 {var details=element.__layerDetails;var paintRect=details.layer.lastPaintRect();var paintRectElement=details.paintRectElement;if(!paintRect||!WebInspector.settings.showPaintRects.get()){paintRectElement.classList.add("hidden");return;}
88 paintRectElement.classList.remove("hidden");if(details.paintCount===details.layer.paintCount())
89 return;details.paintCount=details.layer.paintCount();var style=paintRectElement.style;style.left=Math.round(paintRect.x*this._scale)+"px";style.top=Math.round(paintRect.y*this._scale)+"px";style.width=Math.round(paintRect.width*this._scale)+"px";style.height=Math.round(paintRect.height*this._scale)+"px";var color=WebInspector.Layers3DView.PaintRectColors[details.paintCount%WebInspector.Layers3DView.PaintRectColors.length];style.borderWidth=Math.ceil(1/this._scale)+"px";style.borderColor=color.toString(WebInspector.Color.Format.RGBA);},_updateElementColor:function(element)
90 {var color;if(element===this._lastOutlinedElement[WebInspector.Layers3DView.OutlineType.Selected])
91 color=WebInspector.Color.PageHighlight.Content.toString(WebInspector.Color.Format.RGBA)||"";else{const base=144;var component=base+20*((element.__layerDetails.depth-1)%5);color="rgba("+component+","+component+","+component+", 0.8)";}
92 element.style.backgroundColor=color;},_layerFromEventPoint:function(event)
93 {var element=this.element.ownerDocument.elementFromPoint(event.pageX,event.pageY);if(!element)
94 return null;element=element.enclosingNodeOrSelfWithClass("layer-container");return element&&element.__layerDetails&&element.__layerDetails.layer;},_onContextMenu:function(event)
95 {var layer=this._layerFromEventPoint(event);var nodeId=layer&&layer.nodeIdForSelfOrAncestor();if(!nodeId)
96 return;var domNode=WebInspector.domModel.nodeForId(nodeId);if(!domNode)
97 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems(domNode);contextMenu.show();},_onMouseMove:function(event)
98 {if(event.which)
99 return;this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerHovered,this._layerFromEventPoint(event));},_onClick:function(event)
100 {this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSelected,this._layerFromEventPoint(event));},_onDoubleClick:function(event)
101 {var layer=this._layerFromEventPoint(event);if(layer)
102 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSnapshotRequested,layer);event.stopPropagation();},__proto__:WebInspector.VBox.prototype}
103 WebInspector.LayerDetails=function(layer,paintRectElement)
104 {this.layer=layer;this.depth=0;this.paintRectElement=paintRectElement;this.paintCount=0;this.scrollRectElements=[];}
105 WebInspector.LayerDetails.prototype={isAboveContentRoot:function()
106 {return this.depth===undefined;}};WebInspector.LayerDetailsView=function(model)
107 {WebInspector.VBox.call(this);this.element.classList.add("layer-details-view");this._emptyView=new WebInspector.EmptyView(WebInspector.UIString("Select a layer to see its details"));this._createTable();this._model=model;this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._onLayerTreeUpdated,this);this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPainted,this._onLayerPainted,this);}
108 WebInspector.LayerDetailsView.CompositingReasonDetail={"transform3D":WebInspector.UIString("Composition due to association with an element with a CSS 3D transform."),"video":WebInspector.UIString("Composition due to association with a <video> element."),"canvas":WebInspector.UIString("Composition due to the element being a <canvas> element."),"plugin":WebInspector.UIString("Composition due to association with a plugin."),"iFrame":WebInspector.UIString("Composition due to association with an <iframe> element."),"backfaceVisibilityHidden":WebInspector.UIString("Composition due to association with an element with a \"backface-visibility: hidden\" style."),"animation":WebInspector.UIString("Composition due to association with an animated element."),"filters":WebInspector.UIString("Composition due to association with an element with CSS filters applied."),"positionFixed":WebInspector.UIString("Composition due to association with an element with a \"position: fixed\" style."),"positionSticky":WebInspector.UIString("Composition due to association with an element with a \"position: sticky\" style."),"overflowScrollingTouch":WebInspector.UIString("Composition due to association with an element with a \"overflow-scrolling: touch\" style."),"blending":WebInspector.UIString("Composition due to association with an element that has blend mode other than \"normal\"."),"assumedOverlap":WebInspector.UIString("Composition due to association with an element that may overlap other composited elements."),"overlap":WebInspector.UIString("Composition due to association with an element overlapping other composited elements."),"negativeZIndexChildren":WebInspector.UIString("Composition due to association with an element with descendants that have a negative z-index."),"transformWithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with composited descendants."),"opacityWithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with opacity applied and composited descendants."),"maskWithCompositedDescendants":WebInspector.UIString("Composition due to association with a masked element and composited descendants."),"reflectionWithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with a reflection and composited descendants."),"filterWithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with CSS filters applied and composited descendants."),"blendingWithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with CSS blending applied and composited descendants."),"clipsCompositingDescendants":WebInspector.UIString("Composition due to association with an element clipping compositing descendants."),"perspective":WebInspector.UIString("Composition due to association with an element with perspective applied."),"preserve3D":WebInspector.UIString("Composition due to association with an element with a \"transform-style: preserve-3d\" style."),"root":WebInspector.UIString("Root layer."),"layerForClip":WebInspector.UIString("Layer for clip."),"layerForScrollbar":WebInspector.UIString("Layer for scrollbar."),"layerForScrollingContainer":WebInspector.UIString("Layer for scrolling container."),"layerForForeground":WebInspector.UIString("Layer for foreground."),"layerForBackground":WebInspector.UIString("Layer for background."),"layerForMask":WebInspector.UIString("Layer for mask."),"layerForVideoOverlay":WebInspector.UIString("Layer for video overlay.")};WebInspector.LayerDetailsView.prototype={setLayer:function(layer)
109 {this._layer=layer;if(this.isShowing())
110 this._update();},wasShown:function()
111 {WebInspector.View.prototype.wasShown.call(this);this._update();},_onLayerTreeUpdated:function()
112 {if(this.isShowing())
113 this._update();},_onLayerPainted:function(event)
114 {var layer=(event.data);if(this._layer===layer)
115 this._paintCountCell.textContent=layer.paintCount();},_update:function()
116 {if(!this._layer){this._tableElement.remove();this._emptyView.show(this.element);return;}
117 this._emptyView.detach();this.element.appendChild(this._tableElement);this._positionCell.textContent=WebInspector.UIString("%d,%d",this._layer.offsetX(),this._layer.offsetY());this._sizeCell.textContent=WebInspector.UIString("%d × %d",this._layer.width(),this._layer.height());this._paintCountCell.textContent=this._layer.paintCount();const bytesPerPixel=4;this._memoryEstimateCell.textContent=Number.bytesToString(this._layer.invisible()?0:this._layer.width()*this._layer.height()*bytesPerPixel);this._layer.requestCompositingReasons(this._updateCompositingReasons.bind(this));},_createTable:function()
118 {this._tableElement=this.element.createChild("table");this._tbodyElement=this._tableElement.createChild("tbody");this._positionCell=this._createRow(WebInspector.UIString("Position in parent:"));this._sizeCell=this._createRow(WebInspector.UIString("Size:"));this._compositingReasonsCell=this._createRow(WebInspector.UIString("Compositing Reasons:"));this._memoryEstimateCell=this._createRow(WebInspector.UIString("Memory estimate:"));this._paintCountCell=this._createRow(WebInspector.UIString("Paint count:"));},_createRow:function(title)
119 {var tr=this._tbodyElement.createChild("tr");var titleCell=tr.createChild("td");titleCell.textContent=title;return tr.createChild("td");},_updateCompositingReasons:function(compositingReasons)
120 {if(!compositingReasons||!compositingReasons.length){this._compositingReasonsCell.textContent="n/a";return;}
121 var fragment=document.createDocumentFragment();for(var i=0;i<compositingReasons.length;++i){if(i)
122 fragment.appendChild(document.createTextNode(","));var span=document.createElement("span");span.title=WebInspector.LayerDetailsView.CompositingReasonDetail[compositingReasons[i]]||"";span.textContent=compositingReasons[i];fragment.appendChild(span);}
123 this._compositingReasonsCell.removeChildren();this._compositingReasonsCell.appendChild(fragment);},__proto__:WebInspector.VBox.prototype};WebInspector.PaintProfilerView=function(model,layers3DView)
124 {WebInspector.VBox.call(this);this.element.classList.add("paint-profiler-view");this._model=model;this._layers3DView=layers3DView;this._canvas=this.element.createChild("canvas","fill");this._context=this._canvas.getContext("2d");this._selectionWindow=new WebInspector.OverviewGrid.Window(this.element,this.element);this._selectionWindow.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._innerBarWidth=4*window.devicePixelRatio;this._minBarHeight=4*window.devicePixelRatio;this._barPaddingWidth=2*window.devicePixelRatio;this._outerBarWidth=this._innerBarWidth+this._barPaddingWidth;this._reset();}
125 WebInspector.PaintProfilerView.prototype={onResize:function()
126 {this._update();},_update:function()
127 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canvas.height=this.element.clientHeight*window.devicePixelRatio;this._samplesPerBar=0;if(!this._profiles||!this._profiles.length)
128 return;var maxBars=Math.floor((this._canvas.width-2*this._barPaddingWidth)/this._outerBarWidth);var sampleCount=this._profiles[0].length;this._samplesPerBar=Math.ceil(sampleCount/maxBars);var barCount=Math.floor(sampleCount/this._samplesPerBar);var maxBarTime=0;var barTimes=[];for(var i=0,lastBarIndex=0,lastBarTime=0;i<sampleCount;){for(var row=0;row<this._profiles.length;row++)
129 lastBarTime+=this._profiles[row][i];++i;if(i-lastBarIndex==this._samplesPerBar||i==sampleCount){lastBarTime/=this._profiles.length*(i-lastBarIndex);barTimes.push(lastBarTime);if(lastBarTime>maxBarTime)
130 maxBarTime=lastBarTime;lastBarTime=0;lastBarIndex=i;}}
131 const paddingHeight=4*window.devicePixelRatio;var scale=(this._canvas.height-paddingHeight-this._minBarHeight)/maxBarTime;this._context.fillStyle="rgba(110, 180, 110, 0.7)";for(var i=0;i<barTimes.length;++i)
132 this._renderBar(i,barTimes[i]*scale+this._minBarHeight);},_renderBar:function(index,height)
133 {var x=this._barPaddingWidth+index*this._outerBarWidth;var y=this._canvas.height-height;this._context.fillRect(x,y,this._innerBarWidth,height);},_onWindowChanged:function()
134 {if(this._updateImageTimer)
135 return;this._updateImageTimer=setTimeout(this._updateImage.bind(this),100);},_updateImage:function()
136 {delete this._updateImageTimer;if(!this._profiles||!this._profiles.length)
137 return;var screenLeft=this._selectionWindow.windowLeft*this._canvas.width;var screenRight=this._selectionWindow.windowRight*this._canvas.width;var barLeft=Math.floor((screenLeft-this._barPaddingWidth)/this._outerBarWidth);var barRight=Math.floor((screenRight-this._barPaddingWidth+this._innerBarWidth)/this._outerBarWidth);var stepLeft=Math.max(0,barLeft*this._samplesPerBar);var stepRight=Math.min(barRight*this._samplesPerBar,this._profiles[0].length);this._snapshot.requestImage(stepLeft,stepRight,this._layers3DView.showImageForLayer.bind(this._layers3DView,this._layer));},_reset:function()
138 {this._snapshot=null;this._profiles=null;this._selectionWindow.reset();},profile:function(layer)
139 {this._reset();this._layer=layer;this._layer.requestSnapshot(onSnapshotDone.bind(this));function onSnapshotDone(snapshot)
140 {this._snapshot=snapshot;if(!snapshot){this._profiles=null;this._update();return;}
141 snapshot.requestImage(null,null,this._layers3DView.showImageForLayer.bind(this._layers3DView,this._layer));snapshot.profile(onProfileDone.bind(this));}
142 function onProfileDone(profiles)
143 {this._profiles=profiles;this._update();}},__proto__:WebInspector.VBox.prototype};;WebInspector.TransformController=function(element)
144 {this.element=element;element.addEventListener("mousemove",this._onMouseMove.bind(this),false);element.addEventListener("mousedown",this._onMouseDown.bind(this),false);element.addEventListener("mouseup",this._onMouseUp.bind(this),false);element.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this.reset();}
145 WebInspector.TransformController.Events={TransformChanged:"TransformChanged"}
146 WebInspector.TransformController.TransformType={Offset:1<<0,Scale:1<<1,Rotation:1<<2}
147 WebInspector.TransformController.prototype={_postChangeEvent:function(changeType)
148 {this.dispatchEventToListeners(WebInspector.TransformController.Events.TransformChanged,changeType);},_onMouseMove:function(event)
149 {if(event.which!==1)
150 return;if(typeof this._originX!=="number")
151 this._setReferencePoint(event);this._rotateX=this._oldRotateX+(this._originY-event.clientY)/2;this._rotateY=this._oldRotateY-(this._originX-event.clientX)/4;this._postChangeEvent(WebInspector.TransformController.TransformType.Rotation);},reset:function()
152 {this._scale=1;this._offsetX=0;this._offsetY=0;this._rotateX=0;this._rotateY=0;},scale:function()
153 {return this._scale;},offsetX:function()
154 {return this._offsetX;},offsetY:function()
155 {return this._offsetY;},rotateX:function()
156 {return this._rotateX;},rotateY:function()
157 {return this._rotateY;},_onMouseWheel:function(event)
158 {if(event.shiftKey){const zoomFactor=1.1;const mouseWheelZoomSpeed=1/120;var scaleFactor=Math.pow(zoomFactor,event.wheelDeltaY*mouseWheelZoomSpeed);this._scale*=scaleFactor;this._offsetX-=(event.clientX-this.element.totalOffsetLeft()-this._offsetX)*(scaleFactor-1);this._offsetY-=(event.clientY-this.element.totalOffsetTop()-this._offsetY)*(scaleFactor-1);this._postChangeEvent(WebInspector.TransformController.TransformType.Scale|WebInspector.TransformController.TransformType.Offset);}else{this._offsetX+=event.wheelDeltaX;this._offsetY+=event.wheelDeltaY;this._postChangeEvent(WebInspector.TransformController.TransformType.Offset);}},_setReferencePoint:function(event)
159 {this._originX=event.clientX;this._originY=event.clientY;this._oldRotateX=this._rotateX;this._oldRotateY=this._rotateY;},_resetReferencePoint:function()
160 {delete this._originX;delete this._originY;delete this._oldRotateX;delete this._oldRotateY;},_onMouseDown:function(event)
161 {if(event.which!==1)
162 return;this._setReferencePoint(event);},_onMouseUp:function(event)
163 {if(event.which!==1)
164 return;this._resetReferencePoint();},__proto__:WebInspector.Object.prototype};WebInspector.LayersPanel=function()
165 {WebInspector.PanelWithSidebarTree.call(this,"layers",225);this.registerRequiredCSS("layersPanel.css");this.sidebarElement().classList.add("outline-disclosure");this.sidebarTree.element.classList.remove("sidebar-tree");this._model=new WebInspector.LayerTreeModel();this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._onLayerTreeUpdated,this);this._currentlySelectedLayer=null;this._currentlyHoveredLayer=null;this._layerTree=new WebInspector.LayerTree(this._model,this.sidebarTree);this._layerTree.addEventListener(WebInspector.LayerTree.Events.LayerSelected,this._onLayerSelected,this);this._layerTree.addEventListener(WebInspector.LayerTree.Events.LayerHovered,this._onLayerHovered,this);this._rightSplitView=new WebInspector.SplitView(false,true,"layerDetailsSplitViewState");this._rightSplitView.show(this.mainElement());this._layers3DView=new WebInspector.Layers3DView(this._model);this._layers3DView.show(this._rightSplitView.mainElement());this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerSelected,this._onLayerSelected,this);this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerHovered,this._onLayerHovered,this);this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerSnapshotRequested,this._onSnapshotRequested,this);this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.show(this._rightSplitView.sidebarElement());this._layerDetailsView=new WebInspector.LayerDetailsView(this._model);this._tabbedPane.appendTab(WebInspector.LayersPanel.DetailsViewTabs.Details,WebInspector.UIString("Details"),this._layerDetailsView);this._paintProfilerView=new WebInspector.PaintProfilerView(this._model,this._layers3DView);this._tabbedPane.appendTab(WebInspector.LayersPanel.DetailsViewTabs.Profiler,WebInspector.UIString("Profiler"),this._paintProfilerView);}
166 WebInspector.LayersPanel.DetailsViewTabs={Details:"details",Profiler:"profiler"};WebInspector.LayersPanel.prototype={wasShown:function()
167 {WebInspector.Panel.prototype.wasShown.call(this);this.sidebarTree.element.focus();this._model.enable();},willHide:function()
168 {this._model.disable();WebInspector.Panel.prototype.willHide.call(this);},_showSnapshot:function(snapshot)
169 {this._model.setSnapshot(snapshot);},_onLayerTreeUpdated:function()
170 {if(this._currentlySelectedLayer&&!this._model.layerById(this._currentlySelectedLayer.id()))
171 this._selectLayer(null);if(this._currentlyHoveredLayer&&!this._model.layerById(this._currentlyHoveredLayer.id()))
172 this._hoverLayer(null);},_onLayerSelected:function(event)
173 {var layer=(event.data);this._selectLayer(layer);},_onLayerHovered:function(event)
174 {var layer=(event.data);this._hoverLayer(layer);},_onSnapshotRequested:function(event)
175 {var layer=(event.data);this._tabbedPane.selectTab(WebInspector.LayersPanel.DetailsViewTabs.Profiler);this._paintProfilerView.profile(layer);},_selectLayer:function(layer)
176 {if(this._currentlySelectedLayer===layer)
177 return;this._currentlySelectedLayer=layer;var nodeId=layer&&layer.nodeIdForSelfOrAncestor();if(nodeId)
178 WebInspector.domModel.highlightDOMNodeForTwoSeconds(nodeId);else
179 WebInspector.domModel.hideDOMNodeHighlight();this._layerTree.selectLayer(layer);this._layers3DView.selectLayer(layer);this._layerDetailsView.setLayer(layer);},_hoverLayer:function(layer)
180 {if(this._currentlyHoveredLayer===layer)
181 return;this._currentlyHoveredLayer=layer;var nodeId=layer&&layer.nodeIdForSelfOrAncestor();if(nodeId)
182 WebInspector.domModel.highlightDOMNode(nodeId);else
183 WebInspector.domModel.hideDOMNodeHighlight();this._layerTree.hoverLayer(layer);this._layers3DView.hoverLayer(layer);},__proto__:WebInspector.PanelWithSidebarTree.prototype}
184 WebInspector.LayersPanel.LayerTreeRevealer=function()
185 {}
186 WebInspector.LayersPanel.LayerTreeRevealer.prototype={reveal:function(layerTree)
187 {if(layerTree instanceof WebInspector.LayerTreeSnapshot)
188 (WebInspector.inspectorView.showPanel("layers"))._showSnapshot(layerTree);}}