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

Side by Side Diff: chrome_linux/resources/inspector/LayersPanel.js

Issue 42163002: Roll Linux reference build to official build 31.0.1650.34 (trunk r224845, branch r230433) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 7 years, 1 month 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
(Empty)
1 WebInspector.LayerTreeModel=function()
2 {WebInspector.Object.call(this);this._layersById={};InspectorBackend.registerLay erTreeDispatcher(new WebInspector.LayerTreeDispatcher(this));LayerTreeAgent.enab le();this._needsRefresh=true;}
3 WebInspector.LayerTreeModel.Events={LayerTreeChanged:"LayerTreeChanged",}
4 WebInspector.LayerTreeModel.prototype={dispose:function()
5 {LayerTreeAgent.disable();},root:function()
6 {return this._root;},contentRoot:function()
7 {return this._contentRoot;},forEachLayer:function(callback,root)
8 {if(!root){root=this.root();if(!root)
9 return false;}
10 return callback(root)||root.children().some(this.forEachLayer.bind(this,callback ));},requestLayers:function(callback)
11 {delete this._delayedRequestLayersTimer;if(!callback)
12 callback=function(){}
13 if(!this._needsRefresh){callback();return;}
14 if(this._pendingRequestLayersCallbacks){this._pendingRequestLayersCallbacks.push (callback);return;}
15 this._pendingRequestLayersCallbacks=[];this._pendingRequestLayersCallbacks.push( callback);function onGetLayers(error,layers)
16 {this._root=null;this._contentRoot=null;if(error){console.error("LayerTreeAgent. getLayers(): "+error);layers=[];}
17 this._repopulate(layers);for(var i=0;i<this._pendingRequestLayersCallbacks.lengt h;++i)
18 this._pendingRequestLayersCallbacks[i]();delete this._pendingRequestLayersCallba cks;}
19 function onDocumentAvailable()
20 {LayerTreeAgent.getLayers(undefined,onGetLayers.bind(this))}
21 WebInspector.domAgent.requestDocument(onDocumentAvailable.bind(this));},layerByI d:function(id)
22 {return this._layersById[id];},_repopulate:function(payload)
23 {var oldLayersById=this._layersById;this._layersById={};for(var i=0;i<payload.le ngth;++i){var layer=oldLayersById[payload[i].layerId];if(layer)
24 layer._reset(payload[i]);else
25 layer=new WebInspector.Layer(payload[i]);this._layersById[layer.id()]=layer;var parentId=layer.parentId();if(!this._contentRoot&&layer.nodeId())
26 this._contentRoot=layer;if(parentId){var parent=this._layersById[parentId];if(!p arent)
27 console.assert(parent,"missing parent "+parentId+" for layer "+layer.id());paren t.addChild(layer);}else{if(this._root)
28 console.assert(false,"Multiple root layers");this._root=layer;}}
29 this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTreeChange d);},_layerTreeChanged:function()
30 {if(this._delayedRequestLayersTimer)
31 return;this._needsRefresh=true;this._delayedRequestLayersTimer=setTimeout(this.r equestLayers.bind(this),100);},__proto__:WebInspector.Object.prototype}
32 WebInspector.Layer=function(layerPayload)
33 {this._reset(layerPayload);}
34 WebInspector.Layer.prototype={id:function()
35 {return this._layerPayload.layerId;},parentId:function()
36 {return this._layerPayload.parentLayerId;},parent:function()
37 {return this._parent;},isRoot:function()
38 {return!this.parentId();},children:function()
39 {return this._children;},addChild:function(child)
40 {if(child._parent)
41 console.assert(false,"Child already has a parent");this._children.push(child);ch ild._parent=this;},nodeId:function()
42 {return this._layerPayload.nodeId;},nodeIdForSelfOrAncestor:function()
43 {for(var layer=this;layer;layer=layer._parent){var nodeId=layer._layerPayload.no deId;if(nodeId)
44 return nodeId;}
45 return null;},offsetX:function()
46 {return this._layerPayload.offsetX;},offsetY:function()
47 {return this._layerPayload.offsetY;},width:function()
48 {return this._layerPayload.width;},height:function()
49 {return this._layerPayload.height;},transform:function()
50 {return this._layerPayload.transform;},anchorPoint:function()
51 {return[this._layerPayload.anchorX||0,this._layerPayload.anchorY||0,this._layerP ayload.anchorZ||0,];},invisible:function()
52 {return this._layerPayload.invisible;},paintCount:function()
53 {return this._layerPayload.paintCount;},requestCompositingReasons:function(callb ack)
54 {function callbackWrapper(error,compositingReasons)
55 {if(error){console.error("LayerTreeAgent.reasonsForCompositingLayer(): "+error); callback(null);return;}
56 callback(compositingReasons);}
57 LayerTreeAgent.compositingReasons(this.id(),callbackWrapper.bind(this));},_reset :function(layerPayload)
58 {this._children=[];this._parent=null;this._layerPayload=layerPayload;}}
59 WebInspector.LayerTreeDispatcher=function(layerTreeModel)
60 {this._layerTreeModel=layerTreeModel;}
61 WebInspector.LayerTreeDispatcher.prototype={layerTreeDidChange:function()
62 {this._layerTreeModel._layerTreeChanged();}};WebInspector.LayerTree=function(mod el,treeOutline)
63 {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;this._needsUpdate=true;}
64 WebInspector.LayerTree.Events={LayerHovered:"LayerHovered",LayerSelected:"LayerS elected"}
65 WebInspector.LayerTree.prototype={setVisible:function(visible)
66 {if(this._isVisible===visible)
67 return;this._isVisible=visible;if(visible&&this._needsUpdate)
68 this._update();},selectLayer:function(layer)
69 {this.hoverLayer(null);var node=layer&&this._treeOutline.getCachedTreeElement(la yer);if(node)
70 node.revealAndSelect(true);else if(this._treeOutline.selectedTreeElement)
71 this._treeOutline.selectedTreeElement.deselect();},hoverLayer:function(layer)
72 {var node=layer&&this._treeOutline.getCachedTreeElement(layer);if(node===this._l astHoveredNode)
73 return;if(this._lastHoveredNode)
74 this._lastHoveredNode.setHovered(false);if(node)
75 node.setHovered(true);this._lastHoveredNode=node;},_update:function()
76 {if(!this._isVisible){this._needsUpdate=true;return;}
77 this._needsUpdate=false;var seenLayers={};function updateLayer(layer)
78 {var id=layer.id();if(seenLayers[id])
79 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)
80 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);}
81 node._update();}}
82 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)
83 this._lastHoveredNode=null;node=nextNode;}}},_onMouseMove:function(event)
84 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(nod e===this._lastHoveredNode)
85 return;this.dispatchEventToListeners(WebInspector.LayerTree.Events.LayerHovered, node&&node.representedObject);},_selectedNodeChanged:function(node)
86 {var layer=(node.representedObject);this.dispatchEventToListeners(WebInspector.L ayerTree.Events.LayerSelected,layer);},_onContextMenu:function(event)
87 {var node=this._treeOutline.treeElementFromPoint(event.pageX,event.pageY);if(!no de||!node.representedObject)
88 return;var layer=(node.representedObject);if(!layer)
89 return;var nodeId=layer.nodeId();if(!nodeId)
90 return;var domNode=WebInspector.domAgent.nodeForId(nodeId);if(!domNode)
91 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},__proto__:WebInspector.Object.prototy pe}
92 WebInspector.LayerTreeElement=function(tree,layer)
93 {TreeElement.call(this,"",layer);this._layerTree=tree;this._update();}
94 WebInspector.LayerTreeElement.prototype={onattach:function()
95 {var selection=document.createElement("div");selection.className="selection";thi s.listItemElement.insertBefore(selection,this.listItemElement.firstChild);},_upd ate:function()
96 {var layer=(this.representedObject);var nodeId=layer.nodeIdForSelfOrAncestor();v ar node=nodeId&&WebInspector.domAgent.nodeForId(nodeId);var title=document.creat eDocumentFragment();title.createChild("div","selection");title.appendChild(docum ent.createTextNode(node?node.appropriateSelectorFor(false):"#"+layer.id()));var details=title.createChild("span","dimmed");details.textContent=WebInspector.UISt ring(" (%d × %d)",layer.width(),layer.height());this.title=title;},onselect:func tion()
97 {this._layerTree._selectedNodeChanged(this);},setHovered:function(hovered)
98 {this.listItemElement.enableStyleClass("hovered",hovered);},__proto__:TreeElemen t.prototype};WebInspector.Layers3DView=function(model)
99 {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._rotatingContainerEleme nt=this.element.createChild("div","fill rotating-container");this.element.addEve ntListener("mousemove",this._onMouseMove.bind(this),false);this.element.addEvent Listener("mouseout",this._onMouseMove.bind(this),false);this.element.addEventLis tener("mousedown",this._onMouseDown.bind(this),false);this.element.addEventListe ner("mouseup",this._onMouseUp.bind(this),false);this.element.addEventListener("c ontextmenu",this._onContextMenu.bind(this),false);this.element.addEventListener( "click",this._onClick.bind(this),false);this._elementsByLayerId={};this._rotateX =0;this._rotateY=0;this._scaleAdjustmentStylesheet=this.element.ownerDocument.he ad.createChild("style");this._scaleAdjustmentStylesheet.disabled=true;this._last OutlinedElement={};}
100 WebInspector.Layers3DView.OutlineType={Hovered:"hovered",Selected:"selected"}
101 WebInspector.Layers3DView.Events={LayerHovered:"LayerHovered",LayerSelected:"Lay erSelected"}
102 WebInspector.Layers3DView.prototype={onResize:function()
103 {this._update();},willHide:function()
104 {this._scaleAdjustmentStylesheet.disabled=true;},wasShown:function()
105 {this._scaleAdjustmentStylesheet.disabled=false;if(this._needsUpdate)
106 this._update();},_setOutline:function(type,layer)
107 {var element=layer?this._elementForLayer(layer):null;var previousElement=this._l astOutlinedElement[type];if(previousElement===element)
108 return;this._lastOutlinedElement[type]=element;if(previousElement){previousEleme nt.removeStyleClass(type);this._updateElementColor(previousElement);}
109 if(element){element.addStyleClass(type);this._updateElementColor(element);}},hov erLayer:function(layer)
110 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,layer);},selectL ayer:function(layer)
111 {this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered,null);this._setO utline(WebInspector.Layers3DView.OutlineType.Selected,layer);},_scaleToFit:funct ion()
112 {var root=this._model.contentRoot();if(!root)
113 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)
114 this._scaleAdjustmentStylesheet.textContent=stylesheetContent;else
115 stylesheetTextNode.nodeValue=stylesheetContent;var element=this._elementForLayer (root);element.style.webkitTransform="scale3d("+this._scale+","+this._scale+","+ this._scale+")";element.style.left=((this._clientWidth-root.width()*this._scale) >>1)+"px";element.style.top=((this._clientHeight-root.height()*this._scale)>>1)+ "px";},_update:function()
116 {if(!this.isShowing()){this._needsUpdate=true;return;}
117 if(!this._model.contentRoot()){this._emptyView.show(this.element);this._rotating ContainerElement.removeChildren();return;}
118 this._emptyView.detach();function updateLayer(layer)
119 {this._updateLayerElement(this._elementForLayer(layer));}
120 this._clientWidth=this.element.clientWidth;this._clientHeight=this.element.clien tHeight;for(var layerId in this._elementsByLayerId){if(this._model.layerById(lay erId))
121 continue;this._elementsByLayerId[layerId].remove();delete this._elementsByLayerI d[layerId];}
122 this._scaleToFit();this._model.forEachLayer(updateLayer.bind(this),this._model.c ontentRoot());this._needsUpdate=false;},_elementForLayer:function(layer)
123 {var element=this._elementsByLayerId[layer.id()];if(element){element.__layer=lay er;return element;}
124 element=document.createElement("div");element.className="layer-container";elemen t.__layer=layer;["fill back-wall","side-wall top","side-wall right","side-wall b ottom","side-wall left"].forEach(element.createChild.bind(element,"div"));this._ elementsByLayerId[layer.id()]=element;return element;},_updateLayerElement:funct ion(element)
125 {var layer=element.__layer;var style=element.style;var isContentRoot=layer===thi s._model.contentRoot();var parentElement=isContentRoot?this._rotatingContainerEl ement:this._elementForLayer(layer.parent());element.__depth=(parentElement.__dep th||0)+1;element.enableStyleClass("invisible",layer.invisible());this._updateEle mentColor(element);if(parentElement!==element.parentElement)
126 parentElement.appendChild(element);style.width=layer.width()+"px";style.height=l ayer.height()+"px";if(isContentRoot)
127 return;style.left=layer.offsetX()+"px";style.top=layer.offsetY()+"px";var transf orm=layer.transform();if(transform){function toFixed5(x)
128 {return x.toFixed(5);}
129 style.webkitTransform="matrix3d("+transform.map(toFixed5).join(",")+") translate Z("+this._layerSpacing+")";var anchor=layer.anchorPoint();style.webkitTransformO rigin=Math.round(anchor[0]*100)+"% "+Math.round(anchor[1]*100)+"% "+anchor[2];}e lse{style.webkitTransform="";style.webkitTransformOrigin="";}},_updateElementCol or:function(element)
130 {var color;if(element===this._lastOutlinedElement[WebInspector.Layers3DView.Outl ineType.Selected])
131 color=WebInspector.Color.PageHighlight.Content.toString(WebInspector.Color.Forma t.RGBA)||"";else{const base=144;var component=base+20*((element.__depth-1)%5);co lor="rgba("+component+","+component+","+component+", 0.8)";}
132 element.style.backgroundColor=color;},_onMouseDown:function(event)
133 {if(event.which!==1)
134 return;this._setReferencePoint(event);},_setReferencePoint:function(event)
135 {this._originX=event.clientX;this._originY=event.clientY;this._oldRotateX=this._ rotateX;this._oldRotateY=this._rotateY;},_resetReferencePoint:function()
136 {delete this._originX;delete this._originY;delete this._oldRotateX;delete this._ oldRotateY;},_onMouseUp:function(event)
137 {if(event.which!==1)
138 return;this._resetReferencePoint();},_layerFromEventPoint:function(event)
139 {var element=this.element.ownerDocument.elementFromPoint(event.pageX,event.pageY );if(!element)
140 return null;element=element.enclosingNodeOrSelfWithClass("layer-container");retu rn element&&element.__layer;},_onMouseMove:function(event)
141 {if(!event.which){this.dispatchEventToListeners(WebInspector.Layers3DView.Events .LayerHovered,this._layerFromEventPoint(event));return;}
142 if(event.which===1){if(typeof this._originX!=="number")
143 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)
144 {var layer=this._layerFromEventPoint(event);var nodeId=layer&&layer.nodeId();if( !nodeId)
145 return;var domNode=WebInspector.domAgent.nodeForId(nodeId);if(!domNode)
146 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApp licableItems(domNode);contextMenu.show();},_onClick:function(event)
147 {this.dispatchEventToListeners(WebInspector.Layers3DView.Events.LayerSelected,th is._layerFromEventPoint(event));},__proto__:WebInspector.View.prototype};WebInsp ector.LayerDetailsView=function()
148 {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.showLayer(null);}
149 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={showLayer:function(layer)
150 {if(!layer){this._tableElement.remove();this._emptyView.show(this.element);retur n;}
151 this._emptyView.detach();this.element.appendChild(this._tableElement);this._posi tionCell.textContent=WebInspector.UIString("%d,%d",layer.offsetX(),layer.offsetY ());this._sizeCell.textContent=WebInspector.UIString("%d × %d",layer.width(),lay er.height());this._paintCountCell.textContent=layer.paintCount();const bytesPerP ixel=4;this._memoryEstimateCell.textContent=Number.bytesToString(layer.invisible ()?0:layer.width()*layer.height()*bytesPerPixel);layer.requestCompositingReasons (this._updateCompositingReasons.bind(this));},_createTable:function()
152 {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)
153 {var tr=this._tbodyElement.createChild("tr");var titleCell=tr.createChild("td"); titleCell.textContent=title;return tr.createChild("td");},_updateCompositingReas ons:function(compositingReasons)
154 {if(!compositingReasons||!compositingReasons.length){this._compositingReasonsCel l.textContent="n/a";return;}
155 var fragment=document.createDocumentFragment();for(var i=0;i<compositingReasons. length;++i){if(i)
156 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);}
157 this._compositingReasonsCell.removeChildren();this._compositingReasonsCell.appen dChild(fragment);},__proto__:WebInspector.View.prototype};WebInspector.LayersPan el=function()
158 {WebInspector.Panel.call(this,"layers");this.registerRequiredCSS("layersPanel.cs s");const initialLayerTreeSidebarWidth=225;const minimumMainWidthPercent=0.5;thi s.createSidebarViewWithTree();this.sidebarElement.addStyleClass("outline-disclos ure");this.sidebarTreeElement.removeStyleClass("sidebar-tree");this._model=new W ebInspector.LayerTreeModel();this._model.addEventListener(WebInspector.LayerTree Model.Events.LayerTreeChanged,this._onLayerTreeUpdated,this);this._currentlySele ctedLayer=null;this._currentlyHoveredLayer=null;this._layerTree=new WebInspector .LayerTree(this._model,this.sidebarTree);this._layerTree.addEventListener(WebIns pector.LayerTree.Events.LayerSelected,this._onLayerSelected,this);this._layerTre e.addEventListener(WebInspector.LayerTree.Events.LayerHovered,this._onLayerHover ed,this);this._layerDetailsSplitView=new WebInspector.SplitView(false,"layerDeta ilsSplitView");this._layerDetailsSplitView.show(this.splitView.mainElement);this ._layers3DView=new WebInspector.Layers3DView(this._model);this._layers3DView.sho w(this._layerDetailsSplitView.firstElement());this._layers3DView.addEventListene r(WebInspector.Layers3DView.Events.LayerSelected,this._onLayerSelected,this);thi s._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerHovered,t his._onLayerHovered,this);this._layerDetailsView=new WebInspector.LayerDetailsVi ew();this._layerDetailsView.show(this._layerDetailsSplitView.secondElement());th is._model.requestLayers();}
159 WebInspector.LayersPanel.prototype={wasShown:function()
160 {WebInspector.Panel.prototype.wasShown.call(this);this._layerTree.setVisible(tru e);this.sidebarTreeElement.focus();},willHide:function()
161 {this._layerTree.setVisible(false);WebInspector.Panel.prototype.willHide.call(th is);},_onLayerTreeUpdated:function()
162 {if(this._currentlySelectedLayer&&!this._model.layerById(this._currentlySelected Layer.id()))
163 this._selectLayer(null);if(this._currentlyHoveredLayer&&!this._model.layerById(t his._currentlyHoveredLayer.id()))
164 this._hoverLayer(null);if(this._currentlySelectedLayer)
165 this._layerDetailsView.showLayer(this._currentlySelectedLayer);},_onLayerSelecte d:function(event)
166 {var layer=(event.data);this._selectLayer(layer);},_onLayerHovered:function(even t)
167 {var layer=(event.data);this._hoverLayer(layer);},_selectLayer:function(layer)
168 {if(this._currentlySelectedLayer===layer)
169 return;this._currentlySelectedLayer=layer;var nodeId=layer&&layer.nodeIdForSelfO rAncestor();if(nodeId)
170 WebInspector.domAgent.highlightDOMNodeForTwoSeconds(nodeId);else
171 WebInspector.domAgent.hideDOMNodeHighlight();this._layerTree.selectLayer(layer); this._layers3DView.selectLayer(layer);this._layerDetailsView.showLayer(layer);}, _hoverLayer:function(layer)
172 {if(this._currentlyHoveredLayer===layer)
173 return;this._currentlyHoveredLayer=layer;var nodeId=layer&&layer.nodeIdForSelfOr Ancestor();if(nodeId)
174 WebInspector.domAgent.highlightDOMNode(nodeId);else
175 WebInspector.domAgent.hideDOMNodeHighlight();this._layerTree.hoverLayer(layer);t his._layers3DView.hoverLayer(layer);},__proto__:WebInspector.Panel.prototype}
OLDNEW
« no previous file with comments | « chrome_linux/resources/inspector/Images/statusbarButtonGlyphs2x.png ('k') | chrome_linux/resources/inspector/NetworkPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698