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

Side by Side Diff: chrome_linux64/resources/inspector/LayersPanel.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.LayerTreeModel=function() 1 WebInspector.LayerTree=function(model,treeOutline)
2 {WebInspector.Object.call(this);this._layersById={};this._lastPaintRectByLayerId ={};InspectorBackend.registerLayerTreeDispatcher(new WebInspector.LayerTreeDispa tcher(this));WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events .DocumentUpdated,this._onDocumentUpdated,this);}
3 WebInspector.LayerTreeModel.Events={LayerTreeChanged:"LayerTreeChanged",LayerPai nted:"LayerPainted",}
4 WebInspector.LayerTreeModel.prototype={disable:function()
5 {if(!this._enabled)
6 return;this._enabled=false;LayerTreeAgent.disable();},enable:function(callback)
7 {if(this._enabled)
8 return;this._enabled=true;WebInspector.domAgent.requestDocument(onDocumentAvaila ble.bind(this));function onDocumentAvailable()
9 {if(!this._enabled)
10 return;LayerTreeAgent.enable();}},root:function()
11 {return this._root;},contentRoot:function()
12 {return this._contentRoot;},forEachLayer:function(callback,root)
13 {if(!root){root=this.root();if(!root)
14 return false;}
15 return callback(root)||root.children().some(this.forEachLayer.bind(this,callback ));},layerById:function(id)
16 {return this._layersById[id]||null;},_repopulate:function(payload)
17 {var oldLayersById=this._layersById;this._layersById={};for(var i=0;i<payload.le ngth;++i){var layerId=payload[i].layerId;var layer=oldLayersById[layerId];if(lay er)
18 layer._reset(payload[i]);else
19 layer=new WebInspector.Layer(payload[i]);this._layersById[layerId]=layer;var par entId=layer.parentId();if(!this._contentRoot&&layer.nodeId())
20 this._contentRoot=layer;var lastPaintRect=this._lastPaintRectByLayerId[layerId]; if(lastPaintRect)
21 layer._lastPaintRect=lastPaintRect;if(parentId){var parent=this._layersById[pare ntId];if(!parent)
22 console.assert(parent,"missing parent "+parentId+" for layer "+layerId);parent.a ddChild(layer);}else{if(this._root)
23 console.assert(false,"Multiple root layers");this._root=layer;}}
24 this._lastPaintRectByLayerId={};},_layerTreeChanged:function(payload)
25 {this._root=null;this._contentRoot=null;if(payload)
26 this._repopulate(payload);this.dispatchEventToListeners(WebInspector.LayerTreeMo del.Events.LayerTreeChanged);},_layerPainted:function(layerId,clipRect)
27 {var layer=this._layersById[layerId];if(!layer){this._lastPaintRectByLayerId[lay erId]=clipRect;return;}
28 layer._didPaint(clipRect);this.dispatchEventToListeners(WebInspector.LayerTreeMo del.Events.LayerPainted,layer);},_onDocumentUpdated:function()
29 {this.disable();this.enable();},__proto__:WebInspector.Object.prototype}
30 WebInspector.Layer=function(layerPayload)
31 {this._reset(layerPayload);}
32 WebInspector.Layer.prototype={id:function()
33 {return this._layerPayload.layerId;},parentId:function()
34 {return this._layerPayload.parentLayerId;},parent:function()
35 {return this._parent;},isRoot:function()
36 {return!this.parentId();},children:function()
37 {return this._children;},addChild:function(child)
38 {if(child._parent)
39 console.assert(false,"Child already has a parent");this._children.push(child);ch ild._parent=this;},nodeId:function()
40 {return this._layerPayload.nodeId;},nodeIdForSelfOrAncestor:function()
41 {for(var layer=this;layer;layer=layer._parent){var nodeId=layer._layerPayload.no deId;if(nodeId)
42 return nodeId;}
43 return null;},offsetX:function()
44 {return this._layerPayload.offsetX;},offsetY:function()
45 {return this._layerPayload.offsetY;},width:function()
46 {return this._layerPayload.width;},height:function()
47 {return this._layerPayload.height;},transform:function()
48 {return this._layerPayload.transform;},anchorPoint:function()
49 {return[this._layerPayload.anchorX||0,this._layerPayload.anchorY||0,this._layerP ayload.anchorZ||0,];},invisible:function()
50 {return this._layerPayload.invisible;},paintCount:function()
51 {return this._paintCount||this._layerPayload.paintCount;},lastPaintRect:function ()
52 {return this._lastPaintRect;},requestCompositingReasons:function(callback)
53 {var wrappedCallback=InspectorBackend.wrapClientCallback(callback,"LayerTreeAgen t.reasonsForCompositingLayer(): ",undefined,[]);LayerTreeAgent.compositingReason s(this.id(),wrappedCallback);},requestSnapshot:function(callback)
54 {var wrappedCallback=InspectorBackend.wrapClientCallback(callback,"LayerTreeAgen t.makeSnapshot(): ",WebInspector.PaintProfilerSnapshot);LayerTreeAgent.makeSnaps hot(this.id(),wrappedCallback);},_didPaint:function(rect)
55 {this._lastPaintRect=rect;this._paintCount=this.paintCount()+1;this._image=null; },_reset:function(layerPayload)
56 {this._children=[];this._parent=null;this._paintCount=0;this._layerPayload=layer Payload;this._image=null;}}
57 WebInspector.LayerTreeDispatcher=function(layerTreeModel)
58 {this._layerTreeModel=layerTreeModel;}
59 WebInspector.LayerTreeDispatcher.prototype={layerTreeDidChange:function(payload)
60 {this._layerTreeModel._layerTreeChanged(payload);},layerPainted:function(layerId ,clipRect)
61 {this._layerTreeModel._layerPainted(layerId,clipRect);}};WebInspector.LayerTree= function(model,treeOutline)
62 {WebInspector.Object.call(this);this._model=model;this._treeOutline=treeOutline; this._treeOutline.childrenListElement.addEventListener("mousemove",this._onMouse Move.bind(this),false);this._treeOutline.childrenListElement.addEventListener("m ouseout",this._onMouseMove.bind(this),false);this._treeOutline.childrenListEleme nt.addEventListener("contextmenu",this._onContextMenu.bind(this),true);this._mod el.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._up date.bind(this));this._lastHoveredNode=null;} 2 {WebInspector.Object.call(this);this._model=model;this._treeOutline=treeOutline; this._treeOutline.childrenListElement.addEventListener("mousemove",this._onMouse Move.bind(this),false);this._treeOutline.childrenListElement.addEventListener("m ouseout",this._onMouseMove.bind(this),false);this._treeOutline.childrenListEleme nt.addEventListener("contextmenu",this._onContextMenu.bind(this),true);this._mod el.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._up date.bind(this));this._lastHoveredNode=null;}
63 WebInspector.LayerTree.Events={LayerHovered:"LayerHovered",LayerSelected:"LayerS elected"} 3 WebInspector.LayerTree.Events={LayerHovered:"LayerHovered",LayerSelected:"LayerS elected"}
64 WebInspector.LayerTree.prototype={selectLayer:function(layer) 4 WebInspector.LayerTree.prototype={selectLayer:function(layer)
65 {this.hoverLayer(null);var node=layer&&this._treeOutline.getCachedTreeElement(la yer);if(node) 5 {this.hoverLayer(null);var node=layer&&this._treeOutline.getCachedTreeElement(la yer);if(node)
66 node.revealAndSelect(true);else if(this._treeOutline.selectedTreeElement) 6 node.revealAndSelect(true);else if(this._treeOutline.selectedTreeElement)
67 this._treeOutline.selectedTreeElement.deselect();},hoverLayer:function(layer) 7 this._treeOutline.selectedTreeElement.deselect();},hoverLayer:function(layer)
68 {var node=layer&&this._treeOutline.getCachedTreeElement(layer);if(node===this._l astHoveredNode) 8 {var node=layer&&this._treeOutline.getCachedTreeElement(layer);if(node===this._l astHoveredNode)
69 return;if(this._lastHoveredNode) 9 return;if(this._lastHoveredNode)
70 this._lastHoveredNode.setHovered(false);if(node) 10 this._lastHoveredNode.setHovered(false);if(node)
71 node.setHovered(true);this._lastHoveredNode=node;},_update:function() 11 node.setHovered(true);this._lastHoveredNode=node;},_update:function()
72 {var seenLayers={};function updateLayer(layer) 12 {var seenLayers={};function updateLayer(layer)
73 {var id=layer.id();if(seenLayers[id]) 13 {var id=layer.id();if(seenLayers[id])
74 console.assert(false,"Duplicate layer id: "+id);seenLayers[id]=true;var node=thi s._treeOutline.getCachedTreeElement(layer);var parent=layer===this._model.conten tRoot()?this._treeOutline:this._treeOutline.getCachedTreeElement(layer.parent()) ;if(!parent) 14 console.assert(false,"Duplicate layer id: "+id);seenLayers[id]=true;var node=thi s._treeOutline.getCachedTreeElement(layer);var parent=layer===this._model.conten tRoot()?this._treeOutline:this._treeOutline.getCachedTreeElement(layer.parent()) ;if(!parent)
75 console.assert(false,"Parent is not in the tree");if(!node){node=new WebInspecto r.LayerTreeElement(this,layer);parent.appendChild(node);}else{var oldParentId=no de.parent.representedObject&&node.parent.representedObject.id();if(oldParentId!= =layer.parentId()){(node.parent||this._treeOutline).removeChild(node);parent.app endChild(node);} 15 console.assert(false,"Parent is not in the tree");if(!node){node=new WebInspecto r.LayerTreeElement(this,layer);parent.appendChild(node);}else{if(node.parent!==p arent){node.parent.removeChild(node);parent.appendChild(node);}
76 node._update();}} 16 node._update();}}
77 if(this._model.contentRoot()) 17 if(this._model.contentRoot())
78 this._model.forEachLayer(updateLayer.bind(this),this._model.contentRoot());for(v ar node=(this._treeOutline.children[0]);node&&!node.root;){if(seenLayers[node.re presentedObject.id()]){node=node.traverseNextTreeElement(false);}else{var nextNo de=node.nextSibling||node.parent;node.parent.removeChild(node);if(node===this._l astHoveredNode) 18 this._model.forEachLayer(updateLayer.bind(this),this._model.contentRoot());for(v ar node=(this._treeOutline.children[0]);node&&!node.root;){if(seenLayers[node.re presentedObject.id()]){node=node.traverseNextTreeElement(false);}else{var nextNo de=node.nextSibling||node.parent;node.parent.removeChild(node);if(node===this._l astHoveredNode)
79 this._lastHoveredNode=null;node=nextNode;}}},_onMouseMove:function(event) 19 this._lastHoveredNode=null;node=nextNode;}}},_onMouseMove:function(event)
80 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(nod e===this._lastHoveredNode) 20 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(nod e===this._lastHoveredNode)
81 return;this.dispatchEventToListeners(WebInspector.LayerTree.Events.LayerHovered, node&&node.representedObject);},_selectedNodeChanged:function(node) 21 return;this.dispatchEventToListeners(WebInspector.LayerTree.Events.LayerHovered, node&&node.representedObject);},_selectedNodeChanged:function(node)
82 {var layer=(node.representedObject);this.dispatchEventToListeners(WebInspector.L ayerTree.Events.LayerSelected,layer);},_onContextMenu:function(event) 22 {var layer=(node.representedObject);this.dispatchEventToListeners(WebInspector.L ayerTree.Events.LayerSelected,layer);},_onContextMenu:function(event)
83 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(!no de||!node.representedObject) 23 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(!no de||!node.representedObject)
84 return;var layer=(node.representedObject);if(!layer) 24 return;var layer=(node.representedObject);if(!layer)
85 return;var nodeId=layer.nodeId();if(!nodeId) 25 return;var nodeId=layer.nodeIdForSelfOrAncestor();if(!nodeId)
86 return;var domNode=WebInspector.domAgent.nodeForId(nodeId);if(!domNode) 26 return;var domNode=WebInspector.domModel.nodeForId(nodeId);if(!domNode)
87 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},__proto__:WebInspector.Object.prototy pe} 27 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},__proto__:WebInspector.Object.prototy pe}
88 WebInspector.LayerTreeElement=function(tree,layer) 28 WebInspector.LayerTreeElement=function(tree,layer)
89 {TreeElement.call(this,"",layer);this._layerTree=tree;this._update();} 29 {TreeElement.call(this,"",layer);this._layerTree=tree;this._update();}
90 WebInspector.LayerTreeElement.prototype={onattach:function() 30 WebInspector.LayerTreeElement.prototype={onattach:function()
91 {var selection=document.createElement("div");selection.className="selection";thi s.listItemElement.insertBefore(selection,this.listItemElement.firstChild);},_upd ate:function() 31 {var selection=document.createElement("div");selection.className="selection";thi s.listItemElement.insertBefore(selection,this.listItemElement.firstChild);},_upd ate:function()
92 {var layer=(this.representedObject);var nodeId=layer.nodeIdForSelfOrAncestor();v ar node=nodeId?WebInspector.domAgent.nodeForId(nodeId):null;var title=document.c reateDocumentFragment();title.createChild("div","selection");title.appendChild(d ocument.createTextNode(node?WebInspector.DOMPresentationUtils.appropriateSelecto rFor(node,false):"#"+layer.id()));var details=title.createChild("span","dimmed") ;details.textContent=WebInspector.UIString(" (%d × %d)",layer.width(),layer.heig ht());this.title=title;},onselect:function() 32 {var layer=(this.representedObject);var nodeId=layer.nodeIdForSelfOrAncestor();v ar node=nodeId?WebInspector.domModel.nodeForId(nodeId):null;var title=document.c reateDocumentFragment();title.createChild("div","selection");title.appendChild(d ocument.createTextNode(node?WebInspector.DOMPresentationUtils.simpleSelector(nod e):"#"+layer.id()));var details=title.createChild("span","dimmed");details.textC ontent=WebInspector.UIString(" (%d × %d)",layer.width(),layer.height());this.tit le=title;},onselect:function()
93 {this._layerTree._selectedNodeChanged(this);return false;},setHovered:function(h overed) 33 {this._layerTree._selectedNodeChanged(this);return false;},setHovered:function(h overed)
94 {this.listItemElement.enableStyleClass("hovered",hovered);},__proto__:TreeElemen t.prototype};WebInspector.Layers3DView=function(model) 34 {this.listItemElement.classList.toggle("hovered",hovered);},__proto__:TreeElemen t.prototype};WebInspector.Layers3DView=function(model)
95 {WebInspector.View.call(this);this.element.classList.add("fill");this.element.cl assList.add("layers-3d-view");this._emptyView=new WebInspector.EmptyView(WebInsp ector.UIString("Not in the composited mode.\nConsider forcing composited mode in Settings."));this._model=model;this._model.addEventListener(WebInspector.LayerT reeModel.Events.LayerTreeChanged,this._update,this);this._model.addEventListener (WebInspector.LayerTreeModel.Events.LayerPainted,this._onLayerPainted,this);this ._rotatingContainerElement=this.element.createChild("div","fill rotating-contain er");this.element.addEventListener("mousemove",this._onMouseMove.bind(this),fals e);this.element.addEventListener("mouseout",this._onMouseMove.bind(this),false); this.element.addEventListener("mousedown",this._onMouseDown.bind(this),false);th is.element.addEventListener("mouseup",this._onMouseUp.bind(this),false);this.ele ment.addEventListener("contextmenu",this._onContextMenu.bind(this),false);this.e lement.addEventListener("dblclick",this._onDoubleClick.bind(this),false);this.el ement.addEventListener("click",this._onClick.bind(this),false);this._elementsByL ayerId={};this._rotateX=0;this._rotateY=0;this._scaleAdjustmentStylesheet=this.e lement.ownerDocument.head.createChild("style");this._scaleAdjustmentStylesheet.d isabled=true;this._lastOutlinedElement={};this._layerImage=document.createElemen t("img");WebInspector.settings.showPaintRects.addChangeListener(this._update,thi s);} 35 {WebInspector.VBox.call(this);this.element.classList.add("layers-3d-view");this. _emptyView=new WebInspector.EmptyView(WebInspector.UIString("Not in the composit ed mode.\nConsider forcing composited mode in Settings."));this._model=model;thi s._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,th is._update,this);this._model.addEventListener(WebInspector.LayerTreeModel.Events .LayerPainted,this._onLayerPainted,this);this._rotatingContainerElement=this.ele ment.createChild("div","fill rotating-container");this._transformController=new WebInspector.TransformController(this.element);this._transformController.addEven tListener(WebInspector.TransformController.Events.TransformChanged,this._onTrans formChanged,this);this.element.addEventListener("dblclick",this._onDoubleClick.b ind(this),false);this.element.addEventListener("click",this._onClick.bind(this), false);this.element.addEventListener("mouseout",this._onMouseMove.bind(this),fal se);this.element.addEventListener("mousemove",this._onMouseMove.bind(this),false );this.element.addEventListener("contextmenu",this._onContextMenu.bind(this),fal se);this._elementsByLayerId={};this._scaleAdjustmentStylesheet=this.element.owne rDocument.head.createChild("style");this._scaleAdjustmentStylesheet.disabled=tru e;this._lastOutlinedElement={};this._layerImage=document.createElement("img");th is._layerImage.style.width="100%";this._layerImage.style.height="100%";WebInspec tor.settings.showPaintRects.addChangeListener(this._update,this);}
96 WebInspector.Layers3DView.OutlineType={Hovered:"hovered",Selected:"selected"} 36 WebInspector.Layers3DView.OutlineType={Hovered:"hovered",Selected:"selected"}
97 WebInspector.Layers3DView.Events={LayerHovered:"LayerHovered",LayerSelected:"Lay erSelected",LayerSnapshotRequested:"LayerSnapshotRequested"} 37 WebInspector.Layers3DView.Events={LayerHovered:"LayerHovered",LayerSelected:"Lay erSelected",LayerSnapshotRequested:"LayerSnapshotRequested"}
98 WebInspector.Layers3DView.PaintRectColors=[WebInspector.Color.fromRGBA([0,0x5F,0 ,0x3F]),WebInspector.Color.fromRGBA([0,0xAF,0,0x3F]),WebInspector.Color.fromRGBA ([0,0xFF,0,0x3F])] 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.UIStri ng("repaints on scroll"),TouchEventHandler:WebInspector.UIString("touch event li stener"),WheelEventHandler:WebInspector.UIString("mousewheel event listener")}
99 WebInspector.Layers3DView.prototype={onResize:function() 40 WebInspector.Layers3DView.prototype={onResize:function()
100 {this._update();},willHide:function() 41 {this._update();},willHide:function()
101 {this._scaleAdjustmentStylesheet.disabled=true;},wasShown:function() 42 {this._scaleAdjustmentStylesheet.disabled=true;},wasShown:function()
102 {this._scaleAdjustmentStylesheet.disabled=false;if(this._needsUpdate) 43 {this._scaleAdjustmentStylesheet.disabled=false;if(this._needsUpdate)
103 this._update();},_setOutline:function(type,layer) 44 this._update();},_setOutline:function(type,layer)
104 {var element=layer?this._elementForLayer(layer):null;var previousElement=this._l astOutlinedElement[type];if(previousElement===element) 45 {var element=layer?this._elementForLayer(layer):null;var previousElement=this._l astOutlinedElement[type];if(previousElement===element)
105 return;this._lastOutlinedElement[type]=element;if(previousElement){previousEleme nt.classList.remove(type);this._updateElementColor(previousElement);} 46 return;this._lastOutlinedElement[type]=element;if(previousElement){previousEleme nt.classList.remove(type);this._updateElementColor(previousElement);}
106 if(element){element.classList.add(type);this._updateElementColor(element);}},hov erLayer:function(layer) 47 if(element){element.classList.add(type);this._updateElementColor(element);}},hov erLayer:function(layer)
107 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,layer);},selectL ayer:function(layer) 48 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,layer);},selectL ayer:function(layer)
108 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,null);this._setO utline(WebInspector.Layers3DView.OutlineType.Selected,layer);},showImageForLayer :function(layer,imageURL) 49 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,null);this._setO utline(WebInspector.Layers3DView.OutlineType.Selected,layer);},showImageForLayer :function(layer,imageURL)
109 {var element=this._elementForLayer(layer);this._layerImage.removeAttribute("src" );if(imageURL) 50 {var element=this._elementForLayer(layer);this._layerImage.removeAttribute("src" );if(imageURL)
110 this._layerImage.src=imageURL;element.appendChild(this._layerImage);},_scaleToFi t:function() 51 this._layerImage.src=imageURL;element.appendChild(this._layerImage);},_scaleToFi t:function()
111 {var root=this._model.contentRoot();if(!root) 52 {var root=this._model.contentRoot();if(!root)
112 return;const padding=40;var scaleX=this._clientWidth/(root.width()+2*padding);va r scaleY=this._clientHeight/(root.height()+2*padding);this._scale=Math.min(scale X,scaleY);const screenLayerSpacing=20;this._layerSpacing=Math.ceil(screenLayerSp acing/this._scale)+"px";const screenLayerThickness=4;var layerThickness=Math.cei l(screenLayerThickness/this._scale)+"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+"); }";va r stylesheetTextNode=this._scaleAdjustmentStylesheet.firstChild;if(!stylesheetTe xtNode||stylesheetTextNode.nodeType!==Node.TEXT_NODE||stylesheetTextNode.nextSib ling) 53 return;const padding=40;var scaleX=this._clientWidth/(root.width()+2*padding);va r scaleY=this._clientHeight/(root.height()+2*padding);var autoScale=Math.min(sca leX,scaleY);this._scale=autoScale*this._transformController.scale();this._paddin gX=((this._clientWidth/autoScale-root.width())>>1)*this._scale;this._paddingY=(( this._clientHeight/autoScale-root.height())>>1)*this._scale;const screenLayerSpa cing=20;this._layerSpacing=screenLayerSpacing+"px";const screenLayerThickness=4; var layerThickness=screenLayerThickness+"px";var stylesheetContent=".layer-conta iner .side-wall { height: "+layerThickness+"; width: "+layerThickness+"; } "+".l ayer-container .back-wall { -webkit-transform: translateZ(-"+layerThickness+"); } "+".layer-container { -webkit-transform: translateZ("+this._layerSpacing+"); } ";var stylesheetTextNode=this._scaleAdjustmentStylesheet.firstChild;if(!styleshe etTextNode||stylesheetTextNode.nodeType!==Node.TEXT_NODE||stylesheetTextNode.nex tSibling)
113 this._scaleAdjustmentStylesheet.textContent=stylesheetContent;else 54 this._scaleAdjustmentStylesheet.textContent=stylesheetContent;else
114 stylesheetTextNode.nodeValue=stylesheetContent;var element=this._elementForLayer (root);element.style.webkitTransform="scale3d("+this._scale+","+this._scale+","+ this._scale+")";element.style.webkitTransformOrigin="";element.style.left=((this ._clientWidth-root.width()*this._scale)>>1)+"px";element.style.top=((this._clien tHeight-root.height()*this._scale)>>1)+"px";},_update:function() 55 stylesheetTextNode.nodeValue=stylesheetContent;var style=this._elementForLayer(r oot).style;style.left=Math.round(this._paddingX)+"px";style.top=Math.round(this. _paddingY)+"px";style.webkitTransformOrigin="";},_onTransformChanged:function(ev ent)
56 {var changedTransforms=(event.data);if(changedTransforms&WebInspector.TransformC ontroller.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._transfo rmController.offsetY();var style=this._rotatingContainerElement.style;style.webk itTransform="translateZ(10000px)"+" rotateX("+this._transformController.rotateX( )+"deg) rotateY("+this._transformController.rotateY()+"deg)"+" translateX("+offs etX+"px) translateY("+offsetY+"px)";style.webkitTransformOrigin=Math.round(this. _paddingX+offsetX+root.width()*this._scale/2)+"px "+Math.round(this._paddingY+of fsetY+root.height()*this._scale/2)+"px";},_createScrollRectElement:function(laye r)
61 {var element=document.createElement("div");var parentLayerElement=this._elements ByLayerId[layer.id()];element.className="scroll-rect";parentLayerElement.appendC hild(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.rou nd(rect.rect.x*this._scale)+"px";style.top=Math.round(rect.rect.y*this._scale)+" px";element.title=WebInspector.Layers3DView.ScrollRectTitles[rect.type];},_updat eScrollRectsForLayer:function(layer)
63 {var layerDetails=this._elementsByLayerId[layer.id()].__layerDetails;function re moveElement(element)
64 {element.remove()}
65 if(layer.scrollRects().length!==layerDetails.scrollRectElements.length){layerDet ails.scrollRectElements.forEach(removeElement);layerDetails.scrollRectElements=l ayer.scrollRects().map(this._createScrollRectElement.bind(this,layer));}
66 for(var i=0;i<layer.scrollRects().length;++i)
67 this._updateScrollRectElement(layer.scrollRects()[i],layerDetails.scrollRectElem ents[i]);},_update:function()
115 {if(!this.isShowing()){this._needsUpdate=true;return;} 68 {if(!this.isShowing()){this._needsUpdate=true;return;}
116 if(!this._model.contentRoot()){this._emptyView.show(this.element);this._rotating ContainerElement.removeChildren();return;} 69 if(!this._model.contentRoot()){this._emptyView.show(this.element);this._rotating ContainerElement.removeChildren();return;}
117 this._emptyView.detach();function updateLayer(layer) 70 this._emptyView.detach();function updateLayer(layer)
118 {this._updateLayerElement(this._elementForLayer(layer));} 71 {this._updateLayerElement(this._elementForLayer(layer));this._updateScrollRectsF orLayer(layer);}
119 this._clientWidth=this.element.clientWidth;this._clientHeight=this.element.clien tHeight;for(var layerId in this._elementsByLayerId){if(this._model.layerById(lay erId)) 72 this._clientWidth=this.element.clientWidth;this._clientHeight=this.element.clien tHeight;for(var layerId in this._elementsByLayerId){if(this._model.layerById(lay erId))
120 continue;this._elementsByLayerId[layerId].remove();delete this._elementsByLayerI d[layerId];} 73 continue;this._elementsByLayerId[layerId].remove();delete this._elementsByLayerI d[layerId];}
121 this._scaleToFit();this._model.forEachLayer(updateLayer.bind(this),this._model.c ontentRoot());this._needsUpdate=false;},_onLayerPainted:function(event) 74 this._scaleToFit();this._updateTransform();this._model.forEachLayer(updateLayer. bind(this));this._needsUpdate=false;},_onLayerPainted:function(event)
122 {var layer=(event.data);this._updatePaintRect(this._elementForLayer(layer));},_e lementForLayer:function(layer) 75 {var layer=(event.data);this._updatePaintRect(this._elementForLayer(layer));},_e lementForLayer:function(layer)
123 {var element=this._elementsByLayerId[layer.id()];if(element){element.__layerDeta ils.layer=layer;return element;} 76 {var element=this._elementsByLayerId[layer.id()];if(element){element.__layerDeta ils.layer=layer;return element;}
124 element=document.createElement("div");element.className="layer-container";["fill back-wall","side-wall top","side-wall right","side-wall bottom","side-wall left "].forEach(element.createChild.bind(element,"div"));element.__layerDetails=new W ebInspector.LayerDetails(layer,element.createChild("div","paint-rect"));this._el ementsByLayerId[layer.id()]=element;return element;},_updateLayerElement:functio n(element) 77 element=document.createElement("div");element.__layerDetails=new WebInspector.La yerDetails(layer,element.createChild("div","paint-rect"));["fill back-wall","sid e-wall top","side-wall right","side-wall bottom","side-wall left"].forEach(eleme nt.createChild.bind(element,"div"));this._elementsByLayerId[layer.id()]=element; return element;},_updateLayerElement:function(element)
125 {var layer=element.__layerDetails.layer;var style=element.style;var isContentRoo t=layer===this._model.contentRoot();var parentElement=isContentRoot?this._rotati ngContainerElement:this._elementForLayer(layer.parent());element.__layerDetails. depth=parentElement.__layerDetails?parentElement.__layerDetails.depth+1:0;elemen t.enableStyleClass("invisible",layer.invisible());this._updateElementColor(eleme nt);if(parentElement!==element.parentElement) 78 {var layer=element.__layerDetails.layer;var style=element.style;var contentRoot= (this._model.contentRoot());var isContentRoot=layer===contentRoot;var isRoot=lay er===this._model.root();var parentElement;if(isContentRoot){parentElement=this._ rotatingContainerElement;element.__layerDetails.depth=0;}else if(isRoot){parentE lement=this._elementForLayer(contentRoot);element.__layerDetails.depth=undefined ;}else{parentElement=this._elementForLayer(layer.parent());element.__layerDetail s.depth=parentElement.__layerDetails.isAboveContentRoot()?undefined:parentElemen t.__layerDetails.depth+1;}
126 parentElement.appendChild(element);style.width=layer.width()+"px";style.height=l ayer.height()+"px";this._updatePaintRect(element);if(isContentRoot) 79 if(!element.__layerDetails.isAboveContentRoot())
127 return;style.left=layer.offsetX()+"px";style.top=layer.offsetY()+"px";var transf orm=layer.transform();if(transform){style.webkitTransform="matrix3d("+transform. map(toFixed5).join(",")+") translateZ("+this._layerSpacing+")";var anchor=layer. anchorPoint();style.webkitTransformOrigin=Math.round(anchor[0]*100)+"% "+Math.ro und(anchor[1]*100)+"% "+anchor[2];}else{style.webkitTransform="";style.webkitTra nsformOrigin="";} 80 element.className="layer-container";else
81 element.className="layer-transparent";element.classList.toggle("invisible",layer .invisible());this._updateElementColor(element);if(parentElement!==element.paren tElement)
82 parentElement.appendChild(element);style.width=Math.round(layer.width()*this._sc ale)+"px";style.height=Math.round(layer.height()*this._scale)+"px";this._updateP aintRect(element);if(isContentRoot||isRoot)
83 return;style.left=Math.round(layer.offsetX()*this._scale)+"px";style.top=Math.ro und(layer.offsetY()*this._scale)+"px";var transform=layer.transform();if(transfo rm){transform=transform.slice();for(var i=12;i<15;++i)
84 transform[i]*=this._scale;style.webkitTransform="matrix3d("+transform.map(toFixe d5).join(",")+") translateZ("+this._layerSpacing+")";var anchor=layer.anchorPoin t();style.webkitTransformOrigin=Math.round(anchor[0]*100)+"% "+Math.round(anchor [1]*100)+"% "+anchor[2];}else{style.webkitTransform="";style.webkitTransformOrig in="";}
128 function toFixed5(x) 85 function toFixed5(x)
129 {return x.toFixed(5);}},_updatePaintRect:function(element) 86 {return x.toFixed(5);}},_updatePaintRect:function(element)
130 {var details=element.__layerDetails;var paintRect=details.layer.lastPaintRect(); var paintRectElement=details.paintRectElement;if(!paintRect||!WebInspector.setti ngs.showPaintRects.get()){paintRectElement.classList.add("hidden");return;} 87 {var details=element.__layerDetails;var paintRect=details.layer.lastPaintRect(); var paintRectElement=details.paintRectElement;if(!paintRect||!WebInspector.setti ngs.showPaintRects.get()){paintRectElement.classList.add("hidden");return;}
131 paintRectElement.classList.remove("hidden");if(details.paintCount===details.laye r.paintCount()) 88 paintRectElement.classList.remove("hidden");if(details.paintCount===details.laye r.paintCount())
132 return;details.paintCount=details.layer.paintCount();var style=paintRectElement. style;style.left=paintRect.x+"px";style.top=paintRect.y+"px";style.width=paintRe ct.width+"px";style.height=paintRect.height+"px";var color=WebInspector.Layers3D View.PaintRectColors[details.paintCount%WebInspector.Layers3DView.PaintRectColor s.length];style.borderWidth=Math.ceil(1/this._scale)+"px";style.borderColor=colo r.toString(WebInspector.Color.Format.RGBA);},_updateElementColor:function(elemen t) 89 return;details.paintCount=details.layer.paintCount();var style=paintRectElement. style;style.left=Math.round(paintRect.x*this._scale)+"px";style.top=Math.round(p aintRect.y*this._scale)+"px";style.width=Math.round(paintRect.width*this._scale) +"px";style.height=Math.round(paintRect.height*this._scale)+"px";var color=WebIn spector.Layers3DView.PaintRectColors[details.paintCount%WebInspector.Layers3DVie w.PaintRectColors.length];style.borderWidth=Math.ceil(1/this._scale)+"px";style. borderColor=color.toString(WebInspector.Color.Format.RGBA);},_updateElementColor :function(element)
133 {var color;if(element===this._lastOutlinedElement[WebInspector.Layers3DView.Outl ineType.Selected]) 90 {var color;if(element===this._lastOutlinedElement[WebInspector.Layers3DView.Outl ineType.Selected])
134 color=WebInspector.Color.PageHighlight.Content.toString(WebInspector.Color.Forma t.RGBA)||"";else{const base=144;var component=base+20*((element.__layerDetails.d epth-1)%5);color="rgba("+component+","+component+","+component+", 0.8)";} 91 color=WebInspector.Color.PageHighlight.Content.toString(WebInspector.Color.Forma t.RGBA)||"";else{const base=144;var component=base+20*((element.__layerDetails.d epth-1)%5);color="rgba("+component+","+component+","+component+", 0.8)";}
135 element.style.backgroundColor=color;},_onMouseDown:function(event) 92 element.style.backgroundColor=color;},_layerFromEventPoint:function(event)
136 {if(event.which!==1)
137 return;this._setReferencePoint(event);},_setReferencePoint:function(event)
138 {this._originX=event.clientX;this._originY=event.clientY;this._oldRotateX=this._ rotateX;this._oldRotateY=this._rotateY;},_resetReferencePoint:function()
139 {delete this._originX;delete this._originY;delete this._oldRotateX;delete this._ oldRotateY;},_onMouseUp:function(event)
140 {if(event.which!==1)
141 return;this._resetReferencePoint();},_layerFromEventPoint:function(event)
142 {var element=this.element.ownerDocument.elementFromPoint(event.pageX,event.pageY );if(!element) 93 {var element=this.element.ownerDocument.elementFromPoint(event.pageX,event.pageY );if(!element)
143 return null;element=element.enclosingNodeOrSelfWithClass("layer-container");retu rn element&&element.__layerDetails&&element.__layerDetails.layer;},_onMouseMove: function(event) 94 return null;element=element.enclosingNodeOrSelfWithClass("layer-container");retu rn element&&element.__layerDetails&&element.__layerDetails.layer;},_onContextMen u:function(event)
144 {if(!event.which){this.dispatchEventToListeners(WebInspector.Layers3DView.Events .LayerHovered,this._layerFromEventPoint(event));return;} 95 {var layer=this._layerFromEventPoint(event);var nodeId=layer&&layer.nodeIdForSel fOrAncestor();if(!nodeId)
145 if(event.which===1){if(typeof this._originX!=="number") 96 return;var domNode=WebInspector.domModel.nodeForId(nodeId);if(!domNode)
146 this._setReferencePoint(event);this._rotateX=this._oldRotateX+(this._originY-eve nt.clientY)/2;this._rotateY=this._oldRotateY-(this._originX-event.clientX)/4;thi s._rotatingContainerElement.style.webkitTransform="translateZ(10000px) rotateX(" +this._rotateX+"deg) rotateY("+this._rotateY+"deg)";}},_onContextMenu:function(e vent) 97 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},_onMouseMove:function(event)
147 {var layer=this._layerFromEventPoint(event);var nodeId=layer&&layer.nodeId();if( !nodeId) 98 {if(event.which)
148 return;var domNode=WebInspector.domAgent.nodeForId(nodeId);if(!domNode) 99 return;this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerHover ed,this._layerFromEventPoint(event));},_onClick:function(event)
149 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},_onClick:function(event)
150 {this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSelected,th is._layerFromEventPoint(event));},_onDoubleClick:function(event) 100 {this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSelected,th is._layerFromEventPoint(event));},_onDoubleClick:function(event)
151 {var layer=this._layerFromEventPoint(event);if(layer) 101 {var layer=this._layerFromEventPoint(event);if(layer)
152 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSnapshotRequ ested,layer);event.stopPropagation();},__proto__:WebInspector.View.prototype} 102 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSnapshotRequ ested,layer);event.stopPropagation();},__proto__:WebInspector.VBox.prototype}
153 WebInspector.LayerDetails=function(layer,paintRectElement) 103 WebInspector.LayerDetails=function(layer,paintRectElement)
154 {this.layer=layer;this.depth=0;this.paintRectElement=paintRectElement;this.paint Count=0;};WebInspector.LayerDetailsView=function(model) 104 {this.layer=layer;this.depth=0;this.paintRectElement=paintRectElement;this.paint Count=0;this.scrollRectElements=[];}
155 {WebInspector.View.call(this);this.element.classList.add("fill");this.element.cl assList.add("layer-details-view");this._emptyView=new WebInspector.EmptyView(Web Inspector.UIString("Select a layer to see its details"));this._createTable();thi s._model=model;this._model.addEventListener(WebInspector.LayerTreeModel.Events.L ayerTreeChanged,this._onLayerTreeUpdated,this);this._model.addEventListener(WebI nspector.LayerTreeModel.Events.LayerPainted,this._onLayerPainted,this);} 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");t his._emptyView=new WebInspector.EmptyView(WebInspector.UIString("Select a layer to see its details"));this._createTable();this._model=model;this._model.addEvent Listener(WebInspector.LayerTreeModel.Events.LayerTreeChanged,this._onLayerTreeUp dated,this);this._model.addEventListener(WebInspector.LayerTreeModel.Events.Laye rPainted,this._onLayerPainted,this);}
156 WebInspector.LayerDetailsView.CompositingReasonDetail={"transform3D":WebInspecto r.UIString("Composition due to association with an element with a CSS 3D transfo rm."),"video":WebInspector.UIString("Composition due to association with a <vide o> element."),"canvas":WebInspector.UIString("Composition due to the element bei ng a <canvas> element."),"plugin":WebInspector.UIString("Composition due to asso ciation with a plugin."),"iFrame":WebInspector.UIString("Composition due to asso ciation with an <iframe> element."),"backfaceVisibilityHidden":WebInspector.UISt ring("Composition due to association with an element with a \"backface-visibilit y: hidden\" style."),"animation":WebInspector.UIString("Composition due to assoc iation with an animated element."),"filters":WebInspector.UIString("Composition due to association with an element with CSS filters applied."),"positionFixed":W ebInspector.UIString("Composition due to association with an element with a \"po sition: fixed\" style."),"positionSticky":WebInspector.UIString("Composition due to association with an element with a \"position: sticky\" style."),"overflowSc rollingTouch":WebInspector.UIString("Composition due to association with an elem ent with a \"overflow-scrolling: touch\" style."),"blending":WebInspector.UIStri ng("Composition due to association with an element that has blend mode other tha n \"normal\"."),"assumedOverlap":WebInspector.UIString("Composition due to assoc iation with an element that may overlap other composited elements."),"overlap":W ebInspector.UIString("Composition due to association with an element overlapping other composited elements."),"negativeZIndexChildren":WebInspector.UIString("Co mposition due to association with an element with descendants that have a negati ve z-index."),"transformWithCompositedDescendants":WebInspector.UIString("Compos ition due to association with an element with composited descendants."),"opacity WithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with opacity applied and composited descendants."),"maskWithCom positedDescendants":WebInspector.UIString("Composition due to association with a masked element and composited descendants."),"reflectionWithCompositedDescendan ts":WebInspector.UIString("Composition due to association with an element with a reflection and composited descendants."),"filterWithCompositedDescendants":WebI nspector.UIString("Composition due to association with an element with CSS filte rs applied and composited descendants."),"blendingWithCompositedDescendants":Web Inspector.UIString("Composition due to association with an element with CSS blen ding applied and composited descendants."),"clipsCompositingDescendants":WebInsp ector.UIString("Composition due to association with an element clipping composit ing descendants."),"perspective":WebInspector.UIString("Composition due to assoc iation with an element with perspective applied."),"preserve3D":WebInspector.UIS tring("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.UISt ring("Layer for scrollbar."),"layerForScrollingContainer":WebInspector.UIString( "Layer for scrolling container."),"layerForForeground":WebInspector.UIString("La yer for foreground."),"layerForBackground":WebInspector.UIString("Layer for back ground."),"layerForMask":WebInspector.UIString("Layer for mask."),"layerForVideo Overlay":WebInspector.UIString("Layer for video overlay.")};WebInspector.LayerDe tailsView.prototype={setLayer:function(layer) 108 WebInspector.LayerDetailsView.CompositingReasonDetail={"transform3D":WebInspecto r.UIString("Composition due to association with an element with a CSS 3D transfo rm."),"video":WebInspector.UIString("Composition due to association with a <vide o> element."),"canvas":WebInspector.UIString("Composition due to the element bei ng a <canvas> element."),"plugin":WebInspector.UIString("Composition due to asso ciation with a plugin."),"iFrame":WebInspector.UIString("Composition due to asso ciation with an <iframe> element."),"backfaceVisibilityHidden":WebInspector.UISt ring("Composition due to association with an element with a \"backface-visibilit y: hidden\" style."),"animation":WebInspector.UIString("Composition due to assoc iation with an animated element."),"filters":WebInspector.UIString("Composition due to association with an element with CSS filters applied."),"positionFixed":W ebInspector.UIString("Composition due to association with an element with a \"po sition: fixed\" style."),"positionSticky":WebInspector.UIString("Composition due to association with an element with a \"position: sticky\" style."),"overflowSc rollingTouch":WebInspector.UIString("Composition due to association with an elem ent with a \"overflow-scrolling: touch\" style."),"blending":WebInspector.UIStri ng("Composition due to association with an element that has blend mode other tha n \"normal\"."),"assumedOverlap":WebInspector.UIString("Composition due to assoc iation with an element that may overlap other composited elements."),"overlap":W ebInspector.UIString("Composition due to association with an element overlapping other composited elements."),"negativeZIndexChildren":WebInspector.UIString("Co mposition due to association with an element with descendants that have a negati ve z-index."),"transformWithCompositedDescendants":WebInspector.UIString("Compos ition due to association with an element with composited descendants."),"opacity WithCompositedDescendants":WebInspector.UIString("Composition due to association with an element with opacity applied and composited descendants."),"maskWithCom positedDescendants":WebInspector.UIString("Composition due to association with a masked element and composited descendants."),"reflectionWithCompositedDescendan ts":WebInspector.UIString("Composition due to association with an element with a reflection and composited descendants."),"filterWithCompositedDescendants":WebI nspector.UIString("Composition due to association with an element with CSS filte rs applied and composited descendants."),"blendingWithCompositedDescendants":Web Inspector.UIString("Composition due to association with an element with CSS blen ding applied and composited descendants."),"clipsCompositingDescendants":WebInsp ector.UIString("Composition due to association with an element clipping composit ing descendants."),"perspective":WebInspector.UIString("Composition due to assoc iation with an element with perspective applied."),"preserve3D":WebInspector.UIS tring("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.UISt ring("Layer for scrollbar."),"layerForScrollingContainer":WebInspector.UIString( "Layer for scrolling container."),"layerForForeground":WebInspector.UIString("La yer for foreground."),"layerForBackground":WebInspector.UIString("Layer for back ground."),"layerForMask":WebInspector.UIString("Layer for mask."),"layerForVideo Overlay":WebInspector.UIString("Layer for video overlay.")};WebInspector.LayerDe tailsView.prototype={setLayer:function(layer)
157 {this._layer=layer;if(this.isShowing()) 109 {this._layer=layer;if(this.isShowing())
158 this._update();},wasShown:function() 110 this._update();},wasShown:function()
159 {WebInspector.View.prototype.wasShown.call(this);this._update();},_onLayerTreeUp dated:function() 111 {WebInspector.View.prototype.wasShown.call(this);this._update();},_onLayerTreeUp dated:function()
160 {if(this.isShowing()) 112 {if(this.isShowing())
161 this._update();},_onLayerPainted:function(event) 113 this._update();},_onLayerPainted:function(event)
162 {var layer=(event.data);if(this._layer===layer) 114 {var layer=(event.data);if(this._layer===layer)
163 this._paintCountCell.textContent=layer.paintCount();},_update:function() 115 this._paintCountCell.textContent=layer.paintCount();},_update:function()
164 {if(!this._layer){this._tableElement.remove();this._emptyView.show(this.element) ;return;} 116 {if(!this._layer){this._tableElement.remove();this._emptyView.show(this.element) ;return;}
165 this._emptyView.detach();this.element.appendChild(this._tableElement);this._posi tionCell.textContent=WebInspector.UIString("%d,%d",this._layer.offsetX(),this._l ayer.offsetY());this._sizeCell.textContent=WebInspector.UIString("%d × %d",this. _layer.width(),this._layer.height());this._paintCountCell.textContent=this._laye r.paintCount();const bytesPerPixel=4;this._memoryEstimateCell.textContent=Number .bytesToString(this._layer.invisible()?0:this._layer.width()*this._layer.height( )*bytesPerPixel);this._layer.requestCompositingReasons(this._updateCompositingRe asons.bind(this));},_createTable:function() 117 this._emptyView.detach();this.element.appendChild(this._tableElement);this._posi tionCell.textContent=WebInspector.UIString("%d,%d",this._layer.offsetX(),this._l ayer.offsetY());this._sizeCell.textContent=WebInspector.UIString("%d × %d",this. _layer.width(),this._layer.height());this._paintCountCell.textContent=this._laye r.paintCount();const bytesPerPixel=4;this._memoryEstimateCell.textContent=Number .bytesToString(this._layer.invisible()?0:this._layer.width()*this._layer.height( )*bytesPerPixel);this._layer.requestCompositingReasons(this._updateCompositingRe asons.bind(this));},_createTable:function()
166 {this._tableElement=this.element.createChild("table");this._tbodyElement=this._t ableElement.createChild("tbody");this._positionCell=this._createRow(WebInspector .UIString("Position in parent:"));this._sizeCell=this._createRow(WebInspector.UI String("Size:"));this._compositingReasonsCell=this._createRow(WebInspector.UIStr ing("Compositing Reasons:"));this._memoryEstimateCell=this._createRow(WebInspect or.UIString("Memory estimate:"));this._paintCountCell=this._createRow(WebInspect or.UIString("Paint count:"));},_createRow:function(title) 118 {this._tableElement=this.element.createChild("table");this._tbodyElement=this._t ableElement.createChild("tbody");this._positionCell=this._createRow(WebInspector .UIString("Position in parent:"));this._sizeCell=this._createRow(WebInspector.UI String("Size:"));this._compositingReasonsCell=this._createRow(WebInspector.UIStr ing("Compositing Reasons:"));this._memoryEstimateCell=this._createRow(WebInspect or.UIString("Memory estimate:"));this._paintCountCell=this._createRow(WebInspect or.UIString("Paint count:"));},_createRow:function(title)
167 {var tr=this._tbodyElement.createChild("tr");var titleCell=tr.createChild("td"); titleCell.textContent=title;return tr.createChild("td");},_updateCompositingReas ons:function(compositingReasons) 119 {var tr=this._tbodyElement.createChild("tr");var titleCell=tr.createChild("td"); titleCell.textContent=title;return tr.createChild("td");},_updateCompositingReas ons:function(compositingReasons)
168 {if(!compositingReasons||!compositingReasons.length){this._compositingReasonsCel l.textContent="n/a";return;} 120 {if(!compositingReasons||!compositingReasons.length){this._compositingReasonsCel l.textContent="n/a";return;}
169 var fragment=document.createDocumentFragment();for(var i=0;i<compositingReasons. length;++i){if(i) 121 var fragment=document.createDocumentFragment();for(var i=0;i<compositingReasons. length;++i){if(i)
170 fragment.appendChild(document.createTextNode(","));var span=document.createEleme nt("span");span.title=WebInspector.LayerDetailsView.CompositingReasonDetail[comp ositingReasons[i]]||"";span.textContent=compositingReasons[i];fragment.appendChi ld(span);} 122 fragment.appendChild(document.createTextNode(","));var span=document.createEleme nt("span");span.title=WebInspector.LayerDetailsView.CompositingReasonDetail[comp ositingReasons[i]]||"";span.textContent=compositingReasons[i];fragment.appendChi ld(span);}
171 this._compositingReasonsCell.removeChildren();this._compositingReasonsCell.appen dChild(fragment);},__proto__:WebInspector.View.prototype};WebInspector.PaintProf ilerView=function(model,layers3DView) 123 this._compositingReasonsCell.removeChildren();this._compositingReasonsCell.appen dChild(fragment);},__proto__:WebInspector.VBox.prototype};WebInspector.PaintProf ilerView=function(model,layers3DView)
172 {WebInspector.View.call(this);this.element.classList.add("fill","paint-profiler- view");this._model=model;this._layers3DView=layers3DView;this._canvas=this.eleme nt.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.Window Changed,this._onWindowChanged,this);this._innerBarWidth=4*window.devicePixelRati o;this._minBarHeight=4*window.devicePixelRatio;this._barPaddingWidth=2*window.de vicePixelRatio;this._outerBarWidth=this._innerBarWidth+this._barPaddingWidth;thi s._reset();} 124 {WebInspector.VBox.call(this);this.element.classList.add("paint-profiler-view"); this._model=model;this._layers3DView=layers3DView;this._canvas=this.element.crea teChild("canvas","fill");this._context=this._canvas.getContext("2d");this._selec tionWindow=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.devicePix elRatio;this._outerBarWidth=this._innerBarWidth+this._barPaddingWidth;this._rese t();}
173 WebInspector.PaintProfilerView.prototype={onResize:function() 125 WebInspector.PaintProfilerView.prototype={onResize:function()
174 {this._update();},_update:function() 126 {this._update();},_update:function()
175 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canva s.height=this.element.clientHeight*window.devicePixelRatio;this._samplesPerBar=0 ;if(!this._profiles||!this._profiles.length) 127 {this._canvas.width=this.element.clientWidth*window.devicePixelRatio;this._canva s.height=this.element.clientHeight*window.devicePixelRatio;this._samplesPerBar=0 ;if(!this._profiles||!this._profiles.length)
176 return;var maxBars=Math.floor((this._canvas.width-2*this._barPaddingWidth)/this. _outerBarWidth);var sampleCount=this._profiles[0].length;this._samplesPerBar=Mat h.ceil(sampleCount/maxBars);var barCount=Math.floor(sampleCount/this._samplesPer Bar);var maxBarTime=0;var barTimes=[];for(var i=0,lastBarIndex=0,lastBarTime=0;i <sampleCount;){for(var row=0;row<this._profiles.length;row++) 128 return;var maxBars=Math.floor((this._canvas.width-2*this._barPaddingWidth)/this. _outerBarWidth);var sampleCount=this._profiles[0].length;this._samplesPerBar=Mat h.ceil(sampleCount/maxBars);var barCount=Math.floor(sampleCount/this._samplesPer Bar);var maxBarTime=0;var barTimes=[];for(var i=0,lastBarIndex=0,lastBarTime=0;i <sampleCount;){for(var row=0;row<this._profiles.length;row++)
177 lastBarTime+=this._profiles[row][i];++i;if(i-lastBarIndex==this._samplesPerBar|| i==sampleCount){lastBarTime/=this._profiles.length*(i-lastBarIndex);barTimes.pus h(lastBarTime);if(lastBarTime>maxBarTime) 129 lastBarTime+=this._profiles[row][i];++i;if(i-lastBarIndex==this._samplesPerBar|| i==sampleCount){lastBarTime/=this._profiles.length*(i-lastBarIndex);barTimes.pus h(lastBarTime);if(lastBarTime>maxBarTime)
178 maxBarTime=lastBarTime;lastBarTime=0;lastBarIndex=i;}} 130 maxBarTime=lastBarTime;lastBarTime=0;lastBarIndex=i;}}
179 const paddingHeight=4*window.devicePixelRatio;var scale=(this._canvas.height-pad dingHeight-this._minBarHeight)/maxBarTime;this._context.fillStyle="rgba(110, 180 , 110, 0.7)";for(var i=0;i<barTimes.length;++i) 131 const paddingHeight=4*window.devicePixelRatio;var scale=(this._canvas.height-pad dingHeight-this._minBarHeight)/maxBarTime;this._context.fillStyle="rgba(110, 180 , 110, 0.7)";for(var i=0;i<barTimes.length;++i)
180 this._renderBar(i,barTimes[i]*scale+this._minBarHeight);},_renderBar:function(in dex,height) 132 this._renderBar(i,barTimes[i]*scale+this._minBarHeight);},_renderBar:function(in dex,height)
181 {var x=this._barPaddingWidth+index*this._outerBarWidth;var y=this._canvas.height -height;this._context.fillRect(x,y,this._innerBarWidth,height);},_onWindowChange d:function() 133 {var x=this._barPaddingWidth+index*this._outerBarWidth;var y=this._canvas.height -height;this._context.fillRect(x,y,this._innerBarWidth,height);},_onWindowChange d:function()
182 {if(this._updateImageTimer) 134 {if(this._updateImageTimer)
183 return;this._updateImageTimer=setTimeout(this._updateImage.bind(this),100);},_up dateImage:function() 135 return;this._updateImageTimer=setTimeout(this._updateImage.bind(this),100);},_up dateImage:function()
184 {delete this._updateImageTimer;if(!this._profiles||!this._profiles.length) 136 {delete this._updateImageTimer;if(!this._profiles||!this._profiles.length)
185 return;var screenLeft=this._selectionWindow.windowLeft*this._canvas.width;var sc reenRight=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._outerBarWidt h);var stepLeft=Math.max(0,barLeft*this._samplesPerBar);var stepRight=Math.min(b arRight*this._samplesPerBar,this._profiles[0].length);this._snapshot.requestImag e(stepLeft,stepRight,this._layers3DView.showImageForLayer.bind(this._layers3DVie w,this._layer));},_reset:function() 137 return;var screenLeft=this._selectionWindow.windowLeft*this._canvas.width;var sc reenRight=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._outerBarWidt h);var stepLeft=Math.max(0,barLeft*this._samplesPerBar);var stepRight=Math.min(b arRight*this._samplesPerBar,this._profiles[0].length);this._snapshot.requestImag e(stepLeft,stepRight,this._layers3DView.showImageForLayer.bind(this._layers3DVie w,this._layer));},_reset:function()
186 {this._snapshot=null;this._profiles=null;this._selectionWindow.reset();},profile :function(layer) 138 {this._snapshot=null;this._profiles=null;this._selectionWindow.reset();},profile :function(layer)
187 {this._reset();this._layer=layer;this._layer.requestSnapshot(onSnapshotDone.bind (this));function onSnapshotDone(snapshot) 139 {this._reset();this._layer=layer;this._layer.requestSnapshot(onSnapshotDone.bind (this));function onSnapshotDone(snapshot)
188 {this._snapshot=snapshot;if(!snapshot){this._profiles=null;this._update();return ;} 140 {this._snapshot=snapshot;if(!snapshot){this._profiles=null;this._update();return ;}
189 snapshot.requestImage(null,null,this._layers3DView.showImageForLayer.bind(this._ layers3DView,this._layer));snapshot.profile(onProfileDone.bind(this));} 141 snapshot.requestImage(null,null,this._layers3DView.showImageForLayer.bind(this._ layers3DView,this._layer));snapshot.profile(onProfileDone.bind(this));}
190 function onProfileDone(profiles) 142 function onProfileDone(profiles)
191 {this._profiles=profiles;this._update();}},__proto__:WebInspector.View.prototype };;WebInspector.LayersPanel=function() 143 {this._profiles=profiles;this._update();}},__proto__:WebInspector.VBox.prototype };;WebInspector.TransformController=function(element)
192 {WebInspector.Panel.call(this,"layers");this.registerRequiredCSS("layersPanel.cs s");const initialLayerTreeSidebarWidth=225;const minimumMainWidthPercent=0.5;thi s.createSidebarViewWithTree();this.splitView.sidebarElement().classList.add("out line-disclosure");this.sidebarTreeElement.classList.remove("sidebar-tree");this. _model=new WebInspector.LayerTreeModel();this._model.addEventListener(WebInspect or.LayerTreeModel.Events.LayerTreeChanged,this._onLayerTreeUpdated,this);this._c urrentlySelectedLayer=null;this._currentlyHoveredLayer=null;this._layerTree=new WebInspector.LayerTree(this._model,this.sidebarTree);this._layerTree.addEventLis tener(WebInspector.LayerTree.Events.LayerSelected,this._onLayerSelected,this);th is._layerTree.addEventListener(WebInspector.LayerTree.Events.LayerHovered,this._ onLayerHovered,this);this._rightSplitView=new WebInspector.SplitView(false,"laye rDetailsSplitView");this.splitView.setMainView(this._rightSplitView);this._layer s3DView=new WebInspector.Layers3DView(this._model);this._layers3DView.show(this. _rightSplitView.firstElement());this._layers3DView.addEventListener(WebInspector .Layers3DView.Events.LayerSelected,this._onLayerSelected,this);this._layers3DVie w.addEventListener(WebInspector.Layers3DView.Events.LayerHovered,this._onLayerHo vered,this);this._layers3DView.addEventListener(WebInspector.Layers3DView.Events .LayerSnapshotRequested,this._onSnapshotRequested,this);this._tabbedPane=new Web Inspector.TabbedPane();this._tabbedPane.element.classList.add("fill");this._tabb edPane.show(this._rightSplitView.secondElement());this._layerDetailsView=new Web Inspector.LayerDetailsView(this._model);this._tabbedPane.appendTab(WebInspector. LayersPanel.DetailsViewTabs.Details,WebInspector.UIString("Details"),this._layer DetailsView);this._paintProfilerView=new WebInspector.PaintProfilerView(this._mo del,this._layers3DView);this._tabbedPane.appendTab(WebInspector.LayersPanel.Deta ilsViewTabs.Profiler,WebInspector.UIString("Profiler"),this._paintProfilerView); } 144 {this.element=element;element.addEventListener("mousemove",this._onMouseMove.bin d(this),false);element.addEventListener("mousedown",this._onMouseDown.bind(this) ,false);element.addEventListener("mouseup",this._onMouseUp.bind(this),false);ele ment.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this.res et();}
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.Transform Changed,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-eve nt.clientY)/2;this._rotateY=this._oldRotateY-(this._originX-event.clientX)/4;thi s._postChangeEvent(WebInspector.TransformController.TransformType.Rotation);},re set: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 sca leFactor=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.totalOffsetT op()-this._offsetY)*(scaleFactor-1);this._postChangeEvent(WebInspector.Transform Controller.TransformType.Scale|WebInspector.TransformController.TransformType.Of fset);}else{this._offsetX+=event.wheelDeltaX;this._offsetY+=event.wheelDeltaY;th is._postChangeEvent(WebInspector.TransformController.TransformType.Offset);}},_s etReferencePoint: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};We bInspector.LayersPanel=function()
165 {WebInspector.PanelWithSidebarTree.call(this,"layers",225);this.registerRequired CSS("layersPanel.css");this.sidebarElement().classList.add("outline-disclosure") ;this.sidebarTree.element.classList.remove("sidebar-tree");this._model=new WebIn spector.LayerTreeModel();this._model.addEventListener(WebInspector.LayerTreeMode l.Events.LayerTreeChanged,this._onLayerTreeUpdated,this);this._currentlySelected Layer=null;this._currentlyHoveredLayer=null;this._layerTree=new WebInspector.Lay erTree(this._model,this.sidebarTree);this._layerTree.addEventListener(WebInspect or.LayerTree.Events.LayerSelected,this._onLayerSelected,this);this._layerTree.ad dEventListener(WebInspector.LayerTree.Events.LayerHovered,this._onLayerHovered,t his);this._rightSplitView=new WebInspector.SplitView(false,true,"layerDetailsSpl itViewState");this._rightSplitView.show(this.mainElement());this._layers3DView=n ew WebInspector.Layers3DView(this._model);this._layers3DView.show(this._rightSpl itView.mainElement());this._layers3DView.addEventListener(WebInspector.Layers3DV iew.Events.LayerSelected,this._onLayerSelected,this);this._layers3DView.addEvent Listener(WebInspector.Layers3DView.Events.LayerHovered,this._onLayerHovered,this );this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerSnap shotRequested,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.UIStrin g("Details"),this._layerDetailsView);this._paintProfilerView=new WebInspector.Pa intProfilerView(this._model,this._layers3DView);this._tabbedPane.appendTab(WebIn spector.LayersPanel.DetailsViewTabs.Profiler,WebInspector.UIString("Profiler"),t his._paintProfilerView);}
193 WebInspector.LayersPanel.DetailsViewTabs={Details:"details",Profiler:"profiler"} ;WebInspector.LayersPanel.prototype={wasShown:function() 166 WebInspector.LayersPanel.DetailsViewTabs={Details:"details",Profiler:"profiler"} ;WebInspector.LayersPanel.prototype={wasShown:function()
194 {WebInspector.Panel.prototype.wasShown.call(this);this.sidebarTreeElement.focus( );this._model.enable();},willHide:function() 167 {WebInspector.Panel.prototype.wasShown.call(this);this.sidebarTree.element.focus ();this._model.enable();},willHide:function()
195 {this._model.disable();WebInspector.Panel.prototype.willHide.call(this);},_onLay erTreeUpdated:function() 168 {this._model.disable();WebInspector.Panel.prototype.willHide.call(this);},_showS napshot:function(snapshot)
169 {this._model.setSnapshot(snapshot);},_onLayerTreeUpdated:function()
196 {if(this._currentlySelectedLayer&&!this._model.layerById(this._currentlySelected Layer.id())) 170 {if(this._currentlySelectedLayer&&!this._model.layerById(this._currentlySelected Layer.id()))
197 this._selectLayer(null);if(this._currentlyHoveredLayer&&!this._model.layerById(t his._currentlyHoveredLayer.id())) 171 this._selectLayer(null);if(this._currentlyHoveredLayer&&!this._model.layerById(t his._currentlyHoveredLayer.id()))
198 this._hoverLayer(null);},_onLayerSelected:function(event) 172 this._hoverLayer(null);},_onLayerSelected:function(event)
199 {var layer=(event.data);this._selectLayer(layer);},_onLayerHovered:function(even t) 173 {var layer=(event.data);this._selectLayer(layer);},_onLayerHovered:function(even t)
200 {var layer=(event.data);this._hoverLayer(layer);},_onSnapshotRequested:function( event) 174 {var layer=(event.data);this._hoverLayer(layer);},_onSnapshotRequested:function( event)
201 {var layer=(event.data);this._tabbedPane.selectTab(WebInspector.LayersPanel.Deta ilsViewTabs.Profiler);this._paintProfilerView.profile(layer);},_selectLayer:func tion(layer) 175 {var layer=(event.data);this._tabbedPane.selectTab(WebInspector.LayersPanel.Deta ilsViewTabs.Profiler);this._paintProfilerView.profile(layer);},_selectLayer:func tion(layer)
202 {if(this._currentlySelectedLayer===layer) 176 {if(this._currentlySelectedLayer===layer)
203 return;this._currentlySelectedLayer=layer;var nodeId=layer&&layer.nodeIdForSelfO rAncestor();if(nodeId) 177 return;this._currentlySelectedLayer=layer;var nodeId=layer&&layer.nodeIdForSelfO rAncestor();if(nodeId)
204 WebInspector.domAgent.highlightDOMNodeForTwoSeconds(nodeId);else 178 WebInspector.domModel.highlightDOMNodeForTwoSeconds(nodeId);else
205 WebInspector.domAgent.hideDOMNodeHighlight();this._layerTree.selectLayer(layer); this._layers3DView.selectLayer(layer);this._layerDetailsView.setLayer(layer);},_ hoverLayer:function(layer) 179 WebInspector.domModel.hideDOMNodeHighlight();this._layerTree.selectLayer(layer); this._layers3DView.selectLayer(layer);this._layerDetailsView.setLayer(layer);},_ hoverLayer:function(layer)
206 {if(this._currentlyHoveredLayer===layer) 180 {if(this._currentlyHoveredLayer===layer)
207 return;this._currentlyHoveredLayer=layer;var nodeId=layer&&layer.nodeIdForSelfOr Ancestor();if(nodeId) 181 return;this._currentlyHoveredLayer=layer;var nodeId=layer&&layer.nodeIdForSelfOr Ancestor();if(nodeId)
208 WebInspector.domAgent.highlightDOMNode(nodeId);else 182 WebInspector.domModel.highlightDOMNode(nodeId);else
209 WebInspector.domAgent.hideDOMNodeHighlight();this._layerTree.hoverLayer(layer);t his._layers3DView.hoverLayer(layer);},__proto__:WebInspector.Panel.prototype} 183 WebInspector.domModel.hideDOMNodeHighlight();this._layerTree.hoverLayer(layer);t his._layers3DView.hoverLayer(layer);},__proto__:WebInspector.PanelWithSidebarTre e.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);}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698